ILIAS  release_8 Revision v8.25-1-g13de6a5eca6
class.ilDclTableViewTableGUI.php
Go to the documentation of this file.
1<?php
2
20{
21 protected ilDclTable $table;
22
23 protected \ILIAS\UI\Renderer $renderer;
24 protected \ILIAS\UI\Factory $factory;
25
32 public function __construct(object $a_parent_obj, $a_parent_cmd, ilDclTable $table, int $ref_id)
33 {
34 global $DIC;
35 $lng = $DIC['lng'];
36 $ilCtrl = $DIC['ilCtrl'];
37
38 $this->factory = $DIC->ui()->factory();
39 $this->renderer = $DIC->ui()->renderer();
40
41 parent::__construct($a_parent_obj, $a_parent_cmd);
42
43 $this->parent_obj = $a_parent_obj;
44 $this->table = $table;
45 $this->ctrl = $ilCtrl;
46 $this->lng = $lng;
47
48 $this->setExternalSegmentation(true);
49 $this->setExternalSorting(true);
50
51 if ($this->parent_obj instanceof ilDclTableViewGUI) {
52 $ilCtrl->setParameterByClass('ildcltableviewgui', 'table_id', $table->getId());
53 $this->setFormAction($ilCtrl->getFormActionByClass('ildcltableviewgui'));
54 $this->addMultiCommand('confirmDeleteTableviews', $lng->txt('dcl_delete_views'));
55 $this->addCommandButton('saveTableViewOrder', $lng->txt('dcl_save_order'));
56
57 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
58 $this->setFormName('tableview_list');
59
60 $this->addColumn('', '', '1', true);
61 $this->addColumn($lng->txt('dcl_order'), '', '30px');
62
63 $this->setRowTemplate('tpl.tableview_list_row.html', 'Modules/DataCollection');
64 $this->setData($this->table->getTableViews());
65 } elseif ($this->parent_obj instanceof ilDclDetailedViewGUI) {
66 $this->setRowTemplate('tpl.detailview_list_row.html', 'Modules/DataCollection');
67 $this->setData($this->table->getVisibleTableViews($ref_id, true));
68 }
69
70 $this->addColumn($lng->txt('title'), '', 'auto');
71 $this->addColumn($lng->txt('description'), '', 'auto');
72 $this->addColumn($lng->txt('dcl_configuration_complete'), '', 'auto');
73 $this->addColumn($lng->txt('actions'), '', '30px');
74
75 $this->setTopCommands(true);
76 $this->setEnableHeader(true);
77 $this->setShowRowsSelector(false);
78 $this->setShowTemplates(false);
79 $this->setEnableHeader(true);
80 $this->setEnableTitle(true);
81 $this->setDefaultOrderDirection('asc');
82 $this->setLimit(0);
83
84 $this->setId('dcl_tableviews');
85 $this->setTitle($lng->txt("dcl_tableviews_table"));
86 $this->setStyle('table', $this->getStyle('table') . ' ' . 'dcl_record_list');
87 }
88
92 public function getHTML(): string
93 {
95 $ilCtrl = $this->ctrl;
96
97 if ($this->getExportMode()) {
98 $this->exportData($this->getExportMode(), true);
99 }
100
101 $this->prepareOutput();
102
103 if (is_object($ilCtrl) && is_object($this->getParentObject()) && $this->getId() == "") {
104 $ilCtrl->saveParameter($this->getParentObject(), $this->getNavParameter());
105 }
106
107 if (!$this->getPrintMode()) {
108 // set form action
109 if ($this->form_action != "" && $this->getOpenFormTag()) {
110 $hash = "";
111
112 if ($this->form_multipart) {
113 $this->tpl->touchBlock("form_multipart_bl");
114 }
115
116 if ($this->getPreventDoubleSubmission()) {
117 $this->tpl->touchBlock("pdfs");
118 }
119
120 $this->tpl->setCurrentBlock("tbl_form_header");
121 $this->tpl->setVariable("FORMACTION", $this->getFormAction() . $hash);
122 $this->tpl->setVariable("FORMNAME", $this->getFormName());
123 $this->tpl->parseCurrentBlock();
124 }
125
126 if ($this->form_action != "" && $this->getCloseFormTag()) {
127 $this->tpl->touchBlock("tbl_form_footer");
128 }
129 }
130
131 if (!$this->enabled['content']) {
132 return $this->render();
133 }
134
135 if (!$this->getExternalSegmentation()) {
136 $this->setMaxCount(count($this->row_data));
137 }
138
140
141 $this->setFooter("tblfooter", $this->lng->txt("previous"), $this->lng->txt("next"));
142
143 $data = $this->getData();
144 if ($this->dataExists()) {
145 // sort
146 if (!$this->getExternalSorting() && $this->enabled["sort"]) {
148 $data,
149 $this->getOrderField(),
150 $this->getOrderDirection(),
151 $this->numericOrdering($this->getOrderField())
152 );
153 }
154
155 // slice
156 if (!$this->getExternalSegmentation()) {
157 $data = array_slice($data, $this->getOffset(), $this->getLimit());
158 }
159 }
160
161 // fill rows
162 if ($this->dataExists()) {
163 if ($this->getPrintMode()) {
165 }
166
167 $this->tpl->addBlockFile(
168 "TBL_CONTENT",
169 "tbl_content",
170 $this->row_template,
171 $this->row_template_dir
172 );
173
174 foreach ($data as $set) {
175 $this->tpl->setCurrentBlock("tbl_content");
176 $this->css_row = ($this->css_row !== "tblrow1")
177 ? "tblrow1"
178 : "tblrow2";
179 $this->tpl->setVariable("CSS_ROW", $this->css_row);
180
181 $this->fillRowFromObject($set);
182 $this->tpl->setCurrentBlock("tbl_content");
183 $this->tpl->parseCurrentBlock();
184 }
185 } else {
186 // add standard no items text (please tell me, if it messes something up, alex, 29.8.2008)
187 $no_items_text = (trim($this->getNoEntriesText()) != '')
188 ? $this->getNoEntriesText()
189 : $lng->txt("no_items");
190
191 $this->css_row = ($this->css_row !== "tblrow1")
192 ? "tblrow1"
193 : "tblrow2";
194
195 $this->tpl->setCurrentBlock("tbl_no_entries");
196 $this->tpl->setVariable('TBL_NO_ENTRY_CSS_ROW', $this->css_row);
197 $this->tpl->setVariable('TBL_NO_ENTRY_COLUMN_COUNT', $this->column_count);
198 $this->tpl->setVariable('TBL_NO_ENTRY_TEXT', trim($no_items_text));
199 $this->tpl->parseCurrentBlock();
200 }
201
202 if (!$this->getPrintMode()) {
203 $this->fillFooter();
204
205 $this->fillHiddenRow();
206
207 $this->fillActionRow();
208
209 $this->storeNavParameter();
210 }
211
212 return $this->render();
213 }
214
218 public function fillRowFromObject(ilDclTableView $a_set): void
219 {
220 if ($this->parent_obj instanceof ilDclTableViewGUI) {
221 $this->tpl->setVariable("ID", $a_set->getId());
222 $this->tpl->setVariable("ORDER_NAME", "order[{$a_set->getId()}]");
223 $this->tpl->setVariable("ORDER_VALUE", $a_set->getOrder());
224 }
225 $this->tpl->setVariable("TITLE", $a_set->getTitle());
226 $this->ctrl->setParameterByClass('ildcltablevieweditgui', 'tableview_id', $a_set->getId());
227 $this->tpl->setVariable("TITLE_LINK", $this->ctrl->getLinkTargetByClass(
228 [ilDclTableListGUI::class, ilDclTableViewGUI::class, ilDclTableViewEditGUI::class]
229 ));
230 $this->tpl->setVariable("DESCRIPTION", $a_set->getDescription());
231
232 $icon = $this->factory->symbol()->icon()->custom(ilUtil::getImagePath('icon_not_ok_monochrome.svg'), $this->lng->txt("yes"));
233 if ($a_set->validateConfigCompletion()) {
234 $icon = $this->factory->symbol()->icon()->custom(ilUtil::getImagePath('icon_ok_monochrome.svg'), $this->lng->txt("no"));
235 }
236 $this->tpl->setVariable("ICON_CONFIG", $this->renderer->render($icon));
237 $this->tpl->setVariable('ACTIONS', $this->buildAction($a_set->getId()));
238 }
239
243 protected function buildAction(int $id): string
244 {
245 if ($this->parent_obj instanceof ilDclTableViewGUI) {
246 $alist = new ilAdvancedSelectionListGUI();
247 $alist->setId($id);
248 $alist->setListTitle($this->lng->txt('actions'));
249 $this->ctrl->setParameterByClass('ildcltableviewgui', 'tableview_id', $id);
250 $this->ctrl->setParameterByClass('ilDclDetailedViewDefinitionGUI', 'tableview_id', $id);
251 $alist->addItem(
252 $this->lng->txt('edit'),
253 '',
254 $this->ctrl->getLinkTargetByClass('ildcltablevieweditgui', 'editGeneralSettings')
255 );
256 $alist->addItem(
257 $this->lng->txt('copy'),
258 '',
259 $this->ctrl->getLinkTargetByClass('ildcltablevieweditgui', 'copy')
260 );
261 $alist->addItem(
262 $this->lng->txt('delete'),
263 '',
264 $this->ctrl->getLinkTargetByClass('ildcltablevieweditgui', 'confirmDelete')
265 );
266
267 return $alist->getHTML();
268 } elseif ($this->parent_obj instanceof ilDclDetailedViewGUI) {
270 $this->ctrl->setParameterByClass('ilDclDetailedViewGUI', 'tableview_id', $id);
271 $this->ctrl->saveParameterByClass('ilDclDetailedViewGUI', 'record_id');
272 $button->setUrl($this->ctrl->getLinkTargetByClass('ilDclDetailedViewGUI', 'renderRecord'));
273 $button->setCaption('view');
274
275 return $button->getToolbarHTML();
276 }
277 return "";
278 }
279}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
static setUseRelativeDates(bool $a_status)
set use relative dates
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
buildAction(int $id)
build either actions menu or view button
__construct(object $a_parent_obj, $a_parent_cmd, ilDclTable $table, int $ref_id)
ilDclTableViewTableGUI constructor.
fillRowFromObject(ilDclTableView $a_set)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
validateConfigCompletion()
Check if the configuration of the view is complete.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getId()
Get table id.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setShowRowsSelector(bool $a_value)
Toggle rows-per-page selector.
getFormName()
get the name of the parent form
prepareOutput()
Anything that must be done before HTML is generated.
setLimit(int $a_limit=0, int $a_default_limit=0)
set max.
determineOffsetAndOrder(bool $a_omit_offset=false)
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
setExternalSegmentation(bool $a_val)
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
setEnableTitle(bool $a_enabletitle)
setFormName(string $a_name="")
addMultiCommand(string $a_cmd, string $a_text)
setShowTemplates(bool $a_value)
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)
setEnableHeader(bool $a_enableheader)
numericOrdering(string $a_field)
Should this field be sorted numeric?
setTopCommands(bool $a_val)
setExternalSorting(bool $a_val)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
setDefaultOrderDirection(string $a_defaultorderdirection)
setData(array $a_data)
Set table data.
exportData(int $format, bool $send=false)
Export and optionally send current table data.
ilLanguage $lng
setStyle(string $a_element, string $a_style)
getStyle(string $a_element)
setMaxCount(int $a_max_count)
set max.
setFooter(string $a_style, string $a_previous="", string $a_next="")
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
global $DIC
Definition: feed.php:28
$ref_id
Definition: ltiauth.php:67
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc