ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilTimingsManageTableGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
12{
16 private $logger = null;
17
18 private $container = null;
19 private $main_container = null;
20 private $failure = false;
21
25 public function __construct($a_parent_class, $a_parent_cmd, ilObject $a_container_obj, ilObjCourse $a_main_container)
26 {
27 global $DIC;
28
29 $this->logger = $DIC->logger()->obj();
30
31 $this->container = $a_container_obj;
32 $this->main_container = $a_main_container;
33 $this->setId('manage_timings_' . $this->getContainerObject()->getRefId());
34
35 parent::__construct($a_parent_class, $a_parent_cmd);
36 }
37
41 public function getContainerObject()
42 {
43 return $this->container;
44 }
45
49 public function getMainContainer()
50 {
52 }
53
57 public function init()
58 {
59 $this->setFormAction($GLOBALS['ilCtrl']->getFormAction($this->getParentObject()));
60 $this->setRowTemplate('tpl.crs_manage_timings_row.html', 'Modules/Course');
61
62 $this->setTitle($this->lng->txt('edit_timings_list'));
63
64 $this->addColumn($this->lng->txt('title'), '', '40%');
65 $this->addColumn($this->lng->txt('crs_timings_short_active'), '', '', false);
66
68 $this->addColumn($this->lng->txt('crs_timings_short_start_end_rel'), '', '', false);
69 $this->addColumn($this->lng->txt('crs_timings_time_frame'), '', '', false);
70 } else {
71 $this->addColumn($this->lng->txt('crs_timings_short_start_end'), '', '', false);
72 $this->addColumn($this->lng->txt('crs_timings_short_end'), '');
73 }
74 $this->addColumn($this->lng->txt('crs_timings_short_changeable'), '', '', false);
75
76
77
78
79 $this->addCommandButton('updateManagedTimings', $this->lng->txt('save'));
80 #$this->addCommandButton('timingsOff', $this->lng->txt('cancel'));
81
82
83 $this->setShowRowsSelector(false);
84 }
85
90 public function setFailureStatus($a_status)
91 {
92 $this->failure = $a_status;
93 }
94
99 public function getFailureStatus()
100 {
101 return $this->failure;
102 }
103
104
109 public function fillRow($set)
110 {
111 if ($set['error'] == true) {
112 $this->tpl->setVariable('TD_CLASS', 'warning');
113 } else {
114 $this->tpl->setVariable('TD_CLASS', 'std');
115 }
116
117 // title
118 if (strlen($set['title_link'])) {
119 $this->tpl->setCurrentBlock('title_link');
120 $this->tpl->setVariable('TITLE_LINK', $set['title_link']);
121 $this->tpl->setVariable('TITLE_LINK_NAME', $set['title']);
122 $this->tpl->parseCurrentBlock();
123 } else {
124 $this->tpl->setCurrentBlock('title_plain');
125 $this->tpl->setVariable('TITLE', $set['title']);
126 $this->tpl->parseCurrentBlock();
127 }
128 if (strlen($set['desc'])) {
129 $this->tpl->setCurrentBlock('item_description');
130 $this->tpl->setVariable('DESC', $set['desc']);
131 $this->tpl->parseCurrentBlock();
132 }
133
134 if ($set['failure']) {
135 $this->tpl->setCurrentBlock('alert');
136 $this->tpl->setVariable('IMG_ALERT', ilUtil::getImagePath("icon_alert.svg"));
137 $this->tpl->setVariable('ALT_ALERT', $this->lng->txt("alert"));
138 $this->tpl->setVariable("TXT_ALERT", $this->lng->txt($set['failure']));
139 $this->tpl->parseCurrentBlock();
140 }
141
142 // active
143 $this->tpl->setVariable('NAME_ACTIVE', 'item[' . $set['ref_id'] . '][active]');
144 $GLOBALS['ilLog']->write(__METHOD__ . ': ' . print_r($_POST, true));
145 if ($this->getFailureStatus()) {
146 $this->tpl->setVariable('CHECKED_ACTIVE', $_POST['item'][$set['ref_id']]['active'] ? 'checked="checked"' : '');
147 } else {
148 $this->tpl->setVariable('CHECKED_ACTIVE', ($set['item']['timing_type'] == ilObjectActivation::TIMINGS_PRESETTING) ? 'checked="checked"' : '');
149 }
150
151 // start
152 if ($this->getMainContainer()->getTimingMode() == ilCourseConstants::IL_CRS_VIEW_TIMING_ABSOLUTE) {
153 include_once './Services/Form/classes/class.ilDateTimeInputGUI.php';
154 $dt_input = new ilDateTimeInputGUI('', 'item[' . $set['ref_id'] . '][sug_start]');
155 $dt_input->setDate(new ilDate($set['item']['suggestion_start'], IL_CAL_UNIX));
156 if ($this->getFailureStatus()) {
157 $dt_input->setDate(new ilDate($_POST['item'][$set['ref_id']]['sug_start'], IL_CAL_DATE));
158 }
159
160 $this->tpl->setVariable('start_abs');
161 $this->tpl->setVariable('SUG_START', $dt_input->render());
162 $this->tpl->parseCurrentBlock();
163 } else {
164 $this->tpl->setCurrentBlock('start_rel');
165 $this->tpl->setVariable('START_REL_VAL', (int) $set['item']['suggestion_start_rel']);
166 if ($this->getFailureStatus()) {
167 $this->tpl->setVariable('START_REL_VAL', $_POST['item'][$set['ref_id']]['sug_start_rel']);
168 } else {
169 $this->tpl->setVariable('START_REL_VAL', (int) $set['item']['suggestion_start_rel']);
170 }
171 $this->tpl->setVariable('START_REL_NAME', 'item[' . $set['ref_id'] . '][sug_start_rel]');
172 $this->tpl->parseCurrentBlock();
173 }
174
175 if ($this->getMainContainer()->getTimingMode() == ilCourseConstants::IL_CRS_VIEW_TIMING_RELATIVE) {
176 if ($this->getFailureStatus()) {
177 $this->tpl->setVariable('VAL_DURATION_A', $_POST['item'][$set['ref_id']]['duration_a']);
178 } else {
179 $duration = $set['item']['suggestion_end_rel'] - $set['item']['suggestion_start_rel'];
180 $this->tpl->setVariable('VAL_DURATION_A', (int) $duration);
181 }
182 $this->tpl->setVariable('NAME_DURATION_A', 'item[' . $set['ref_id'] . '][duration_a]');
183 } else {
184 include_once './Services/Form/classes/class.ilDateTimeInputGUI.php';
185 $dt_end = new ilDateTimeInputGUI('', 'item[' . $set['ref_id'] . '][sug_end]');
186 $dt_end->setDate(new ilDate($set['item']['suggestion_end'], IL_CAL_UNIX));
187 if ($this->getFailureStatus()) {
188 $dt_end->setDate(new ilDate($_POST['item'][$set['ref_id']]['sug_end'], IL_CAL_DATE));
189 }
190
191 $this->tpl->setVariable('end_abs');
192 $this->tpl->setVariable('SUG_END', $dt_end->render());
193 $this->tpl->parseCurrentBlock();
194 }
195
196 // changeable
197 $this->tpl->setVariable('NAME_CHANGE', 'item[' . $set['ref_id'] . '][change]');
198 $this->tpl->setVariable('CHECKED_CHANGE', $set['item']['changeable'] ? 'checked="checked"' : '');
199 if ($this->getFailureStatus()) {
200 $this->tpl->setVariable('CHECKED_CHANGE', $_POST['item'][$set['ref_id']]['change'] ? 'checked="checked"' : '');
201 } else {
202 $this->tpl->setVariable('CHECKED_CHANGE', $set['item']['changeable'] ? 'checked="checked"' : '');
203 }
204 }
205
206
210 public function parse($a_item_data, $a_failed_update = array())
211 {
212 $rows = array();
213 foreach ($a_item_data as $item) {
214 $current_row = array();
215
216 // no item groups
217 if ($item['type'] == 'itgr') {
218 continue;
219 }
220 $current_row['ref_id'] = $item['ref_id'];
221 $current_row = $this->parseTitle($current_row, $item);
222
223 // dubios error handling
224 if (array_key_exists($item['ref_id'], $a_failed_update)) {
225 $current_row['failed'] = true;
226 $current_row['failure'] = $a_failed_update[$item['ref_id']];
227 }
228 $current_row['item'] = $item;
229
230 $rows[] = $current_row;
231 }
232 $this->setData($rows);
233 }
234
235
236
240 protected function parseTitle($current_row, $item)
241 {
242 include_once './Services/Link/classes/class.ilLink.php';
243 switch ($item['type']) {
244 case 'fold':
245 case 'grp':
246 $current_row['title'] = $item['title'];
247 $current_row['title_link'] = ilLink::_getLink($item['ref_id'], $item['type']);
248 break;
249
250 case 'sess':
251 if (strlen($item['title'])) {
252 $current_row['title'] = $item['title'];
253 } else {
254 include_once('./Modules/Session/classes/class.ilSessionAppointment.php');
256 $current_row['title'] = ilSessionAppointment::_appointmentToString(
257 $app_info['start'],
258 $app_info['end'],
259 $app_info['fullday']
260 );
261 }
262 $current_row['title_link'] = ilLink::_getLink($item['ref_id'], $item['type']);
263 break;
264
265 default:
266 $current_row['title'] = $item['title'];
267 $current_row['title_link'] = '';
268 break;
269
270 }
271 $current_row['desc'] = $item['desc'];
272
273 return $current_row;
274 }
275}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_DATE
const IL_CAL_UNIX
This class represents a date/time property in a property form.
Class for single dates.
Class ilObjCourse.
Class ilObject Basic functions for all objects.
static _lookupObjId($a_id)
static _lookupAppointment($a_obj_id)
lookup appointment
static _appointmentToString($start, $end, $fulltime)
Class ilTable2GUI.
setShowRowsSelector($a_value)
Toggle rows-per-page selector.
getParentObject()
Get parent object.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
getFormAction()
Get Form action parameter.
setData($a_data)
set table data @access public
setRowTemplate($a_template, $a_template_dir="")
Set row template.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setId($a_val)
Set id.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
TableGUI class for timings administration.
__construct($a_parent_class, $a_parent_cmd, ilObject $a_container_obj, ilObjCourse $a_main_container)
Constructor.
parse($a_item_data, $a_failed_update=array())
Parse table content.
parseTitle($current_row, $item)
Parse title.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
failure()
Definition: failure.php:2
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$rows
Definition: xhr_table.php:10