thematic_plan.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * View (MVC patter) for thematic plan
  5. * @author Christian Fasanando <christian1827@gmail.com>
  6. * @package chamilo.course_progress
  7. */
  8. // actions menu
  9. $new_thematic_plan_data = array();
  10. if (!empty($thematic_plan_data))
  11. foreach($thematic_plan_data as $thematic_item) {
  12. $thematic_simple_list[] = $thematic_item['description_type'];
  13. $new_thematic_plan_data[$thematic_item['description_type']] = $thematic_item;
  14. }
  15. $new_id = ADD_THEMATIC_PLAN;
  16. if (!empty($thematic_simple_list))
  17. foreach($thematic_simple_list as $item) {
  18. if ($item >= ADD_THEMATIC_PLAN) {
  19. $new_id = $item + 1;
  20. $default_thematic_plan_title[$item] = $new_thematic_plan_data[$item]['title'];
  21. }
  22. }
  23. $i=1;
  24. echo Display::tag('h2', $thematic_data['title']);
  25. echo $thematic_data['content'];
  26. if (isset($message) && $message == 'ok') {
  27. Display::display_normal_message(get_lang('ThematicSectionHasBeenCreatedSuccessfull'));
  28. }
  29. $param_gradebook = null;
  30. if ($action == 'thematic_plan_list') {
  31. $form = new FormValidator(
  32. 'thematic_plan_add',
  33. 'POST',
  34. 'index.php?action=thematic_plan_list&thematic_id='.$thematic_id.'&'.api_get_cidreq().$param_gradebook
  35. );
  36. $form->addElement('hidden', 'action', 'thematic_plan_add');
  37. //$form->addElement('hidden', 'thematic_plan_token', $token);
  38. $form->addElement('hidden', 'thematic_id', $thematic_id);
  39. foreach ($default_thematic_plan_title as $id => $title) {
  40. $form->addElement('hidden', 'description_type['.$id.']', $id);
  41. $form->addText('title['.$id.']', get_lang('Title'), false, array('size'=>'50'));
  42. $form->addHtmlEditor(
  43. 'description['.$id.']',
  44. get_lang('Description'),
  45. false,
  46. false,
  47. array(
  48. 'ToolbarStartExpanded' => 'false',
  49. 'ToolbarSet' => 'TrainingDescription',
  50. 'Height' => '150'
  51. )
  52. );
  53. if (!empty($thematic_simple_list) && in_array($id, $thematic_simple_list)) {
  54. $thematic_plan = $new_thematic_plan_data[$id];
  55. // set default values
  56. $default['title['.$id.']'] = $thematic_plan['title'];
  57. $default['description['.$id.']'] = $thematic_plan['description'];
  58. $thematic_plan = null;
  59. } else {
  60. $thematic_plan = null;
  61. $default['title['.$id.']'] = $title;
  62. $default['description['.$id.']']= '';
  63. }
  64. $form->setDefaults($default);
  65. }
  66. $form->addButtonSave(get_lang('Save'));
  67. $form->display();
  68. } elseif ($action == 'thematic_plan_add' || $action == 'thematic_plan_edit') {
  69. if ($description_type >= ADD_THEMATIC_PLAN) {
  70. $header_form = get_lang('NewBloc');
  71. } else {
  72. $header_form = $default_thematic_plan_title[$description_type];
  73. }
  74. if (!$error) {
  75. $token = md5(uniqid(rand(),TRUE));
  76. $_SESSION['thematic_plan_token'] = $token;
  77. }
  78. // display form
  79. $form = new FormValidator('thematic_plan_add','POST','index.php?action=thematic_plan_edit&thematic_id='.$thematic_id.'&'.api_get_cidreq().$param_gradebook,'','style="width: 100%;"');
  80. //$form->addElement('header', '', $header_form);
  81. $form->addElement('hidden', 'action', $action);
  82. $form->addElement('hidden', 'thematic_plan_token', $token);
  83. if (!empty($thematic_id)) {
  84. $form->addElement('hidden', 'thematic_id', $thematic_id);
  85. }
  86. if (!empty($description_type)) {
  87. $form->addElement('hidden', 'description_type', $description_type);
  88. }
  89. $form->addText('title', get_lang('Title'), true, array('size'=>'50'));
  90. $form->addHtmlEditor('description', get_lang('Description'), false, false, array('ToolbarStartExpanded'=>'false', 'ToolbarSet' => 'TrainingDescription', 'Width' => '80%', 'Height' => '150'));
  91. $form->addButtonSave(get_lang('Save'));
  92. if ($description_type < ADD_THEMATIC_PLAN) {
  93. $default['title'] = $default_thematic_plan_title[$description_type];
  94. }
  95. if (!empty($thematic_plan_data)) {
  96. // set default values
  97. $default['title'] = $thematic_plan_data[0]['title'];
  98. $default['description'] = $thematic_plan_data[0]['description'];
  99. }
  100. $form->setDefaults($default);
  101. if (isset($default_thematic_plan_question[$description_type])) {
  102. $message = '<strong>'.get_lang('QuestionPlan').'</strong><br />';
  103. $message .= $default_thematic_plan_question[$description_type];
  104. Display::display_normal_message($message, false);
  105. }
  106. // error messages
  107. if ($error) {
  108. Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'),false);
  109. }
  110. $form->display();
  111. }