thematic_plan.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. }
  24. $i=1;
  25. echo Display::tag('h2', $thematic_data['title']);
  26. echo $thematic_data['content'];
  27. if (isset($message) && $message == 'ok') {
  28. Display::display_normal_message(get_lang('ThematicSectionHasBeenCreatedSuccessfull'));
  29. }
  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()
  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. // display form
  75. $form = new FormValidator(
  76. 'thematic_plan_add',
  77. 'POST',
  78. 'index.php?action=thematic_plan_edit&thematic_id='.$thematic_id.'&'.api_get_cidreq(),
  79. '',
  80. 'style="width: 100%;"'
  81. );
  82. $form->addElement('hidden', 'action', $action);
  83. $form->addElement('hidden', 'thematic_plan_token', $token);
  84. if (!empty($thematic_id)) {
  85. $form->addElement('hidden', 'thematic_id', $thematic_id);
  86. }
  87. if (!empty($description_type)) {
  88. $form->addElement('hidden', 'description_type', $description_type);
  89. }
  90. $form->addText('title', get_lang('Title'), true, array('size'=>'50'));
  91. $form->addHtmlEditor(
  92. 'description',
  93. get_lang('Description'),
  94. false,
  95. false,
  96. array(
  97. 'ToolbarStartExpanded' => 'false',
  98. 'ToolbarSet' => 'TrainingDescription',
  99. 'Width' => '80%',
  100. 'Height' => '150',
  101. )
  102. );
  103. $form->addButtonSave(get_lang('Save'));
  104. if ($description_type < ADD_THEMATIC_PLAN) {
  105. $default['title'] = $default_thematic_plan_title[$description_type];
  106. }
  107. if (!empty($thematic_plan_data)) {
  108. // set default values
  109. $default['title'] = $thematic_plan_data[0]['title'];
  110. $default['description'] = $thematic_plan_data[0]['description'];
  111. }
  112. $form->setDefaults($default);
  113. if (isset($default_thematic_plan_question[$description_type])) {
  114. $message = '<strong>'.get_lang('QuestionPlan').'</strong><br />';
  115. $message .= $default_thematic_plan_question[$description_type];
  116. Display::display_normal_message($message, false);
  117. }
  118. // error messages
  119. if ($error) {
  120. Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'),false);
  121. }
  122. $form->display();
  123. }