56 $this->
setId(
'tos_documents');
59 parent::__construct($a_parent_obj, $command);
61 $this->
setTitle($this->lng->txt(
'tos_tbl_docs_title'));
62 $this->
setFormAction($this->ctrl->getFormAction($this->getParentObject(), $command));
70 $this->
setRowTemplate(
'tpl.tos_documents_row.html',
'Services/TermsOfService');
72 if ($this->isEditable) {
75 $this->
addCommandButton(
'saveDocumentSorting', $this->lng->txt(
'sorting_save'));
88 if ($this->isEditable) {
95 'is_checkbox' =>
true,
101 'field' =>
'sorting',
102 'txt' => $this->lng->txt(
'tos_tbl_docs_head_sorting'),
111 'txt' => $this->lng->txt(
'tos_tbl_docs_head_title'),
119 'field' =>
'creation_ts',
120 'txt' => $this->lng->txt(
'tos_tbl_docs_head_created'),
127 'field' =>
'modification_ts',
128 'txt' => $this->lng->txt(
'tos_tbl_docs_head_last_change'),
135 'field' =>
'criteria',
136 'txt' => $this->lng->txt(
'tos_tbl_docs_head_criteria'),
142 if ($this->isEditable) {
144 'field' =>
'actions',
145 'txt' => $this->lng->txt(
'actions'),
162 foreach ($data[
'items'] as
$key => $document) {
165 $data[
'items'][
$key] = [
166 'id' => $document->getId(),
167 'title' => $document->getTitle(),
168 'creation_ts' => $document->getCreationTs(),
169 'modification_ts' => $document->getModificationTs(),
170 'text' => $document->getText(),
172 'criteriaAssignments' => $document->criteria()
182 if (in_array($column, [
'creation_ts',
'modification_ts'])) {
184 } elseif (
'sorting' === $column) {
186 } elseif (
'title' === $column) {
188 } elseif (
'actions' === $column) {
190 } elseif (
'chb' === $column) {
191 return \ilUtil::formCheckbox(
false,
'tos_id[]', $row[
'id']);
192 } elseif (
'criteria' === $column) {
193 return $this->formatCriterionAssignments($column, $row);
196 return parent::formatCellValue($column, $row);
206 if (!$this->isEditable) {
210 $this->ctrl->setParameter($this->
getParentObject(),
'tos_id', $row[
'id']);
212 $editBtn = $this->uiFactory
215 $this->lng->txt(
'edit'),
216 $this->ctrl->getLinkTarget($this->
getParentObject(),
'showEditDocumentForm')
219 $deleteModal = $this->uiFactory
222 $this->lng->txt(
'tos_doc_delete'),
223 $this->lng->txt(
'tos_sure_delete_documents_s'),
227 $deleteBtn = $this->uiFactory
229 ->shy($this->lng->txt(
'delete'),
'#')
230 ->withOnClick($deleteModal->getShowSignal());
232 $this->uiComponents[] = $deleteModal;
234 $attachCriterionBtn = $this->uiFactory
237 $this->lng->txt(
'tos_tbl_docs_action_add_criterion'),
238 $this->ctrl->getLinkTarget($this->
getParentObject(),
'showAttachCriterionForm')
243 $dropDown = $this->uiFactory
245 ->standard([$editBtn, $deleteBtn, $attachCriterionBtn])
246 ->withLabel($this->lng->txt(
'actions'));
248 return $this->uiRenderer->render([$dropDown]);
256 protected function formatCriterionAssignments(
string $column, array
$row) :
string 260 if (0 === count($row[
'criteriaAssignments'])) {
261 return $this->lng->txt(
'tos_tbl_docs_cell_not_criterion');
264 foreach ($row[
'criteriaAssignments'] as $criterion) {
267 $this->ctrl->setParameter($this->
getParentObject(),
'tos_id', $row[
'id']);
268 $this->ctrl->setParameter($this->
getParentObject(),
'crit_id', $criterion->getId());
270 $editBtn = $this->uiFactory
273 $this->lng->txt(
'edit'),
274 $this->ctrl->getLinkTarget($this->
getParentObject(),
'showChangeCriterionForm')
277 $deleteModal = $this->uiFactory
280 $this->lng->txt(
'tos_doc_detach_crit_confirm_title'),
281 $this->lng->txt(
'tos_doc_sure_detach_crit'),
282 $this->ctrl->getFormAction($this->
getParentObject(),
'detachCriterionAssignment')
285 $deleteBtn = $this->uiFactory
287 ->shy($this->lng->txt(
'delete'),
'#')
288 ->withOnClick($deleteModal->getShowSignal());
290 $dropDown = $this->uiFactory
292 ->standard([$editBtn, $deleteBtn]);
294 $criterionType = $this->criterionTypeFactory->findByTypeIdent($criterion->getCriterionId(),
true);
295 $typeGui = $criterionType->ui($this->lng);
297 $items[implode(
' ', [
298 $typeGui->getIdentPresentation(),
299 ($this->isEditable ? $this->uiRenderer->render($dropDown) :
'')
301 $this->uiFactory->legacy(
302 $this->uiRenderer->render(
303 $typeGui->getValuePresentation(
304 $criterion->getCriterionValue(),
310 if ($this->isEditable) {
311 $this->uiComponents[] = $deleteModal;
318 $criteriaList = $this->uiFactory
320 ->descriptive($items);
322 return $this->uiRenderer->render([
332 protected function formatTitle(
string $column, array $row) : string
334 $modal = $this->uiFactory
336 ->lightbox([$this->uiFactory->modal()->lightboxTextPage($row[
'text'], $row[
'title'])]);
338 $titleLink = $this->uiFactory
340 ->shy($row[$column],
'#')
341 ->withOnClick($modal->getShowSignal());
343 return $this->uiRenderer->render([$titleLink, $modal]);
352 $value = ($this->i++) * $this->factor;
353 if (!$this->isEditable) {
357 $sortingField = new \ilNumberInputGUI(
'',
'sorting[' . $row[
'id'] .
']');
358 $sortingField->setValue($value);
359 $sortingField->setMaxLength(4);
360 $sortingField->setSize(2);
362 return $sortingField->render(
'toolbar');
370 return parent::getHTML() . $this->uiRenderer->render($this->uiComponents);
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
Class ilTermsOfServiceDocumentTableGUI.
setExternalSorting($a_val)
Set external sorting.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
formatActionsDropDown(string $column, array $row)
Interface ilTermsOfServiceControllerEnabled.
setExternalSegmentation($a_val)
Set external segmentation.
getParentObject()
Get parent object.
formatSorting(array $row)
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
setSelectAllCheckbox($a_select_all_checkbox, $a_select_all_on_top=false)
Set the name of the checkbox that should be toggled with a select all button.
addMultiCommand($a_cmd, $a_text)
Add Command button.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
formatCellValue(string $column, array $row)
setFormName($a_formname="")
Set Form name.
formatTitle(string $column, array $row)
__construct(\ilTermsOfServiceControllerEnabled $a_parent_obj, string $command, \ilTermsOfServiceCriterionTypeFactoryInterface $criterionTypeFactory, ILIAS\UI\Factory $uiFactory, ILIAS\UI\Renderer $uiRenderer, bool $isEditable=false)
ilTermsOfServiceDocumentTableGUI constructor.
preProcessData(array &$data)
setLimit($a_limit=0, $a_default_limit=0)
Interface ilTermsOfServiceCriterionTypeFactoryInterface.