Merge pull request #2990 from chamilo/lp_item_title_as_html

Lp item title as html
pull/2999/head
Julio Montoya 6 years ago committed by GitHub
commit 209e64f851
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      main/admin/course_category.php
  2. 2
      main/course_description/add.php
  3. 2
      main/course_description/edit.php
  4. 24
      main/course_home/course_home.php
  5. 2
      main/course_progress/thematic.php
  6. 2
      main/exercise/ReadingComprehension.php
  7. 2
      main/exercise/exercise.class.php
  8. 2
      main/exercise/question.class.php
  9. 4
      main/glossary/index.php
  10. 15
      main/inc/lib/course_home.lib.php
  11. 2
      main/inc/lib/formvalidator/Element/HtmlEditor.php
  12. 8
      main/inc/lib/pear/HTML/QuickForm/textarea.php
  13. 5
      main/install/configuration.dist.php
  14. 491
      main/lp/learnpath.class.php
  15. 10
      main/lp/lp_add.php
  16. 2
      main/lp/lp_add_audio.php
  17. 2
      main/lp/lp_add_category.php
  18. 2
      main/lp/lp_add_item.php
  19. 2
      main/lp/lp_admin_view.php
  20. 2
      main/lp/lp_build.php
  21. 2
      main/lp/lp_content.php
  22. 5
      main/lp/lp_controller.php
  23. 16
      main/lp/lp_edit.php
  24. 9
      main/lp/lp_edit_item.php
  25. 2
      main/lp/lp_edit_item_prereq.php
  26. 2
      main/lp/lp_impress.php
  27. 2
      main/lp/lp_list.php
  28. 2
      main/lp/lp_move_item.php
  29. 4
      main/lp/lp_subscribe_users.php
  30. 2
      main/lp/lp_update_scorm.php
  31. 6
      main/lp/lp_view.php
  32. 2
      main/lp/lp_view_item.php
  33. 2
      main/portfolio/add_category.php
  34. 2
      main/portfolio/add_item.php
  35. 2
      main/portfolio/edit_category.php
  36. 2
      main/portfolio/edit_item.php
  37. 4
      main/template/default/learnpath/scorm_list.tpl
  38. 6
      src/Chamilo/CoreBundle/Component/Editor/CkEditor/CkEditor.php
  39. 2
      src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/Minimal.php
  40. 44
      src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/TitleAsHtml.php
  41. 29
      src/Chamilo/CoreBundle/Component/Editor/Editor.php

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

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

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

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

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

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

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

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

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

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

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

@ -58,6 +58,14 @@ class HTML_QuickForm_textarea extends HTML_QuickForm_element
$columnsSize = isset($attributes['cols-size']) ? $attributes['cols-size'] : null; $columnsSize = isset($attributes['cols-size']) ? $attributes['cols-size'] : null;
$this->setColumnsSize($columnsSize); $this->setColumnsSize($columnsSize);
parent::__construct($elementName, $label, $attributes); 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->_persistantFreeze = true;
$this->_type = 'textarea'; $this->_type = 'textarea';
$this->_value = null; $this->_value = null;

@ -399,6 +399,11 @@ ALTER TABLE c_tool CHANGE name name LONGTEXT NOT NULL;
-- Only with allow_portfolio_tool enabled -- Only with allow_portfolio_tool enabled
ALTER TABLE portfolio CHANGE title title LONGTEXT NOT NULL; ALTER TABLE portfolio CHANGE title title LONGTEXT NOT NULL;
ALTER TABLE portfolio_category 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; // $_configuration['save_titles_as_html'] = false;

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

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

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

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

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

