*/ require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php'; api_protect_course_script(); /** @var learnpath $learnPath */ $learnPath = Session::read('oLP'); $nameTools = get_lang('Document'); $this_section = SECTION_COURSES; Event::event_access_tool(TOOL_LEARNPATH); $lpId = $learnPath->get_id(); if (api_is_in_gradebook()) { $interbreadcrumb[] = [ 'url' => Category::getUrl(), 'name' => get_lang('Assessments'), ]; } $interbreadcrumb[] = [ 'url' => 'lp_controller.php?action=list&'.api_get_cidreq(), 'name' => get_lang('Learning paths'), ]; $interbreadcrumb[] = [ 'url' => api_get_self()."?action=build&lp_id=".$lpId.'&'.api_get_cidreq(), 'name' => $learnPath->getNameNoTags(), ]; $htmlHeadXtra[] = ''; $defaults = []; $form = new FormValidator( 'form1', 'post', 'lp_controller.php?'.api_get_cidreq() ); // Form title $form->addElement('header', get_lang('Edit')); // Title if (api_get_configuration_value('save_titles_as_html')) { $form->addHtmlEditor( 'lp_name', get_lang('Learning path name'), true, false, ['ToolbarSet' => 'TitleAsHtml'] ); } else { $form->addElement('text', 'lp_name', api_ucfirst(get_lang('Title')), ['size' => 43]); } $form->applyFilter('lp_name', 'html_filter'); $form->addRule('lp_name', get_lang('Required field'), 'required'); $form->addElement('hidden', 'lp_encoding'); $items = learnpath::getCategoryFromCourseIntoSelect(api_get_course_int_id(), true); $form->addElement('select', 'category_id', get_lang('Category'), $items); // Hide toc frame $form->addElement( 'checkbox', 'hide_toc_frame', null, get_lang('Hide table of contents frame') ); if (api_get_setting('allow_course_theme') === 'true') { $mycourselptheme = api_get_course_setting('allow_learning_path_theme'); if (!empty($mycourselptheme) && $mycourselptheme != -1 && $mycourselptheme == 1) { //LP theme picker $theme_select = $form->addElement('SelectGraphical theme', 'lp_theme', get_lang('Graphical theme')); $form->applyFilter('lp_theme', 'trim'); $s_theme = $learnPath->get_theme(); $theme_select->setSelected($s_theme); //default } } // Author $form->addElement( 'html_editor', 'lp_author', get_lang('Author'), ['size' => 80], ['ToolbarSet' => 'LearningPathAuthor', 'Width' => '100%', 'Height' => '200px'] ); $form->applyFilter('lp_author', 'html_filter'); // LP image if (strlen($learnPath->get_preview_image()) > 0) { $show_preview_image = 'get_preview_image().'>'; $form->addElement('label', get_lang('Image preview'), $show_preview_image); $form->addElement('checkbox', 'remove_picture', null, get_lang('Remove picture')); } $label = $learnPath->get_preview_image() != '' ? get_lang('Update Image') : get_lang('Add image'); $form->addElement('file', 'lp_preview_image', [$label, get_lang('Trainer picture will resize if needed')]); $form->addRule('lp_preview_image', get_lang('Only PNG, JPG or GIF images allowed'), 'filetype', ['jpg', 'jpeg', 'png', 'gif']); // Search terms (only if search is activated). if (api_get_setting('search_enabled') === 'true') { $specific_fields = get_specific_field_list(); foreach ($specific_fields as $specific_field) { $form->addElement('text', $specific_field['code'], $specific_field['name']); $filter = [ 'c_id' => "'".api_get_course_int_id()."'", 'field_id' => $specific_field['id'], 'ref_id' => $learnPath->lp_id, 'tool_id' => '\''.TOOL_LEARNPATH.'\'', ]; $values = get_specific_field_values_list($filter, ['value']); if (!empty($values)) { $arr_str_values = []; foreach ($values as $value) { $arr_str_values[] = $value['value']; } $defaults[$specific_field['code']] = implode(', ', $arr_str_values); } } } $hideTableOfContents = $learnPath->getHideTableOfContents(); $defaults['lp_encoding'] = Security::remove_XSS($learnPath->encoding); $defaults['lp_name'] = Security::remove_XSS($learnPath->get_name()); $defaults['lp_author'] = Security::remove_XSS($learnPath->get_author()); $defaults['hide_toc_frame'] = $hideTableOfContents; $defaults['category_id'] = $learnPath->getCategoryId(); $defaults['accumulate_scorm_time'] = $learnPath->getAccumulateScormTime(); $expired_on = $learnPath->expired_on; $publicated_on = $learnPath->publicated_on; // Prerequisites $form->addElement('html', '