ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilUnitCategoryTableGUI.php
Go to the documentation of this file.
1 <?php
2 
23 abstract class ilUnitCategoryTableGUI extends ilTable2GUI
24 {
25  private \ILIAS\UI\Factory $ui_factory;
26  private \ILIAS\UI\Renderer $ui_renderer;
27 
32  public function __construct(ilUnitConfigurationGUI $controller, $cmd)
33  {
37  global $DIC;
38  $ilCtrl = $DIC['ilCtrl'];
39  $this->ui_factory = $DIC->ui()->factory();
40  $this->ui_renderer = $DIC->ui()->renderer();
41 
42  $this->setId('ucats_' . $controller->getUniqueId());
43 
44  parent::__construct($controller, $cmd);
45 
46  $this->addColumn('', '', '1%', true);
47  $this->addColumn($this->lng->txt('title'), 'category', '99%');
48  $this->addColumn('', '', '1%', true);
49 
50  $this->setDefaultOrderDirection('category');
51  $this->setDefaultOrderDirection('ASC');
52  $ref_id = $DIC->testQuestionPool()->internal()->request()->getRefId();
53  $type = ilObject::_lookupType($ref_id, true);
54  if ($type === 'assf') {
55  $hasAccess = $DIC->rbac()->system()->checkAccess('edit', $ref_id);
56  } else {
57  $hasAccess = $DIC->access()->checkAccess('edit', $cmd, $ref_id);
58  }
59  if ($hasAccess) {
60  if ($this->getParentObject()->isCRUDContext()) {
61  $this->addMultiCommand('confirmDeleteCategories', $this->lng->txt('delete'));
62  } else {
63  $this->addMultiCommand('confirmImportGlobalCategories', $this->lng->txt('import'));
64  }
65  }
66 
67  $this->populateTitle();
68 
69  $this->setFormAction($ilCtrl->getFormAction($this->getParentObject(), $cmd));
70  $this->setSelectAllCheckbox('category_ids[]');
71  $this->setRowTemplate('tpl.unit_category_row.html', 'Modules/TestQuestionPool');
72  }
73 
74  abstract protected function populateTitle(): void;
75 
79  public function fillRow(array $row): void
80  {
84  global $DIC;
85  $ilCtrl = $DIC['ilCtrl'];
86 
87  $row['chb'] = ilLegacyFormElementsUtil::formCheckbox(false, 'category_ids[]', $row['category_id']);
88 
89  $actions = [];
90 
91  $ilCtrl->setParameter($this->getParentObject(), 'category_id', $row['category_id']);
92  $actions[] = $this->ui_factory->link()->standard($this->lng->txt('un_show_units'), $ilCtrl->getLinkTarget($this->getParentObject(), 'showUnitsOfCategory'));
93  $ref_id = $DIC->testQuestionPool()->internal()->request()->getRefId();
94  $type = ilObject::_lookupType($ref_id, true);
95  if ($type === 'assf') {
96  $hasAccess = $DIC->rbac()->system()->checkAccess('edit', $ref_id);
97  } else {
98  $hasAccess = $DIC->access()->checkAccess('edit', 'showUnitCategoryModificationForm', $ref_id) &&
99  $DIC->access()->checkAccess('edit', 'confirmDeleteCategory', $ref_id);
100  }
101  if ($this->getParentObject()->isCRUDContext()) {
102  if ($hasAccess) {
103  $actions[] = $this->ui_factory->link()->standard($this->lng->txt('edit'), $ilCtrl->getLinkTarget($this->getParentObject(), 'showUnitCategoryModificationForm'));
104  $actions[] = $this->ui_factory->link()->standard($this->lng->txt('delete'), $ilCtrl->getLinkTarget($this->getParentObject(), 'confirmDeleteCategory'));
105  }
106  } else {
107  $actions[] = $this->ui_factory->link()->standard($this->lng->txt('import'), $ilCtrl->getLinkTarget($this->getParentObject(), 'confirmImportGlobalCategory'));
108  }
109  $row['title_href'] = $ilCtrl->getLinkTarget($this->getParentObject(), 'showUnitsOfCategory');
110  $ilCtrl->setParameter($this->getParentObject(), 'category_id', '');
111  $dropdown = $this->ui_factory->dropdown()->standard($actions)->withLabel($this->lng->txt('actions'));
112  $row['actions'] = $this->ui_renderer->render($dropdown);
113 
114  parent::fillRow($row);
115  }
116 }
setFormAction(string $a_form_action, bool $a_multipart=false)
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setId(string $a_val)
global $DIC
Definition: feed.php:28
$ref_id
Definition: ltiauth.php:67
__construct(VocabulariesInterface $vocabularies)
fillRow(array $a_set)
Standard Version of Fill Row.
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setDefaultOrderDirection(string $a_defaultorderdirection)
static formCheckbox(bool $checked, string $varname, string $value, bool $disabled=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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)
__construct(?object $a_parent_obj, string $a_parent_cmd="", string $a_template_context="")
static _lookupType(int $id, bool $reference=false)
addMultiCommand(string $a_cmd, string $a_text)