ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilUnitCategoryTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
23
28abstract class ilUnitCategoryTableGUI extends ilTable2GUI
29{
30 private \ILIAS\UI\Factory $ui_factory;
31 private \ILIAS\UI\Renderer $ui_renderer;
32
34 private \ILIAS\Refinery\Factory $refinery;
35
40 public function __construct(ilUnitConfigurationGUI $controller, $cmd)
41 {
45 global $DIC;
46 $ilCtrl = $DIC['ilCtrl'];
47 $this->ui_factory = $DIC->ui()->factory();
48 $this->ui_renderer = $DIC->ui()->renderer();
49 $this->refinery = $DIC->refinery();
50
51 $this->setId('ucats_' . $controller->getUniqueId());
52
53 parent::__construct($controller, $cmd);
54
55 $this->addColumn('', '', '1%', true);
56 $this->addColumn($this->lng->txt('title'), 'category', '99%');
57 $this->addColumn('', '', '1%', true);
58
59 $this->setDefaultOrderDirection('category');
60 $this->setDefaultOrderDirection('ASC');
61
62 $local_dic = QuestionPoolDIC::dic();
63 $this->request = $local_dic['request_data_collector'];
64 $ref_id = $this->request->getRefId();
65 $type = ilObject::_lookupType($ref_id, true);
66 if ($type === 'assf') {
67 $hasAccess = $DIC->rbac()->system()->checkAccess('edit', $ref_id);
68 } else {
69 $hasAccess = $DIC->access()->checkAccess('edit', $cmd, $ref_id);
70 }
71 if ($hasAccess) {
72 if ($this->getParentObject()->isCRUDContext()) {
73 $this->addMultiCommand('confirmDeleteCategories', $this->lng->txt('delete'));
74 } else {
75 $this->addMultiCommand('confirmImportGlobalCategories', $this->lng->txt('import'));
76 }
77 }
78
79 $this->populateTitle();
80
81 $this->setFormAction($ilCtrl->getFormAction($this->getParentObject(), $cmd));
82 $this->setSelectAllCheckbox('category_ids[]');
83 $this->setRowTemplate('tpl.unit_category_row.html', 'components/ILIAS/TestQuestionPool');
84 }
85
86 abstract protected function populateTitle(): void;
87
91 public function fillRow(array $row): void
92 {
93 global $DIC;
94
95 $row['chb'] = ilLegacyFormElementsUtil::formCheckbox(false, 'category_ids[]', (string) $row['category_id']);
96
97 $actions = [];
98
99 $this->ctrl->setParameter($this->getParentObject(), 'category_id', $row['category_id']);
100 $actions[] = $this->ui_factory->link()->standard($this->lng->txt('un_show_units'), $this->ctrl->getLinkTarget($this->getParentObject(), 'showUnitsOfCategory'));
101 $ref_id = $this->request->getRefId();
102 $type = ilObject::_lookupType($ref_id, true);
103 if ($type === 'assf') {
104 $hasAccess = $DIC->rbac()->system()->checkAccess('edit', $ref_id);
105 } else {
106 $hasAccess = $DIC->access()->checkAccess('edit', 'showUnitCategoryModificationForm', $ref_id) &&
107 $DIC->access()->checkAccess('edit', 'confirmDeleteCategory', $ref_id);
108 }
109 if ($this->getParentObject()->isCRUDContext()) {
110 if ($hasAccess) {
111 $actions[] = $this->ui_factory->link()->standard($this->lng->txt('edit'), $this->ctrl->getLinkTarget($this->getParentObject(), 'showUnitCategoryModificationForm'));
112 $actions[] = $this->ui_factory->link()->standard($this->lng->txt('delete'), $this->ctrl->getLinkTarget($this->getParentObject(), 'confirmDeleteCategory'));
113 }
114 } else {
115 $actions[] = $this->ui_factory->link()->standard($this->lng->txt('import'), $this->ctrl->getLinkTarget($this->getParentObject(), 'confirmImportGlobalCategory'));
116 }
117 $row['title_href'] = $this->ctrl->getLinkTarget($this->getParentObject(), 'showUnitsOfCategory');
118 $this->ctrl->setParameter($this->getParentObject(), 'category_id', '');
119 $dropdown = $this->ui_factory->dropdown()->standard($actions)->withLabel($this->lng->txt('actions'));
120 $row['actions'] = $this->ui_renderer->render($dropdown);
121
122 $row['category'] = $this->refinery->encode()->htmlSpecialCharsAsEntities()->transform($row['category']);
123 $row['category_link_title'] = $this->refinery->encode()->htmlAttributeValue()->transform(
124 $row['category']
125 );
126
127 parent::fillRow($row);
128 }
129}
static formCheckbox(bool $checked, string $varname, string $value, bool $disabled=false)
static _lookupType(int $id, bool $reference=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(?object $a_parent_obj, string $a_parent_cmd="", string $a_template_context="")
addMultiCommand(string $a_cmd, string $a_text)
setFormAction(string $a_form_action, bool $a_multipart=false)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
setDefaultOrderDirection(string $a_defaultorderdirection)
Class ilUnitCategoryTableGUI @abstract.
Class ilUnitConfigurationGUI.
$ref_id
Definition: ltiauth.php:66
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26