ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilDclEditViewTableGUI.php
Go to the documentation of this file.
1 <?php
2 
20 {
21  protected ilLanguage $lng;
22  protected ilCtrl $ctrl;
23 
24  public function __construct(ilDclEditViewDefinitionGUI $a_parent_obj)
25  {
26  parent::__construct($a_parent_obj);
27 
28  $this->setId('dcl_tableviews');
29  $this->setTitle($this->lng->txt('dcl_tableview_fieldsettings'));
30  $this->addColumn($this->lng->txt('dcl_tableview_fieldtitle'), "", 'auto');
31  $this->addColumn($this->lng->txt('dcl_tableview_field_access'), "", 'auto');
32 
33  $this->ctrl->saveParameter($this, 'tableview_id');
34  $this->setFormAction($this->ctrl->getFormActionByClass('ildcleditviewdefinitiongui'));
35  $this->addCommandButton('saveTable', $this->lng->txt('dcl_save'));
36 
37  $this->setExternalSegmentation(true);
38  $this->setExternalSorting(true);
39 
40  $this->setRowTemplate('tpl.tableview_edit_view.html', 'Modules/DataCollection');
41  $this->setTopCommands(true);
42  $this->setEnableHeader(true);
43  $this->setShowRowsSelector(false);
44  $this->setShowTemplates(false);
45  $this->setEnableHeader(true);
46  $this->setEnableTitle(true);
47  $this->setDefaultOrderDirection('asc');
48 
49  $this->parseData($a_parent_obj->tableview->getFieldSettings());
50  }
51 
52  public function parseData($data)
53  {
54  $this->setData($data);
55  }
56 
60  public function getHTML(): string
61  {
62  $lng = $this->lng;
63  $ilCtrl = $this->ctrl;
64 
65  if ($this->getExportMode()) {
66  $this->exportData($this->getExportMode(), true);
67  }
68 
69  $this->prepareOutput();
70 
71  if (is_object($ilCtrl) && is_object($this->getParentObject()) && $this->getId() == "") {
72  $ilCtrl->saveParameter($this->getParentObject(), $this->getNavParameter());
73  }
74 
75  if (!$this->getPrintMode()) {
76  // set form action
77  if ($this->form_action != "" && $this->getOpenFormTag()) {
78  $hash = "";
79 
80  if ($this->form_multipart) {
81  $this->tpl->touchBlock("form_multipart_bl");
82  }
83 
84  if ($this->getPreventDoubleSubmission()) {
85  $this->tpl->touchBlock("pdfs");
86  }
87 
88  $this->tpl->setCurrentBlock("tbl_form_header");
89  $this->tpl->setVariable("FORMACTION", $this->getFormAction() . $hash);
90  $this->tpl->setVariable("FORMNAME", $this->getFormName());
91  $this->tpl->parseCurrentBlock();
92  }
93 
94  if ($this->form_action != "" && $this->getCloseFormTag()) {
95  $this->tpl->touchBlock("tbl_form_footer");
96  }
97  }
98 
99  if (!$this->enabled['content']) {
100  return $this->render();
101  }
102 
103  if (!$this->getExternalSegmentation()) {
104  $this->setMaxCount(count($this->row_data));
105  }
106 
107  $this->determineOffsetAndOrder();
108 
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"]) {
115  $data = ilArrayUtil::sortArray(
116  $data,
117  $this->getOrderField(),
118  $this->getOrderDirection(),
119  $this->numericOrdering($this->getOrderField())
120  );
121  }
122 
123  // slice
124  if (!$this->getExternalSegmentation()) {
125  $data = array_slice($data, $this->getOffset(), $this->getLimit());
126  }
127  }
128 
129  // fill rows
130  if ($this->dataExists()) {
131  if ($this->getPrintMode()) {
133  }
134 
135  $this->tpl->addBlockFile(
136  "TBL_CONTENT",
137  "tbl_content",
138  $this->row_template,
139  $this->row_template_dir
140  );
141 
142  foreach ($data as $set) {
143  $this->tpl->setCurrentBlock("tbl_content");
144  $this->css_row = ($this->css_row !== "tblrow1")
145  ? "tblrow1"
146  : "tblrow2";
147  $this->tpl->setVariable("CSS_ROW", $this->css_row);
148 
149  $this->fillRowFromObject($set);
150  $this->tpl->setCurrentBlock("tbl_content");
151  $this->tpl->parseCurrentBlock();
152  }
153  } else {
154  // add standard no items text (please tell me, if it messes something up, alex, 29.8.2008)
155  $no_items_text = (trim($this->getNoEntriesText()) != '')
156  ? $this->getNoEntriesText()
157  : $lng->txt("no_items");
158 
159  $this->css_row = ($this->css_row !== "tblrow1")
160  ? "tblrow1"
161  : "tblrow2";
162 
163  $this->tpl->setCurrentBlock("tbl_no_entries");
164  $this->tpl->setVariable('TBL_NO_ENTRY_CSS_ROW', $this->css_row);
165  $this->tpl->setVariable('TBL_NO_ENTRY_COLUMN_COUNT', $this->column_count);
166  $this->tpl->setVariable('TBL_NO_ENTRY_TEXT', trim($no_items_text));
167  $this->tpl->parseCurrentBlock();
168  }
169 
170  if (!$this->getPrintMode()) {
171  $this->fillFooter();
172 
173  $this->fillHiddenRow();
174 
175  $this->fillActionRow();
176 
177  $this->storeNavParameter();
178  }
179 
180  return $this->render();
181  }
182 
183  public function fillRowFromObject(object $a_set): void
184  {
185  global $DIC;
186  $lng = $DIC['lng'];
187  $field = $a_set->getFieldObject();
188 
189  if (!$field->isStandardField() || $field->getId() === 'owner') {
190  $this->tpl->setVariable('TEXT_VISIBLE', $lng->txt('dcl_tableview_visible'));
191  $this->tpl->setVariable('TEXT_REQUIRED_VISIBLE', $lng->txt('dcl_tableview_required_visible'));
192  $this->tpl->setVariable('TEXT_LOCKED_VISIBLE', $lng->txt('dcl_tableview_locked_visible'));
193  $this->tpl->setVariable('TEXT_NOT_VISIBLE', $lng->txt('dcl_tableview_not_visible'));
194  $this->tpl->setVariable('IS_LOCKED', $a_set->isLockedEdit() ? 'checked' : '');
195  $this->tpl->setVariable('IS_REQUIRED', $a_set->isRequiredEdit() ? 'checked' : '');
196  $this->tpl->setVariable('DEFAULT_VALUE', $a_set->getDefaultValue());
197  $this->tpl->setVariable('IS_VISIBLE', $a_set->isVisibleEdit() ? 'checked' : '');
198  $this->tpl->setVariable('IS_NOT_VISIBLE', !$a_set->isVisibleEdit() ? 'checked' : '');
199  } else {
200  $this->tpl->setVariable('HIDDEN', 'hidden');
201  }
202 
203  $this->tpl->setVariable('FIELD_ID', $a_set->getField());
204  $this->tpl->setVariable('TITLE', $field->getTitle());
205  $this->tpl->parseCurrentBlock();
206  }
207 }
setData(array $a_data)
numericOrdering(string $a_field)
Should this field be sorted numeric?
prepareOutput()
Anything that must be done before HTML is generated.
setTopCommands(bool $a_val)
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...
setFormAction(string $a_form_action, bool $a_multipart=false)
setEnableTitle(bool $a_enabletitle)
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setShowTemplates(bool $a_value)
setId(string $a_val)
exportData(int $format, bool $send=false)
Export and optionally send current table data.
global $DIC
Definition: feed.php:28
setExternalSorting(bool $a_val)
setShowRowsSelector(bool $a_value)
Toggle rows-per-page selector.
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setDefaultOrderDirection(string $a_defaultorderdirection)
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
__construct(ilDclEditViewDefinitionGUI $a_parent_obj)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setFooter(string $a_style, string $a_previous="", string $a_next="")
__construct(Container $dic, ilPlugin $plugin)
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)
static setUseRelativeDates(bool $a_status)
set use relative dates
determineOffsetAndOrder(bool $a_omit_offset=false)
setEnableHeader(bool $a_enableheader)
setMaxCount(int $a_max_count)
set max.
setExternalSegmentation(bool $a_val)
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)