ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilWorkflowEngineDefinitionsTableGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2016 ILIAS open source, Extended GPL, see docs/LICENSE */
3
5require_once './Services/Table/classes/class.ilTable2GUI.php';
7require_once './Services/Form/classes/class.ilTextInputGUI.php';
9require_once './Services/Form/classes/class.ilCheckboxInputGUI.php';
11require_once './Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php';
12
23{
25 protected $ilCtrl;
26
28 protected $lng;
29
37 public function __construct($parent_obj, $parent_cmd, $template_context = "")
38 {
39 $this->setId('wfedef');
40 parent::__construct($parent_obj, $parent_cmd, $template_context);
41
42 global $DIC;
43 $this->ilCtrl = $DIC['ilCtrl'];
44 $this->lng = $DIC['lng'];
45
46 $this->initColumns();
47 $this->setEnableHeader(true);
48
50
51 $this->initFilter();
52
53 $this->setRowTemplate("tpl.wfe_def_row.html", "Services/WorkflowEngine");
54 $this->populateTable();
55
56 $this->setDefaultOrderField("title");
57 $this->setDefaultOrderDirection("asc");
58 $this->setTitle($this->lng->txt("definitions"));
59 }
60
64 public function initFilter()
65 {
66 $title_filter_input = new ilTextInputGUI($this->lng->txt("title"), "title");
67 $title_filter_input->setMaxLength(64);
68 $title_filter_input->setSize(20);
69 $this->addFilterItem($title_filter_input);
70 $title_filter_input->readFromSession();
71 $this->filter["title"] = $title_filter_input->getValue();
72
73 $instances_filter_input = new ilCheckboxInputGUI($this->lng->txt('instances'), 'instances');
74 $this->addFilterItem($instances_filter_input);
75 $instances_filter_input->readFromSession();
76 $this->filter['instances'] = $instances_filter_input->getChecked();
77 }
78
82 public function initColumns()
83 {
84 $this->addColumn($this->lng->txt("title"), "title", "20%");
85
86 $selected_columns = $this->getSelectedColumns();
87
88 if (in_array('file', $selected_columns)) {
89 $this->addColumn($this->lng->txt("file"), "file", "30%");
90 }
91
92 if (in_array('version', $selected_columns)) {
93 $this->addColumn($this->lng->txt("version"), "version", "10%");
94 }
95
96 if (in_array('status', $selected_columns)) {
97 $this->addColumn($this->lng->txt("status"), "status", "10%");
98 }
99
100 if (in_array('instances', $selected_columns)) {
101 $this->addColumn($this->lng->txt("instances"), "instances", "15%");
102 }
103
104 $this->addColumn($this->lng->txt("actions"), "", "10%");
105 }
106
110 public function getSelectableColumns()
111 {
112 $cols["file"] = array(
113 "txt" => $this->lng->txt("file"),
114 "default" => true);
115 $cols["version"] = array(
116 "txt" => $this->lng->txt("version"),
117 "default" => true);
118 $cols["status"] = array(
119 "txt" => $this->lng->txt("status"),
120 "default" => true);
121 $cols["instances"] = array(
122 "txt" => $this->lng->txt("instances"),
123 "default" => true);
124 return $cols;
125 }
126
130 private function populateTable()
131 {
132 global $DIC;
133
134 require_once 'Services/WorkflowEngine/classes/administration/class.ilWorkflowDefinitionRepository.php';
135 $repository = new ilWorkflowDefinitionRepository(
136 $DIC['ilDB'],
137 $DIC['filesystem'],
139 );
140
141 $baseList = $repository->getAll();
142
143 $that = $this;
144
145 array_walk($baseList, function (array &$definition) use ($that) {
146 $status = $that->lng->txt('missing_parsed_class');
147 if ($definition['status']) {
148 $status = 'OK';
149 }
150
151 $definition['status'] = $status;
152 });
153
154 $filteredBaseList = array_filter($baseList, function ($item) use ($that) {
155 return !$this->isFiltered($item);
156 });
157
158 $this->setData($filteredBaseList);
159 }
160
166 public function isFiltered($row)
167 {
168 // Title filter
169 $title_filter = $this->getFilterItemByPostVar('title');
170 if ($title_filter->getValue() != null) {
171 if (strpos(strtolower($row['title']), strtolower($title_filter->getValue())) === false) {
172 return true;
173 }
174 }
175
176 // Instances filter
177 $instances_filter = $this->getFilterItemByPostVar('instances');
178 if ($instances_filter->getChecked() && $row['instances']['active'] == 0) {
179 return true;
180 }
181
182 return false;
183 }
184
188 protected function fillRow($set)
189 {
190 $this->tpl->setVariable('VAL_TITLE', $set['title']);
191
192 $selected_columns = $this->getSelectedColumns();
193
194 if (in_array('file', $selected_columns)) {
195 $this->tpl->setVariable('VAL_FILE', $set['file']);
196 }
197
198 if (in_array('version', $selected_columns)) {
199 $this->tpl->setVariable('VAL_VERSION', $set['version']);
200 }
201
202 if (in_array('status', $selected_columns)) {
203 if ($set['status'] != 'OK') {
204 $this->tpl->setVariable('VAL_STATUS', $set['status']);
205 } else {
206 $this->tpl->setVariable('VAL_STATUS', $this->lng->txt('ok'));
207 }
208 }
209
210 if (in_array('instances', $selected_columns)) {
211 $this->tpl->setVariable('TXT_INSTANCES_TOTAL', $this->lng->txt('total'));
212 $this->tpl->setVariable('VAL_INSTANCES_TOTAL', 0 + $set['instances']['total']);
213 $this->tpl->setVariable('TXT_INSTANCES_ACTIVE', $this->lng->txt('active'));
214 $this->tpl->setVariable('VAL_INSTANCES_ACTIVE', 0 + $set['instances']['active']);
215 }
216
217 $action = new ilAdvancedSelectionListGUI();
218 $action->setId('asl_' . $set['id']);
219 $action->setListTitle($this->lng->txt('actions'));
220 $this->ilCtrl->setParameter($this->parent_obj, 'process_id', $set['id']);
221 $action->addItem(
222 $this->lng->txt('start_process'),
223 'start',
224 $this->ilCtrl->getLinkTarget($this->parent_obj, 'definitions.start')
225 );
226
227 if (0 + $set['instances']['active'] == 0) {
228 $action->addItem(
229 $this->lng->txt('delete_definition'),
230 'delete',
231 $this->ilCtrl->getLinkTarget($this->parent_obj, 'definitions.confirmdelete')
232 );
233 }
234
235 require_once ilObjWorkflowEngine::getRepositoryDir() . '/' . $set['id'] . '.php';
236 $class = substr($set['id'], 4);
237 if ($class::$startEventRequired == true) {
238 $action->addItem(
239 $this->lng->txt('start_listening'),
240 'startlistening',
241 $this->ilCtrl->getLinkTarget($this->parent_obj, 'definitions.startlistening')
242 );
243
244 $action->addItem(
245 $this->lng->txt('stop_listening'),
246 'stoplistening',
247 $this->ilCtrl->getLinkTarget($this->parent_obj, 'definitions.stoplistening')
248 );
249 }
250
251 $this->tpl->setVariable('HTML_ASL', $action->getHTML());
252 }
253}
An exception for terminatinating execution or to throw for unit testing.
User interface class for advanced drop-down selection lists.
This class represents a checkbox property in a property form.
This class provides processing control methods.
getFormAction( $a_gui_obj, $a_fallback_cmd="", $a_anchor="", $a_asynch=false, $xml_style=false)
Get form action url for gui class object.
setParameter($a_obj, $a_parameter, $a_value)
Set parameters that should be passed a form and link of a gui class.
static getRepositoryDir($relative=false)
Class ilTable2GUI.
getSelectedColumns()
Get selected columns.
setEnableHeader($a_enableheader)
Set Enable Header.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
setData($a_data)
set table data @access public
setRowTemplate($a_template, $a_template_dir="")
Set row template.
getFilterItemByPostVar($a_post_var)
addFilterItem($a_input_item, $a_optional=false)
Add filter item.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
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.
setId($a_val)
Set id.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
This class represents a text property in a property form.
Class ilWorkflowDefinitionRepository.
__construct($parent_obj, $parent_cmd, $template_context="")
ilWorkflowEngineDefinitionsTableGUI constructor.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$DIC
Definition: xapitoken.php:46
$cols
Definition: xhr_table.php:11