123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- <?php
- /* For licensing terms, see /license.txt */
- /**
- * View (MVC patter) for thematic plan
- * @author Christian Fasanando <christian1827@gmail.com>
- * @package chamilo.course_progress
- */
- // actions menu
- $new_thematic_plan_data = array();
- if (!empty($thematic_plan_data))
- foreach($thematic_plan_data as $thematic_item) {
- $thematic_simple_list[] = $thematic_item['description_type'];
- $new_thematic_plan_data[$thematic_item['description_type']] = $thematic_item;
- }
- $new_id = ADD_THEMATIC_PLAN;
- if (!empty($thematic_simple_list)) {
- foreach($thematic_simple_list as $item) {
- if ($item >= ADD_THEMATIC_PLAN) {
- $new_id = $item + 1;
- $default_thematic_plan_title[$item] = $new_thematic_plan_data[$item]['title'];
- }
- }
- }
- $i=1;
- echo Display::tag('h2', $thematic_data['title']);
- echo $thematic_data['content'];
- if (isset($message) && $message == 'ok') {
- Display::display_normal_message(get_lang('ThematicSectionHasBeenCreatedSuccessfull'));
- }
- if ($action === 'thematic_plan_list') {
- $form = new FormValidator(
- 'thematic_plan_add',
- 'POST',
- 'index.php?action=thematic_plan_list&thematic_id='.$thematic_id.'&'.api_get_cidreq()
- );
- $form->addElement('hidden', 'action', 'thematic_plan_add');
- //$form->addElement('hidden', 'thematic_plan_token', $token);
- $form->addElement('hidden', 'thematic_id', $thematic_id);
- foreach ($default_thematic_plan_title as $id => $title) {
- $form->addElement('hidden', 'description_type['.$id.']', $id);
- $form->addText('title['.$id.']', get_lang('Title'), false, array('size'=>'50'));
- $form->addHtmlEditor(
- 'description['.$id.']',
- get_lang('Description'),
- false,
- false,
- array(
- 'ToolbarStartExpanded' => 'false',
- 'ToolbarSet' => 'TrainingDescription',
- 'Height' => '150'
- )
- );
- if (!empty($thematic_simple_list) && in_array($id, $thematic_simple_list)) {
- $thematic_plan = $new_thematic_plan_data[$id];
- // set default values
- $default['title['.$id.']'] = $thematic_plan['title'];
- $default['description['.$id.']'] = $thematic_plan['description'];
- $thematic_plan = null;
- } else {
- $thematic_plan = null;
- $default['title['.$id.']'] = $title;
- $default['description['.$id.']']= '';
- }
- $form->setDefaults($default);
- }
- $form->addButtonSave(get_lang('Save'));
- $form->display();
- } elseif ($action == 'thematic_plan_add' || $action == 'thematic_plan_edit') {
- if ($description_type >= ADD_THEMATIC_PLAN) {
- $header_form = get_lang('NewBloc');
- } else {
- $header_form = $default_thematic_plan_title[$description_type];
- }
- // display form
- $form = new FormValidator(
- 'thematic_plan_add',
- 'POST',
- 'index.php?action=thematic_plan_edit&thematic_id='.$thematic_id.'&'.api_get_cidreq(),
- '',
- 'style="width: 100%;"'
- );
- $form->addElement('hidden', 'action', $action);
- $form->addElement('hidden', 'thematic_plan_token', $token);
- if (!empty($thematic_id)) {
- $form->addElement('hidden', 'thematic_id', $thematic_id);
- }
- if (!empty($description_type)) {
- $form->addElement('hidden', 'description_type', $description_type);
- }
- $form->addText('title', get_lang('Title'), true, array('size'=>'50'));
- $form->addHtmlEditor(
- 'description',
- get_lang('Description'),
- false,
- false,
- array(
- 'ToolbarStartExpanded' => 'false',
- 'ToolbarSet' => 'TrainingDescription',
- 'Width' => '80%',
- 'Height' => '150',
- )
- );
- $form->addButtonSave(get_lang('Save'));
- if ($description_type < ADD_THEMATIC_PLAN) {
- $default['title'] = $default_thematic_plan_title[$description_type];
- }
- if (!empty($thematic_plan_data)) {
- // set default values
- $default['title'] = $thematic_plan_data[0]['title'];
- $default['description'] = $thematic_plan_data[0]['description'];
- }
- $form->setDefaults($default);
- if (isset($default_thematic_plan_question[$description_type])) {
- $message = '<strong>'.get_lang('QuestionPlan').'</strong><br />';
- $message .= $default_thematic_plan_question[$description_type];
- Display::display_normal_message($message, false);
- }
- // error messages
- if ($error) {
- Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'),false);
- }
- $form->display();
- }
|