thematic_plan.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 ($message == 'ok') {
  27. Display::display_normal_message(get_lang('ThematicSectionHasBeenCreatedSuccessfull'));
  28. }
  29. if ($action == 'thematic_plan_list') {
  30. $form = new FormValidator('thematic_plan_add','POST','index.php?action=thematic_plan_list&thematic_id='.$thematic_id.'&'.api_get_cidreq().$param_gradebook,'','style="width: 100%;"');
  31. $form->addElement('hidden', 'action', 'thematic_plan_add');
  32. $form->addElement('hidden', 'thematic_plan_token', $token);
  33. $form->addElement('hidden', 'thematic_id', $thematic_id);
  34. foreach ($default_thematic_plan_title as $id => $title) {
  35. $form->addElement('hidden', 'description_type['.$id.']', $id);
  36. $form->addText('title['.$id.']', get_lang('Title'), false, array('size'=>'50'));
  37. $form->addHtmlEditor('description['.$id.']', get_lang('Description'), false, false, array('ToolbarStartExpanded'=>'false', 'ToolbarSet' => 'TrainingDescription', 'Width' => '80%', 'Height' => '150'));
  38. //$form->addElement('textarea', 'description['.$id.']', get_lang('Description'));
  39. if (!empty($thematic_simple_list) && in_array($id, $thematic_simple_list)) {
  40. $thematic_plan = $new_thematic_plan_data[$id];
  41. // set default values
  42. $default['title['.$id.']'] = $thematic_plan['title'];
  43. $default['description['.$id.']'] = $thematic_plan['description'];
  44. $thematic_plan = null;
  45. } else {
  46. $thematic_plan = null;
  47. $default['title['.$id.']'] = $title;
  48. $default['description['.$id.']']= '';
  49. }
  50. $form->setDefaults($default);
  51. }
  52. $form->addElement('style_submit_button', null, get_lang('Save'), 'id="add_plan" class="save"');
  53. $form->display();
  54. } else if ($action == 'thematic_plan_add' || $action == 'thematic_plan_edit') {
  55. if ($description_type >= ADD_THEMATIC_PLAN) {
  56. $header_form = get_lang('NewBloc');
  57. } else {
  58. $header_form = $default_thematic_plan_title[$description_type];
  59. }
  60. if (!$error) {
  61. $token = md5(uniqid(rand(),TRUE));
  62. $_SESSION['thematic_plan_token'] = $token;
  63. }
  64. // display form
  65. $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%;"');
  66. //$form->addElement('header', '', $header_form);
  67. $form->addElement('hidden', 'action', $action);
  68. $form->addElement('hidden', 'thematic_plan_token', $token);
  69. if (!empty($thematic_id)) {
  70. $form->addElement('hidden', 'thematic_id', $thematic_id);
  71. }
  72. if (!empty($description_type)) {
  73. $form->addElement('hidden', 'description_type', $description_type);
  74. }
  75. $form->addText('title', get_lang('Title'), true, array('size'=>'50'));
  76. $form->addHtmlEditor('description', get_lang('Description'), false, false, array('ToolbarStartExpanded'=>'false', 'ToolbarSet' => 'TrainingDescription', 'Width' => '80%', 'Height' => '150'));
  77. //$form->addElement('html','<div class="clear" style="margin-top:50px;"></div>');
  78. $form->addElement('style_submit_button', null, get_lang('Save'), 'class="save"');
  79. if ($description_type < ADD_THEMATIC_PLAN) {
  80. $default['title'] = $default_thematic_plan_title[$description_type];
  81. }
  82. if (!empty($thematic_plan_data)) {
  83. // set default values
  84. $default['title'] = $thematic_plan_data[0]['title'];
  85. $default['description'] = $thematic_plan_data[0]['description'];
  86. }
  87. $form->setDefaults($default);
  88. if (isset($default_thematic_plan_question[$description_type])) {
  89. $message = '<strong>'.get_lang('QuestionPlan').'</strong><br />';
  90. $message .= $default_thematic_plan_question[$description_type];
  91. Display::display_normal_message($message, false);
  92. }
  93. // error messages
  94. if ($error) {
  95. Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'),false);
  96. }
  97. $form->display();
  98. }