thematic_plan.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. if ($action == 'thematic_plan_list') {
  30. $form = new FormValidator(
  31. 'thematic_plan_add',
  32. 'POST',
  33. 'index.php?action=thematic_plan_list&thematic_id='.$thematic_id.'&'.api_get_cidreq()
  34. );
  35. $form->addElement('hidden', 'action', 'thematic_plan_add');
  36. //$form->addElement('hidden', 'thematic_plan_token', $token);
  37. $form->addElement('hidden', 'thematic_id', $thematic_id);
  38. foreach ($default_thematic_plan_title as $id => $title) {
  39. $form->addElement('hidden', 'description_type['.$id.']', $id);
  40. $form->addText('title['.$id.']', get_lang('Title'), false, array('size'=>'50'));
  41. $form->addHtmlEditor(
  42. 'description['.$id.']',
  43. get_lang('Description'),
  44. false,
  45. false,
  46. array(
  47. 'ToolbarStartExpanded' => 'false',
  48. 'ToolbarSet' => 'TrainingDescription',
  49. 'Height' => '150'
  50. )
  51. );
  52. if (!empty($thematic_simple_list) && in_array($id, $thematic_simple_list)) {
  53. $thematic_plan = $new_thematic_plan_data[$id];
  54. // set default values
  55. $default['title['.$id.']'] = $thematic_plan['title'];
  56. $default['description['.$id.']'] = $thematic_plan['description'];
  57. $thematic_plan = null;
  58. } else {
  59. $thematic_plan = null;
  60. $default['title['.$id.']'] = $title;
  61. $default['description['.$id.']']= '';
  62. }
  63. $form->setDefaults($default);
  64. }
  65. $form->addButtonSave(get_lang('Save'));
  66. $form->display();
  67. } elseif ($action == 'thematic_plan_add' || $action == 'thematic_plan_edit') {
  68. if ($description_type >= ADD_THEMATIC_PLAN) {
  69. $header_form = get_lang('NewBloc');
  70. } else {
  71. $header_form = $default_thematic_plan_title[$description_type];
  72. }
  73. if (!$error) {
  74. $token = md5(uniqid(rand(),TRUE));
  75. $_SESSION['thematic_plan_token'] = $token;
  76. }
  77. // display form
  78. $form = new FormValidator(
  79. 'thematic_plan_add',
  80. 'POST',
  81. 'index.php?action=thematic_plan_edit&thematic_id='.$thematic_id.'&'.api_get_cidreq(),
  82. '',
  83. 'style="width: 100%;"'
  84. );
  85. $form->addElement('hidden', 'action', $action);
  86. $form->addElement('hidden', 'thematic_plan_token', $token);
  87. if (!empty($thematic_id)) {
  88. $form->addElement('hidden', 'thematic_id', $thematic_id);
  89. }
  90. if (!empty($description_type)) {
  91. $form->addElement('hidden', 'description_type', $description_type);
  92. }
  93. $form->addText('title', get_lang('Title'), true, array('size'=>'50'));
  94. $form->addHtmlEditor(
  95. 'description',
  96. get_lang('Description'),
  97. false,
  98. false,
  99. array(
  100. 'ToolbarStartExpanded' => 'false',
  101. 'ToolbarSet' => 'TrainingDescription',
  102. 'Width' => '80%',
  103. 'Height' => '150',
  104. )
  105. );
  106. $form->addButtonSave(get_lang('Save'));
  107. if ($description_type < ADD_THEMATIC_PLAN) {
  108. $default['title'] = $default_thematic_plan_title[$description_type];
  109. }
  110. if (!empty($thematic_plan_data)) {
  111. // set default values
  112. $default['title'] = $thematic_plan_data[0]['title'];
  113. $default['description'] = $thematic_plan_data[0]['description'];
  114. }
  115. $form->setDefaults($default);
  116. if (isset($default_thematic_plan_question[$description_type])) {
  117. $message = '<strong>'.get_lang('QuestionPlan').'</strong><br />';
  118. $message .= $default_thematic_plan_question[$description_type];
  119. Display::display_normal_message($message, false);
  120. }
  121. // error messages
  122. if ($error) {
  123. Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'),false);
  124. }
  125. $form->display();
  126. }