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