|
@@ -9,68 +9,69 @@
|
|
|
|
|
|
// protect a course script
|
|
|
api_protect_course_script(true);
|
|
|
+
|
|
|
if (empty($id)) {
|
|
|
- $id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : '';
|
|
|
- if (empty($id)) {
|
|
|
- // If the ID was not provided, find the first matching description item given the item type
|
|
|
- $course_description = new CourseDescription();
|
|
|
- $description = $course_description->get_data_by_description_type($description_type);
|
|
|
- if (count($description) > 0) {
|
|
|
- $id = $description['id'];
|
|
|
- }
|
|
|
- // If no corresponding description is found, edit a new one
|
|
|
- unset($course_description);
|
|
|
- }
|
|
|
+ $id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : '';
|
|
|
+ if (empty($id)) {
|
|
|
+ // If the ID was not provided, find the first matching description item given the item type
|
|
|
+ $course_description = new CourseDescription();
|
|
|
+ $description = $course_description->get_data_by_description_type($description_type);
|
|
|
+ if (count($description) > 0) {
|
|
|
+ $id = $description['id'];
|
|
|
+ }
|
|
|
+ // If no corresponding description is found, edit a new one
|
|
|
+ unset($course_description);
|
|
|
+ }
|
|
|
}
|
|
|
$original_id = $id;
|
|
|
|
|
|
if (empty($error)) {
|
|
|
- $token = Security::get_token();
|
|
|
+ $token = Security::get_token();
|
|
|
}
|
|
|
// display categories
|
|
|
$categories = array();
|
|
|
foreach ($default_description_titles as $id => $title) {
|
|
|
- $categories[$id] = $title;
|
|
|
+ $categories[$id] = $title;
|
|
|
}
|
|
|
$categories[ADD_BLOCK] = get_lang('NewBloc');
|
|
|
|
|
|
$i = 1;
|
|
|
echo '<div class="actions" style="margin-bottom:30px">';
|
|
|
echo '<a href="index.php?'.api_get_cidreq().'">'.
|
|
|
- Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('ToolCourseDescription'), '', ICON_SIZE_MEDIUM).
|
|
|
- '</a>';
|
|
|
+ Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('ToolCourseDescription'), '', ICON_SIZE_MEDIUM).
|
|
|
+ '</a>';
|
|
|
|
|
|
ksort($categories);
|
|
|
foreach ($categories as $id => $title) {
|
|
|
- if ($i == ADD_BLOCK) {
|
|
|
- echo '<a href="index.php?'.api_get_cidreq().'&action=add">'.
|
|
|
- Display::return_icon($default_description_icon[$id], $title, '', ICON_SIZE_MEDIUM).'</a>';
|
|
|
- break;
|
|
|
- } else {
|
|
|
- echo '<a href="index.php?action=edit&'.api_get_cidreq().'&description_type='.$id.'">'.
|
|
|
- Display::return_icon($default_description_icon[$id], $title, '', ICON_SIZE_MEDIUM).'</a>';
|
|
|
- $i++;
|
|
|
- }
|
|
|
+ if ($i == ADD_BLOCK) {
|
|
|
+ echo '<a href="index.php?'.api_get_cidreq().'&action=add">'.
|
|
|
+ Display::return_icon($default_description_icon[$id], $title, '', ICON_SIZE_MEDIUM).'</a>';
|
|
|
+ break;
|
|
|
+ } else {
|
|
|
+ echo '<a href="index.php?action=edit&'.api_get_cidreq().'&description_type='.$id.'">'.
|
|
|
+ Display::return_icon($default_description_icon[$id], $title, '', ICON_SIZE_MEDIUM).'</a>';
|
|
|
+ $i++;
|
|
|
+ }
|
|
|
}
|
|
|
echo '</div>';
|
|
|
|
|
|
// error messages
|
|
|
if (isset($error) && intval($error) == 1) {
|
|
|
- echo Display::return_message(get_lang('FormHasErrorsPleaseComplete'), 'error', false);
|
|
|
+ echo Display::return_message(get_lang('FormHasErrorsPleaseComplete'), 'error', false);
|
|
|
}
|
|
|
|
|
|
// default header title form
|
|
|
$description_type = intval($description_type);
|
|
|
$header = $default_description_titles[$description_type];
|
|
|
if ($description_type >= ADD_BLOCK) {
|
|
|
- $header = $default_description_titles[ADD_BLOCK];
|
|
|
+ $header = $default_description_titles[ADD_BLOCK];
|
|
|
}
|
|
|
|
|
|
// display form
|
|
|
$form = new FormValidator(
|
|
|
- 'course_description',
|
|
|
- 'POST',
|
|
|
- 'index.php?action=edit&id='.$original_id.'&description_type='.$description_type.'&'.api_get_cidreq()
|
|
|
+ 'course_description',
|
|
|
+ 'POST',
|
|
|
+ 'index.php?action=edit&id='.$original_id.'&description_type='.$description_type.'&'.api_get_cidreq()
|
|
|
);
|
|
|
$form->addElement('header', $header);
|
|
|
$form->addElement('hidden', 'id', $original_id);
|
|
@@ -90,15 +91,15 @@ if (api_get_configuration_value('save_titles_as_html')) {
|
|
|
$form->applyFilter('title', 'html_filter');
|
|
|
}
|
|
|
$form->addHtmlEditor(
|
|
|
- 'contentDescription',
|
|
|
- get_lang('Content'),
|
|
|
- true,
|
|
|
- false,
|
|
|
- array(
|
|
|
- 'ToolbarSet' => 'TrainingDescription',
|
|
|
- 'Width' => '100%',
|
|
|
- 'Height' => '200',
|
|
|
- )
|
|
|
+ 'contentDescription',
|
|
|
+ get_lang('Content'),
|
|
|
+ true,
|
|
|
+ false,
|
|
|
+ array(
|
|
|
+ 'ToolbarSet' => 'TrainingDescription',
|
|
|
+ 'Width' => '100%',
|
|
|
+ 'Height' => '200',
|
|
|
+ )
|
|
|
);
|
|
|
$form->addButtonCreate(get_lang('Save'));
|
|
|
|
|
@@ -113,9 +114,9 @@ $default['description_type'] = $description_type;
|
|
|
|
|
|
$form->setDefaults($default);
|
|
|
|
|
|
-if (isset ($question[$description_type])) {
|
|
|
- $message = '<strong>'.get_lang('QuestionPlan').'</strong><br />';
|
|
|
- $message .= $question[$description_type];
|
|
|
- Display::addFlash(Display::return_message($message, 'normal', false));
|
|
|
+if (isset($question[$description_type])) {
|
|
|
+ $message = '<strong>'.get_lang('QuestionPlan').'</strong><br />';
|
|
|
+ $message .= $question[$description_type];
|
|
|
+ Display::addFlash(Display::return_message($message, 'normal', false));
|
|
|
}
|
|
|
$form->display();
|