@ -48,7 +48,7 @@ $interbreadcrumb[] = [
]; ];
$interbreadcrumb[] = [ $interbreadcrumb[] = [
'url' => api_get_self()."?action=build&lp_id=$learnpath_id&".api_get_cidreq(), '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[] = [ $interbreadcrumb[] = [
'url' => api_get_self()."?action=add_item&type=step&lp_id=$learnpath_id&".api_get_cidreq(), 'url' => api_get_self()."?action=add_item&type=step&lp_id=$learnpath_id&".api_get_cidreq(),

@ -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' => '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. // Theme calls.
$lp_theme_css = $learnPath->get_theme(); $lp_theme_css = $learnPath->get_theme();

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

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

@ -35,7 +35,7 @@ $interbreadcrumb[] = [
]; ];
$interbreadcrumb[] = [ $interbreadcrumb[] = [
'url' => api_get_self()."?action=build&lp_id=".$lpId.'&'.api_get_cidreq(), 'url' => api_get_self()."?action=build&lp_id=".$lpId.'&'.api_get_cidreq(),
'name' => $learnPath->get_name(), 'name' => $learnPath->getNameNoTags(),
]; ];
$htmlHeadXtra[] = '<script> $htmlHeadXtra[] = '<script>
@ -65,10 +65,20 @@ $form = new FormValidator(
); );
// Form title // Form title
$form->addElement('header', get_lang('EditLPSettings')); $form->addElement('header', get_lang('Edit'));
// Title // Title
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->addElement('text', 'lp_name', api_ucfirst(get_lang('LearnpathTitle')), ['size' => 43]);
}
$form->applyFilter('lp_name', 'html_filter'); $form->applyFilter('lp_name', 'html_filter');
$form->addRule('lp_name', get_lang('ThisFieldIsRequired'), 'required'); $form->addRule('lp_name', get_lang('ThisFieldIsRequired'), 'required');
$form->addElement('hidden', 'lp_encoding'); $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('label', get_lang('ImagePreview'), $show_preview_image);
$form->addElement('checkbox', 'remove_picture', null, get_lang('DelImage')); $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->addElement('file', 'lp_preview_image', [$label, get_lang('ImageWillResizeMsg')]);
$form->addRule('lp_preview_image', get_lang('OnlyImagesAllowed'), 'filetype', ['jpg', 'jpeg', 'png', 'gif']); $form->addRule('lp_preview_image', get_lang('OnlyImagesAllowed'), 'filetype', ['jpg', 'jpeg', 'png', 'gif']);

@ -42,12 +42,9 @@ if (!$is_allowed_to_edit || $isStudentView) {
exit; exit;
} }
// From here on, we are admin because of the previous condition, so don't check anymore. // 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(); $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 Course admin section
@ -65,7 +62,7 @@ $interbreadcrumb[] = [
]; ];
$interbreadcrumb[] = [ $interbreadcrumb[] = [
'url' => api_get_self()."?action=build&lp_id=$learnpath_id&".api_get_cidreq(), 'url' => api_get_self()."?action=build&lp_id=$learnpath_id&".api_get_cidreq(),
'name' => Security::remove_XSS($therow['name']), 'name' => $learnPath->getNameNoTags(),
]; ];
$interbreadcrumb[] = [ $interbreadcrumb[] = [
'url' => api_get_self()."?action=add_item&type=step&lp_id=$learnpath_id&".api_get_cidreq(), 'url' => api_get_self()."?action=add_item&type=step&lp_id=$learnpath_id&".api_get_cidreq(),

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

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

@ -316,7 +316,7 @@ foreach ($categories as $item) {
} }
$url_start_lp = 'lp_controller.php?'.$cidReq.'&action=view&lp_id='.$id; $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; $extra = null;
if ($is_allowed_to_edit) { if ($is_allowed_to_edit) {

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

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

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

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

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

@ -5,7 +5,7 @@ use Chamilo\CoreBundle\Entity\PortfolioCategory;
$form = new FormValidator('add_category', 'post', "$baseUrl&action=add_category"); $form = new FormValidator('add_category', 'post', "$baseUrl&action=add_category");
if (api_get_configuration_value('save_titles_as_html')) { 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 { } else {
$form->addText('title', get_lang('Title')); $form->addText('title', get_lang('Title'));
$form->applyFilter('title', 'trim'); $form->applyFilter('title', 'trim');

@ -11,7 +11,7 @@ $categories = $em
$form = new FormValidator('add_portfolio', 'post', $baseUrl.'action=add_item'); $form = new FormValidator('add_portfolio', 'post', $baseUrl.'action=add_item');
if (api_get_configuration_value('save_titles_as_html')) { 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 { } else {
$form->addText('title', get_lang('Title')); $form->addText('title', get_lang('Title'));
$form->applyFilter('title', 'trim'); $form->applyFilter('title', 'trim');

@ -3,7 +3,7 @@
$form = new FormValidator('edit_category', 'post', $baseUrl."action=edit_category&id={$category->getId()}"); $form = new FormValidator('edit_category', 'post', $baseUrl."action=edit_category&id={$category->getId()}");
if (api_get_configuration_value('save_titles_as_html')) { 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 { } else {
$form->addText('title', get_lang('Title')); $form->addText('title', get_lang('Title'));
$form->applyFilter('title', 'trim'); $form->applyFilter('title', 'trim');

@ -9,7 +9,7 @@ $categories = $em
$form = new FormValidator('edit_portfolio', 'post', $baseUrl."action=edit_item&id={$item->getId()}"); $form = new FormValidator('edit_portfolio', 'post', $baseUrl."action=edit_item&id={$item->getId()}");
if (api_get_configuration_value('save_titles_as_html')) { 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 { } else {
$form->addText('title', get_lang('Title')); $form->addText('title', get_lang('Title'));
$form->applyFilter('title', 'trim'); $form->applyFilter('title', 'trim');

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

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

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

@ -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;
}
}

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

Loading…
Cancel
Save