ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilUnitTableGUI.php
Go to the documentation of this file.
1<?php
2
23{
27 private $position = 1;
28 private \ILIAS\UI\Factory $ui_factory;
29 private \ILIAS\UI\Renderer $ui_renderer;
30
36 public function __construct(ilUnitConfigurationGUI $controller, $default_cmd, assFormulaQuestionUnitCategory $category)
37 {
42 global $DIC;
43 $ilCtrl = $DIC['ilCtrl'];
44 $lng = $DIC['lng'];
45 $this->ui_factory = $DIC->ui()->factory();
46 $this->ui_renderer = $DIC->ui()->renderer();
47
48 $this->setId('units_' . $controller->getUniqueId());
49
50 parent::__construct($controller, $default_cmd);
51
52 $ilCtrl->setParameter($this->getParentObject(), 'category_id', $category->getId());
53
54 if ($this->getParentObject()->isCRUDContext()) {
55 $this->addColumn('', '', '1%', true);
56 $this->setSelectAllCheckbox('unit_ids[]');
57 $this->addMultiCommand('confirmDeleteUnits', $this->lng->txt('delete'));
58 $this->addCommandButton('saveOrder', $this->lng->txt('un_save_order'));
59 }
60
61 $this->setTitle(sprintf($this->lng->txt('un_units_of_category_x'), $category->getDisplayString()));
62
63 $this->addColumn($this->lng->txt('un_sequence'), '');
64 $this->addColumn($this->lng->txt('unit'), '');
65 $this->addColumn($this->lng->txt('baseunit'), '');
66 $this->addColumn($this->lng->txt('factor'), '');
67 $this->addColumn('', '', '1%', true);
68
69 // Show all units because of sorting
70 $this->setLimit(PHP_INT_MAX);
71
72 $this->setFormAction($ilCtrl->getFormAction($this->getParentObject(), 'showUnitsOfCategory'));
73
74 $this->setDefaultOrderDirection('sequence');
75 $this->setDefaultOrderDirection('ASC');
76
77 $this->setRowTemplate('tpl.unit_row_html', 'components/ILIAS/TestQuestionPool');
78 }
79
83 public function fillRow(array $a_set): void
84 {
88 global $DIC;
89 $ilCtrl = $DIC['ilCtrl'];
90
91 if ($this->getParentObject()->isCRUDContext()) {
92 $a_set['chb'] = ilLegacyFormElementsUtil::formCheckbox(false, 'unit_ids[]', $a_set['unit_id']);
93
94 $sequence = new ilNumberInputGUI('', 'sequence[' . $a_set['unit_id'] . ']');
95 $sequence->setValue($this->position++ * 10);
96 $sequence->setMinValue(0);
97 $sequence->setSize(3);
98 $a_set['sequence'] = $sequence->render();
99
100 $actions = [];
101 $ilCtrl->setParameter($this->getParentObject(), 'unit_id', $a_set['unit_id']);
102 $actions[] = $this->ui_factory->link()->standard($this->lng->txt('edit'), $ilCtrl->getLinkTarget($this->getParentObject(), 'showUnitModificationForm'));
103 $actions[] = $this->ui_factory->link()->standard($this->lng->txt('delete'), $ilCtrl->getLinkTarget($this->getParentObject(), 'confirmDeleteUnit'));
104 $ilCtrl->setParameter($this->getParentObject(), 'unit_id', '');
105 $dropdown = $this->ui_factory->dropdown()->standard($actions)->withLabel($this->lng->txt('actions'));
106 $a_set['actions'] = $this->ui_renderer->render($dropdown);
107 }
108 if ($a_set['unit_id'] == $a_set['baseunit_id']) {
109 $a_set['baseunit'] = '';
110 }
111 parent::fillRow($a_set);
112 }
113}
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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ILIAS UI Renderer $ui_renderer
ILIAS UI Factory $ui_factory
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26