parent
784f70862b
commit
96b7ea0677
File diff suppressed because it is too large
Load Diff
@ -1,99 +0,0 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
use ChamiloSession as Session; |
||||
|
||||
/** |
||||
* Thematic Controller script. |
||||
* Prepares the common background variables to give to the scripts corresponding to |
||||
* the requested action. |
||||
* |
||||
* This file contains class used like controller for thematic, |
||||
* it should be included inside a dispatcher file (e.g: index.php) |
||||
* |
||||
* !!! WARNING !!! : ALL DATES IN THIS MODULE ARE STORED IN UTC ! |
||||
* DO NOT CONVERT DURING THE TRANSITION FROM CHAMILO 1.8.x TO 2.0 |
||||
* |
||||
* @author Christian Fasanando <christian1827@gmail.com> |
||||
* @author Julio Montoya <gugli100@gmail.com> token support improving UI |
||||
*/ |
||||
class ThematicController |
||||
{ |
||||
/** |
||||
* Constructor. |
||||
*/ |
||||
public function __construct() |
||||
{ |
||||
$this->toolname = 'course_progress'; |
||||
$this->view = new View($this->toolname); |
||||
} |
||||
|
||||
/** |
||||
* This method is used for thematic advance control (update, insert or listing) |
||||
* render to thematic_advance.php. |
||||
* |
||||
* @param string $action |
||||
*/ |
||||
public function thematic_advance($action) |
||||
{ |
||||
$thematic = new Thematic(); |
||||
$attendance = new Attendance(); |
||||
$data = []; |
||||
$displayHeader = !empty($_REQUEST['display']) && 'no_header' === $_REQUEST['display'] ? false : true; |
||||
|
||||
|
||||
$thematic_id = intval($_REQUEST['thematic_id']); |
||||
$thematic_advance_id = isset($_REQUEST['thematic_advance_id']) ? (int) $_REQUEST['thematic_advance_id'] : null; |
||||
$thematic_advance_data = []; |
||||
switch ($action) { |
||||
case 'thematic_advance_delete': |
||||
|
||||
break; |
||||
case 'thematic_advance_list': |
||||
if (!api_is_allowed_to_edit(null, true)) { |
||||
echo ''; |
||||
exit; |
||||
} |
||||
|
||||
$data['action'] = $_REQUEST['action']; |
||||
$data['thematic_id'] = $_REQUEST['thematic_id']; |
||||
$data['attendance_select'] = $attendance_select; |
||||
if (isset($_REQUEST['thematic_advance_id'])) { |
||||
$data['thematic_advance_id'] = $_REQUEST['thematic_advance_id']; |
||||
$thematic_advance_data = $thematic->get_thematic_advance_list($_REQUEST['thematic_advance_id']); |
||||
$data['thematic_advance_data'] = $thematic_advance_data; |
||||
} |
||||
break; |
||||
default: |
||||
$thematic_advance_data = $thematic->get_thematic_advance_list($thematic_advance_id); |
||||
break; |
||||
} |
||||
|
||||
// get calendar select by attendance id |
||||
$calendar_select = []; |
||||
if (!empty($thematic_advance_data)) { |
||||
if (!empty($thematic_advance_data['attendance_id'])) { |
||||
$attendance_calendar = $attendance->get_attendance_calendar($thematic_advance_data['attendance_id']); |
||||
if (!empty($attendance_calendar)) { |
||||
foreach ($attendance_calendar as $calendar) { |
||||
$calendar_select[$calendar['date_time']] = $calendar['date_time']; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
$data['action'] = $action; |
||||
$data['thematic_id'] = $thematic_id; |
||||
$data['thematic_advance_id'] = $thematic_advance_id; |
||||
$data['attendance_select'] = $attendance_select; |
||||
$data['thematic_advance_data'] = $thematic_advance_data; |
||||
$data['calendar_select'] = $calendar_select; |
||||
$layoutName = $displayHeader ? 'layout' : 'layout_no_header'; |
||||
|
||||
// render to the view |
||||
$this->view->set_data($data); |
||||
$this->view->set_layout($layoutName); |
||||
$this->view->set_template('thematic_advance'); |
||||
$this->view->render(); |
||||
} |
||||
} |
@ -1,109 +0,0 @@ |
||||
<?php |
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
use ChamiloSession as Session; |
||||
|
||||
/** |
||||
* View (MVC patter) for thematic plan. |
||||
* |
||||
* @author Christian Fasanando <christian1827@gmail.com> |
||||
*/ |
||||
$tpl = new Template(get_lang('Thematic control')); |
||||
$toolbar = null; |
||||
$formLayout = null; |
||||
|
||||
// actions menu |
||||
$new_thematic_plan_data = []; |
||||
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']; |
||||
} |
||||
} |
||||
} |
||||
|
||||
if (isset($message) && 'ok' == $message) { |
||||
echo Display::return_message(get_lang('Thematic section has been created successfully'), 'normal'); |
||||
} |
||||
|
||||
if ('thematic_plan_list' === $action) { |
||||
$token = Security::get_token(); |
||||
Session::write('thematic_plan_token', $token); |
||||
$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) { |
||||
$btnDelete = Display::toolbarButton( |
||||
get_lang('Delete'), |
||||
'#', |
||||
'times', |
||||
'danger', |
||||
['role' => 'button', 'data-id' => $id, 'class' => 'btn-delete'] |
||||
); |
||||
|
||||
$form->addElement('hidden', 'description_type['.$id.']', $id); |
||||
$form->addText("title[$id]", [get_lang('Title'), null, $btnDelete], false); |
||||
$form->addHtmlEditor( |
||||
'description['.$id.']', |
||||
get_lang('Description'), |
||||
false, |
||||
false, |
||||
[ |
||||
'ToolbarStartExpanded' => 'false', |
||||
'ToolbarSet' => 'Basic', |
||||
'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->addGroup([ |
||||
$form->addButton( |
||||
'add_item', |
||||
get_lang('Save and add new item'), |
||||
'plus', |
||||
'info', |
||||
'default', |
||||
null, |
||||
[], |
||||
true |
||||
), |
||||
$form->addButtonSave(get_lang('Save'), 'submit', true), |
||||
]); |
||||
$formLayout = $form->returnForm(); |
||||
} elseif ('thematic_plan_add' == $action || 'thematic_plan_edit' == $action) { |
||||
|
||||
} |
||||
|
||||
|
||||
|
||||
$content = $tpl->fetch($thematicLayout); |
||||
$tpl->assign('content', $content); |
||||
|
||||
$tpl->display_one_col_template(); |
@ -1,9 +0,0 @@ |
||||
{% autoescape false %} |
||||
<div class="row"> |
||||
<div class="col-md-12"> |
||||
<div class="thematic-plan"> |
||||
{{ form_thematic }} |
||||
</div> |
||||
</div> |
||||
</div> |
||||
{% endautoescape %} |
@ -1,11 +0,0 @@ |
||||
{% autoescape false %} |
||||
<div class="row"> |
||||
<div class="col-md-12"> |
||||
<h3>{{ title_thematic }}</h3> |
||||
{{ content_thematic }} |
||||
<div class="thematic-plan"> |
||||
{{ form_thematic }} |
||||
</div> |
||||
</div> |
||||
</div> |
||||
{% endautoescape %} |
Loading…
Reference in new issue