add.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * View (MVC patter) for adding a course description.
  5. *
  6. * @author Christian Fasanando <christian1827@gmail.com>
  7. *
  8. * @package chamilo.course_description
  9. */
  10. // protect a course script
  11. api_protect_course_script(true);
  12. // display categories
  13. $categories = [];
  14. foreach ($default_description_titles as $id => $title) {
  15. $categories[$id] = $title;
  16. }
  17. $categories[ADD_BLOCK] = get_lang('Other');
  18. $i = 1;
  19. echo '<div class="actions" style="margin-bottom:30px">';
  20. echo '<a href="index.php?'.api_get_cidreq().'">'.
  21. Display::return_icon('back.png', get_lang('Back to').' '.get_lang('Course description'), '', ICON_SIZE_MEDIUM).
  22. '</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">'.
  27. Display::return_icon($default_description_icon[$id], $title, '', ICON_SIZE_MEDIUM).'</a>';
  28. break;
  29. } else {
  30. echo '<a href="index.php?action=edit&'.api_get_cidreq().'&description_type='.$id.'">'.
  31. Display::return_icon($default_description_icon[$id], $title, '', ICON_SIZE_MEDIUM).'</a>';
  32. $i++;
  33. }
  34. }
  35. echo '</div>';
  36. // error messages
  37. if (isset($error) && intval($error) == 1) {
  38. echo Display::return_message(
  39. get_lang('The form contains incorrect or incomplete data. Please check your input.'),
  40. 'error',
  41. false
  42. );
  43. }
  44. // default header title form
  45. $header = '';
  46. $description_type = intval($description_type);
  47. if ($description_type >= ADD_BLOCK) {
  48. $header = $default_description_titles[ADD_BLOCK];
  49. }
  50. // display form
  51. $form = new FormValidator(
  52. 'course_description',
  53. 'POST',
  54. 'index.php?action=add&'.api_get_cidreq()
  55. );
  56. $form->addElement('header', $header);
  57. $form->addElement('hidden', 'description_type', $description_type);
  58. if (api_get_configuration_value('save_titles_as_html')) {
  59. $form->addHtmlEditor(
  60. 'title',
  61. get_lang('Title'),
  62. true,
  63. false,
  64. ['ToolbarSet' => 'TitleAsHtml']
  65. );
  66. } else {
  67. $form->addText('title', get_lang('Title'));
  68. $form->applyFilter('title', 'html_filter');
  69. }
  70. $form->addHtmlEditor(
  71. 'contentDescription',
  72. get_lang('Content'),
  73. true,
  74. false,
  75. [
  76. 'ToolbarSet' => 'Basic',
  77. 'Width' => '100%',
  78. 'Height' => '200',
  79. ]
  80. );
  81. $form->addButtonCreate(get_lang('Save'));
  82. // display default questions
  83. if (isset($question[$description_type])) {
  84. $message = '<strong>'.get_lang('Help').'</strong><br />';
  85. $message .= $question[$description_type];
  86. echo Display::return_message($message, 'normal', false);
  87. }
  88. $form->display();