ILIAS  release_8 Revision v8.24
class.ilDclTableListTableGUI.php
Go to the documentation of this file.
1<?php
2
20{
25 {
26 global $DIC;
27 $lng = $DIC['lng'];
28 $ilCtrl = $DIC['ilCtrl'];
29
31
32 $this->parent_obj = $parent_obj;
33 $this->ctrl = $ilCtrl;
34 $this->lng = $lng;
35
36 $this->setId('dcl_table_list');
37 $this->addColumn('', '', '1', true);
38 $this->addColumn($lng->txt('dcl_order'), "", '30px');
39 $this->addColumn($lng->txt('title'), "", 'auto');
40 $this->addColumn($lng->txt('dcl_visible'), "", '250px', false, '', $this->lng->txt('dcl_visible_desc'));
41 $this->addColumn(
42 $lng->txt('dcl_comments'),
43 "",
44 '200px',
45 false,
46 '',
47 $this->lng->txt('dcl_public_comments_desc')
48 );
49 $this->addColumn($lng->txt('actions'), "", '30px');
50
51 $this->setSelectAllCheckbox('dcl_table_ids[]');
52 $this->addMultiCommand('confirmDeleteTables', $lng->txt('dcl_delete_tables'));
53
54 $this->setFormAction($ilCtrl->getFormActionByClass('ildcltablelistgui'));
55 $this->addCommandButton('save', $lng->txt('dcl_save'));
56
57 $this->setFormAction($ilCtrl->getFormAction($parent_obj));
58 $this->setFormName('table_list');
59
60 //those two are important as we get our data as objects not as arrays.
61 $this->setExternalSegmentation(true);
62 $this->setExternalSorting(true);
63
64 $this->setTopCommands(true);
65 $this->setEnableHeader(true);
66 $this->setShowRowsSelector(false);
67 $this->setShowTemplates(false);
68 $this->setEnableHeader(true);
69 $this->setEnableTitle(true);
70 $this->setDefaultOrderDirection('asc');
71
72 $this->setTitle($lng->txt('dcl_table_list_tables'));
73 $this->setRowTemplate('tpl.table_list_row.html', 'Modules/DataCollection');
74 $this->setStyle('table', $this->getStyle('table') . ' ' . 'dcl_record_list');
75
76 $tables = $this->parent_obj->getDataCollectionObject()->getTables();
77 $this->setData($tables);
78 }
79
83 public function getHTML(): string
84 {
86 $ilCtrl = $this->ctrl;
87
88 if ($this->getExportMode()) {
89 $this->exportData($this->getExportMode(), true);
90 }
91
92 $this->prepareOutput();
93
94 if (is_object($ilCtrl) && is_object($this->getParentObject()) && $this->getId() == "") {
95 $ilCtrl->saveParameter($this->getParentObject(), $this->getNavParameter());
96 }
97
98 if (!$this->getPrintMode()) {
99 // set form action
100 if ($this->form_action != "" && $this->getOpenFormTag()) {
101 $hash = "";
102
103 if ($this->form_multipart) {
104 $this->tpl->touchBlock("form_multipart_bl");
105 }
106
107 if ($this->getPreventDoubleSubmission()) {
108 $this->tpl->touchBlock("pdfs");
109 }
110
111 $this->tpl->setCurrentBlock("tbl_form_header");
112 $this->tpl->setVariable("FORMACTION", $this->getFormAction() . $hash);
113 $this->tpl->setVariable("FORMNAME", $this->getFormName());
114 $this->tpl->parseCurrentBlock();
115 }
116
117 if ($this->form_action != "" && $this->getCloseFormTag()) {
118 $this->tpl->touchBlock("tbl_form_footer");
119 }
120 }
121
122 if (!$this->enabled['content']) {
123 return $this->render();
124 }
125
126 if (!$this->getExternalSegmentation()) {
127 $this->setMaxCount(count($this->row_data));
128 }
129
131
132 $this->setFooter("tblfooter", $this->lng->txt("previous"), $this->lng->txt("next"));
133
134 $data = $this->getData();
135 if ($this->dataExists()) {
136 // sort
137 if (!$this->getExternalSorting() && $this->enabled["sort"]) {
139 $data,
140 $this->getOrderField(),
141 $this->getOrderDirection(),
142 $this->numericOrdering($this->getOrderField())
143 );
144 }
145
146 // slice
147 if (!$this->getExternalSegmentation()) {
148 $data = array_slice($data, $this->getOffset(), $this->getLimit());
149 }
150 }
151
152 // fill rows
153 if ($this->dataExists()) {
154 if ($this->getPrintMode()) {
156 }
157
158 $this->tpl->addBlockFile(
159 "TBL_CONTENT",
160 "tbl_content",
161 $this->row_template,
162 $this->row_template_dir
163 );
164
165 foreach ($data as $set) {
166 $this->tpl->setCurrentBlock("tbl_content");
167 $this->css_row = ($this->css_row !== "tblrow1")
168 ? "tblrow1"
169 : "tblrow2";
170 $this->tpl->setVariable("CSS_ROW", $this->css_row);
171
172 $this->fillRowFromObject($set);
173 $this->tpl->setCurrentBlock("tbl_content");
174 $this->tpl->parseCurrentBlock();
175 }
176 } else {
177 // add standard no items text (please tell me, if it messes something up, alex, 29.8.2008)
178 $no_items_text = (trim($this->getNoEntriesText()) != '')
179 ? $this->getNoEntriesText()
180 : $lng->txt("no_items");
181
182 $this->css_row = ($this->css_row !== "tblrow1")
183 ? "tblrow1"
184 : "tblrow2";
185
186 $this->tpl->setCurrentBlock("tbl_no_entries");
187 $this->tpl->setVariable('TBL_NO_ENTRY_CSS_ROW', $this->css_row);
188 $this->tpl->setVariable('TBL_NO_ENTRY_COLUMN_COUNT', $this->column_count);
189 $this->tpl->setVariable('TBL_NO_ENTRY_TEXT', trim($no_items_text));
190 $this->tpl->parseCurrentBlock();
191 }
192
193 if (!$this->getPrintMode()) {
194 $this->fillFooter();
195
196 $this->fillHiddenRow();
197
198 $this->fillActionRow();
199
200 $this->storeNavParameter();
201 }
202
203 return $this->render();
204 }
205
206 public function fillRowFromObject(ilDclTable $a_set): void
207 {
208 $this->tpl->setVariable("ID", $a_set->getId());
209 $this->tpl->setVariable("ORDER_NAME", "order[{$a_set->getId()}]");
210 $this->tpl->setVariable("ORDER_VALUE", $a_set->getOrder());
211 $this->tpl->setVariable("TITLE", $a_set->getTitle());
212
213 $this->ctrl->setParameterByClass('ildclfieldlistgui', 'table_id', $a_set->getId());
214 $this->tpl->setVariable("TITLE_LINK", $this->ctrl->getLinkTargetByClass('ildclfieldlistgui'));
215
216 $this->tpl->setVariable("CHECKBOX_NAME_VISIBLE", 'visible[' . $a_set->getId() . ']');
217 if ($a_set->getIsVisible()) {
218 $this->tpl->setVariable("CHECKBOX_CHECKED_VISIBLE", 'checked');
219 }
220 $this->tpl->setVariable("CHECKBOX_NAME_COMMENTS", 'comments[' . $a_set->getId() . ']');
221 if ($a_set->getPublicCommentsEnabled()) {
222 $this->tpl->setVariable("CHECKBOX_CHECKED_COMMENTS", 'checked');
223 }
224 $this->tpl->setVariable('ACTIONS', $this->buildActions($a_set->getId()));
225 }
226
227 protected function buildActions(int $id): string
228 {
229 $alist = new ilAdvancedSelectionListGUI();
230 $alist->setId($id);
231 $alist->setListTitle($this->lng->txt('actions'));
232 $this->ctrl->setParameterByClass('ildclfieldlistgui', 'table_id', $id);
233 $this->ctrl->setParameterByClass('ildcltableviewgui', 'table_id', $id);
234 $this->ctrl->setParameterByClass('ildcltableeditgui', 'table_id', $id);
235 $alist->addItem(
236 $this->lng->txt('settings'),
237 '',
238 $this->ctrl->getLinkTargetByClass('ildcltableeditgui', 'edit')
239 );
240 $alist->addItem(
241 $this->lng->txt('dcl_list_fields'),
242 '',
243 $this->ctrl->getLinkTargetByClass('ildclfieldlistgui', 'listFields')
244 );
245 $alist->addItem($this->lng->txt('dcl_tableviews'), '', $this->ctrl->getLinkTargetByClass('ildcltableviewgui'));
246 $alist->addItem(
247 $this->lng->txt('delete'),
248 '',
249 $this->ctrl->getLinkTargetByClass('ildcltableeditgui', 'confirmDelete')
250 );
251
252 return $alist->getHTML();
253 }
254}
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...
__construct(ilDclTableListGUI $parent_obj)
ilDclTableListTableGUI constructor.
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.
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)
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
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="")
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc