Ver Fonte

Merge pull request #2990 from chamilo/lp_item_title_as_html

Lp item title as html
Julio Montoya há 5 anos atrás
pai
commit
209e64f851
41 ficheiros alterados com 330 adições e 422 exclusões
  1. 1 1
      main/admin/course_category.php
  2. 1 1
      main/course_description/add.php
  3. 1 1
      main/course_description/edit.php
  4. 19 13
      main/course_home/course_home.php
  5. 1 1
      main/course_progress/thematic.php
  6. 1 1
      main/exercise/ReadingComprehension.php
  7. 1 1
      main/exercise/exercise.class.php
  8. 1 1
      main/exercise/question.class.php
  9. 2 2
      main/glossary/index.php
  10. 6 9
      main/inc/lib/course_home.lib.php
  11. 2 0
      main/inc/lib/formvalidator/Element/HtmlEditor.php
  12. 8 0
      main/inc/lib/pear/HTML/QuickForm/textarea.php
  13. 5 0
      main/install/configuration.dist.php
  14. 147 344
      main/lp/learnpath.class.php
  15. 16 6
      main/lp/lp_add.php
  16. 1 1
      main/lp/lp_add_audio.php
  17. 1 1
      main/lp/lp_add_category.php
  18. 1 1
      main/lp/lp_add_item.php
  19. 1 1
      main/lp/lp_admin_view.php
  20. 1 1
      main/lp/lp_build.php
  21. 1 1
      main/lp/lp_content.php
  22. 3 2
      main/lp/lp_controller.php
  23. 14 4
      main/lp/lp_edit.php
  24. 3 6
      main/lp/lp_edit_item.php
  25. 1 1
      main/lp/lp_edit_item_prereq.php
  26. 1 1
      main/lp/lp_impress.php
  27. 1 1
      main/lp/lp_list.php
  28. 1 1
      main/lp/lp_move_item.php
  29. 2 2
      main/lp/lp_subscribe_users.php
  30. 1 1
      main/lp/lp_update_scorm.php
  31. 3 3
      main/lp/lp_view.php
  32. 1 1
      main/lp/lp_view_item.php
  33. 1 1
      main/portfolio/add_category.php
  34. 1 1
      main/portfolio/add_item.php
  35. 1 1
      main/portfolio/edit_category.php
  36. 1 1
      main/portfolio/edit_item.php
  37. 2 2
      main/template/default/learnpath/scorm_list.tpl
  38. 3 3
      src/Chamilo/CoreBundle/Component/Editor/CkEditor/CkEditor.php
  39. 1 1
      src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/Minimal.php
  40. 44 0
      src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/TitleAsHtml.php
  41. 27 2
      src/Chamilo/CoreBundle/Component/Editor/Editor.php

+ 1 - 1
main/admin/course_category.php

@@ -106,7 +106,7 @@ if ($action == 'add' || $action == 'edit') {
             get_lang('CategoryName'),
             true,
             false,
-            ['ToolbarSet' => 'Minimal']
+            ['ToolbarSet' => 'TitleAsHtml']
         );
     } else {
         $form->addElement('text', 'name', get_lang("CategoryName"));

+ 1 - 1
main/course_description/add.php

@@ -68,7 +68,7 @@ if (api_get_configuration_value('save_titles_as_html')) {
         get_lang('Title'),
         true,
         false,
-        ['ToolbarSet' => 'Minimal']
+        ['ToolbarSet' => 'TitleAsHtml']
     );
 } else {
     $form->addText('title', get_lang('Title'));

+ 1 - 1
main/course_description/edit.php

@@ -86,7 +86,7 @@ if (api_get_configuration_value('save_titles_as_html')) {
         get_lang('Title'),
         true,
         false,
-        ['ToolbarSet' => 'Minimal']
+        ['ToolbarSet' => 'TitleAsHtml']
     );
 } else {
     $form->addText('title', get_lang('Title'));

+ 19 - 13
main/course_home/course_home.php

@@ -227,7 +227,7 @@ if (!empty($lpAutoLaunch)) {
                 } else {
                     $session_key = 'lp_autolaunch_'.$session_id.'_'.api_get_course_int_id().'_'.api_get_user_id();
                     if (!isset($_SESSION[$session_key])) {
-                        //redirecting to the LP
+                        // Redirecting to the LP
                         $url = api_get_path(WEB_CODE_PATH).'lp/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$lp_data['id'];
 
                         $_SESSION[$session_key] = true;
@@ -325,9 +325,8 @@ if ($documentAutoLaunch == 1) {
     }
 }
 
+// Used in different pages
 $tool_table = Database::get_course_table(TABLE_TOOL_LIST);
-$temps = time();
-$reqdate = "&reqdate=$temps";
 
 /*	Introduction section (editable by course admins) */
 $content = Display::return_introduction_section(
@@ -349,16 +348,22 @@ if (!empty($autoLaunchWarning)) {
     );
 }
 
-if (api_get_setting('homepage_view') === 'activity' ||
-    api_get_setting('homepage_view') === 'activity_big'
-) {
-    require 'activity.php';
-} elseif (api_get_setting('homepage_view') === '2column') {
-    require '2column.php';
-} elseif (api_get_setting('homepage_view') === '3column') {
-    require '3column.php';
-} elseif (api_get_setting('homepage_view') === 'vertical_activity') {
-    require 'vertical_activity.php';
+$homePageView = api_get_setting('homepage_view');
+
+switch ($homePageView) {
+    case 'activity':
+    case 'activity_big':
+        require 'activity.php';
+        break;
+    case '2column':
+        require '2column.php';
+        break;
+    case '3column':
+        require '3column.php';
+        break;
+    case 'vertical_activity':
+        require 'vertical_activity.php';
+        break;
 }
 
 // Get session-career diagram
@@ -417,6 +422,7 @@ Session::erase('_gid');
 Session::erase('oLP');
 Session::erase('lpobject');
 api_remove_in_gradebook();
+Exercise::cleanSessionVariables();
 DocumentManager::removeGeneratedAudioTempFile();
 
 $tpl = new Template(null);

+ 1 - 1
main/course_progress/thematic.php

@@ -237,7 +237,7 @@ if ($action == 'thematic_list') {
             get_lang('Title'),
             true,
             false,
-            ['ToolbarSet' => 'Minimal']
+            ['ToolbarSet' => 'TitleAsHtml']
         );
     } else {
         $form->addText('title', get_lang('Title'), true, ['size' => '50']);

+ 1 - 1
main/exercise/ReadingComprehension.php

@@ -141,7 +141,7 @@ class ReadingComprehension extends UniqueAnswer
         $form->addTextarea('questionDescription', get_lang('Text'), ['rows' => 20]);
         // question name
         if (api_get_configuration_value('save_titles_as_html')) {
-            $editorConfig = ['ToolbarSet' => 'Minimal'];
+            $editorConfig = ['ToolbarSet' => 'TitleAsHtml'];
             $form->addHtmlEditor(
                 'questionName',
                 get_lang('Question'),

+ 1 - 1
main/exercise/exercise.class.php

@@ -1923,7 +1923,7 @@ class Exercise
                 get_lang('ExerciseName'),
                 false,
                 false,
-                ['ToolbarSet' => 'Minimal']
+                ['ToolbarSet' => 'TitleAsHtml']
             );
         } else {
             $form->addElement(

+ 1 - 1
main/exercise/question.class.php

@@ -1600,7 +1600,7 @@ abstract class Question
 
         // question name
         if (api_get_configuration_value('save_titles_as_html')) {
-            $editorConfig = ['ToolbarSet' => 'Minimal'];
+            $editorConfig = ['ToolbarSet' => 'TitleAsHtml'];
             $form->addHtmlEditor(
                 'questionName',
                 get_lang('Question'),

+ 2 - 2
main/glossary/index.php

@@ -93,7 +93,7 @@ switch ($action) {
                 get_lang('TermName'),
                 false,
                 false,
-                ['ToolbarSet' => 'Minimal']
+                ['ToolbarSet' => 'TitleAsHtml']
             );
         } else {
             $form->addElement('text', 'name', get_lang('TermName'), ['id' => 'glossary_title']);
@@ -157,7 +157,7 @@ switch ($action) {
                     get_lang('TermName'),
                     false,
                     false,
-                    ['ToolbarSet' => 'Minimal']
+                    ['ToolbarSet' => 'TitleAsHtml']
                 );
             } else {
                 $form->addElement('text', 'name', get_lang('TermName'), ['id' => 'glossary_title']);

+ 6 - 9
main/inc/lib/course_home.lib.php

@@ -858,7 +858,7 @@ class CourseHome
                 $item = [];
                 $studentview = false;
                 $tool['original_link'] = $tool['link'];
-                if ($tool['image'] == 'scormbuilder.gif') {
+                if ($tool['image'] === 'scormbuilder.gif') {
                     // Check if the published learnpath is visible for student
                     $lpId = self::getPublishedLpIdFromLink($tool['link']);
                     if (api_is_allowed_to_edit(null, true)) {
@@ -926,9 +926,8 @@ class CourseHome
                             switch ($visibility) {
                                 case '0':
                                     $info = pathinfo($tool['image']);
-                                    $basename = basename($tool['image'], '.'.$info['extension']); // $file is set to "index"
+                                    $basename = basename($tool['image'], '.'.$info['extension']);
                                     $tool['image'] = $basename.'_na.'.$info['extension'];
-
                                     $link['name'] = Display::return_icon(
                                         'invisible.png',
                                         get_lang('Activate'),
@@ -977,7 +976,7 @@ class CourseHome
                     }
                 }
 
-                $item['visibility'] = null;
+                $item['visibility'] = '';
                 if (isset($lnk) && is_array($lnk)) {
                     foreach ($lnk as $this_link) {
                         if (empty($tool['adminlink'])) {
@@ -986,8 +985,6 @@ class CourseHome
                                 $this_link['name'].'</a>';
                         }
                     }
-                } else {
-                    $item['visibility'] .= '';
                 }
 
                 // NOTE : Table contains only the image file name, not full path
@@ -1002,14 +999,14 @@ class CourseHome
                 if ($tool['visibility'] == '0' && $toolAdmin != '1') {
                     $class = 'text-muted';
                     $info = pathinfo($tool['image']);
-                    $basename = basename($tool['image'], '.'.$info['extension']); // $file is set to "index"
+                    $basename = basename($tool['image'], '.'.$info['extension']);
                     $tool['image'] = $basename.'_na.'.$info['extension'];
                 }
 
                 $qm_or_amp = strpos($tool['link'], '?') === false ? '?' : '&';
 
                 // If it's a link, we don't add the cidReq
-                if ($tool['image'] == 'file_html.png' || $tool['image'] == 'file_html_na.png') {
+                if ($tool['image'] === 'file_html.png' || $tool['image'] === 'file_html_na.png') {
                     $tool['link'] = $tool['link'];
                 } else {
                     $tool['link'] = $tool['link'].$qm_or_amp.api_get_cidreq();
@@ -1216,7 +1213,7 @@ class CourseHome
             'external_na.gif',
         ];
 
-        $toolName = Security::remove_XSS(stripslashes($tool['name']));
+        $toolName = Security::remove_XSS(stripslashes(strip_tags($tool['name'])));
 
         if (isset($tool['image']) && in_array($tool['image'], $already_translated_icons)) {
             return $toolName;

+ 2 - 0
main/inc/lib/formvalidator/Element/HtmlEditor.php

@@ -35,11 +35,13 @@ class HtmlEditor extends HTML_QuickForm_textarea
         }
 
         parent::__construct($name, $label, $attributes);
+        $id = $this->getAttribute('id');
         $this->_persistantFreeze = true;
         $this->_type = 'html_editor';
         $editor = new CkEditor();
         if ($editor) {
             $this->editor = $editor;
+            $this->editor->setTextareaId($id);
             $this->editor->setName($name);
             $this->editor->processConfig($config);
         }

+ 8 - 0
main/inc/lib/pear/HTML/QuickForm/textarea.php

@@ -58,6 +58,14 @@ class HTML_QuickForm_textarea extends HTML_QuickForm_element
         $columnsSize = isset($attributes['cols-size']) ? $attributes['cols-size'] : null;
         $this->setColumnsSize($columnsSize);
         parent::__construct($elementName, $label, $attributes);
+
+        $id = $this->getAttribute('id');
+
+        if (empty($id)) {
+            $name = $this->getAttribute('name');
+            $this->setAttribute('id', uniqid($name.'_'));
+        }
+
         $this->_persistantFreeze = true;
         $this->_type = 'textarea';
         $this->_value = null;

+ 5 - 0
main/install/configuration.dist.php

@@ -399,6 +399,11 @@ ALTER TABLE c_tool CHANGE name name LONGTEXT NOT NULL;
 -- Only with allow_portfolio_tool enabled
 ALTER TABLE portfolio CHANGE title title LONGTEXT NOT NULL;
 ALTER TABLE portfolio_category CHANGE title title LONGTEXT NOT NULL;
+
+New changes:
+
+ALTER TABLE c_lp CHANGE name name LONGTEXT NOT NULL;
+ALTER TABLE c_lp_item CHANGE title title LONGTEXT NOT NULL;
 --
 */
 // $_configuration['save_titles_as_html'] = false;

+ 147 - 344
main/lp/learnpath.class.php

@@ -253,11 +253,6 @@ class learnpath
                         ORDER BY parent_item_id, display_order";
                 $res = Database::query($sql);
 
-                if ($debug) {
-                    error_log('learnpath::__construct() '.__LINE__.' - query lp items: '.$sql);
-                    error_log('-- Start while--');
-                }
-
                 $lp_item_id_list = [];
                 while ($row = Database::fetch_array($res)) {
                     $lp_item_id_list[] = $row['iid'];
@@ -342,10 +337,6 @@ class learnpath
                     }
                 }
 
-                if ($debug) {
-                    error_log('learnpath::__construct() '.__LINE__.' ----- end while ----');
-                }
-
                 if (!empty($lp_item_id_list)) {
                     $lp_item_id_list_to_string = implode("','", $lp_item_id_list);
                     if (!empty($lp_item_id_list_to_string)) {
@@ -359,14 +350,6 @@ class learnpath
                                     lp_view_id = ".$this->get_view_id()." AND
                                     lp_item_id IN ('".$lp_item_id_list_to_string."')
                                 ORDER BY view_count DESC ";
-
-                        if ($debug) {
-                            error_log(
-                                'learnpath::__construct() - Selecting item_views: '.$sql,
-                                0
-                            );
-                        }
-
                         $status_list = [];
                         $res = Database::query($sql);
                         while ($row = Database:: fetch_array($res)) {
@@ -524,7 +507,7 @@ class learnpath
                 WHERE
                     c_id = $course_id AND
                     lp_id = ".$this->get_id()." AND
-                    parent_item_id = ".$parent;
+                    parent_item_id = $parent ";
 
         $res_count = Database::query($sql);
         $row = Database::fetch_array($res_count);
@@ -1164,6 +1147,7 @@ class learnpath
     public function delete_children_items($id)
     {
         $course_id = $this->course_info['real_id'];
+
         $num = 0;
         $id = (int) $id;
         if (empty($id) || empty($course_id)) {
@@ -3302,7 +3286,7 @@ class learnpath
         }
 
         $dirTypes = self::getChapterTypes();
-        $mycurrentitemid = $this->get_current_item_id();
+        $currentItemId = $this->get_current_item_id();
         $list = [];
         $classStatus = [
             'not attempted' => 'scorm_not_attempted',
@@ -3346,7 +3330,7 @@ class learnpath
                     $subtree['title'] = $title;
                     $subtree['class'] = $classStyle.' '.$cssStatus;
                     $subtree['url'] = $this->get_link('http', $subtree['id'], $tree);
-                    $subtree['current_id'] = $mycurrentitemid;
+                    $subtree['current_id'] = $currentItemId;
                 }
                 $list[] = $subtree;
             }
@@ -3368,7 +3352,7 @@ class learnpath
             $toc_list = $this->get_toc();
         }
         // Temporary variables.
-        $mycurrentitemid = $this->get_current_item_id();
+        $currentItemId = $this->get_current_item_id();
         $list = [];
         $arrayList = [];
         $classStatus = [
@@ -3432,7 +3416,7 @@ class learnpath
             } else {
                 $list['title'] = stripslashes($title);
                 $list['url'] = $this->get_link('http', $item['id'], $toc_list);
-                $list['current_id'] = $mycurrentitemid;
+                $list['current_id'] = $currentItemId;
             }
             $arrayList[] = $list;
         }
@@ -3497,6 +3481,14 @@ class learnpath
         return 'N/A';
     }
 
+    /**
+     * @return string
+     */
+    public function getNameNoTags()
+    {
+        return strip_tags($this->get_name());
+    }
+
     /**
      * Gets a link to the resource from the present location, depending on item ID.
      *
@@ -5989,34 +5981,7 @@ class learnpath
     public function processBuildMenuElements($update_audio = 'false')
     {
         $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
-        $course_id = api_get_course_int_id();
-        $table = Database::get_course_table(TABLE_LP_ITEM);
-
-        $sql = "SELECT * FROM $table
-                WHERE c_id = $course_id AND lp_id = ".$this->lp_id;
-
-        $result = Database::query($sql);
-        $arrLP = [];
-        while ($row = Database::fetch_array($result)) {
-            $arrLP[] = [
-                'id' => $row['iid'],
-                'item_type' => $row['item_type'],
-                'title' => Security::remove_XSS($row['title']),
-                'path' => $row['path'],
-                'description' => Security::remove_XSS($row['description']),
-                'parent_item_id' => $row['parent_item_id'],
-                'previous_item_id' => $row['previous_item_id'],
-                'next_item_id' => $row['next_item_id'],
-                'max_score' => $row['max_score'],
-                'min_score' => $row['min_score'],
-                'mastery_score' => $row['mastery_score'],
-                'prerequisite' => $row['prerequisite'],
-                'display_order' => $row['display_order'],
-                'audio' => $row['audio'],
-                'prerequisite_max_score' => $row['prerequisite_max_score'],
-                'prerequisite_min_score' => $row['prerequisite_min_score'],
-            ];
-        }
+        $arrLP = $this->getItemsForForm();
 
         $this->tree_array($arrLP);
         $arrLP = isset($this->arrMenu) ? $this->arrMenu : [];
@@ -6482,7 +6447,6 @@ class learnpath
      */
     public function return_new_tree($update_audio = 'false', $drop_element_here = false)
     {
-        $return = '';
         $result = $this->processBuildMenuElements($update_audio);
 
         $list = '<ul id="lp_item_list">';
@@ -6501,7 +6465,7 @@ class learnpath
         }
         $list .= '</ul>';
 
-        $return .= Display::panelCollapse(
+        $return = Display::panelCollapse(
             $this->name,
             $list,
             'scorm-list',
@@ -6533,7 +6497,7 @@ class learnpath
                 $item['type'] = $default_content[$item['load_data']]['item_type'];
             }
             $sub_list = '';
-            if (isset($item['type']) && $item['type'] == 'dir') {
+            if (isset($item['type']) && $item['type'] === 'dir') {
                 // empty value
                 $sub_list = Display::tag('li', '', ['class' => 'sub_item empty']);
             }
@@ -7453,7 +7417,6 @@ class learnpath
     {
         $course_id = api_get_course_int_id();
         $id = (int) $id;
-        $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
         $tbl_quiz = Database::get_course_table(TABLE_QUIZ_TEST);
 
         if ($id != 0 && is_array($extra_info)) {
@@ -7480,30 +7443,7 @@ class learnpath
             $parent = $extra_info['parent_item_id'];
         }
 
-        $sql = "SELECT * FROM $tbl_lp_item 
-                WHERE c_id = $course_id AND lp_id = ".$this->lp_id;
-
-        $result = Database::query($sql);
-        $arrLP = [];
-        while ($row = Database::fetch_array($result)) {
-            $arrLP[] = [
-                'id' => $row['iid'],
-                'item_type' => $row['item_type'],
-                'title' => $row['title'],
-                'path' => $row['path'],
-                'description' => $row['description'],
-                'parent_item_id' => $row['parent_item_id'],
-                'previous_item_id' => $row['previous_item_id'],
-                'next_item_id' => $row['next_item_id'],
-                'display_order' => $row['display_order'],
-                'max_score' => $row['max_score'],
-                'min_score' => $row['min_score'],
-                'mastery_score' => $row['mastery_score'],
-                'prerequisite' => $row['prerequisite'],
-                'max_time_allowed' => $row['max_time_allowed'],
-            ];
-        }
-
+        $arrLP = $this->getItemsForForm();
         $this->tree_array($arrLP);
         $arrLP = isset($this->arrMenu) ? $this->arrMenu : [];
         unset($this->arrMenu);
@@ -7530,7 +7470,7 @@ class learnpath
         $form->addHeader($legend);
 
         if ($action != 'move') {
-            $form->addText('title', get_lang('Title'), true, ['id' => 'idTitle']);
+            $this->setItemTitle($form);
             $defaults['title'] = $item_title;
         }
 
@@ -7620,13 +7560,13 @@ class learnpath
             }
         }
 
-        if ($action == 'add') {
+        if ($action === 'add') {
             $form->addButtonSave(get_lang('AddExercise'), 'submit_button');
         } else {
             $form->addButtonSave(get_lang('EditCurrentExecice'), 'submit_button');
         }
 
-        if ($action == 'move') {
+        if ($action === 'move') {
             $form->addHidden('title', $item_title);
             $form->addHidden('description', $item_description);
         }
@@ -7656,8 +7596,7 @@ class learnpath
     public function display_hotpotatoes_form($action = 'add', $id = 0, $extra_info = '')
     {
         $course_id = api_get_course_int_id();
-        $uploadPath = DIR_HOTPOTATOES; //defined in main_api
-        $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
+        $uploadPath = DIR_HOTPOTATOES;
 
         if ($id != 0 && is_array($extra_info)) {
             $item_title = stripslashes($extra_info['title']);
@@ -7665,9 +7604,9 @@ class learnpath
         } elseif (is_numeric($extra_info)) {
             $TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT);
 
-            $sql = "SELECT * FROM ".$TBL_DOCUMENT."
+            $sql = "SELECT * FROM $TBL_DOCUMENT
                     WHERE
-                        c_id = ".$course_id." AND
+                        c_id = $course_id AND
                         path LIKE '".$uploadPath."/%/%htm%' AND
                         iid = ".(int) $extra_info."
                     ORDER BY iid ASC";
@@ -7686,35 +7625,12 @@ class learnpath
             $item_description = '';
         }
 
+        $parent = 0;
         if ($id != 0 && is_array($extra_info)) {
             $parent = $extra_info['parent_item_id'];
-        } else {
-            $parent = 0;
-        }
-
-        $sql = "SELECT * FROM $tbl_lp_item
-                WHERE c_id = $course_id AND lp_id = ".$this->lp_id;
-        $result = Database::query($sql);
-        $arrLP = [];
-        while ($row = Database::fetch_array($result)) {
-            $arrLP[] = [
-                'id' => $row['id'],
-                'item_type' => $row['item_type'],
-                'title' => $row['title'],
-                'path' => $row['path'],
-                'description' => $row['description'],
-                'parent_item_id' => $row['parent_item_id'],
-                'previous_item_id' => $row['previous_item_id'],
-                'next_item_id' => $row['next_item_id'],
-                'display_order' => $row['display_order'],
-                'max_score' => $row['max_score'],
-                'min_score' => $row['min_score'],
-                'mastery_score' => $row['mastery_score'],
-                'prerequisite' => $row['prerequisite'],
-                'max_time_allowed' => $row['max_time_allowed'],
-            ];
         }
 
+        $arrLP = $this->getItemsForForm();
         $legend = '<legend>';
         if ($action == 'add') {
             $legend .= get_lang('CreateTheExercise');
@@ -7738,9 +7654,7 @@ class learnpath
         $return .= '<td class="input">';
         $return .= '<select id="idParent" name="parent" onChange="javascript: load_cbo(this.value);" size="1">';
         $return .= '<option class="top" value="0">'.$this->name.'</option>';
-        $arrHide = [
-            $id,
-        ];
+        $arrHide = [$id];
 
         if (count($arrLP) > 0) {
             for ($i = 0; $i < count($arrLP); $i++) {
@@ -7781,7 +7695,8 @@ class learnpath
                     $selected = '';
                 }
 
-                $return .= '<option '.$selected.'value="'.$arrLP[$i]['id'].'">'.get_lang('After').' "'.$arrLP[$i]['title'].'"</option>';
+                $return .= '<option '.$selected.'value="'.$arrLP[$i]['id'].'">'.
+                    get_lang('After').' "'.$arrLP[$i]['title'].'"</option>';
             }
         }
 
@@ -7849,9 +7764,11 @@ class learnpath
     public function display_forum_form($action = 'add', $id = 0, $extra_info = '')
     {
         $course_id = api_get_course_int_id();
-        $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
         $tbl_forum = Database::get_course_table(TABLE_FORUM);
 
+        $item_title = '';
+        $item_description = '';
+
         if ($id != 0 && is_array($extra_info)) {
             $item_title = stripslashes($extra_info['title']);
         } elseif (is_numeric($extra_info)) {
@@ -7864,41 +7781,12 @@ class learnpath
 
             $item_title = $row['title'];
             $item_description = $row['comment'];
-        } else {
-            $item_title = '';
-            $item_description = '';
         }
-
+        $parent = 0;
         if ($id != 0 && is_array($extra_info)) {
             $parent = $extra_info['parent_item_id'];
-        } else {
-            $parent = 0;
         }
-
-        $sql = "SELECT * FROM $tbl_lp_item
-                WHERE
-                    c_id = $course_id AND
-                    lp_id = ".$this->lp_id;
-        $result = Database::query($sql);
-        $arrLP = [];
-        while ($row = Database::fetch_array($result)) {
-            $arrLP[] = [
-                'id' => $row['iid'],
-                'item_type' => $row['item_type'],
-                'title' => $row['title'],
-                'path' => $row['path'],
-                'description' => $row['description'],
-                'parent_item_id' => $row['parent_item_id'],
-                'previous_item_id' => $row['previous_item_id'],
-                'next_item_id' => $row['next_item_id'],
-                'display_order' => $row['display_order'],
-                'max_score' => $row['max_score'],
-                'min_score' => $row['min_score'],
-                'mastery_score' => $row['mastery_score'],
-                'prerequisite' => $row['prerequisite'],
-            ];
-        }
-
+        $arrLP = $this->getItemsForForm();
         $this->tree_array($arrLP);
         $arrLP = isset($this->arrMenu) ? $this->arrMenu : [];
         unset($this->arrMenu);
@@ -7921,12 +7809,7 @@ class learnpath
         $form->addHeader($legend);
 
         if ($action != 'move') {
-            $form->addText(
-                'title',
-                get_lang('Title'),
-                true,
-                ['id' => 'idTitle', 'class' => 'learnpath_item_form']
-            );
+            $this->setItemTitle($form);
             $defaults['title'] = $item_title;
         }
 
@@ -8070,9 +7953,10 @@ class learnpath
         if (empty($course_id)) {
             return null;
         }
-        $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
         $tbl_forum = Database::get_course_table(TABLE_FORUM_THREAD);
 
+        $item_title = '';
+        $item_description = '';
         if ($id != 0 && is_array($extra_info)) {
             $item_title = stripslashes($extra_info['title']);
         } elseif (is_numeric($extra_info)) {
@@ -8084,40 +7968,14 @@ class learnpath
 
             $item_title = $row['title'];
             $item_description = '';
-        } else {
-            $item_title = '';
-            $item_description = '';
         }
 
+        $parent = 0;
         if ($id != 0 && is_array($extra_info)) {
             $parent = $extra_info['parent_item_id'];
-        } else {
-            $parent = 0;
-        }
-
-        $sql = "SELECT * FROM $tbl_lp_item
-                WHERE c_id = $course_id AND lp_id = ".$this->lp_id;
-        $result = Database::query($sql);
-
-        $arrLP = [];
-        while ($row = Database::fetch_array($result)) {
-            $arrLP[] = [
-                'id' => $row['iid'],
-                'item_type' => $row['item_type'],
-                'title' => $row['title'],
-                'path' => $row['path'],
-                'description' => $row['description'],
-                'parent_item_id' => $row['parent_item_id'],
-                'previous_item_id' => $row['previous_item_id'],
-                'next_item_id' => $row['next_item_id'],
-                'display_order' => $row['display_order'],
-                'max_score' => $row['max_score'],
-                'min_score' => $row['min_score'],
-                'mastery_score' => $row['mastery_score'],
-                'prerequisite' => $row['prerequisite'],
-            ];
         }
 
+        $arrLP = $this->getItemsForForm();
         $this->tree_array($arrLP);
         $arrLP = isset($this->arrMenu) ? $this->arrMenu : [];
         unset($this->arrMenu);
@@ -8212,12 +8070,7 @@ class learnpath
         }
 
         if ($action != 'move') {
-            $form->addText(
-                'title',
-                get_lang('Title'),
-                true,
-                ['id' => 'idTitle']
-            );
+            $this->setItemTitle($form);
             $defaults['title'] = $item_title;
 
             $id_prerequisite = 0;
@@ -8339,7 +8192,7 @@ class learnpath
             $arrLP[] = [
                 'id' => $row['iid'],
                 'item_type' => $row['item_type'],
-                'title' => $row['title'],
+                'title' => $this->cleanItemTitle($row['title']),
                 'path' => $row['path'],
                 'description' => $row['description'],
                 'parent_item_id' => $row['parent_item_id'],
@@ -8359,7 +8212,7 @@ class learnpath
 
         $url = api_get_self().'?'.api_get_cidreq().'&action='.$action.'&type='.$item_type.'&lp_id='.$this->lp_id;
 
-        $form = new FormValidator('form', 'POST', $url);
+        $form = new FormValidator('form_'.$item_type, 'POST', $url);
         $defaults['title'] = api_html_entity_decode(
             $item_title,
             ENT_QUOTES,
@@ -8373,7 +8226,7 @@ class learnpath
         $charset = api_get_system_encoding();
         for ($i = 0; $i < count($arrLP); $i++) {
             if ($action != 'add') {
-                if ($arrLP[$i]['item_type'] == 'dir' && !in_array($arrLP[$i]['id'], $arrHide) &&
+                if ($arrLP[$i]['item_type'] === 'dir' && !in_array($arrLP[$i]['id'], $arrHide) &&
                     !in_array($arrLP[$i]['parent_item_id'], $arrHide)
                 ) {
                     $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title'];
@@ -8383,7 +8236,7 @@ class learnpath
                     }
                 }
             } else {
-                if ($arrLP[$i]['item_type'] == 'dir') {
+                if ($arrLP[$i]['item_type'] === 'dir') {
                     $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title'];
                     $arrHide[$arrLP[$i]['id']]['padding'] = 20 + $arrLP[$i]['depth'] * 20;
                     if ($parent == $arrLP[$i]['id']) {
@@ -8394,9 +8247,7 @@ class learnpath
         }
 
         if ($action != 'move') {
-            $form->addElement('text', 'title', get_lang('Title'));
-            $form->applyFilter('title', 'html_filter');
-            $form->addRule('title', get_lang('ThisFieldIsRequired'), 'required');
+            $this->setItemTitle($form);
         } else {
             $form->addElement('hidden', 'title');
         }
@@ -8408,7 +8259,7 @@ class learnpath
             '',
             [
                 'id' => 'idParent',
-                'onchange' => "javascript: load_cbo(this.value);",
+                'onchange' => 'javascript: load_cbo(this.value);',
             ]
         );
 
@@ -8428,6 +8279,7 @@ class learnpath
         if (is_array($arrLP)) {
             reset($arrLP);
         }
+
         $arrHide = [];
         // POSITION
         for ($i = 0; $i < count($arrLP); $i++) {
@@ -8467,7 +8319,7 @@ class learnpath
         }
 
         // When new chapter add at the end
-        if ($action == 'add_item') {
+        if ($action === 'add_item') {
             $position->setSelected($lastPosition);
         }
 
@@ -8478,7 +8330,7 @@ class learnpath
         $form->addButtonSave(get_lang('SaveSection'), 'submit_button');
 
         //fix in order to use the tab
-        if ($item_type == 'dir') {
+        if ($item_type === 'dir') {
             $form->addElement('hidden', 'type', 'dir');
         }
 
@@ -8503,7 +8355,6 @@ class learnpath
             );
 
             $relative_prefix = '';
-
             $editor_config = [
                 'ToolbarSet' => 'LearningPathDocuments',
                 'Width' => '100%',
@@ -8562,7 +8413,6 @@ class learnpath
     {
         $course_id = api_get_course_int_id();
         $_course = api_get_course_info();
-        $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
         $tbl_doc = Database::get_course_table(TABLE_DOCUMENT);
 
         $no_display_edit_textarea = false;
@@ -8594,6 +8444,9 @@ class learnpath
                 }
             }
         }
+
+        $item_title = '';
+        $item_description = '';
         if ($id != 0 && is_array($extra_info)) {
             $item_title = stripslashes($extra_info['title']);
             $item_description = stripslashes($extra_info['description']);
@@ -8614,39 +8467,15 @@ class learnpath
                 $path_parts = pathinfo($row['path']);
                 $item_title = stripslashes($path_parts['filename']);
             }
-        } else {
-            $item_title = '';
-            $item_description = '';
         }
+
         $return = '<legend>';
         $parent = 0;
         if ($id != 0 && is_array($extra_info)) {
             $parent = $extra_info['parent_item_id'];
         }
 
-        $sql = "SELECT * FROM $tbl_lp_item
-                WHERE c_id = $course_id AND lp_id = ".$this->lp_id;
-        $result = Database::query($sql);
-        $arrLP = [];
-
-        while ($row = Database::fetch_array($result)) {
-            $arrLP[] = [
-                'id' => $row['iid'],
-                'item_type' => $row['item_type'],
-                'title' => $row['title'],
-                'path' => $row['path'],
-                'description' => $row['description'],
-                'parent_item_id' => $row['parent_item_id'],
-                'previous_item_id' => $row['previous_item_id'],
-                'next_item_id' => $row['next_item_id'],
-                'display_order' => $row['display_order'],
-                'max_score' => $row['max_score'],
-                'min_score' => $row['min_score'],
-                'mastery_score' => $row['mastery_score'],
-                'prerequisite' => $row['prerequisite'],
-            ];
-        }
-
+        $arrLP = $this->getItemsForForm();
         $this->tree_array($arrLP);
         $arrLP = isset($this->arrMenu) ? $this->arrMenu : [];
         unset($this->arrMenu);
@@ -8701,14 +8530,7 @@ class learnpath
             if (isset($data['id'])) {
                 $defaults['directory_parent_id'] = $data['id'];
             }
-
-            $form->addElement(
-                'text',
-                'title',
-                get_lang('Title'),
-                ['id' => 'idTitle', 'class' => 'col-md-4']
-            );
-            $form->applyFilter('title', 'html_filter');
+            $this->setItemTitle($form);
         }
 
         $arrHide[0]['value'] = $this->name;
@@ -8951,7 +8773,6 @@ class learnpath
     {
         $course_id = api_get_course_int_id();
         $_course = api_get_course_info();
-        $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
         $tbl_doc = Database::get_course_table(TABLE_DOCUMENT);
 
         $no_display_edit_textarea = false;
@@ -8968,6 +8789,8 @@ class learnpath
         }
         $no_display_add = false;
 
+        $item_title = '';
+        $item_description = '';
         if ($id != 0 && is_array($extra_info)) {
             $item_title = stripslashes($extra_info['title']);
             $item_description = stripslashes($extra_info['description']);
@@ -8986,44 +8809,19 @@ class learnpath
                 $path_parts = pathinfo($row['path']);
                 $item_title = stripslashes($path_parts['filename']);
             }
-        } else {
-            $item_title = '';
-            $item_description = '';
         }
 
+        $parent = 0;
         if ($id != 0 && is_array($extra_info)) {
             $parent = $extra_info['parent_item_id'];
-        } else {
-            $parent = 0;
-        }
-
-        $sql = "SELECT * FROM $tbl_lp_item WHERE c_id = $course_id AND lp_id = ".$this->lp_id;
-        $result = Database::query($sql);
-        $arrLP = [];
-
-        while ($row = Database::fetch_array($result)) {
-            $arrLP[] = [
-                'id' => $row['iid'],
-                'item_type' => $row['item_type'],
-                'title' => $row['title'],
-                'path' => $row['path'],
-                'description' => $row['description'],
-                'parent_item_id' => $row['parent_item_id'],
-                'previous_item_id' => $row['previous_item_id'],
-                'next_item_id' => $row['next_item_id'],
-                'display_order' => $row['display_order'],
-                'max_score' => $row['max_score'],
-                'min_score' => $row['min_score'],
-                'mastery_score' => $row['mastery_score'],
-                'prerequisite' => $row['prerequisite'],
-            ];
         }
 
+        $arrLP = $this->getItemsForForm();
         $this->tree_array($arrLP);
         $arrLP = isset($this->arrMenu) ? $this->arrMenu : [];
         unset($this->arrMenu);
 
-        if ($action == 'add') {
+        if ($action === 'add') {
             $formHeader = get_lang('CreateTheDocument');
         } else {
             $formHeader = get_lang('EditTheCurrentDocument');
@@ -9074,14 +8872,7 @@ class learnpath
         if (isset($data['id'])) {
             $defaults['directory_parent_id'] = $data['id'];
         }
-
-        $form->addElement(
-            'text',
-            'title',
-            get_lang('Title')
-        );
-        $form->applyFilter('title', 'trim');
-        $form->applyFilter('title', 'html_filter');
+        $this->setItemTitle($form);
 
         $arrHide[0]['value'] = $this->name;
         $arrHide[0]['padding'] = 20;
@@ -9417,7 +9208,6 @@ class learnpath
     public function display_link_form($action = 'add', $id = 0, $extra_info = '')
     {
         $course_id = api_get_course_int_id();
-        $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
         $tbl_link = Database::get_course_table(TABLE_LINK);
 
         $item_title = '';
@@ -9451,28 +9241,7 @@ class learnpath
             $parent = $extra_info['parent_item_id'];
         }
 
-        $sql = "SELECT * FROM $tbl_lp_item
-                WHERE c_id = $course_id AND lp_id = ".$this->lp_id;
-        $result = Database::query($sql);
-        $arrLP = [];
-
-        while ($row = Database::fetch_array($result)) {
-            $arrLP[] = [
-                'id' => $row['id'],
-                'item_type' => $row['item_type'],
-                'title' => $row['title'],
-                'path' => $row['path'],
-                'description' => $row['description'],
-                'parent_item_id' => $row['parent_item_id'],
-                'previous_item_id' => $row['previous_item_id'],
-                'next_item_id' => $row['next_item_id'],
-                'display_order' => $row['display_order'],
-                'max_score' => $row['max_score'],
-                'min_score' => $row['min_score'],
-                'mastery_score' => $row['mastery_score'],
-                'prerequisite' => $row['prerequisite'],
-            ];
-        }
+        $arrLP = $this->getItemsForForm();
 
         $this->tree_array($arrLP);
         $arrLP = isset($this->arrMenu) ? $this->arrMenu : [];
@@ -9489,7 +9258,7 @@ class learnpath
         $form->addHeader($legend);
 
         if ($action != 'move') {
-            $form->addText('title', get_lang('Title'), true, ['class' => 'learnpath_item_form']);
+            $this->setItemTitle($form);
             $defaults['title'] = $item_title;
         }
 
@@ -9624,7 +9393,6 @@ class learnpath
         $extra_info = ''
     ) {
         $course_id = api_get_course_int_id();
-        $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
         $tbl_publication = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
 
         $item_title = get_lang('Student_publication');
@@ -9649,28 +9417,7 @@ class learnpath
             $parent = $extra_info['parent_item_id'];
         }
 
-        $sql = "SELECT * FROM $tbl_lp_item 
-                WHERE c_id = $course_id AND lp_id = ".$this->lp_id;
-        $result = Database::query($sql);
-        $arrLP = [];
-
-        while ($row = Database::fetch_array($result)) {
-            $arrLP[] = [
-                'id' => $row['iid'],
-                'item_type' => $row['item_type'],
-                'title' => $row['title'],
-                'path' => $row['path'],
-                'description' => $row['description'],
-                'parent_item_id' => $row['parent_item_id'],
-                'previous_item_id' => $row['previous_item_id'],
-                'next_item_id' => $row['next_item_id'],
-                'display_order' => $row['display_order'],
-                'max_score' => $row['max_score'],
-                'min_score' => $row['min_score'],
-                'mastery_score' => $row['mastery_score'],
-                'prerequisite' => $row['prerequisite'],
-            ];
-        }
+        $arrLP = $this->getItemsForForm();
 
         $this->tree_array($arrLP);
         $arrLP = isset($this->arrMenu) ? $this->arrMenu : [];
@@ -9687,12 +9434,7 @@ class learnpath
         }
 
         if ($action != 'move') {
-            $form->addText(
-                'title',
-                get_lang('Title'),
-                true,
-                ['class' => 'learnpath_item_form', 'id' => 'idTitle']
-            );
+            $this->setItemTitle($form);
         }
 
         $parentSelect = $form->addSelect(
@@ -9914,6 +9656,7 @@ class learnpath
         $return .= 'var child_value = new Array();'."\n\n";
         $return .= 'child_name[0] = new Array();'."\n";
         $return .= 'child_value[0] = new Array();'."\n\n";
+
         $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
         $sql = "SELECT * FROM ".$tbl_lp_item."
                 WHERE 
@@ -9924,7 +9667,9 @@ class learnpath
         $res_zero = Database::query($sql);
         $i = 0;
 
-        while ($row_zero = Database::fetch_array($res_zero)) {
+        $list = $this->getItemsForForm(true);
+
+        foreach ($list as $row_zero) {
             if ($row_zero['item_type'] !== TOOL_LP_FINAL_ITEM) {
                 if ($row_zero['item_type'] == TOOL_QUIZ) {
                     $row_zero['title'] = Exercise::get_formated_title_variable($row_zero['title']);
@@ -9934,6 +9679,7 @@ class learnpath
                 $return .= 'child_value[0]['.$i++.'] = "'.$row_zero['iid'].'";'."\n";
             }
         }
+
         $return .= "\n";
         $sql = "SELECT * FROM $tbl_lp_item
                 WHERE c_id = $course_id AND lp_id = ".$this->lp_id;
@@ -9950,7 +9696,7 @@ class learnpath
             $return .= 'child_value['.$row['iid'].'] = new Array();'."\n\n";
 
             while ($row_parent = Database::fetch_array($res_parent)) {
-                $js_var = json_encode(get_lang('After').' '.$row_parent['title']);
+                $js_var = json_encode(get_lang('After').' '.$this->cleanItemTitle($row_parent['title']));
                 $return .= 'child_name['.$row['iid'].']['.$i.'] =   '.$js_var.' ;'."\n";
                 $return .= 'child_value['.$row['iid'].']['.$i++.'] = "'.$row_parent['iid'].'";'."\n";
             }
@@ -10100,7 +9846,6 @@ class learnpath
         $sql = "SELECT * FROM $tbl_lp_item
                 WHERE c_id = $course_id AND lp_id = ".$this->lp_id;
         $result = Database::query($sql);
-        $arrLP = [];
 
         $selectedMinScore = [];
         $selectedMaxScore = [];
@@ -10111,26 +9856,9 @@ class learnpath
                 $selectedMaxScore[$row['prerequisite']] = $row['prerequisite_max_score'];
             }
             $masteryScore[$row['iid']] = $row['mastery_score'];
-
-            $arrLP[] = [
-                'id' => $row['iid'],
-                'item_type' => $row['item_type'],
-                'title' => $row['title'],
-                'ref' => $row['ref'],
-                'description' => $row['description'],
-                'parent_item_id' => $row['parent_item_id'],
-                'previous_item_id' => $row['previous_item_id'],
-                'next_item_id' => $row['next_item_id'],
-                'max_score' => $row['max_score'],
-                'min_score' => $row['min_score'],
-                'mastery_score' => $row['mastery_score'],
-                'prerequisite' => $row['prerequisite'],
-                'display_order' => $row['display_order'],
-                'prerequisite_min_score' => $row['prerequisite_min_score'],
-                'prerequisite_max_score' => $row['prerequisite_max_score'],
-            ];
         }
 
+        $arrLP = $this->getItemsForForm();
         $this->tree_array($arrLP);
         $arrLP = isset($this->arrMenu) ? $this->arrMenu : [];
         unset($this->arrMenu);
@@ -13820,6 +13548,81 @@ EOD;
         return Display::img($path);
     }
 
+    /**
+     * @param string $value
+     *
+     * @return string
+     */
+    public function cleanItemTitle($value)
+    {
+        $value = Security::remove_XSS(strip_tags($value));
+
+        return $value;
+    }
+
+    /**
+     * @param FormValidator $form
+     */
+    public function setItemTitle(FormValidator $form)
+    {
+        if (api_get_configuration_value('save_titles_as_html')) {
+            $form->addHtmlEditor(
+                'title',
+                get_lang('Title'),
+                true,
+                false,
+                ['ToolbarSet' => 'TitleAsHtml']
+            );
+        } else {
+            $form->addText('title', get_lang('Title'), true, ['id' => 'idTitle', 'class' => 'learnpath_item_form']);
+            $form->applyFilter('title', 'trim');
+            $form->applyFilter('title', 'html_filter');
+        }
+    }
+
+    /**
+     * @return array
+     */
+    public function getItemsForForm($addParentCondition = false)
+    {
+        $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
+        $course_id = api_get_course_int_id();
+
+        $sql = "SELECT * FROM $tbl_lp_item 
+                WHERE c_id = $course_id AND lp_id = ".$this->lp_id;
+
+        if ($addParentCondition) {
+            $sql .= ' AND parent_item_id = 0 ';
+        }
+        $sql .= ' ORDER BY display_order ASC';
+
+        $result = Database::query($sql);
+        $arrLP = [];
+        while ($row = Database::fetch_array($result)) {
+            $arrLP[] = [
+                'iid' => $row['iid'],
+                'id' => $row['iid'],
+                'item_type' => $row['item_type'],
+                'title' => $this->cleanItemTitle($row['title']),
+                'path' => $row['path'],
+                'description' => Security::remove_XSS($row['description']),
+                'parent_item_id' => $row['parent_item_id'],
+                'previous_item_id' => $row['previous_item_id'],
+                'next_item_id' => $row['next_item_id'],
+                'display_order' => $row['display_order'],
+                'max_score' => $row['max_score'],
+                'min_score' => $row['min_score'],
+                'mastery_score' => $row['mastery_score'],
+                'prerequisite' => $row['prerequisite'],
+                'max_time_allowed' => $row['max_time_allowed'],
+                'prerequisite_min_score' => $row['prerequisite_min_score'],
+                'prerequisite_max_score' => $row['prerequisite_max_score'],
+            ];
+        }
+
+        return $arrLP;
+    }
+
     /**
      * Get the depth level of LP item.
      *

+ 16 - 6
main/lp/lp_add.php

@@ -91,12 +91,22 @@ $form = new FormValidator(
 $form->addHeader(get_lang('AddLpToStart'));
 
 // Title
-$form->addElement(
-    'text',
-    'lp_name',
-    api_ucfirst(get_lang('LPName')),
-    ['autofocus' => 'autofocus']
-);
+if (api_get_configuration_value('save_titles_as_html')) {
+    $form->addHtmlEditor(
+        'lp_name',
+        get_lang('LPName'),
+        true,
+        false,
+        ['ToolbarSet' => 'TitleAsHtml']
+    );
+} else {
+    $form->addElement(
+        'text',
+        'lp_name',
+        api_ucfirst(get_lang('LPName')),
+        ['autofocus' => 'autofocus']
+    );
+}
 $form->applyFilter('lp_name', 'html_filter');
 $form->addRule('lp_name', get_lang('ThisFieldIsRequired'), 'required');
 

+ 1 - 1
main/lp/lp_add_audio.php

@@ -40,7 +40,7 @@ $interbreadcrumb[] = [
 ];
 $interbreadcrumb[] = [
     'url' => api_get_self()."?action=build&lp_id=$learnpath_id&".api_get_cidreq(),
-    'name' => $lp->get_name(),
+    'name' => $lp->getNameNoTags(),
 ];
 
 switch ($type) {

+ 1 - 1
main/lp/lp_add_category.php

@@ -37,7 +37,7 @@ if (api_get_configuration_value('save_titles_as_html')) {
         get_lang('Name'),
         true,
         false,
-        ['ToolbarSet' => 'Minimal', 'Height' => '100']
+        ['ToolbarSet' => 'TitleAsHtml']
     );
 } else {
     $form->addText('name', get_lang('Name'), true);

+ 1 - 1
main/lp/lp_add_item.php

@@ -99,7 +99,7 @@ $interbreadcrumb[] = [
 ];
 $interbreadcrumb[] = [
     'url' => api_get_self()."?action=build&lp_id=$lpId&".api_get_cidreq(),
-    'name' => $learnPath->get_name(),
+    'name' => $learnPath->getNameNoTags(),
 ];
 
 switch ($type) {

+ 1 - 1
main/lp/lp_admin_view.php

@@ -48,7 +48,7 @@ $interbreadcrumb[] = [
 ];
 $interbreadcrumb[] = [
     'url' => api_get_self()."?action=build&lp_id=$learnpath_id&".api_get_cidreq(),
-    "name" => Security::remove_XSS($learnPath->get_name()),
+    "name" => Security::remove_XSS($learnPath->getNameNoTags()),
 ];
 $interbreadcrumb[] = [
     'url' => api_get_self()."?action=add_item&type=step&lp_id=$learnpath_id&".api_get_cidreq(),

+ 1 - 1
main/lp/lp_build.php

@@ -44,7 +44,7 @@ if (api_is_in_gradebook()) {
     ];
 }
 $interbreadcrumb[] = ['url' => 'lp_controller.php?action=list&'.api_get_cidreq(), 'name' => get_lang('LearningPaths')];
-$interbreadcrumb[] = ['url' => '#', "name" => $learnPath->get_name()];
+$interbreadcrumb[] = ['url' => '#', 'name' => $learnPath->getNameNoTags()];
 
 // Theme calls.
 $lp_theme_css = $learnPath->get_theme();

+ 1 - 1
main/lp/lp_content.php

@@ -103,7 +103,7 @@ if (api_is_in_gradebook()) {
     ];
 }
 // Define the 'doc.inc.php' as language file.
-$nameTools = $learnPath->get_name();
+$nameTools = $learnPath->getNameNoTags();
 $interbreadcrumb[] = [
     'url' => api_get_path(WEB_CODE_PATH).'lp/lp_list.php?'.api_get_cidreq(),
     'name' => get_lang('Doc'),

+ 3 - 2
main/lp/lp_controller.php

@@ -1187,15 +1187,15 @@ switch ($action) {
             }
             $_SESSION['oLP']->set_theme($_REQUEST['lp_theme']);
 
+            $hide_toc_frame = null;
             if (isset($_REQUEST['hide_toc_frame']) && $_REQUEST['hide_toc_frame'] == 1) {
                 $hide_toc_frame = $_REQUEST['hide_toc_frame'];
-            } else {
-                $hide_toc_frame = null;
             }
             $_SESSION['oLP']->set_hide_toc_frame($hide_toc_frame);
             $_SESSION['oLP']->set_prerequisite(isset($_POST['prerequisites']) ? (int) $_POST['prerequisites'] : 0);
             $_SESSION['oLP']->setAccumulateWorkTime(isset($_REQUEST['accumulate_work_time']) ? $_REQUEST['accumulate_work_time'] : 0);
             $_SESSION['oLP']->set_use_max_score(isset($_POST['use_max_score']) ? 1 : 0);
+
             $subscribeUsers = isset($_REQUEST['subscribe_users']) ? 1 : 0;
             $_SESSION['oLP']->setSubscribeUsers($subscribeUsers);
 
@@ -1211,6 +1211,7 @@ switch ($action) {
             if (isset($_REQUEST['activate_end_date_check']) && $_REQUEST['activate_end_date_check'] == 1) {
                 $expired_on = $_REQUEST['expired_on'];
             }
+
             $_SESSION['oLP']->setCategoryId($_REQUEST['category_id']);
             $_SESSION['oLP']->set_modified_on();
             $_SESSION['oLP']->set_publicated_on($publicated_on);

+ 14 - 4
main/lp/lp_edit.php

@@ -35,7 +35,7 @@ $interbreadcrumb[] = [
 ];
 $interbreadcrumb[] = [
     'url' => api_get_self()."?action=build&lp_id=".$lpId.'&'.api_get_cidreq(),
-    'name' => $learnPath->get_name(),
+    'name' => $learnPath->getNameNoTags(),
 ];
 
 $htmlHeadXtra[] = '<script>
@@ -65,10 +65,20 @@ $form = new FormValidator(
 );
 
 // Form title
-$form->addElement('header', get_lang('EditLPSettings'));
+$form->addElement('header', get_lang('Edit'));
 
 // Title
-$form->addElement('text', 'lp_name', api_ucfirst(get_lang('LearnpathTitle')), ['size' => 43]);
+if (api_get_configuration_value('save_titles_as_html')) {
+    $form->addHtmlEditor(
+        'lp_name',
+        get_lang('LPName'),
+        true,
+        false,
+        ['ToolbarSet' => 'TitleAsHtml']
+    );
+} else {
+    $form->addElement('text', 'lp_name', api_ucfirst(get_lang('LearnpathTitle')), ['size' => 43]);
+}
 $form->applyFilter('lp_name', 'html_filter');
 $form->addRule('lp_name', get_lang('ThisFieldIsRequired'), 'required');
 $form->addElement('hidden', 'lp_encoding');
@@ -111,7 +121,7 @@ if (strlen($learnPath->get_preview_image()) > 0) {
     $form->addElement('label', get_lang('ImagePreview'), $show_preview_image);
     $form->addElement('checkbox', 'remove_picture', null, get_lang('DelImage'));
 }
-$label = ($learnPath->get_preview_image() != '' ? get_lang('UpdateImage') : get_lang('AddImage'));
+$label = $learnPath->get_preview_image() != '' ? get_lang('UpdateImage') : get_lang('AddImage');
 $form->addElement('file', 'lp_preview_image', [$label, get_lang('ImageWillResizeMsg')]);
 $form->addRule('lp_preview_image', get_lang('OnlyImagesAllowed'), 'filetype', ['jpg', 'jpeg', 'png', 'gif']);
 

+ 3 - 6
main/lp/lp_edit_item.php

@@ -42,12 +42,9 @@ if (!$is_allowed_to_edit || $isStudentView) {
     exit;
 }
 // From here on, we are admin because of the previous condition, so don't check anymore.
-
+/** @var learnpath $learnPath */
+$learnPath = Session::read('oLP');
 $course_id = api_get_course_int_id();
-$sql = "SELECT * FROM $tbl_lp
-        WHERE c_id = $course_id AND id = $learnpath_id";
-$result = Database::query($sql);
-$therow = Database::fetch_array($result);
 
 /*
     Course admin section
@@ -65,7 +62,7 @@ $interbreadcrumb[] = [
 ];
 $interbreadcrumb[] = [
     'url' => api_get_self()."?action=build&lp_id=$learnpath_id&".api_get_cidreq(),
-    'name' => Security::remove_XSS($therow['name']),
+    'name' => $learnPath->getNameNoTags(),
 ];
 $interbreadcrumb[] = [
     'url' => api_get_self()."?action=add_item&type=step&lp_id=$learnpath_id&".api_get_cidreq(),

+ 1 - 1
main/lp/lp_edit_item_prereq.php

@@ -49,7 +49,7 @@ $interbreadcrumb[] = [
 ];
 $interbreadcrumb[] = [
     'url' => api_get_self()."?action=build&lp_id=$learnpath_id",
-    'name' => stripslashes($lp->get_name()),
+    'name' => $lp->getNameNoTags(),
 ];
 $interbreadcrumb[] = [
     'url' => api_get_self()."?action=add_item&type=step&lp_id=$learnpath_id&".api_get_cidreq(),

+ 1 - 1
main/lp/lp_impress.php

@@ -59,7 +59,7 @@ if ($is_allowed_to_edit) {
     ];
     $interbreadcrumb[] = [
         'url' => api_get_self()."?action=add_item&type=step&lp_id=".$lp->lp_id."&isStudentView=false&".api_get_cidreq(),
-        'name' => $lp->get_name(),
+        'name' => $lp->getNameNoTags(),
     ];
     $interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Preview')];
     echo return_breadcrumb($interbreadcrumb, null, null);

+ 1 - 1
main/lp/lp_list.php

@@ -316,7 +316,7 @@ foreach ($categories as $item) {
             }
 
             $url_start_lp = 'lp_controller.php?'.$cidReq.'&action=view&lp_id='.$id;
-            $name = Security::remove_XSS($details['lp_name']);
+            $name = strip_tags(Security::remove_XSS($details['lp_name']));
             $extra = null;
 
             if ($is_allowed_to_edit) {

+ 1 - 1
main/lp/lp_move_item.php

@@ -63,7 +63,7 @@ $interbreadcrumb[] = [
 ];
 $interbreadcrumb[] = [
     'url' => api_get_self()."?action=build&lp_id=$learnpath_id&".api_get_cidreq(),
-    'name' => stripslashes($learnPath->get_name()),
+    'name' => $learnPath->getNameNoTags(),
 ];
 $interbreadcrumb[] = [
     'url' => api_get_self()."?action=add_item&type=step&lp_id=$learnpath_id&".api_get_cidreq(),

+ 2 - 2
main/lp/lp_subscribe_users.php

@@ -37,8 +37,8 @@ $interbreadcrumb[] = [
 ];
 
 $interbreadcrumb[] = [
-    'url' => api_get_self()."?action=build&lp_id=".$oLP->get_id().'&'.api_get_cidreq(),
-    'name' => $oLP->get_name(),
+    'url' => api_get_self().'?action=build&lp_id='.$oLP->get_id().'&'.api_get_cidreq(),
+    'name' => $oLP->getNameNoTags(),
 ];
 
 $courseId = api_get_course_int_id();

+ 1 - 1
main/lp/lp_update_scorm.php

@@ -36,7 +36,7 @@ $interbreadcrumb[] = [
 ];
 $interbreadcrumb[] = [
     'url' => api_get_self()."?action=build&lp_id=$lpId&".api_get_cidreq(),
-    'name' => $lp->get_name(),
+    'name' => $lp->getNameNoTags(),
 ];
 
 $form = new FormValidator(

+ 3 - 3
main/lp/lp_view.php

@@ -447,7 +447,7 @@ if ($is_allowed_to_edit) {
     ];
     $interbreadcrumb[] = [
         'url' => api_get_self()."?action=add_item&type=step&lp_id={$lp->lp_id}&isStudentView=false&".api_get_cidreq(true, true, 'course'),
-        'name' => $lp->get_name(),
+        'name' => $lp->getNameNoTags(),
     ];
 
     $interbreadcrumb[] = [
@@ -606,7 +606,7 @@ if (Tracking::minimumTimeAvailable(api_get_session_id(), api_get_course_int_id()
 
 $template->assign('lp_accumulate_work_time', $lpMinTime);
 $template->assign('lp_mode', $lp->mode);
-$template->assign('lp_title_scorm', $lp->name);
+$template->assign('lp_title_scorm', $lp->get_name());
 if (api_get_configuration_value('lp_view_accordion') === true && $lpType == 1) {
     $template->assign('data_panel', $lp->getParentToc($get_toc_list));
 } else {
@@ -619,7 +619,7 @@ $template->assign(
     'lp_preview_image',
     Display::img(
         $lpPreviewImagePath,
-        $lp->name,
+        $lp->getNameNoTags(),
         [],
         ICON_SIZE_BIG
     )

+ 1 - 1
main/lp/lp_view_item.php

@@ -78,7 +78,7 @@ $interbreadcrumb[] = [
 ];
 $interbreadcrumb[] = [
     'url' => api_get_self()."?action=build&lp_id=$learnpath_id&".api_get_cidreq(),
-    'name' => $lp->get_name(),
+    'name' => $lp->getNameNoTags(),
 ];
 $interbreadcrumb[] = [
     'url' => api_get_self()."?action=add_item&type=step&lp_id=$learnpath_id&".api_get_cidreq(),

+ 1 - 1
main/portfolio/add_category.php

@@ -5,7 +5,7 @@ use Chamilo\CoreBundle\Entity\PortfolioCategory;
 
 $form = new FormValidator('add_category', 'post', "$baseUrl&action=add_category");
 if (api_get_configuration_value('save_titles_as_html')) {
-    $form->addHtmlEditor('title', get_lang('Title'), true, false, ['ToolbarSet' => 'NotebookStudent']);
+    $form->addHtmlEditor('title', get_lang('Title'), true, false, ['ToolbarSet' => 'TitleAsHtml']);
 } else {
     $form->addText('title', get_lang('Title'));
     $form->applyFilter('title', 'trim');

+ 1 - 1
main/portfolio/add_item.php

@@ -11,7 +11,7 @@ $categories = $em
 
 $form = new FormValidator('add_portfolio', 'post', $baseUrl.'action=add_item');
 if (api_get_configuration_value('save_titles_as_html')) {
-    $form->addHtmlEditor('title', get_lang('Title'), true, false, ['ToolbarSet' => 'NotebookStudent']);
+    $form->addHtmlEditor('title', get_lang('Title'), true, false, ['ToolbarSet' => 'TitleAsHtml']);
 } else {
     $form->addText('title', get_lang('Title'));
     $form->applyFilter('title', 'trim');

+ 1 - 1
main/portfolio/edit_category.php

@@ -3,7 +3,7 @@
 
 $form = new FormValidator('edit_category', 'post', $baseUrl."action=edit_category&id={$category->getId()}");
 if (api_get_configuration_value('save_titles_as_html')) {
-    $form->addHtmlEditor('title', get_lang('Title'), true, false, ['ToolbarSet' => 'NotebookStudent']);
+    $form->addHtmlEditor('title', get_lang('Title'), true, false, ['ToolbarSet' => 'TitleAsHtml']);
 } else {
     $form->addText('title', get_lang('Title'));
     $form->applyFilter('title', 'trim');

+ 1 - 1
main/portfolio/edit_item.php

@@ -9,7 +9,7 @@ $categories = $em
 
 $form = new FormValidator('edit_portfolio', 'post', $baseUrl."action=edit_item&id={$item->getId()}");
 if (api_get_configuration_value('save_titles_as_html')) {
-    $form->addHtmlEditor('title', get_lang('Title'), true, false, ['ToolbarSet' => 'NotebookStudent']);
+    $form->addHtmlEditor('title', get_lang('Title'), true, false, ['ToolbarSet' => 'TitleAsHtml']);
 } else {
     $form->addText('title', get_lang('Title'));
     $form->applyFilter('title', 'trim');

+ 2 - 2
main/template/default/learnpath/scorm_list.tpl

@@ -8,11 +8,11 @@
             {% for item in data_list %}
             <div id="toc_{{ item.id }}" class="{{ item.class }} item-{{ item.type }}">
                 {% if item.type == 'dir' %}
-                <div class="section {{ item.css_level }}" title="{{ item.description }}">
+                <div class="section {{ item.css_level }}" title="{{ item.description | striptags | e('html') }}">
                     {{ item.title }}
                 </div>
                 {% else %}
-                <div class="item {{ item.css_level }}" title="{{ item.description }}">
+                <div class="item {{ item.css_level }}" title="{{ item.description | striptags | e('html') }}">
                     <a name="atoc_{{ item.id }}"></a>
                     <a data-type="type-{{ item.type }}" class="items-list"  href="#"
                        onclick="switch_item('{{ item.current_id }}','{{ item.id }}'); return false;">

+ 3 - 3
src/Chamilo/CoreBundle/Component/Editor/CkEditor/CkEditor.php

@@ -41,7 +41,7 @@ class CkEditor extends Editor
      */
     public function createHtml($value)
     {
-        $html = '<textarea id="'.$this->getName().'" name="'.$this->getName().'" class="ckeditor">
+        $html = '<textarea id="'.$this->getTextareaId().'" name="'.$this->getName().'" class="ckeditor">
                  '.$value.'
                  </textarea>';
         $html .= $this->editorReplace();
@@ -74,7 +74,7 @@ class CkEditor extends Editor
             $style .= api_get_css(ChamiloApi::getEditorDocStylePath());
         }
 
-        $html = '<textarea id="'.$this->getName().'" name="'.$this->getName().'" class="ckeditor">
+        $html = '<textarea id="'.$this->getTextareaId().'" name="'.$this->getName().'" class="ckeditor">
                  '.$style.$value.'
                  </textarea>';
         $html .= $this->editorReplace();
@@ -97,7 +97,7 @@ class CkEditor extends Editor
         $javascript = $this->toJavascript($config);
 
         $html = "<script>
-           CKEDITOR.replace('".$this->getName()."',
+           CKEDITOR.replace('".$this->getTextareaId()."',
                $javascript
            );
            </script>";

+ 1 - 1
src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/Minimal.php

@@ -24,7 +24,7 @@ class Minimal extends Basic
             [
                 'name' => 'basicstyles',
                 'groups' => ['basicstyles', 'cleanup'],
-                'items' => ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript'],
+                'items' => ['Bold', 'Italic', 'Underline', 'Strike', 'TextColor'],
             ],
             [
                 'name' => 'paragraph',

+ 44 - 0
src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/TitleAsHtml.php

@@ -0,0 +1,44 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+namespace Chamilo\CoreBundle\Component\Editor\CkEditor\Toolbar;
+
+/**
+ * Toolbar used to allow titles to have an HTML format.
+ *
+ * @package Chamilo\CoreBundle\Component\Editor\CkEditor\Toolbar
+ */
+class TitleAsHtml extends Basic
+{
+    /**
+     * @return mixed
+     */
+    public function getConfig()
+    {
+        $config['toolbar'] = [
+            [
+                'name' => 'clipboard',
+                'groups' => ['clipboard', 'undo'],
+                'items' => ['Cut', 'Copy', 'Paste', '-', 'Undo', 'Redo'],
+            ],
+            [
+                'name' => 'basicstyles',
+                'groups' => ['basicstyles', 'cleanup'],
+                'items' => ['Bold', 'Italic', 'Underline', 'Strike', 'TextColor', 'BGColor'],
+            ],
+//            [
+//                'name' => 'paragraph',
+//                'groups' => ['list', 'indent', 'blocks', 'align', 'bidi'],
+//                'items' => ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent'],
+//            ],
+            [
+                'name' => 'links',
+                'items' => ['Link', 'Unlink', 'Source'],
+            ],
+        ];
+
+        $config['height'] = '100';
+
+        return $config;
+    }
+}

+ 27 - 2
src/Chamilo/CoreBundle/Component/Editor/Editor.php

@@ -13,6 +13,11 @@ use Symfony\Component\Translation\Translator;
  */
 class Editor
 {
+    /**
+     * @var string
+     */
+    public $textareaId;
+
     /**
      * Name of the instance.
      *
@@ -80,6 +85,26 @@ class Editor
         $this->name = $name;
     }
 
+    /**
+     * @return string
+     */
+    public function getTextareaId()
+    {
+        return $this->textareaId;
+    }
+
+    /**
+     * @param string $textareaId
+     *
+     * @return Editor
+     */
+    public function setTextareaId($textareaId)
+    {
+        $this->textareaId = $textareaId;
+
+        return $this;
+    }
+
     /**
      * Return the HTML code required to run editor.
      *
@@ -89,7 +114,7 @@ class Editor
      */
     public function createHtml($value)
     {
-        $html = '<textarea id="'.$this->getName().'" name="'.$this->getName().'">'.$value.'</textarea>';
+        $html = '<textarea id="'.$this->getTextareaId().'" name="'.$this->getName().'">'.$value.'</textarea>';
 
         return $html;
     }
@@ -105,7 +130,7 @@ class Editor
         $javascript = $this->toJavascript($config);
 
         $html = "<script>
-           CKEDITOR.replace('".$this->name."',
+           CKEDITOR.replace('".$this->getTextareaId()."',
                $javascript
            );