'IntroductionTool', 'Width' => '100%', 'Height' => '300' ); $form->addHtmlEditor('intro_content', null, false, false, $config, true); $form->addButtonSave(get_lang('SaveIntroText'), 'intro_cmdUpdate'); /* INTRODUCTION MICRO MODULE - COMMANDS SECTION (IF ALLOWED) */ $course_id = api_get_course_int_id(); $moduleId = intval($moduleId); if ($intro_editAllowed) { /* Replace command */ if ($intro_cmdUpdate) { if ($form->validate()) { $form_values = $form->exportValues(); $intro_content = $form_values['intro_content']; $criteria = [ 'cId' => $course_id, 'id' => $moduleId, 'sessionId' => $session_id, ]; if (!empty($intro_content)) { /** @var CToolIntro $toolIntro */ $toolIntro = Database::getManager() ->getRepository('ChamiloCourseBundle:CToolIntro') ->findOneBy($criteria); if ($toolIntro) { $toolIntro->setIntroText($intro_content); } else { $toolIntro = new CToolIntro(); $toolIntro ->setSessionId($session_id) ->setCId($course_id) ->setIntroText($intro_content) ->setId($moduleId); } Database::getManager()->persist($toolIntro); Database::getManager()->flush(); Display::addFlash(Display::return_message(get_lang('IntroductionTextUpdated'), 'confirmation', false)); } else { // got to the delete command $intro_cmdDel = true; } } else { $intro_cmdEdit = true; } } /* Delete Command */ if ($intro_cmdDel) { $sql = "DELETE FROM $TBL_INTRODUCTION WHERE c_id = $course_id AND id = $moduleId AND session_id = $session_id"; Database::query($sql); Display::addFlash(Display::return_message(get_lang('IntroductionTextDeleted'), 'confirmation')); } } /* INTRODUCTION MICRO MODULE - DISPLAY SECTION */ /* Retrieves the module introduction text, if exist */ /* @todo use a lib to query the $TBL_INTRODUCTION table */ // Getting course intro $intro_content = ''; $sql = "SELECT intro_text FROM $TBL_INTRODUCTION WHERE c_id = $course_id AND id = $moduleId AND session_id = 0"; $intro_dbQuery = Database::query($sql); if (Database::num_rows($intro_dbQuery) > 0) { $intro_dbResult = Database::fetch_array($intro_dbQuery); $intro_content = $intro_dbResult['intro_text']; } // Getting session intro if (!empty($session_id)) { $sql = "SELECT intro_text FROM $TBL_INTRODUCTION WHERE c_id = $course_id AND id = $moduleId AND session_id = $session_id"; $intro_dbQuery = Database::query($sql); $introSessionContent = ''; if (Database::num_rows($intro_dbQuery) > 0) { $intro_dbResult = Database::fetch_array($intro_dbQuery); $introSessionContent = $intro_dbResult['intro_text']; } // If the course session intro exists replace it. if (!empty($introSessionContent)) { $intro_content = $introSessionContent; } } // Default behaviour show iframes. $userStatus = COURSEMANAGERLOWSECURITY; // Allows to do a remove_XSS in course introduction with user status COURSEMANAGERLOWSECURITY // Block embed type videos (like vimeo, wistia, etc) - see BT#12244 BT#12556 if (api_get_configuration_value('course_introduction_html_strict_filtering')) { $userStatus = COURSEMANAGER; } $intro_content = Security::remove_XSS($intro_content, $userStatus); /* Determines the correct display */ if ($intro_cmdEdit || $intro_cmdAdd) { $intro_dispDefault = false; $intro_dispForm = true; $intro_dispCommand = false; } else { $intro_dispDefault = true; $intro_dispForm = false; if ($intro_editAllowed) { $intro_dispCommand = true; } else { $intro_dispCommand = false; } } /* Executes the display */ // display thematic advance inside a postit if ($intro_dispForm) { $default['intro_content'] = $intro_content; $form->setDefaults($default); $introduction_section .= '
'; $introduction_section .= $form->returnForm(); $introduction_section .= '
'; } $thematic_description_html = ''; $thematicItemTwo = ''; if ($tool == TOOL_COURSE_HOMEPAGE && !isset($_GET['intro_cmdEdit'])) { // Only show this if we're on the course homepage and we're not currently editing $thematic = new Thematic(); $displayMode = api_get_course_setting('display_info_advance_inside_homecourse'); $class1 = ''; if ($displayMode == '1') { // Show only the current course progress step // $information_title = get_lang('InfoAboutLastDoneAdvance'); $last_done_advance = $thematic->get_last_done_thematic_advance(); $thematic_advance_info = $thematic->get_thematic_advance_list($last_done_advance); $subTitle1 = get_lang('CurrentTopic'); $class1 = ' current'; } else if ($displayMode == '2') { // Show only the two next course progress steps // $information_title = get_lang('InfoAboutNextAdvanceNotDone'); $last_done_advance = $thematic->get_next_thematic_advance_not_done(); $next_advance_not_done = $thematic->get_next_thematic_advance_not_done(2); $thematic_advance_info = $thematic->get_thematic_advance_list($last_done_advance); $thematic_advance_info2 = $thematic->get_thematic_advance_list($next_advance_not_done); $subTitle1 = $subTitle2 = get_lang('NextTopic'); } else if ($displayMode == '3') { // Show the current and next course progress steps // $information_title = get_lang('InfoAboutLastDoneAdvanceAndNextAdvanceNotDone'); $last_done_advance = $thematic->get_last_done_thematic_advance(); $next_advance_not_done = $thematic->get_next_thematic_advance_not_done(); $thematic_advance_info = $thematic->get_thematic_advance_list($last_done_advance); $thematic_advance_info2 = $thematic->get_thematic_advance_list($next_advance_not_done); $subTitle1 = get_lang('CurrentTopic'); $subTitle2 = get_lang('NextTopic'); $class1 = ' current'; } if (!empty($thematic_advance_info)) { $thematic_advance = get_lang('CourseThematicAdvance'); $thematicScore = $thematic->get_total_average_of_thematic_advances().'%'; $thematicUrl = api_get_path(WEB_CODE_PATH).'course_progress/index.php?action=thematic_details&'.api_get_cidreq(); $thematic_info = $thematic->get_thematic_list( $thematic_advance_info['thematic_id'] ); $thematic_advance_info['start_date'] = api_get_local_time( $thematic_advance_info['start_date'] ); $thematic_advance_info['start_date'] = api_format_date( $thematic_advance_info['start_date'], DATE_TIME_FORMAT_LONG ); $userInfo = api_get_user_info(); $courseInfo = api_get_course_info(); $titleThematic = $thematic_advance.' : '.$courseInfo['name'].' ( '.$thematicScore.' )'; $infoUser = '
'; $infoUser .= '
'.$thematicScore.'
'; $thematicItemOne = '
' . $subTitle1.'

'.Display::returnFontAwesomeIcon('book').strip_tags($thematic_info['title']).'

' . Display::returnFontAwesomeIcon('calendar-o').$thematic_advance_info['start_date'].'

' . Display::returnFontAwesomeIcon('file-text-o').strip_tags($thematic_advance_info['content']).'

'. Display::returnFontAwesomeIcon('clock-o').get_lang('DurationInHours').' : '.$thematic_advance_info['duration'].' - '.get_lang('SeeDetail').'

'; if (!empty($thematic_advance_info2)) { $thematic_info2 = $thematic->get_thematic_list($thematic_advance_info2['thematic_id']); $thematic_advance_info2['start_date'] = api_get_local_time($thematic_advance_info2['start_date']); $thematic_advance_info2['start_date'] = api_format_date($thematic_advance_info2['start_date'], DATE_TIME_FORMAT_LONG); $thematicItemTwo = '
'.$subTitle2.'

'. Display::returnFontAwesomeIcon('book').$thematic_info2['title'].'

' . Display::returnFontAwesomeIcon('calendar-o').$thematic_advance_info2['start_date'].'

' . Display::returnFontAwesomeIcon('file-text-o').strip_tags($thematic_advance_info2['content']).'

'. Display::returnFontAwesomeIcon('clock-o').get_lang('DurationInHours').' : '.$thematic_advance_info2['duration'].' - '.get_lang('SeeDetail').'

'; } $thematicPanel = '
'; $thematicPanel .= '
'.$infoUser.'
'; $thematicPanel .= '
'.$thematicItemOne.$thematicItemTwo.'
'; $thematicPanel .= '
'; $thematicPanel .= '
'.get_lang('ShowFullCourseAdvance').'
'; $thematicProgress = Display::panelCollapse($titleThematic, $thematicPanel, 'thematic', null, 'accordion-thematic', 'collapse-thematic', false); } } $introduction_section .= '
'; if (!empty($thematic_advance_info)) { $introduction_section .= '
'; $introduction_section .= $thematic_description_html; $introduction_section .= $thematicProgress; $introduction_section .= '
'; } $editIconButton = ''; if (api_is_allowed_to_edit() && empty($session_id)) { $editIconButton = Display::url( ' ', api_get_path(WEB_CODE_PATH).'course_info/tools.php?'.api_get_cidreq(), ['class' => 'btn btn-default', 'title' => get_lang('CustomizeIcons')] ); } $toolbar = ''; $textIntro = ''; if ($intro_dispCommand) { if (empty($intro_content)) { // Displays "Add intro" commands $toolbar .= '
'; $toolbar .= '
'; if (!empty($courseId)) { $textIntro = ''; $textIntro .= ' '; $textIntro .= ""; $toolbar .= $textIntro.$editIconButton; } else { $toolbar .= ''.get_lang('AddIntro').''; $toolbar .= $editIconButton; } $toolbar .= '
'; } else { // Displays "edit intro && delete intro" commands $toolbar .= '
'; $toolbar .= '
'; if (!empty($courseId)) { $toolbar .= ' '; $toolbar .= $editIconButton; $toolbar .= ""; } else { $toolbar .= ' "'; $toolbar .= $editIconButton; $toolbar .= ""; } $toolbar .= "
"; // Fix for chrome XSS filter for videos in iframes - BT#7930 $browser = api_get_navigator(); if (strpos($introduction_section, '