add.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. // default header title form
  35. $header = '';
  36. $description_type = intval($description_type);
  37. if ($description_type >= ADD_BLOCK) {
  38. $header = $default_description_titles[ADD_BLOCK];
  39. }
  40. // display form
  41. $form = new FormValidator(
  42. 'course_description',
  43. 'POST',
  44. 'index.php?action=add&'.api_get_cidreq()
  45. );
  46. $form->addElement('header', $header);
  47. $form->addElement('hidden', 'description_type', $description_type);
  48. $form->addText('title', get_lang('Title'), true);
  49. $form->applyFilter('title','html_filter');
  50. $form->addHtmlEditor(
  51. 'contentDescription',
  52. get_lang('Content'),
  53. true,
  54. false,
  55. array(
  56. 'ToolbarSet' => 'TrainingDescription',
  57. 'Width' => '100%',
  58. 'Height' => '200',
  59. )
  60. );
  61. $form->addButtonCreate(get_lang('Save'));
  62. // display default questions
  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. $form->display();