ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilConditionHandlerTableGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once './Services/Table/classes/class.ilTable2GUI.php';
6 
14 {
15  protected $enable_editing;
16 
23  public function __construct($a_parent_obj, $a_parent_cmd, $a_enable_editing = false)
24  {
25  $this->enable_editing = $a_enable_editing;
26 
27  parent::__construct($a_parent_obj, $a_parent_cmd);
28 
29  $this->initTable();
30  }
31 
36  public function fillRow($a_row)
37  {
38  global $ilCtrl;
39 
40  $this->tpl->setVariable('OBJ_SRC', $a_row['icon']);
41  $this->tpl->setVariable('OBJ_ALT', $a_row['icon_alt']);
42  $this->tpl->setVariable('OBJ_TITLE', $a_row['title']);
43  include_once './Services/Link/classes/class.ilLink.php';
44  $this->tpl->setVariable('OBJ_LINK', ilLink::_getLink($a_row['ref_id'], $a_row['type']));
45  $this->tpl->setVariable('OBJ_DESCRIPTION', $a_row['description']);
46  $this->tpl->setVariable('COND_ID', $a_row['id']);
47  $this->tpl->setVariable('OBJ_CONDITION', $a_row['condition']);
48 
49  if (!$this->enable_editing) {
50  $this->tpl->setCurrentBlock("obligatory_static");
51  $this->tpl->setVariable('OBL_SRC', ilUtil::getImagePath($a_row['obligatory'] ? 'icon_ok.svg' : 'icon_not_ok.svg'));
52  $this->tpl->setVariable(
53  'OBL_ALT',
54  $this->lng->txt($a_row['obligatory'] ?
55  'precondition_obligatory_alt' :
56  'precondition_not_obligatory_alt')
57  );
58  $this->tpl->parseCurrentBlock();
59  } else {
60  $this->tpl->setCurrentBlock("obligatory_edit");
61  $this->tpl->setVariable('OBL_ID', $a_row['id']);
62  $this->tpl->setVariable('OBL_STATUS', $a_row['obligatory'] ? ' checked="checked"' : '');
63  $this->tpl->parseCurrentBlock();
64  }
65 
66  $ilCtrl->setParameterByClass(get_class($this->getParentObject()), 'condition_id', $a_row['id']);
67  $this->tpl->setVariable('EDIT_LINK', $ilCtrl->getLinkTargetByClass(get_class($this->getParentObject()), 'edit'));
68  $this->tpl->setVariable('TXT_EDIT', $this->lng->txt('edit'));
69  }
70 
75  public function setConditions($a_conditions)
76  {
77  foreach ((array) $a_conditions as $condition) {
78  if ($condition['trigger_type'] == 'crsg') {
79  continue;
80  }
81 
82  $row['id'] = $condition['condition_id'];
83  $row['ref_id'] = $condition['trigger_ref_id'];
84  $row['type'] = $condition['trigger_type'];
85  $row['title'] = ilObject::_lookupTitle($condition['trigger_obj_id']);
86  $row['description'] = ilObject::_lookupDescription($condition['trigger_obj_id']);
87  $row['icon'] = ilObject::_getIcon($condition['trigger_obj_id']);
88  $row['icon_alt'] = $this->lng->txt('obj_' . $condition['trigger_type']);
89  $row['condition'] = $this->lng->txt('condition_' . $condition['operator']);
90  $row['obligatory'] = $condition['obligatory'];
91 
92  $rows[] = $row;
93  }
94  $this->setData($rows);
95  }
96 
101  protected function initTable()
102  {
103  global $ilCtrl;
104 
105  $this->lng->loadLanguageModule('rbac');
106 
107  $this->setRowTemplate('tpl.condition_handler_row.html', 'Services/AccessControl');
108 
109  $this->setTitle($this->lng->txt('active_preconditions'));
110 
111  $this->addColumn('', '', '1');
112  $this->addColumn($this->lng->txt('rbac_precondition_source'), 'title', '66%');
113  $this->addColumn($this->lng->txt('condition'), 'condition');
114  $this->addColumn($this->lng->txt('precondition_obligatory'), 'obligatory');
115  $this->addColumn($this->lng->txt('actions'));
116 
117  $this->enable('select_all');
118  $this->setSelectAllCheckbox('conditions');
119 
120  $this->setDefaultOrderField('title');
121  $this->setDefaultOrderDirection('asc');
122 
123  $this->setFormAction($ilCtrl->getFormAction($this->getParentObject(), $this->getParentCmd()));
124  $this->addMultiCommand('askDelete', $this->lng->txt('delete'));
125 
126  if ($this->enable_editing) {
127  $this->addCommandButton("saveObligatoryList", $this->lng->txt("rbac_precondition_save_obligatory"));
128  }
129  }
130 }
static _getIcon( $a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
static _lookupTitle($a_id)
lookup object title
getParentCmd()
Get parent command.
getParentObject()
Get parent object.
global $ilCtrl
Definition: ilias.php:18
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
Class ilTable2GUI.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static _lookupDescription($a_id)
lookup object description
Table presentation of conditions.
addMultiCommand($a_cmd, $a_text)
Add Command button.
enable($a_module_name)
enables particular modules of table
setRowTemplate($a_template, $a_template_dir="")
Set row template.
Create styles array
The data for the language used.
$rows
Definition: xhr_table.php:10
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setConditions($a_conditions)
Set and parse conditions.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setSelectAllCheckbox($a_select_all_checkbox)
Set the name of the checkbox that should be toggled with a select all button.
__construct($a_parent_obj, $a_parent_cmd, $a_enable_editing=false)
Constructor.