ILIAS  release_8 Revision v8.24
class.ilTermsOfServiceAcceptanceHistoryTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
23
29{
32 protected int $numRenderedCriteria = 0;
34
35 public function __construct(
37 string $command,
41 ilGlobalTemplateInterface $globalTemplate
42 ) {
43 $this->criterionTypeFactory = $criterionTypeFactory;
44 $this->uiFactory = $uiFactory;
45 $this->uiRenderer = $uiRenderer;
46
47 $this->setId('tos_acceptance_history');
48 $this->setFormName('tos_acceptance_history');
49
50 parent::__construct($controller, $command);
51
52 $this->setTitle($this->lng->txt('tos_acceptance_history'));
53 $this->setFormAction($this->ctrl->getFormAction($controller, 'applyAcceptanceHistoryFilter'));
54
55 $this->setDefaultOrderDirection('DESC');
56 $this->setDefaultOrderField('ts');
57 $this->setExternalSorting(true);
58 $this->setExternalSegmentation(true);
59
60 iljQueryUtil::initjQuery($globalTemplate);
61 ilYuiUtil::initPanel(false, $globalTemplate);
62 ilYuiUtil::initOverlay($globalTemplate);
63 $globalTemplate->addJavaScript('./Services/Form/js/Form.js');
64
65 $this->setShowRowsSelector(true);
66
67 $this->setRowTemplate('tpl.tos_acceptance_history_table_row.html', 'Services/TermsOfService');
68
69 $this->initFilter();
70 $this->setFilterCommand('applyAcceptanceHistoryFilter');
71 $this->setResetCommand('resetAcceptanceHistoryFilter');
72 }
73
74 protected function getColumnDefinition(): array
75 {
76 $i = 0;
77
78 return [
79 ++$i => [
80 'field' => 'ts',
81 'txt' => $this->lng->txt('tos_tbl_hist_head_acceptance_date'),
82 'default' => true,
83 'optional' => false,
84 'sortable' => true
85 ],
86 ++$i => [
87 'field' => 'login',
88 'txt' => $this->lng->txt('tos_tbl_hist_head_login'),
89 'default' => true,
90 'optional' => false,
91 'sortable' => true
92 ],
93 ++$i => [
94 'field' => 'firstname',
95 'txt' => $this->lng->txt('tos_tbl_hist_head_firstname'),
96 'default' => false,
97 'optional' => true,
98 'sortable' => true
99 ],
100 ++$i => [
101 'field' => 'lastname',
102 'txt' => $this->lng->txt('tos_tbl_hist_head_lastname'),
103 'default' => false,
104 'optional' => true,
105 'sortable' => true
106 ],
107 ++$i => [
108 'field' => 'title',
109 'txt' => $this->lng->txt('tos_tbl_hist_head_document'),
110 'default' => true,
111 'optional' => false,
112 'sortable' => true
113 ],
114 ++$i => [
115 'field' => 'criteria',
116 'txt' => $this->lng->txt('tos_tbl_hist_head_criteria'),
117 'default' => false,
118 'optional' => true,
119 'sortable' => false
120 ],
121 ];
122 }
123
124 protected function formatCellValue(string $column, array $row): string
125 {
126 if ('ts' === $column) {
128 } elseif ('title' === $column) {
129 return $this->formatTitle($column, $row);
130 } elseif ('criteria' === $column) {
131 return $this->formatCriterionAssignments($column, $row);
132 }
133
134 return parent::formatCellValue($column, $row);
135 }
136
137 protected function getUniqueCriterionListingAttribute(): string
138 {
139 return '<span class="ilNoDisplay">' . ($this->numRenderedCriteria++) . '</span>';
140 }
141
142 protected function formatCriterionAssignments(string $column, array $row): string
143 {
144 $items = [];
145
146 $criteria = new ilTermsOfServiceAcceptanceHistoryCriteriaBag($row['criteria']);
147
148 if (0 === count($criteria)) {
149 return $this->lng->txt('tos_tbl_hist_cell_not_criterion');
150 }
151
152 foreach ($criteria as $criterion) {
153 $criterionType = $this->criterionTypeFactory->findByTypeIdent($criterion['id'], true);
154 $typeGui = $criterionType->ui($this->lng);
155
156 $items[$typeGui->getIdentPresentation() .
157 $this->getUniqueCriterionListingAttribute()] = $typeGui->getValuePresentation(
158 new ilTermsOfServiceCriterionConfig($criterion['value']),
159 $this->uiFactory
160 );
161 }
162
163 $criteriaList = $this->uiFactory
164 ->listing()
165 ->descriptive($items);
166
167 return $this->uiRenderer->render([
168 $criteriaList
169 ]);
170 }
171
172 protected function formatTitle(string $column, array $row): string
173 {
174 $modal = $this->uiFactory
175 ->modal()
176 ->lightbox([$this->uiFactory->modal()->lightboxTextPage($row['text'], $row['title'])]);
177
178 $titleLink = $this->uiFactory
179 ->button()
180 ->shy($row[$column], '#')
181 ->withOnClick($modal->getShowSignal());
182
183 return $this->uiRenderer->render([$titleLink, $modal]);
184 }
185
186 public function numericOrdering(string $a_field): bool
187 {
188 return 'ts' === $a_field;
189 }
190
191 public function initFilter(): void
192 {
193 $ul = new ilTextInputGUI(
194 $this->lng->txt('login') . '/' . $this->lng->txt('email') . '/' . $this->lng->txt('name'),
195 'query'
196 );
197 $ul->setDataSource($this->ctrl->getLinkTarget($this->getParentObject(), 'addUserAutoComplete', '', true));
198 $ul->setSize(20);
199 $ul->setSubmitFormOnEnter(true);
200 $this->addFilterItem($ul);
201 $ul->readFromSession();
202 $this->filter['query'] = $ul->getValue();
203
204 $duration = new ilDateDurationInputGUI($this->lng->txt('tos_period'), 'period');
205 $duration->setAllowOpenIntervals(true);
206 $duration->setShowTime(true);
207 $duration->setStartText($this->lng->txt('tos_period_from'));
208 $duration->setEndText($this->lng->txt('tos_period_until'));
209 $duration->setStart(new ilDateTime(null, IL_CAL_UNIX));
210 $duration->setEnd(new ilDateTime(null, IL_CAL_UNIX));
211 $this->addFilterItem($duration, true);
212 $duration->readFromSession();
213 $this->optional_filter['period'] = $duration->getValue();
214 }
215}
const IL_CAL_UNIX
return true
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
@classDescription Date and time handling
setShowRowsSelector(bool $a_value)
Toggle rows-per-page selector.
setFilterCommand(string $a_val, string $a_caption="")
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
setExternalSegmentation(bool $a_val)
addFilterItem(ilTableFilterItem $a_input_item, bool $a_optional=false)
setFormName(string $a_name="")
setFormAction(string $a_form_action, bool $a_multipart=false)
setDefaultOrderField(string $a_defaultorderfield)
setExternalSorting(bool $a_val)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
setDefaultOrderDirection(string $a_defaultorderdirection)
setResetCommand(string $a_val, string $a_caption="")
ilTermsOfServiceCriterionTypeFactoryInterface $criterionTypeFactory
__construct(ilTermsOfServiceControllerEnabled $controller, string $command, ilTermsOfServiceCriterionTypeFactoryInterface $criterionTypeFactory, Factory $uiFactory, Renderer $uiRenderer, ilGlobalTemplateInterface $globalTemplate)
formatCellValue(string $column, array $row)
Define a final formatting for a cell value.
numericOrdering(string $a_field)
Should this field be sorted numeric?
Class ilTermsOfServiceCriterionConfig.
This class represents a text property in a property form.
static initPanel(bool $a_resize=false, ?ilGlobalTemplateInterface $a_main_tpl=null)
Init yui panel used in Modules/Test, Services/TermsOfService (Jan 2022)
static initOverlay(?ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Overlay module used in Modules/Test, Services/TermsOfService, Services/Tracking,...
static initjQuery(ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
This is how the factory for UI elements looks.
Definition: Factory.php:38
An entity that renders components to a string output.
Definition: Renderer.php:31
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addJavaScript(string $a_js_file, bool $a_add_version_parameter=true, int $a_batch=2)
Add a javascript file that should be included in the header.
Interface ilTermsOfServiceControllerEnabled.
$i
Definition: metadata.php:41
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc