ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilDclEditViewTableGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 {
23  protected ilLanguage $lng;
24  protected ilCtrl $ctrl;
25 
26  public function __construct(ilDclEditViewDefinitionGUI $a_parent_obj)
27  {
28  parent::__construct($a_parent_obj);
29 
30  $this->setId('dcl_tableviews');
31  $this->setTitle($this->lng->txt('dcl_tableview_fieldsettings'));
32  $this->addColumn($this->lng->txt('dcl_tableview_fieldtitle'), "", 'auto');
33  $this->addColumn($this->lng->txt('dcl_tableview_field_access'), "", 'auto');
34 
35  $this->ctrl->saveParameter($this, 'tableview_id');
36  $this->setFormAction($this->ctrl->getFormActionByClass('ildcleditviewdefinitiongui'));
37  $this->addCommandButton('saveTable', $this->lng->txt('dcl_save'));
38 
39  $this->setExternalSegmentation(true);
40  $this->setExternalSorting(true);
41 
42  $this->setRowTemplate('tpl.tableview_edit_view.html', 'Modules/DataCollection');
43  $this->setTopCommands(true);
44  $this->setEnableHeader(true);
45  $this->setShowRowsSelector(false);
46  $this->setShowTemplates(false);
47  $this->setEnableHeader(true);
48  $this->setEnableTitle(true);
49  $this->setDefaultOrderDirection('asc');
50 
51  $this->parseData($a_parent_obj->tableview->getFieldSettings());
52  }
53 
54  public function parseData($data)
55  {
56  $this->setData($data);
57  }
58 
62  public function getHTML(): string
63  {
64  $lng = $this->lng;
65  $ilCtrl = $this->ctrl;
66 
67  if ($this->getExportMode()) {
68  $this->exportData($this->getExportMode(), true);
69  }
70 
71  $this->prepareOutput();
72 
73  if (is_object($this->getParentObject()) && $this->getId() == "") {
74  $ilCtrl->saveParameter($this->getParentObject(), $this->getNavParameter());
75  }
76 
77  if (!$this->getPrintMode()) {
78  // set form action
79  if ($this->form_action != "" && $this->getOpenFormTag()) {
80  $hash = "";
81 
82  if ($this->form_multipart) {
83  $this->tpl->touchBlock("form_multipart_bl");
84  }
85 
86  if ($this->getPreventDoubleSubmission()) {
87  $this->tpl->touchBlock("pdfs");
88  }
89 
90  $this->tpl->setCurrentBlock("tbl_form_header");
91  $this->tpl->setVariable("FORMACTION", $this->getFormAction() . $hash);
92  $this->tpl->setVariable("FORMNAME", $this->getFormName());
93  $this->tpl->parseCurrentBlock();
94  }
95 
96  if ($this->form_action != "" && $this->getCloseFormTag()) {
97  $this->tpl->touchBlock("tbl_form_footer");
98  }
99  }
100 
101  if (!$this->enabled['content']) {
102  return $this->render();
103  }
104 
105  if (!$this->getExternalSegmentation()) {
106  $this->setMaxCount(count($this->row_data));
107  }
108 
109  $this->determineOffsetAndOrder();
110 
111  $this->setFooter("tblfooter", $this->lng->txt("previous"), $this->lng->txt("next"));
112 
113  $data = $this->getData();
114  if ($this->dataExists()) {
115  // sort
116  if (!$this->getExternalSorting() && $this->enabled["sort"]) {
117  $data = ilArrayUtil::sortArray(
118  $data,
119  $this->getOrderField(),
120  $this->getOrderDirection(),
121  $this->numericOrdering($this->getOrderField())
122  );
123  }
124 
125  // slice
126  if (!$this->getExternalSegmentation()) {
127  $data = array_slice($data, $this->getOffset(), $this->getLimit());
128  }
129  }
130 
131  // fill rows
132  if ($this->dataExists()) {
133  if ($this->getPrintMode()) {
135  }
136 
137  $this->tpl->addBlockFile(
138  "TBL_CONTENT",
139  "tbl_content",
140  $this->row_template,
141  $this->row_template_dir
142  );
143 
144  foreach ($data as $set) {
145  $this->tpl->setCurrentBlock("tbl_content");
146  $this->css_row = ($this->css_row !== "tblrow1")
147  ? "tblrow1"
148  : "tblrow2";
149  $this->tpl->setVariable("CSS_ROW", $this->css_row);
150 
151  $this->fillRowFromObject($set);
152  $this->tpl->setCurrentBlock("tbl_content");
153  $this->tpl->parseCurrentBlock();
154  }
155  } else {
156  // add standard no items text (please tell me, if it messes something up, alex, 29.8.2008)
157  $no_items_text = (trim($this->getNoEntriesText()) != '')
158  ? $this->getNoEntriesText()
159  : $lng->txt("no_items");
160 
161  $this->css_row = ($this->css_row !== "tblrow1")
162  ? "tblrow1"
163  : "tblrow2";
164 
165  $this->tpl->setCurrentBlock("tbl_no_entries");
166  $this->tpl->setVariable('TBL_NO_ENTRY_CSS_ROW', $this->css_row);
167  $this->tpl->setVariable('TBL_NO_ENTRY_COLUMN_COUNT', $this->column_count);
168  $this->tpl->setVariable('TBL_NO_ENTRY_TEXT', trim($no_items_text));
169  $this->tpl->parseCurrentBlock();
170  }
171 
172  if (!$this->getPrintMode()) {
173  $this->fillFooter();
174 
175  $this->fillHiddenRow();
176 
177  $this->fillActionRow();
178 
179  $this->storeNavParameter();
180  }
181 
182  return $this->render();
183  }
184 
185  public function fillRowFromObject(object $a_set): void
186  {
187  global $DIC;
188  $lng = $DIC['lng'];
189  $field = $a_set->getFieldObject();
190 
191  if (!$field->isStandardField() || $field->getId() === 'owner') {
192  $this->tpl->setVariable('TEXT_VISIBLE', $lng->txt('dcl_tableview_visible'));
193  $this->tpl->setVariable('TEXT_REQUIRED_VISIBLE', $lng->txt('dcl_tableview_required_visible'));
194  $this->tpl->setVariable('TEXT_LOCKED_VISIBLE', $lng->txt('dcl_tableview_locked_visible'));
195  $this->tpl->setVariable('TEXT_NOT_VISIBLE', $lng->txt('dcl_tableview_not_visible'));
196  $this->tpl->setVariable('IS_LOCKED', $a_set->isLockedEdit() ? 'checked' : '');
197  $this->tpl->setVariable('IS_REQUIRED', $a_set->isRequiredEdit() ? 'checked' : '');
198  $this->tpl->setVariable('DEFAULT_VALUE', $a_set->getDefaultValue());
199  $this->tpl->setVariable('IS_VISIBLE', $a_set->isVisibleEdit() ? 'checked' : '');
200  $this->tpl->setVariable('IS_NOT_VISIBLE', !$a_set->isVisibleEdit() ? 'checked' : '');
201  } else {
202  $this->tpl->setVariable('HIDDEN', 'hidden');
203  }
204 
205  $this->tpl->setVariable('FIELD_ID', $a_set->getField());
206  $this->tpl->setVariable('TITLE', $field->getTitle());
207  $this->tpl->parseCurrentBlock();
208  }
209 }
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="")
ilDclEditViewDefinitionGUI: ilDclTableViewEditGUI
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.
__construct(VocabulariesInterface $vocabularies)
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)
setFooter(string $a_style, string $a_previous="", string $a_next="")
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)