Lp title and lp item title can have html content see BT#15259

pull/2990/head
Julio 6 years ago
parent b4bbea1928
commit b04fc3d65a
  1. 5
      main/install/configuration.dist.php
  2. 485
      main/lp/learnpath.class.php
  3. 12
      main/lp/lp_add.php
  4. 2
      main/lp/lp_add_audio.php
  5. 2
      main/lp/lp_add_item.php
  6. 2
      main/lp/lp_admin_view.php
  7. 2
      main/lp/lp_build.php
  8. 2
      main/lp/lp_content.php
  9. 13
      main/lp/lp_controller.php
  10. 14
      main/lp/lp_edit.php
  11. 9
      main/lp/lp_edit_item.php
  12. 2
      main/lp/lp_edit_item_prereq.php
  13. 2
      main/lp/lp_impress.php
  14. 2
      main/lp/lp_list.php
  15. 2
      main/lp/lp_move_item.php
  16. 4
      main/lp/lp_subscribe_users.php
  17. 2
      main/lp/lp_update_scorm.php
  18. 2
      main/lp/lp_view.php
  19. 2
      main/lp/lp_view_item.php
  20. 4
      main/template/default/learnpath/scorm_list.tpl
  21. 2
      src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/Minimal.php

@ -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->lp_view_id." AND lp_view_id = ".$this->lp_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)) {
@ -503,9 +486,6 @@ class learnpath
$userId = 0 $userId = 0
) { ) {
$course_id = $this->course_info['real_id']; $course_id = $this->course_info['real_id'];
if ($this->debug > 0) {
error_log('In learnpath::add_item('.$parent.','.$previous.','.$type.','.$id.','.$title.')');
}
if (empty($course_id)) { if (empty($course_id)) {
// Sometimes Oogie doesn't catch the course info but sets $this->cc // Sometimes Oogie doesn't catch the course info but sets $this->cc
$this->course_info = api_get_course_info($this->cc); $this->course_info = api_get_course_info($this->cc);
@ -527,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);
@ -618,9 +598,6 @@ class learnpath
$new_item_id = Database::insert($tbl_lp_item, $params); $new_item_id = Database::insert($tbl_lp_item, $params);
if ($new_item_id) { if ($new_item_id) {
if ($this->debug > 2) {
error_log('Inserting dir/chapter: '.$new_item_id, 0);
}
$sql = "UPDATE $tbl_lp_item SET id = iid WHERE iid = $new_item_id"; $sql = "UPDATE $tbl_lp_item SET id = iid WHERE iid = $new_item_id";
Database::query($sql); Database::query($sql);
@ -3201,14 +3178,8 @@ class learnpath
*/ */
public function get_toc() public function get_toc()
{ {
if ($this->debug > 0) {
error_log('learnpath::get_toc()', 0);
}
$toc = []; $toc = [];
foreach ($this->ordered_items as $item_id) { foreach ($this->ordered_items as $item_id) {
if ($this->debug > 2) {
error_log('learnpath::get_toc(): getting info for item '.$item_id, 0);
}
// TODO: Change this link generation and use new function instead. // TODO: Change this link generation and use new function instead.
$toc[] = [ $toc[] = [
'id' => $item_id, 'id' => $item_id,
@ -3221,9 +3192,6 @@ class learnpath
'parent' => $this->items[$item_id]->get_parent(), 'parent' => $this->items[$item_id]->get_parent(),
]; ];
} }
if ($this->debug > 2) {
error_log('In learnpath::get_toc() - TOC array: '.print_r($toc, true), 0);
}
return $toc; return $toc;
} }
@ -3452,7 +3420,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',
@ -3496,7 +3464,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;
} }
@ -3514,14 +3482,11 @@ class learnpath
*/ */
public function getListArrayToc($toc_list = []) public function getListArrayToc($toc_list = [])
{ {
if ($this->debug > 0) {
error_log('In learnpath::get_html_toc()', 0);
}
if (empty($toc_list)) { if (empty($toc_list)) {
$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 = [
@ -3585,7 +3550,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;
} }
@ -6197,9 +6162,6 @@ class learnpath
*/ */
public function tree_array($array) public function tree_array($array)
{ {
if ($this->debug > 1) {
error_log('In learnpath::tree_array()', 0);
}
$array = $this->sort_tree_array($array); $array = $this->sort_tree_array($array);
$this->create_tree_array($array); $this->create_tree_array($array);
} }
@ -6354,34 +6316,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 : [];
@ -6812,7 +6747,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">';
@ -6831,7 +6765,7 @@ class learnpath
} }
$list .= '</ul>'; $list .= '</ul>';
$return .= Display::panelCollapse( $return = Display::panelCollapse(
$this->name, $this->name,
$list, $list,
'scorm-list', 'scorm-list',
@ -6863,7 +6797,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']);
} }
@ -7215,9 +7149,9 @@ class learnpath
$originalTitle = !empty($title) ? $title : $_POST['title']; $originalTitle = !empty($title) ? $title : $_POST['title'];
if (!empty($title)) { if (!empty($title)) {
$title = api_replace_dangerous_char(stripslashes($title)); $title = api_replace_dangerous_char(strip_tags(stripslashes($title)));
} else { } else {
$title = api_replace_dangerous_char(stripslashes($_POST['title'])); $title = api_replace_dangerous_char(strip_tags(stripslashes($_POST['title'])));
} }
$title = disable_dangerous_file($title); $title = disable_dangerous_file($title);
@ -7786,7 +7720,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)) {
@ -7813,30 +7746,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);
@ -7863,7 +7773,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;
} }
@ -7959,7 +7869,7 @@ class learnpath
$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);
} }
@ -7989,8 +7899,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']);
@ -8025,29 +7934,7 @@ class learnpath
$parent = 0; $parent = 0;
} }
$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'],
'max_time_allowed' => $row['max_time_allowed'],
];
}
$legend = '<legend>'; $legend = '<legend>';
if ($action == 'add') { if ($action == 'add') {
$legend .= get_lang('CreateTheExercise'); $legend .= get_lang('CreateTheExercise');
@ -8071,9 +7958,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++) {
@ -8114,7 +7999,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>';
} }
} }
@ -8182,9 +8068,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)) {
@ -8197,41 +8085,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;
}
$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);
@ -8254,12 +8113,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;
} }
@ -8403,9 +8257,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)) {
@ -8417,40 +8272,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);
@ -8545,12 +8374,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;
@ -8727,7 +8551,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->applyFilter('title', 'html_filter');
$form->addRule('title', get_lang('ThisFieldIsRequired'), 'required'); $form->addRule('title', get_lang('ThisFieldIsRequired'), 'required');
} else { } else {
@ -8895,7 +8719,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;
@ -8927,6 +8750,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']);
@ -8947,39 +8773,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);
@ -9034,14 +8836,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;
@ -9284,7 +9079,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;
@ -9301,6 +9095,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']);
@ -9319,44 +9115,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');
@ -9407,14 +9178,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;
@ -9750,7 +9514,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 = '';
@ -9784,28 +9547,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 : [];
@ -9822,7 +9564,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;
} }
@ -9957,7 +9699,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');
@ -9982,28 +9723,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 : [];
@ -10020,12 +9740,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(
@ -10247,6 +9962,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
@ -10257,7 +9973,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']);
@ -10267,6 +9985,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;
@ -10283,7 +10002,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";
} }
@ -10433,7 +10152,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 = [];
@ -10444,26 +10162,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);
@ -12395,9 +12096,6 @@ EOD;
public function select_previous_item_id() public function select_previous_item_id()
{ {
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
if ($this->debug > 0) {
error_log('In learnpath::select_previous_item_id()', 0);
}
$table_lp_item = Database::get_course_table(TABLE_LP_ITEM); $table_lp_item = Database::get_course_table(TABLE_LP_ITEM);
// Get the max order of the items // Get the max order of the items
@ -14268,4 +13966,81 @@ EOD;
return ''; return '';
} }
/**
* @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' => 'Minimal', 'Height' => '100']
);
} else {
$form->addText('title', get_lang('Title'), true, ['id' => 'idTitle', 'class' => 'learnpath_item_form']);
$form->applyFilter('title', 'html_filter');
$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;
}
} }

@ -97,12 +97,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' => 'Minimal', 'Height' => '100']
);
} 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');
@ -169,5 +179,5 @@ $form->setDefaults($defaults);
$form->addButtonCreate(get_lang('CreateLearningPath')); $form->addButtonCreate(get_lang('CreateLearningPath'));
$form->display(); $form->display();
// Footer
Display::display_footer(); Display::display_footer();

@ -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) {

@ -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'),

@ -428,8 +428,6 @@ switch ($action) {
Session::write('refresh', 1); Session::write('refresh', 1);
if (isset($_POST['submit_button']) && !empty($post_title)) { if (isset($_POST['submit_button']) && !empty($post_title)) {
// If a title was submitted:
// Updating the lp.modified_on // Updating the lp.modified_on
$_SESSION['oLP']->set_modified_on(); $_SESSION['oLP']->set_modified_on();
@ -1058,10 +1056,9 @@ 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);
@ -1073,18 +1070,16 @@ switch ($action) {
$accumulateScormTime = isset($_REQUEST['accumulate_scorm_time']) ? $_REQUEST['accumulate_scorm_time'] : 'true'; $accumulateScormTime = isset($_REQUEST['accumulate_scorm_time']) ? $_REQUEST['accumulate_scorm_time'] : 'true';
$_SESSION['oLP']->setAccumulateScormTime($accumulateScormTime); $_SESSION['oLP']->setAccumulateScormTime($accumulateScormTime);
$publicated_on = null;
if (isset($_REQUEST['activate_start_date_check']) && $_REQUEST['activate_start_date_check'] == 1) { if (isset($_REQUEST['activate_start_date_check']) && $_REQUEST['activate_start_date_check'] == 1) {
$publicated_on = $_REQUEST['publicated_on']; $publicated_on = $_REQUEST['publicated_on'];
} else {
$publicated_on = null;
} }
$expired_on = null;
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'];
} else {
$expired_on = null;
} }
$_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>
@ -68,7 +68,17 @@ $form = new FormValidator(
$form->addElement('header', get_lang('EditLPSettings')); $form->addElement('header', get_lang('EditLPSettings'));
// Title // Title
if (api_get_configuration_value('save_titles_as_html')) {
$form->addHtmlEditor(
'lp_name',
get_lang('LPName'),
true,
false,
['ToolbarSet' => 'Minimal', 'Height' => '100']
);
} 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);

@ -326,7 +326,7 @@ foreach ($categories as $item) {
.'</div>'; .'</div>';
} }
$my_title = $name; $my_title = strip_tags($name);
$icon_learnpath = Display::return_icon( $icon_learnpath = Display::return_icon(
'learnpath.png', 'learnpath.png',
get_lang('LPName') get_lang('LPName')

@ -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(

@ -452,7 +452,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[] = [

@ -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(),

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

@ -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',

Loading…
Cancel
Save