thematic_plan.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. }
  16. $new_id = ADD_THEMATIC_PLAN;
  17. if (!empty($thematic_simple_list))
  18. foreach($thematic_simple_list as $item) {
  19. if ($item >= ADD_THEMATIC_PLAN) {
  20. $new_id = $item + 1;
  21. $default_thematic_plan_title[$item] = $new_thematic_plan_data[$item]['title'];
  22. }
  23. }
  24. $i=1;
  25. echo Display::tag('h2', $thematic_data['title']);
  26. echo $thematic_data['content'];
  27. if ($message == 'ok') {
  28. Display::display_normal_message(get_lang('ThematicSectionHasBeenCreatedSuccessfull'));
  29. }
  30. if ($action == 'thematic_plan_list') {
  31. $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%;"');
  32. $form->addElement('hidden', 'action', 'thematic_plan_add');
  33. $form->addElement('hidden', 'thematic_plan_token', $token);
  34. $form->addElement('hidden', 'thematic_id', $thematic_id);
  35. if (empty($thematic_plan_data)) {
  36. foreach ($default_thematic_plan_title as $id => $title) {
  37. $form->addElement('hidden', 'description_type['.$id.']', $id);
  38. $form->add_textfield('title['.$id.']', get_lang('Title'), true, array('class'=>'span4'));
  39. $form->add_html_editor('description['.$id.']', get_lang('Description'), false, false, array('ToolbarStartExpanded'=>'false', 'ToolbarSet' => 'TrainingDescription', 'Width' => '80%', 'Height' => '150'));
  40. $default['title['.$id.']'] = $title;
  41. $default['description['.$id.']']= '';
  42. $form->setDefaults($default);
  43. }
  44. } else {
  45. foreach ($thematic_plan_data as $data) {
  46. $form->addElement('hidden', 'description_type['.$data['description_type'].']', $data['description_type']);
  47. $form->add_textfield('title['.$data['id'].']', get_lang('Title'), true, array('class'=>'span4'));
  48. //$form->add_html_editor('description['.$data['id'].']', get_lang('Description'), false, false, array('ToolbarStartExpanded'=>'false', 'ToolbarSet' => 'TrainingDescription', 'Width' => '80%', 'Height' => '150'));
  49. $form->addElement('textarea', 'description['.$data['id'].']', get_lang('Description'));
  50. $default['title['.$data['id'].']'] = $data['title'];
  51. $default['description['.$data['id'].']'] = $data['description'];
  52. $form->addElement('checkbox', 'delete['.$data['id'].']', null, get_lang('Delete'));
  53. $form->addElement('html', '<hr>');
  54. $form->setDefaults($default);
  55. }
  56. }
  57. $form->addElement('style_submit_button', null, get_lang('Save'), 'id="add_plan" class="save"');
  58. $form->display();
  59. } else if ($action == 'thematic_plan_add' || $action == 'thematic_plan_edit') {
  60. if ($description_type >= ADD_THEMATIC_PLAN) {
  61. $header_form = get_lang('NewBloc');
  62. } else {
  63. $header_form = $default_thematic_plan_title[$description_type];
  64. }
  65. if (!$error) {
  66. $token = md5(uniqid(rand(),TRUE));
  67. $_SESSION['thematic_plan_token'] = $token;
  68. }
  69. // display form
  70. $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%;"');
  71. //$form->addElement('header', '', $header_form);
  72. $form->addElement('hidden', 'action', $action);
  73. $form->addElement('hidden', 'thematic_plan_token', $token);
  74. if (!empty($thematic_id)) {
  75. $form->addElement('hidden', 'thematic_id', $thematic_id);
  76. }
  77. if (!empty($description_type)) {
  78. $form->addElement('hidden', 'description_type', $description_type);
  79. }
  80. $form->add_textfield('title', get_lang('Title'), true, array('size'=>'50'));
  81. $form->add_html_editor('description', get_lang('Description'), false, false, array('ToolbarStartExpanded'=>'false', 'ToolbarSet' => 'TrainingDescription', 'Width' => '80%', 'Height' => '150'));
  82. //$form->addElement('html','<div class="clear" style="margin-top:50px;"></div>');
  83. $form->addElement('style_submit_button', null, get_lang('Save'), 'class="save"');
  84. if ($description_type < ADD_THEMATIC_PLAN) {
  85. $default['title'] = $default_thematic_plan_title[$description_type];
  86. }
  87. if (!empty($thematic_plan_data)) {
  88. // set default values
  89. $default['title'] = $thematic_plan_data[0]['title'];
  90. $default['description'] = $thematic_plan_data[0]['description'];
  91. }
  92. $form->setDefaults($default);
  93. if (isset($default_thematic_plan_question[$description_type])) {
  94. $message = '<strong>'.get_lang('QuestionPlan').'</strong><br />';
  95. $message .= $default_thematic_plan_question[$description_type];
  96. Display::display_normal_message($message, false);
  97. }
  98. // error messages
  99. if ($error) {
  100. Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'),false);
  101. }
  102. $form->display();
  103. }