ILIAS  release_8 Revision v8.24
class.ilDclTableViewEditFieldsTableGUI.php
Go to the documentation of this file.
1<?php
2
20{
21 public function __construct(ilDclTableViewEditGUI $a_parent_obj)
22 {
23 global $DIC;
24 $lng = $DIC['lng'];
25 $ilCtrl = $DIC['ilCtrl'];
26 parent::__construct($a_parent_obj);
27
28 $this->setId('dcl_tableviews');
29 $this->setTitle($lng->txt('dcl_tableview_fieldsettings'));
30 $this->addColumn($lng->txt('dcl_fieldtitle'), "", 'auto');
31 $this->addColumn($lng->txt('dcl_field_visible'), "", 'auto');
32 $this->addColumn($lng->txt('dcl_filter'), "", 'auto');
33 $this->addColumn($lng->txt('dcl_std_filter'), "", 'auto');
34 $this->addColumn($lng->txt('dcl_filter_changeable'), "", 'auto');
35
36 $ilCtrl->saveParameter($this, 'tableview_id');
37 $this->setFormAction($ilCtrl->getFormActionByClass('ildcltablevieweditgui'));
38 $this->addCommandButton('saveTable', $lng->txt('dcl_save'));
39
40 $this->setExternalSegmentation(true);
41 $this->setExternalSorting(true);
42
43 $this->setRowTemplate('tpl.tableview_fields_row.html', 'Modules/DataCollection');
44 $this->setTopCommands(true);
45 $this->setEnableHeader(true);
46 $this->setShowRowsSelector(false);
47 $this->setShowTemplates(false);
48 $this->setEnableHeader(true);
49 $this->setEnableTitle(true);
50 $this->setDefaultOrderDirection('asc');
51
52 $this->parseData($a_parent_obj->tableview->getFieldSettings());
53 }
54
55 public function parseData(array $data): void
56 {
57 //enable/disable comments
58 if (!$this->parent_obj->table->getPublicCommentsEnabled()) {
59 foreach ($data as $key => $rec) {
60 if ($rec->getField() == 'comments') {
61 unset($data[$key]);
62 }
63 }
64 }
65 $this->setData($data);
66 }
67
71 public function getHTML(): string
72 {
74 $ilCtrl = $this->ctrl;
75
76 if ($this->getExportMode()) {
77 $this->exportData($this->getExportMode(), true);
78 }
79
80 $this->prepareOutput();
81
82 if (is_object($ilCtrl) && is_object($this->getParentObject()) && $this->getId() == "") {
83 $ilCtrl->saveParameter($this->getParentObject(), $this->getNavParameter());
84 }
85
86 if (!$this->getPrintMode()) {
87 // set form action
88 if ($this->form_action != "" && $this->getOpenFormTag()) {
89 $hash = "";
90
91 if ($this->form_multipart) {
92 $this->tpl->touchBlock("form_multipart_bl");
93 }
94
95 if ($this->getPreventDoubleSubmission()) {
96 $this->tpl->touchBlock("pdfs");
97 }
98
99 $this->tpl->setCurrentBlock("tbl_form_header");
100 $this->tpl->setVariable("FORMACTION", $this->getFormAction() . $hash);
101 $this->tpl->setVariable("FORMNAME", $this->getFormName());
102 $this->tpl->parseCurrentBlock();
103 }
104
105 if ($this->form_action != "" && $this->getCloseFormTag()) {
106 $this->tpl->touchBlock("tbl_form_footer");
107 }
108 }
109
110 if (!$this->enabled['content']) {
111 return $this->render();
112 }
113
114 if (!$this->getExternalSegmentation()) {
115 $this->setMaxCount(count($this->row_data));
116 }
117
119
120 $this->setFooter("tblfooter", $this->lng->txt("previous"), $this->lng->txt("next"));
121
122 $data = $this->getData();
123 if ($this->dataExists()) {
124 // sort
125 if (!$this->getExternalSorting() && $this->enabled["sort"]) {
127 $data,
128 $this->getOrderField(),
129 $this->getOrderDirection(),
130 $this->numericOrdering($this->getOrderField())
131 );
132 }
133
134 // slice
135 if (!$this->getExternalSegmentation()) {
136 $data = array_slice($data, $this->getOffset(), $this->getLimit());
137 }
138 }
139
140 // fill rows
141 if ($this->dataExists()) {
142 if ($this->getPrintMode()) {
144 }
145
146 $this->tpl->addBlockFile(
147 "TBL_CONTENT",
148 "tbl_content",
149 $this->row_template,
150 $this->row_template_dir
151 );
152
153 foreach ($data as $set) {
154 $this->tpl->setCurrentBlock("tbl_content");
155 $this->css_row = ($this->css_row !== "tblrow1")
156 ? "tblrow1"
157 : "tblrow2";
158 $this->tpl->setVariable("CSS_ROW", $this->css_row);
159
160 $this->fillRowFromObject($set);
161 $this->tpl->setCurrentBlock("tbl_content");
162 $this->tpl->parseCurrentBlock();
163 }
164 } else {
165 // add standard no items text (please tell me, if it messes something up, alex, 29.8.2008)
166 $no_items_text = (trim($this->getNoEntriesText()) != '')
167 ? $this->getNoEntriesText()
168 : $lng->txt("no_items");
169
170 $this->css_row = ($this->css_row !== "tblrow1")
171 ? "tblrow1"
172 : "tblrow2";
173
174 $this->tpl->setCurrentBlock("tbl_no_entries");
175 $this->tpl->setVariable('TBL_NO_ENTRY_CSS_ROW', $this->css_row);
176 $this->tpl->setVariable('TBL_NO_ENTRY_COLUMN_COUNT', $this->column_count);
177 $this->tpl->setVariable('TBL_NO_ENTRY_TEXT', trim($no_items_text));
178 $this->tpl->parseCurrentBlock();
179 }
180
181 if (!$this->getPrintMode()) {
182 $this->fillFooter();
183
184 $this->fillHiddenRow();
185
186 $this->fillActionRow();
187
188 $this->storeNavParameter();
189 }
190
191 return $this->render();
192 }
193
197 public function fillRowFromObject(object $a_set): void
198 {
199 $field = $a_set->getFieldObject();
200 if ($field->getId() == 'comments' && !$this->parent_obj->table->getPublicCommentsEnabled()) {
201 return;
202 }
203
204 $this->tpl->setVariable('FIELD_TITLE', $field->getTitle());
205 $this->tpl->setVariable('ID', $a_set->getId());
206 $this->tpl->setVariable('FIELD_ID', $a_set->getField());
207 $this->tpl->setVariable('VISIBLE', $a_set->isVisibleInList() ? 'checked' : '');
208 if ($field->allowFilterInListView()) {
209 $this->tpl->setVariable('IN_FILTER', $a_set->isInFilter() ? 'checked' : '');
210 $this->tpl->setVariable('FILTER_VALUE', $this->getStandardFilterHTML($field, $a_set->getFilterValue()));
211 $this->tpl->setVariable('FILTER_CHANGEABLE', $a_set->isFilterChangeable() ? 'checked' : '');
212 } else {
213 $this->tpl->setVariable('NO_FILTER', '');
214 }
215 }
216
220 protected function getStandardFilterHTML(ilDclBaseFieldModel $field, array $value): string
221 {
222 $field_representation = ilDclFieldFactory::getFieldRepresentationInstance($field);
223 $field_representation->addFilterInputFieldToTable($this);
224 $filter = end($this->filters);
225 $this->filters = array();
226 $filter->setValueByArray($value);
227
228 return $filter->render();
229 }
230}
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...
static getFieldRepresentationInstance(ilDclBaseFieldModel $field)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getStandardFilterHTML(ilDclBaseFieldModel $field, array $value)
__construct(ilDclTableViewEditGUI $a_parent_obj)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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)
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
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
string $key
Consumer key/client ID value.
Definition: System.php:193