ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilDclCreateViewTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
27 ];
28
29 public function __construct(ilDclCreateViewDefinitionGUI $a_parent_obj)
30 {
31 parent::__construct($a_parent_obj);
32 $ilCtrl = $this->ctrl;
34
35 $this->setId('dcl_tableviews');
36 $this->setTitle($lng->txt('dcl_tableview_fieldsettings'));
37 $this->addColumn($lng->txt('dcl_tableview_fieldtitle'), "", 'auto');
38 $this->addColumn($lng->txt('dcl_tableview_field_access'), "", 'auto');
39 $this->addColumn($lng->txt('dcl_tableview_default_value'), "", 'auto');
40
41 $ilCtrl->saveParameter($this, 'tableview_id');
42 $this->setFormAction($ilCtrl->getFormActionByClass('ildclcreateviewdefinitiongui'));
43 $this->addCommandButton('saveTable', $lng->txt('save'));
44
45 $this->setExternalSegmentation(true);
46 $this->setExternalSorting(true);
47
48 $this->setRowTemplate('tpl.tableview_create_view.html', 'components/ILIAS/DataCollection');
49 $this->setTopCommands(true);
50 $this->setEnableHeader(true);
51 $this->setShowRowsSelector(false);
52 $this->setEnableHeader(true);
53 $this->setEnableTitle(true);
54 $this->setDefaultOrderDirection('asc');
55
56 $this->parseData($a_parent_obj->tableview->getFieldSettings());
57 }
58
59 public function parseData(array $data): void
60 {
61 $this->setData($data);
62 }
63
67 public function getHTML(): string
68 {
70 $ilCtrl = $this->ctrl;
71
72 if ($this->getExportMode()) {
73 $this->exportData($this->getExportMode(), true);
74 }
75 $this->prepareOutput();
76 if (is_object($this->getParentObject()) && $this->getId() == "") {
77 $ilCtrl->saveParameter($this->getParentObject(), $this->getNavParameter());
78 }
79 if (!$this->getPrintMode()) {
80 // set form action
81 if ($this->form_action != "" && $this->getOpenFormTag()) {
82 $hash = "";
83
84 if ($this->form_multipart) {
85 $this->tpl->touchBlock("form_multipart_bl");
86 }
87
88 if ($this->getPreventDoubleSubmission()) {
89 $this->tpl->touchBlock("pdfs");
90 }
91
92 $this->tpl->setCurrentBlock("tbl_form_header");
93 $this->tpl->setVariable("FORMACTION", $this->getFormAction() . $hash);
94 $this->tpl->setVariable("FORMNAME", $this->getFormName());
95 $this->tpl->parseCurrentBlock();
96 }
97
98 if ($this->form_action != "" && $this->getCloseFormTag()) {
99 $this->tpl->touchBlock("tbl_form_footer");
100 }
101 }
102 if (!$this->enabled['content']) {
103 return $this->render();
104 }
105 if (!$this->getExternalSegmentation()) {
106 $this->setMaxCount(count($this->row_data));
107 }
109 $this->setFooter("tblfooter", $this->lng->txt("previous"), $this->lng->txt("next"));
110
111 $data = $this->getData();
112 if ($this->dataExists()) {
113 // sort
114 if (!$this->getExternalSorting() && $this->enabled["sort"]) {
116 $data,
117 $this->getOrderField(),
118 $this->getOrderDirection(),
119 $this->numericOrdering($this->getOrderField())
120 );
121 }
122 // slice
123 if (!$this->getExternalSegmentation()) {
124 $data = array_slice($data, $this->getOffset(), $this->getLimit());
125 }
126 }
127
128 // fill rows
129 if ($this->dataExists()) {
130 if ($this->getPrintMode()) {
132 }
133 $this->tpl->addBlockFile(
134 "TBL_CONTENT",
135 "tbl_content",
136 $this->row_template,
137 $this->row_template_dir
138 );
139 foreach ($data as $set) {
140 $this->tpl->setCurrentBlock("tbl_content");
141 $this->css_row = ($this->css_row !== "tblrow1")
142 ? "tblrow1"
143 : "tblrow2";
144 $this->tpl->setVariable("CSS_ROW", $this->css_row);
145 $this->fillRowFromObject($set);
146 $this->tpl->setCurrentBlock("tbl_content");
147 $this->tpl->parseCurrentBlock();
148 }
149 } else {
150 // add standard no items text (please tell me, if it messes something up, alex, 29.8.2008)
151 $no_items_text = (trim($this->getNoEntriesText()) != '')
152 ? $this->getNoEntriesText()
153 : $lng->txt("no_items");
154 $this->css_row = ($this->css_row !== "tblrow1")
155 ? "tblrow1"
156 : "tblrow2";
157 $this->tpl->setCurrentBlock("tbl_no_entries");
158 $this->tpl->setVariable('TBL_NO_ENTRY_CSS_ROW', $this->css_row);
159 $this->tpl->setVariable('TBL_NO_ENTRY_COLUMN_COUNT', $this->column_count);
160 $this->tpl->setVariable('TBL_NO_ENTRY_TEXT', trim($no_items_text));
161 $this->tpl->parseCurrentBlock();
162 }
163
164 if (!$this->getPrintMode()) {
165 $this->fillFooter();
166 $this->fillHiddenRow();
167 $this->fillActionRow();
168 $this->storeNavParameter();
169 }
170 return $this->render();
171 }
172
173 public function fillRowFromObject(ilDclTableViewFieldSetting $a_set): void
174 {
176 $field = $a_set->getFieldObject();
177 $match = ilDclTableViewBaseDefaultValue::findSingle($field->getDatatypeId(), $a_set->getId());
178
180 $item = ilDclCache::getFieldRepresentation($field)->getInputField(new ilPropertyFormGUI());
181
182 if (!is_null($match)) {
183 if ($item instanceof ilDclCheckboxInputGUI) {
184 $item->setChecked((bool) $match->getValue());
185 } else {
186 $item->setValue((string) $match->getValue());
187 }
188 }
189
190 if (!$field->isStandardField()) {
191 $this->tpl->setVariable('TEXT_VISIBLE', $lng->txt('dcl_tableview_visible'));
192 $this->tpl->setVariable('TEXT_REQUIRED_VISIBLE', $lng->txt('dcl_tableview_required_visible'));
193 $this->tpl->setVariable('TEXT_LOCKED_VISIBLE', $lng->txt('dcl_tableview_locked_visible'));
194 $this->tpl->setVariable('TEXT_NOT_VISIBLE', $lng->txt('dcl_tableview_not_visible'));
195 $this->tpl->setVariable('IS_LOCKED', $a_set->isLockedCreate() ? 'checked' : '');
196 $this->tpl->setVariable('IS_REQUIRED', $a_set->isRequiredCreate() ? 'checked' : '');
197 $this->tpl->setVariable('DEFAULT_VALUE', $a_set->getDefaultValue());
198 $this->tpl->setVariable('IS_VISIBLE', $a_set->isVisibleCreate() ? 'checked' : '');
199 $this->tpl->setVariable('IS_NOT_VISIBLE', !$a_set->isVisibleCreate() ? 'checked' : '');
200 if (!is_null($item) && in_array($field->getDatatypeId(), self::VALID_DEFAULT_VALUE_TYPES)) {
201 $name = "default_" . $a_set->getId() . "_" . $field->getDatatypeId();
202 $item->setPostVar($name);
203 if ($item instanceof ilTextAreaInputGUI) {
204 $replacement_box = new ilTextInputGUI();
205 $replacement_box->setPostVar($item->getPostVar());
206 $replacement_box->setValue($item->getValue());
207 $this->tpl->setVariable('INPUT', $replacement_box->render());
208 } else {
209 $this->tpl->setVariable('INPUT', $item->render());
210 }
211
212 // Workaround as empty checkboxes do not get posted
213 if ($item instanceof ilDclCheckboxInputGUI) {
214 $this->tpl->setVariable('EXTRA_INPUT', "<input type=\"hidden\" name=\"$name\" value=\"0\" />");
215 }
216 }
217 } else {
218 $this->tpl->setVariable('HIDDEN', 'hidden');
219 }
220
221 $this->tpl->setVariable('FIELD_ID', $a_set->getField());
222 $this->tpl->setVariable('TITLE', $field->getTitle());
223 $this->tpl->parseCurrentBlock();
224 }
225}
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 getFieldRepresentation(ilDclBaseFieldModel $field)
@ilCtrl_IsCalledBy ilDclCreateViewDefinitionGUI: ilDclTableViewEditGUI
__construct(ilDclCreateViewDefinitionGUI $a_parent_obj)
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 class represents a property form user interface.
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="")
This class represents a text area property in a property form.
This class represents a text property in a property form.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc