ILIAS  trunk Revision v11.0_alpha-1702-gfd3ecb7f852
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilConditionHandlerTableGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
26 {
27  protected bool $enable_editing;
28 
29  public function __construct(object $a_parent_obj, string $a_parent_cmd, bool $a_enable_editing = false)
30  {
31  $this->enable_editing = $a_enable_editing;
32 
33  parent::__construct($a_parent_obj, $a_parent_cmd);
34 
35  $this->initTable();
36  }
37 
38  protected function fillRow(array $a_set): void
39  {
40  $this->tpl->setVariable('OBJ_SRC', $a_set['icon']);
41  $this->tpl->setVariable('OBJ_ALT', $a_set['icon_alt']);
42  $this->tpl->setVariable('OBJ_TITLE', $a_set['title']);
43  $this->tpl->setVariable('OBJ_LINK', ilLink::_getLink($a_set['ref_id']));
44  $this->tpl->setVariable('OBJ_DESCRIPTION', $a_set['description']);
45  $this->tpl->setVariable('COND_ID', $a_set['id']);
46  $this->tpl->setVariable('OBJ_CONDITION', $a_set['condition']);
47 
48  if (!$this->enable_editing) {
49  $this->tpl->setCurrentBlock("obligatory_static");
50  $this->tpl->setVariable(
51  'OBL_SRC',
52  ilUtil::getImagePath($a_set['obligatory'] ? 'standard/icon_ok.svg' : 'standard/icon_not_ok.svg')
53  );
54  $this->tpl->setVariable(
55  'OBL_ALT',
56  $this->lng->txt($a_set['obligatory'] ?
57  'precondition_obligatory_alt' :
58  'precondition_not_obligatory_alt')
59  );
60  $this->tpl->parseCurrentBlock();
61  } else {
62  $this->tpl->setCurrentBlock("obligatory_edit");
63  $this->tpl->setVariable('OBL_ID', $a_set['id']);
64  $this->tpl->setVariable('OBL_STATUS', $a_set['obligatory'] ? ' checked="checked"' : '');
65  $this->tpl->parseCurrentBlock();
66  }
67 
68  if ($this->getParentObject() !== null) {
69  $this->ctrl->setParameterByClass(get_class($this->getParentObject()), 'condition_id', $a_set['id']);
70  $this->tpl->setVariable(
71  'EDIT_LINK',
72  $this->ctrl->getLinkTargetByClass(get_class($this->getParentObject()), 'edit')
73  );
74  }
75  $this->tpl->setVariable('TXT_EDIT', $this->lng->txt('edit'));
76  }
77 
82  public function setConditions(array $a_conditions): void
83  {
84  $rows = [];
85  foreach ($a_conditions as $condition) {
86  if ($condition['trigger_type'] === 'crsg') {
87  continue;
88  }
89  $row['id'] = $condition['condition_id'];
90  $row['ref_id'] = $condition['trigger_ref_id'];
91  $row['type'] = $condition['trigger_type'];
92  $row['title'] = ilObject::_lookupTitle($condition['trigger_obj_id']);
93  $row['description'] = ilObject::_lookupDescription($condition['trigger_obj_id']);
94  $row['icon'] = ilObject::_getIcon((int) $condition['trigger_obj_id']);
95  $row['icon_alt'] = $this->lng->txt('obj_' . $condition['trigger_type']);
96  $row['condition'] = $this->lng->txt('condition_' . $condition['operator']);
97  $row['obligatory'] = $condition['obligatory'];
98 
99  $rows[] = $row;
100  }
101  $this->setData($rows);
102  }
103 
107  protected function initTable(): void
108  {
109  $this->lng->loadLanguageModule('rbac');
110 
111  $this->setRowTemplate('tpl.condition_handler_row.html', 'components/ILIAS/Conditions');
112  $this->setTitle($this->lng->txt('active_preconditions'));
113  $this->addColumn('', '', '1');
114  $this->addColumn($this->lng->txt('rbac_precondition_source'), 'title', '66%');
115  $this->addColumn($this->lng->txt('condition'), 'condition');
116  $this->addColumn($this->lng->txt('precondition_obligatory'), 'obligatory');
117  $this->addColumn($this->lng->txt('actions'));
118 
119  $this->enable('select_all');
120  $this->setSelectAllCheckbox('conditions');
121 
122  $this->setDefaultOrderField('title');
123  $this->setDefaultOrderDirection('asc');
124 
125  $this->setFormAction($this->ctrl->getFormAction($this->getParentObject(), $this->getParentCmd()));
126  $this->addMultiCommand('askDelete', $this->lng->txt('delete'));
127 
128  if ($this->enable_editing) {
129  $this->addCommandButton("saveObligatoryList", $this->lng->txt("rbac_precondition_save_obligatory"));
130  }
131  }
132 }
setData(array $a_data)
__construct(object $a_parent_obj, string $a_parent_cmd, bool $a_enable_editing=false)
enable(string $a_module_name)
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
setFormAction(string $a_form_action, bool $a_multipart=false)
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
setConditions(array $a_conditions)
Set and parse conditions.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static _lookupTitle(int $obj_id)
setDefaultOrderField(string $a_defaultorderfield)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
Table presentation of conditions.
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
setDefaultOrderDirection(string $a_defaultorderdirection)
static _lookupDescription(int $obj_id)
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
__construct(Container $dic, ilPlugin $plugin)
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)
addMultiCommand(string $a_cmd, string $a_text)