ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilTermsOfServiceAcceptanceHistoryTableGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
3
6
12{
14 protected $uiFactory;
15
17 protected $uiRenderer;
18
20 protected $numRenderedCriteria = 0;
21
24
33 public function __construct(
35 string $command,
39 ) {
40 $this->criterionTypeFactory = $criterionTypeFactory;
41 $this->uiFactory = $uiFactory;
42 $this->uiRenderer = $uiRenderer;
43
44 $this->setId('tos_acceptance_history');
45 $this->setFormName('tos_acceptance_history');
46
47 parent::__construct($controller, $command);
48
49 $this->setTitle($this->lng->txt('tos_acceptance_history'));
50 $this->setFormAction($this->ctrl->getFormAction($controller, 'applyAcceptanceHistoryFilter'));
51
52 $this->setDefaultOrderDirection('DESC');
53 $this->setDefaultOrderField('ts');
54 $this->setExternalSorting(true);
55 $this->setExternalSegmentation(true);
56
60
61 $this->setShowRowsSelector(true);
62
63 $this->setRowTemplate('tpl.tos_acceptance_history_table_row.html', 'Services/TermsOfService');
64
65 $this->initFilter();
66 $this->setFilterCommand('applyAcceptanceHistoryFilter');
67 $this->setResetCommand('resetAcceptanceHistoryFilter');
68 }
69
73 protected function getColumnDefinition() : array
74 {
75 $i = 0;
76
77 return [
78 ++$i => [
79 'field' => 'ts',
80 'txt' => $this->lng->txt('tos_tbl_hist_head_acceptance_date'),
81 'default' => true,
82 'optional' => false,
83 'sortable' => true
84 ],
85 ++$i => [
86 'field' => 'login',
87 'txt' => $this->lng->txt('tos_tbl_hist_head_login'),
88 'default' => true,
89 'optional' => false,
90 'sortable' => true
91 ],
92 ++$i => [
93 'field' => 'firstname',
94 'txt' => $this->lng->txt('tos_tbl_hist_head_firstname'),
95 'default' => false,
96 'optional' => true,
97 'sortable' => true
98 ],
99 ++$i => [
100 'field' => 'lastname',
101 'txt' => $this->lng->txt('tos_tbl_hist_head_lastname'),
102 'default' => false,
103 'optional' => true,
104 'sortable' => true
105 ],
106 ++$i => [
107 'field' => 'title',
108 'txt' => $this->lng->txt('tos_tbl_hist_head_document'),
109 'default' => true,
110 'optional' => false,
111 'sortable' => true
112 ],
113 ++$i => [
114 'field' => 'criteria',
115 'txt' => $this->lng->txt('tos_tbl_hist_head_criteria'),
116 'default' => false,
117 'optional' => true,
118 'sortable' => false
119 ],
120 ];
121 }
122
126 protected function formatCellValue(string $column, array $row) : string
127 {
128 if ('ts' === $column) {
129 return \ilDatePresentation::formatDate(new \ilDateTime($row[$column], IL_CAL_UNIX));
130 } elseif ('title' === $column) {
131 return $this->formatTitle($column, $row);
132 } elseif ('criteria' === $column) {
133 return $this->formatCriterionAssignments($column, $row);
134 }
135
136 return parent::formatCellValue($column, $row);
137 }
138
142 protected function getUniqueCriterionListingAttribute() : string
143 {
144 return '<span class="ilNoDisplay">' . ($this->numRenderedCriteria++) . '</span>';
145 }
146
152 protected function formatCriterionAssignments(string $column, array $row) : string
153 {
154 $items = [];
155
156 $criteria = new \ilTermsOfServiceAcceptanceHistoryCriteriaBag($row['criteria']);
157
158 if (0 === count($criteria)) {
159 return $this->lng->txt('tos_tbl_hist_cell_not_criterion');
160 }
161
162 foreach ($criteria as $criterion) {
163 $criterionType = $this->criterionTypeFactory->findByTypeIdent($criterion['id'], true);
164 $typeGui = $criterionType->ui($this->lng);
165
166 $items[
167 $typeGui->getIdentPresentation() .
169 ] = $typeGui->getValuePresentation(
170 new \ilTermsOfServiceCriterionConfig($criterion['value']),
171 $this->uiFactory
172 );
173 }
174
175 $criteriaList = $this->uiFactory
176 ->listing()
177 ->descriptive($items);
178
179 return $this->uiRenderer->render([
180 $criteriaList
181 ]);
182 }
183
189 protected function formatTitle(string $column, array $row) : string
190 {
191 $modal = $this->uiFactory
192 ->modal()
193 ->lightbox([$this->uiFactory->modal()->lightboxTextPage($row['text'], $row['title'])]);
194
195 $titleLink = $this->uiFactory
196 ->button()
197 ->shy($row[$column], '#')
198 ->withOnClick($modal->getShowSignal());
199
200 return $this->uiRenderer->render([$titleLink, $modal]);
201 }
202
206 public function numericOrdering($column)
207 {
208 if ('ts' === $column) {
209 return true;
210 }
211
212 return false;
213 }
214
218 public function initFilter()
219 {
220 $ul = new ilTextInputGUI(
221 $this->lng->txt('login') . '/' . $this->lng->txt('email') . '/' . $this->lng->txt('name'),
222 'query'
223 );
224 $ul->setDataSource($this->ctrl->getLinkTarget($this->getParentObject(), 'addUserAutoComplete', '', true));
225 $ul->setSize(20);
226 $ul->setSubmitFormOnEnter(true);
227 $this->addFilterItem($ul);
228 $ul->readFromSession();
229 $this->filter['query'] = $ul->getValue();
230
231 $this->tpl->addJavaScript("./Services/Form/js/Form.js");
232 $duration = new \ilDateDurationInputGUI($this->lng->txt('tos_period'), 'period');
233 $duration->setAllowOpenIntervals(true);
234 $duration->setShowTime(true);
235 $duration->setStartText($this->lng->txt('tos_period_from'));
236 $duration->setEndText($this->lng->txt('tos_period_until'));
237 $duration->setStart(new \ilDateTime(null, IL_CAL_UNIX));
238 $duration->setEnd(new \ilDateTime(null, IL_CAL_UNIX));
239 $this->addFilterItem($duration, true);
240 $duration->readFromSession();
241 $this->optional_filter['period'] = $duration->getValue();
242 }
243}
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_UNIX
@classDescription Date and time handling
setExternalSorting($a_val)
Set external sorting.
setShowRowsSelector($a_value)
Toggle rows-per-page selector.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
setResetCommand($a_val, $a_caption=null)
Set reset filter command.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
addFilterItem($a_input_item, $a_optional=false)
Add filter item.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
setExternalSegmentation($a_val)
Set external segmentation.
setId($a_val)
Set id.
setFormName($a_formname="")
Set Form name.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setFilterCommand($a_val, $a_caption=null)
Set filter command.
numericOrdering($column)
Should this field be sorted numeric?boolean numeric ordering; default is false
initFilter()
Init filter.Overwrite this to initialize all filter input property objects.
__construct(\ilTermsOfServiceControllerEnabled $controller, string $command, \ilTermsOfServiceCriterionTypeFactoryInterface $criterionTypeFactory, Factory $uiFactory, Renderer $uiRenderer)
ilTermsOfServiceAcceptanceHistoryTableGUI constructor.
formatCellValue(string $column, array $row)
Define a final formatting for a cell value.string
Class ilTermsOfServiceCriterionConfig.
This class represents a text property in a property form.
static initPanel($a_resize=false, ilTemplate $a_main_tpl=null)
Init yui panel.
static initOverlay(ilTemplate $a_main_tpl=null)
Init YUI Overlay module.
static initjQuery($a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
$i
Definition: disco.tpl.php:19
This is how the factory for UI elements looks.
Definition: Factory.php:16
An entity that renders components to a string output.
Definition: Renderer.php:15
Interface ilTermsOfServiceControllerEnabled.
$row