thematic_plan.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. $categories = array ();
  10. foreach ($default_thematic_plan_title as $id => $title) {
  11. $categories[$id] = $title;
  12. }
  13. $categories[ADD_THEMATIC_PLAN] = get_lang('NewBloc');
  14. $i=1;
  15. echo '<div class="actions" style="margin-bottom:30px">';
  16. ksort($categories);
  17. foreach ($categories as $id => $title) {
  18. if ($i == ADD_THEMATIC_PLAN) {
  19. echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_plan_add&thematic_id='.$thematic_id.'&description_type='.$next_description_type.'">'.Display::return_icon($default_thematic_plan_icon[$id], $title, array('height'=>'22')).' '.$title.'</a>';
  20. break;
  21. } else {
  22. echo '<a href="index.php?action=thematic_plan_edit&'.api_get_cidreq().'&description_type='.$id.'&thematic_id='.$thematic_id.'">'.Display::return_icon($default_thematic_plan_icon[$id], $title, array('height'=>'22')).' '.$title.'</a>&nbsp;&nbsp;';
  23. $i++;
  24. }
  25. }
  26. echo '</div>';
  27. if ($action == 'thematic_plan_list') {
  28. if (isset($thematic_plan_data) && count($thematic_plan_data) > 0) {
  29. foreach ($thematic_plan_data as $thematic_plan) {
  30. echo '<div class="sectiontitle">';
  31. //delete
  32. echo '<a href="'.api_get_self().'?cidReq='.api_get_course_id().'&thematic_id='.$thematic_plan['thematic_id'].'&action=thematic_plan_delete&description_type='.$thematic_plan['description_type'].'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)).'\')) return false;">';
  33. echo Display::return_icon('delete.gif', get_lang('Delete'), array('style' => 'vertical-align:middle;float:right;'));
  34. echo '</a> ';
  35. //edit
  36. echo '<a href="'.api_get_self().'?cidReq='.api_get_course_id().'&thematic_id='.$thematic_plan['thematic_id'].'&action=thematic_plan_edit&description_type='.$thematic_plan['description_type'].'">';
  37. echo Display::return_icon('edit.gif', get_lang('Edit'), array('style' => 'vertical-align:middle;float:right; padding-right:4px;'));
  38. echo '</a> ';
  39. echo $thematic_plan['title'];
  40. echo '</div>';
  41. echo '<div class="sectioncomment">';
  42. echo text_filter($thematic_plan['description']);
  43. echo '</div>';
  44. }
  45. } else {
  46. echo '<em>'.get_lang('ThisCourseDescriptionIsEmpty').'</em>';
  47. }
  48. } else if ($action == 'thematic_plan_add' || $action == 'thematic_plan_edit') {
  49. if ($description_type >= ADD_THEMATIC_PLAN) {
  50. $header_form = get_lang('NewBloc');
  51. } else {
  52. $header_form = $default_thematic_plan_title[$description_type];
  53. }
  54. if (!$error) {
  55. $token = md5(uniqid(rand(),TRUE));
  56. $_SESSION['thematic_plan_token'] = $token;
  57. }
  58. // display form
  59. $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%;"');
  60. $form->addElement('header', '', $header_form);
  61. $form->addElement('hidden', 'action', $action);
  62. $form->addElement('hidden', 'thematic_plan_token', $token);
  63. if (!empty($thematic_id)) {
  64. $form->addElement('hidden', 'thematic_id', $thematic_id);
  65. }
  66. if (!empty($description_type)) {
  67. $form->addElement('hidden', 'description_type', $description_type);
  68. }
  69. $form->add_textfield('title', get_lang('Title'), true, array('size'=>'50'));
  70. $form->add_html_editor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'TrainingDescription', 'Width' => '100%', 'Height' => '200'));
  71. $form->addElement('html','<div class="clear" style="margin-top:50px;"></div>');
  72. $form->addElement('style_submit_button', null, get_lang('Save'), 'class="save"');
  73. if ($description_type < ADD_THEMATIC_PLAN) {
  74. $default['title'] = $default_thematic_plan_title[$description_type];
  75. }
  76. if (!empty($thematic_plan_data)) {
  77. // set default values
  78. $default['title'] = $thematic_plan_data[0]['title'];
  79. $default['description'] = $thematic_plan_data[0]['description'];
  80. }
  81. $form->setDefaults($default);
  82. if (isset($default_thematic_plan_question[$description_type])) {
  83. $message = '<strong>'.get_lang('QuestionPlan').'</strong><br />';
  84. $message .= $default_thematic_plan_question[$description_type];
  85. Display::display_normal_message($message, false);
  86. }
  87. // error messages
  88. if ($error) {
  89. Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'),false);
  90. }
  91. $form->display();
  92. }
  93. ?>