edit.php 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * View (MVC patter) for editing a course description
  5. * @author Christian Fasanando <christian1827@gmail.com>
  6. * @package chamilo.course_description
  7. */
  8. // protect a course script
  9. api_protect_course_script(true);
  10. $original_id = $id;
  11. if (!$error) {
  12. $token = Security::get_token();
  13. }
  14. // display categories
  15. $categories = array();
  16. foreach ($default_description_titles as $id => $title) {
  17. $categories[$id] = $title;
  18. }
  19. $categories[ADD_BLOCK] = get_lang('NewBloc');
  20. $i=1;
  21. echo '<div class="actions" style="margin-bottom:30px">';
  22. echo '<a href="index.php?'.api_get_cidreq().'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('ToolCourseDescription'),'',ICON_SIZE_MEDIUM).'</a>';
  23. ksort($categories);
  24. foreach ($categories as $id => $title) {
  25. if ($i==ADD_BLOCK) {
  26. echo '<a href="index.php?'.api_get_cidreq().'&action=add">'.Display::return_icon($default_description_icon[$id], $title,'',ICON_SIZE_MEDIUM).'</a>';
  27. break;
  28. } else {
  29. 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>';
  30. $i++;
  31. }
  32. }
  33. echo '</div>';
  34. // error messages
  35. if (isset($error) && intval($error) == 1) {
  36. Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'),false);
  37. }
  38. // default header title form
  39. $description_type = intval($description_type);
  40. $header = $default_description_titles[$description_type];
  41. if ($description_type >= ADD_BLOCK) {
  42. $header = $default_description_titles[ADD_BLOCK];
  43. }
  44. // display form
  45. $form = new FormValidator('course_description','POST','index.php?action=edit&id='.$original_id.'&description_type='.$description_type.'&'.api_get_cidreq());
  46. $form->addElement('header','',$header);
  47. $form->addElement('hidden', 'id', $original_id);
  48. $form->addElement('hidden', 'description_type',$description_type);
  49. $form->addElement('hidden', 'sec_token',$token);
  50. $form->add_textfield('title', get_lang('Title'), true, array('size'=>'50'));
  51. $form->applyFilter('title','html_filter');
  52. if (api_get_setting('wcag_anysurfer_public_pages')=='true') {
  53. WCAG_rendering::prepare_admin_form($description_content, $form);
  54. } else {
  55. $form->add_html_editor('contentDescription', get_lang('Content'), true, false, array('ToolbarSet' => 'TrainingDescription', 'Width' => '100%', 'Height' => '200'));
  56. }
  57. $form->addElement('style_submit_button', null, get_lang('Save'), 'class="save"');
  58. // Set some default values
  59. $default['title'] = Security::remove_XSS($description_title);
  60. $default['contentDescription'] = Security::remove_XSS($description_content,COURSEMANAGERLOWSECURITY);
  61. $default['description_type'] = $description_type;
  62. $form->setDefaults($default);
  63. if (isset ($question[$description_type])) {
  64. $message = '<strong>'.get_lang('QuestionPlan').'</strong><br />';
  65. $message .= $question[$description_type];
  66. Display::display_normal_message($message, false);
  67. }
  68. if (api_get_setting('wcag_anysurfer_public_pages')=='true') {
  69. echo (WCAG_Rendering::editor_header());
  70. }
  71. $form->display();
  72. if (api_get_setting('wcag_anysurfer_public_pages')=='true') {
  73. echo (WCAG_Rendering::editor_footer());
  74. }