add.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'),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. if (!$error) {
  45. $token = Security::get_token();
  46. }
  47. // display form
  48. $form = new FormValidator(
  49. 'course_description',
  50. 'POST',
  51. 'index.php?action=add&'.api_get_cidreq()
  52. );
  53. $form->addElement('header', '', $header);
  54. $form->addElement('hidden', 'description_type', $description_type);
  55. $form->addElement('hidden', 'sec_token', $token);
  56. $form->addText('title', get_lang('Title'), true, array('size'=>'width: 350px;'));
  57. $form->applyFilter('title','html_filter');
  58. $form->addHtmlEditor(
  59. 'contentDescription',
  60. get_lang('Content'),
  61. true,
  62. false,
  63. array(
  64. 'ToolbarSet' => 'TrainingDescription',
  65. 'Width' => '100%',
  66. 'Height' => '200',
  67. )
  68. );
  69. $form->addButtonCreate(get_lang('Save'));
  70. // display default questions
  71. if (isset ($question[$description_type])) {
  72. $message = '<strong>'.get_lang('QuestionPlan').'</strong><br />';
  73. $message .= $question[$description_type];
  74. Display::display_normal_message($message, false);
  75. }
  76. $form->display();