add.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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().'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('ToolCourseDescription'),'',ICON_SIZE_MEDIUM).'</a>';
  19. ksort($categories);
  20. foreach ($categories as $id => $title) {
  21. if ($i==ADD_BLOCK) {
  22. echo '<a href="index.php?'.api_get_cidreq().'&action=add">'.Display::return_icon($default_description_icon[$id], $title, '',ICON_SIZE_MEDIUM).'</a>';
  23. break;
  24. } else {
  25. 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>';
  26. $i++;
  27. }
  28. }
  29. echo '</div>';
  30. // error messages
  31. if (isset($error) && intval($error) == 1) {
  32. Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'),false);
  33. }
  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. if (!$error) {
  41. $token = Security::get_token();
  42. }
  43. // display form
  44. $form = new FormValidator('course_description','POST','index.php?action=add&'.api_get_cidreq());
  45. $form->addElement('header', '', $header);
  46. $form->addElement('hidden', 'description_type',$description_type);
  47. $form->addElement('hidden', 'sec_token',$token);
  48. $form->add_textfield('title', get_lang('Title'), true, array('size'=>'width: 350px;'));
  49. $form->applyFilter('title','html_filter');
  50. if (api_get_setting('wcag_anysurfer_public_pages')=='true') {
  51. WCAG_rendering::prepare_admin_form($description_content, $form);
  52. } else {
  53. $form->add_html_editor('contentDescription', get_lang('Content'), true, false, array('ToolbarSet' => 'TrainingDescription', 'Width' => '100%', 'Height' => '200'));
  54. }
  55. $form->addElement('style_submit_button', null, get_lang('Save'), 'class="save"');
  56. // display default questions
  57. if (isset ($question[$description_type])) {
  58. $message = '<strong>'.get_lang('QuestionPlan').'</strong><br />';
  59. $message .= $question[$description_type];
  60. Display::display_normal_message($message, false);
  61. }
  62. if (api_get_setting('wcag_anysurfer_public_pages')=='true') {
  63. echo (WCAG_Rendering::editor_header());
  64. }
  65. $form->display();
  66. if (api_get_setting('wcag_anysurfer_public_pages')=='true') {
  67. echo (WCAG_Rendering::editor_footer());
  68. }