add.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * View (MVC patter) for adding 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. // display categories
  11. $categories = array();
  12. foreach ($default_description_titles as $id => $title) {
  13. $categories[$id] = $title;
  14. }
  15. $categories[ADD_BLOCK] = get_lang('NewBloc');
  16. $i = 1;
  17. echo '<div class="actions" style="margin-bottom:30px">';
  18. echo '<a href="index.php?'.api_get_cidreq().'">'.
  19. Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('ToolCourseDescription'), '', ICON_SIZE_MEDIUM).
  20. '</a>';
  21. ksort($categories);
  22. foreach ($categories as $id => $title) {
  23. if ($i == ADD_BLOCK) {
  24. echo '<a href="index.php?'.api_get_cidreq().'&action=add">'.
  25. Display::return_icon($default_description_icon[$id], $title, '', ICON_SIZE_MEDIUM).'</a>';
  26. break;
  27. } else {
  28. echo '<a href="index.php?action=edit&'.api_get_cidreq().'&description_type='.$id.'">'.
  29. 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. echo Display::return_message(get_lang('FormHasErrorsPleaseComplete'), 'error', false);
  37. }
  38. // default header title form
  39. $header = '';
  40. $description_type = intval($description_type);
  41. if ($description_type >= ADD_BLOCK) {
  42. $header = $default_description_titles[ADD_BLOCK];
  43. }
  44. // display form
  45. $form = new FormValidator(
  46. 'course_description',
  47. 'POST',
  48. 'index.php?action=add&'.api_get_cidreq()
  49. );
  50. $form->addElement('header', $header);
  51. $form->addElement('hidden', 'description_type', $description_type);
  52. if (api_get_configuration_value('save_titles_as_html')) {
  53. $form->addHtmlEditor(
  54. 'title',
  55. get_lang('Title'),
  56. true,
  57. false,
  58. ['ToolbarSet' => 'Minimal']
  59. );
  60. } else {
  61. $form->addText('title', get_lang('Title'));
  62. $form->applyFilter('title', 'html_filter');
  63. }
  64. $form->addHtmlEditor(
  65. 'contentDescription',
  66. get_lang('Content'),
  67. true,
  68. false,
  69. array(
  70. 'ToolbarSet' => 'TrainingDescription',
  71. 'Width' => '100%',
  72. 'Height' => '200',
  73. )
  74. );
  75. $form->addButtonCreate(get_lang('Save'));
  76. // display default questions
  77. if (isset ($question[$description_type])) {
  78. $message = '<strong>'.get_lang('QuestionPlan').'</strong><br />';
  79. $message .= $question[$description_type];
  80. echo Display::return_message($message, 'normal', false);
  81. }
  82. $form->display();