*
* @package chamilo.course_description
*/
class CourseDescriptionController
{
private $toolname;
private $view;
/**
* Constructor.
*/
public function __construct()
{
$this->toolname = 'course_description';
$this->view = new View($this->toolname);
}
/**
* It's used for listing course description,
* render to listing view.
*
* @param bool true for listing history (optional)
* @param array message for showing by action['edit','add','destroy'] (optional)
*/
public function listing($history = false, $messages = [])
{
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
$course_description = new CourseDescription();
$session_id = api_get_session_id();
$data = [];
$course_description->set_session_id($session_id);
$course_description_data = $course_description->get_description_data();
$data['descriptions'] = isset($course_description_data['descriptions']) ? $course_description_data['descriptions'] : '';
$data['default_description_titles'] = $course_description->get_default_description_title();
$data['default_description_title_editable'] = $course_description->get_default_description_title_editable();
$data['default_description_icon'] = $course_description->get_default_description_icon();
$data['messages'] = $messages;
$browser = api_get_navigator();
api_protect_course_script(true);
if (!is_array($data['descriptions'])) {
$data['descriptions'] = [$data['descriptions']];
}
// Prepare confirmation code for item deletion
global $htmlHeadXtra;
$htmlHeadXtra[] = "";
foreach ($data['descriptions'] as $id => $description) {
if (!empty($description['content'])
&& strpos($description['content'], '