ILIAS  trunk Revision v12.0_alpha-1540-g00f839d5fa1
class.ilUnitTableGUI.php
Go to the documentation of this file.
1<?php
2
21
26{
30 private $position = 1;
31 private \ILIAS\UI\Factory $ui_factory;
32 private \ILIAS\UI\Renderer $ui_renderer;
35
41 public function __construct(ilUnitConfigurationGUI $controller, $default_cmd, assFormulaQuestionUnitCategory $category)
42 {
47 global $DIC;
48 $ilCtrl = $DIC['ilCtrl'];
49 $lng = $DIC['lng'];
50 $this->ui_factory = $DIC->ui()->factory();
51 $this->ui_renderer = $DIC->ui()->renderer();
52 $this->access = $DIC->access();
53 $this->request = QuestionPoolDIC::dic()['request_data_collector'];
54
55 $this->setId('units_' . $controller->getUniqueId());
56
57 parent::__construct($controller, $default_cmd);
58
59 $ilCtrl->setParameter($this->getParentObject(), 'category_id', $category->getId());
60
61 if (
62 $this->getParentObject()?->isCRUDContext()
63 && $this->access->checkAccess('write', '', $this->request->getRefId())
64 ) {
65 $this->addColumn('', '', '1%', true);
66 $this->setSelectAllCheckbox('unit_ids[]');
67 $this->addMultiCommand('confirmDeleteUnits', $this->lng->txt('delete'));
68 $this->addCommandButton('saveOrder', $this->lng->txt('un_save_order'));
69 }
70
71 $this->setTitle(sprintf($this->lng->txt('un_units_of_category_x'), $category->getDisplayString()));
72
73 $this->addColumn($this->lng->txt('un_sequence'), '');
74 $this->addColumn($this->lng->txt('unit'), '');
75 $this->addColumn($this->lng->txt('baseunit'), '');
76 $this->addColumn($this->lng->txt('factor'), '');
77 $this->addColumn('', '', '1%', true);
78
79 // Show all units because of sorting
80 $this->setLimit(PHP_INT_MAX);
81
82 $this->setFormAction($ilCtrl->getFormAction($this->getParentObject(), 'showUnitsOfCategory'));
83
84 $this->setDefaultOrderDirection('sequence');
85 $this->setDefaultOrderDirection('ASC');
86
87 $this->setRowTemplate('tpl.unit_row_html', 'components/ILIAS/TestQuestionPool');
88 }
89
93 public function fillRow(array $a_set): void
94 {
98 global $DIC;
99 $ilCtrl = $DIC['ilCtrl'];
100
101 if (
102 $this->getParentObject()?->isCRUDContext()
103 && $this->access->checkAccess('write', '', $this->request->getRefId())
104 ) {
105 $a_set['chb'] = ilLegacyFormElementsUtil::formCheckbox(false, 'unit_ids[]', $a_set['unit_id']);
106
107 $sequence = new ilNumberInputGUI('', 'sequence[' . $a_set['unit_id'] . ']');
108 $sequence->setValue($this->position++ * 10);
109 $sequence->setMinValue(0);
110 $sequence->setSize(3);
111 $a_set['sequence'] = $sequence->render();
112
113 $actions = [];
114 $ilCtrl->setParameter($this->getParentObject(), 'unit_id', $a_set['unit_id']);
115 $actions[] = $this->ui_factory->link()->standard($this->lng->txt('edit'), $ilCtrl->getLinkTarget($this->getParentObject(), 'showUnitModificationForm'));
116 $actions[] = $this->ui_factory->link()->standard($this->lng->txt('delete'), $ilCtrl->getLinkTarget($this->getParentObject(), 'confirmDeleteUnit'));
117 $ilCtrl->setParameter($this->getParentObject(), 'unit_id', '');
118 $dropdown = $this->ui_factory->dropdown()->standard($actions)->withLabel($this->lng->txt('actions'));
119 $a_set['actions'] = $this->ui_renderer->render($dropdown);
120 }
121 if ($a_set['unit_id'] == $a_set['baseunit_id']) {
122 $a_set['baseunit'] = '';
123 }
124 parent::fillRow($a_set);
125 }
126}
static formCheckbox(bool $checked, string $varname, string $value, bool $disabled=false)
This class represents a number property in a property form.
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="")
setLimit(int $a_limit=0, int $a_default_limit=0)
set max.
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
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)
fillRow(array $a_set)
Standard Version of Fill Row.
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)
ilLanguage $lng
Class ilUnitConfigurationGUI.
Class ilUnitTableGUI.
ilAccessHandler $access
ILIAS UI Renderer $ui_renderer
RequestDataCollector $request
ILIAS UI Factory $ui_factory
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26