ILIAS  release_8 Revision v8.24
class.ilConditionHandlerTableGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
21/******************************************************************************
22 *
23 * This file is part of ILIAS, a powerful learning management system
24 * published by ILIAS open source e-Learning e.V.
25 *
26 * ILIAS is licensed with the GPL-3.0,
27 * see https://www.gnu.org/licenses/gpl-3.0.en.html
28 * You should have received a copy of said license along with the
29 * source code, too.
30 *
31 * If this is not the case or you just want to try ILIAS, you'll find
32 * us at:
33 * https://www.ilias.de
34 * https://github.com/ILIAS-eLearning
35 *
36 *****************************************************************************/
37
43{
44 protected bool $enable_editing;
45
46 public function __construct(object $a_parent_obj, string $a_parent_cmd, bool $a_enable_editing = false)
47 {
48 $this->enable_editing = $a_enable_editing;
49
50 parent::__construct($a_parent_obj, $a_parent_cmd);
51
52 $this->initTable();
53 }
54
55 protected function fillRow(array $a_set): void
56 {
57 $this->tpl->setVariable('OBJ_SRC', $a_set['icon']);
58 $this->tpl->setVariable('OBJ_ALT', $a_set['icon_alt']);
59 $this->tpl->setVariable('OBJ_TITLE', $a_set['title']);
60 $this->tpl->setVariable('OBJ_LINK', ilLink::_getLink($a_set['ref_id']));
61 $this->tpl->setVariable('OBJ_DESCRIPTION', $a_set['description']);
62 $this->tpl->setVariable('COND_ID', $a_set['id']);
63 $this->tpl->setVariable('OBJ_CONDITION', $a_set['condition']);
64
65 if (!$this->enable_editing) {
66 $this->tpl->setCurrentBlock("obligatory_static");
67 $this->tpl->setVariable(
68 'OBL_SRC',
69 ilUtil::getImagePath($a_set['obligatory'] ? 'icon_ok.svg' : 'icon_not_ok.svg')
70 );
71 $this->tpl->setVariable(
72 'OBL_ALT',
73 $this->lng->txt($a_set['obligatory'] ?
74 'precondition_obligatory_alt' :
75 'precondition_not_obligatory_alt')
76 );
77 $this->tpl->parseCurrentBlock();
78 } else {
79 $this->tpl->setCurrentBlock("obligatory_edit");
80 $this->tpl->setVariable('OBL_ID', $a_set['id']);
81 $this->tpl->setVariable('OBL_STATUS', $a_set['obligatory'] ? ' checked="checked"' : '');
82 $this->tpl->parseCurrentBlock();
83 }
84
85 if ($this->getParentObject() !== null) {
86 $this->ctrl->setParameterByClass(get_class($this->getParentObject()), 'condition_id', $a_set['id']);
87 $this->tpl->setVariable(
88 'EDIT_LINK',
89 $this->ctrl->getLinkTargetByClass(get_class($this->getParentObject()), 'edit')
90 );
91 }
92 $this->tpl->setVariable('TXT_EDIT', $this->lng->txt('edit'));
93 }
94
99 public function setConditions(array $a_conditions): void
100 {
101 $rows = [];
102 foreach ($a_conditions as $condition) {
103 if ($condition['trigger_type'] === 'crsg') {
104 continue;
105 }
106 $row['id'] = $condition['condition_id'];
107 $row['ref_id'] = $condition['trigger_ref_id'];
108 $row['type'] = $condition['trigger_type'];
109 $row['title'] = ilObject::_lookupTitle($condition['trigger_obj_id']);
110 $row['description'] = ilObject::_lookupDescription($condition['trigger_obj_id']);
111 $row['icon'] = ilObject::_getIcon((int) $condition['trigger_obj_id']);
112 $row['icon_alt'] = $this->lng->txt('obj_' . $condition['trigger_type']);
113 $row['condition'] = $this->lng->txt('condition_' . $condition['operator']);
114 $row['obligatory'] = $condition['obligatory'];
115
116 $rows[] = $row;
117 }
118 $this->setData($rows);
119 }
120
124 protected function initTable(): void
125 {
126 $this->lng->loadLanguageModule('rbac');
127
128 $this->setRowTemplate('tpl.condition_handler_row.html', 'Services/Conditions');
129 $this->setTitle($this->lng->txt('active_preconditions'));
130 $this->addColumn('', '', '1');
131 $this->addColumn($this->lng->txt('rbac_precondition_source'), 'title', '66%');
132 $this->addColumn($this->lng->txt('condition'), 'condition');
133 $this->addColumn($this->lng->txt('precondition_obligatory'), 'obligatory');
134 $this->addColumn($this->lng->txt('actions'));
135
136 $this->enable('select_all');
137 $this->setSelectAllCheckbox('conditions');
138
139 $this->setDefaultOrderField('title');
140 $this->setDefaultOrderDirection('asc');
141
142 $this->setFormAction($this->ctrl->getFormAction($this->getParentObject(), $this->getParentCmd()));
143 $this->addMultiCommand('askDelete', $this->lng->txt('delete'));
144
145 if ($this->enable_editing) {
146 $this->addCommandButton("saveObligatoryList", $this->lng->txt("rbac_precondition_save_obligatory"));
147 }
148 }
149}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setConditions(array $a_conditions)
Set and parse conditions.
__construct(object $a_parent_obj, string $a_parent_cmd, bool $a_enable_editing=false)
fillRow(array $a_set)
Standard Version of Fill Row.
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
static _lookupTitle(int $obj_id)
static _lookupDescription(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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)
setDefaultOrderField(string $a_defaultorderfield)
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setDefaultOrderDirection(string $a_defaultorderdirection)
setData(array $a_data)
Set table data.
enable(string $a_module_name)
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$rows
Definition: xhr_table.php:10