ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
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('save'));
38 
39  $this->setExternalSegmentation(true);
40  $this->setExternalSorting(true);
41 
42  $this->setRowTemplate('tpl.tableview_edit_view.html', 'components/ILIAS/DataCollection');
43  $this->setTopCommands(true);
44  $this->setEnableHeader(true);
45  $this->setShowRowsSelector(false);
46  $this->setEnableHeader(true);
47  $this->setEnableTitle(true);
48  $this->setDefaultOrderDirection('asc');
49 
50  $this->parseData($a_parent_obj->tableview->getFieldSettings());
51  }
52 
53  public function parseData($data)
54  {
55  $this->setData($data);
56  }
57 
61  public function getHTML(): string
62  {
63  $lng = $this->lng;
64  $ilCtrl = $this->ctrl;
65 
66  if ($this->getExportMode()) {
67  $this->exportData($this->getExportMode(), true);
68  }
69 
70  $this->prepareOutput();
71 
72  if (is_object($this->getParentObject()) && $this->getId() == "") {
73  $ilCtrl->saveParameter($this->getParentObject(), $this->getNavParameter());
74  }
75 
76  if (!$this->getPrintMode()) {
77  // set form action
78  if ($this->form_action != "" && $this->getOpenFormTag()) {
79  $hash = "";
80 
81  if ($this->form_multipart) {
82  $this->tpl->touchBlock("form_multipart_bl");
83  }
84 
85  if ($this->getPreventDoubleSubmission()) {
86  $this->tpl->touchBlock("pdfs");
87  }
88 
89  $this->tpl->setCurrentBlock("tbl_form_header");
90  $this->tpl->setVariable("FORMACTION", $this->getFormAction() . $hash);
91  $this->tpl->setVariable("FORMNAME", $this->getFormName());
92  $this->tpl->parseCurrentBlock();
93  }
94 
95  if ($this->form_action != "" && $this->getCloseFormTag()) {
96  $this->tpl->touchBlock("tbl_form_footer");
97  }
98  }
99 
100  if (!$this->enabled['content']) {
101  return $this->render();
102  }
103 
104  if (!$this->getExternalSegmentation()) {
105  $this->setMaxCount(count($this->row_data));
106  }
107 
108  $this->determineOffsetAndOrder();
109 
110  $this->setFooter("tblfooter", $this->lng->txt("previous"), $this->lng->txt("next"));
111 
112  $data = $this->getData();
113  if ($this->dataExists()) {
114  // sort
115  if (!$this->getExternalSorting() && $this->enabled["sort"]) {
116  $data = ilArrayUtil::sortArray(
117  $data,
118  $this->getOrderField(),
119  $this->getOrderDirection(),
120  $this->numericOrdering($this->getOrderField())
121  );
122  }
123 
124  // slice
125  if (!$this->getExternalSegmentation()) {
126  $data = array_slice($data, $this->getOffset(), $this->getLimit());
127  }
128  }
129 
130  // fill rows
131  if ($this->dataExists()) {
132  if ($this->getPrintMode()) {
134  }
135 
136  $this->tpl->addBlockFile(
137  "TBL_CONTENT",
138  "tbl_content",
139  $this->row_template,
140  $this->row_template_dir
141  );
142 
143  foreach ($data as $set) {
144  $this->tpl->setCurrentBlock("tbl_content");
145  $this->css_row = ($this->css_row !== "tblrow1")
146  ? "tblrow1"
147  : "tblrow2";
148  $this->tpl->setVariable("CSS_ROW", $this->css_row);
149 
150  $this->fillRowFromObject($set);
151  $this->tpl->setCurrentBlock("tbl_content");
152  $this->tpl->parseCurrentBlock();
153  }
154  } else {
155  // add standard no items text (please tell me, if it messes something up, alex, 29.8.2008)
156  $no_items_text = (trim($this->getNoEntriesText()) != '')
157  ? $this->getNoEntriesText()
158  : $lng->txt("no_items");
159 
160  $this->css_row = ($this->css_row !== "tblrow1")
161  ? "tblrow1"
162  : "tblrow2";
163 
164  $this->tpl->setCurrentBlock("tbl_no_entries");
165  $this->tpl->setVariable('TBL_NO_ENTRY_CSS_ROW', $this->css_row);
166  $this->tpl->setVariable('TBL_NO_ENTRY_COLUMN_COUNT', $this->column_count);
167  $this->tpl->setVariable('TBL_NO_ENTRY_TEXT', trim($no_items_text));
168  $this->tpl->parseCurrentBlock();
169  }
170 
171  if (!$this->getPrintMode()) {
172  $this->fillFooter();
173 
174  $this->fillHiddenRow();
175 
176  $this->fillActionRow();
177 
178  $this->storeNavParameter();
179  }
180 
181  return $this->render();
182  }
183 
184  public function fillRowFromObject(object $a_set): void
185  {
186  global $DIC;
187  $lng = $DIC['lng'];
188  $field = $a_set->getFieldObject();
189 
190  if (!$field->isStandardField() || $field->getId() === 'owner') {
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->isLockedEdit() ? 'checked' : '');
196  $this->tpl->setVariable('IS_REQUIRED', $a_set->isRequiredEdit() ? 'checked' : '');
197  $this->tpl->setVariable('DEFAULT_VALUE', $a_set->getDefaultValue());
198  $this->tpl->setVariable('IS_VISIBLE', $a_set->isVisibleEdit() ? 'checked' : '');
199  $this->tpl->setVariable('IS_NOT_VISIBLE', !$a_set->isVisibleEdit() ? 'checked' : '');
200  } else {
201  $this->tpl->setVariable('HIDDEN', 'hidden');
202  }
203 
204  $this->tpl->setVariable('FIELD_ID', $a_set->getField());
205  $this->tpl->setVariable('TITLE', $field->getTitle());
206  $this->tpl->parseCurrentBlock();
207  }
208 }
setData(array $a_data)
numericOrdering(string $a_field)
Should this field be sorted numeric?
static array static setUseRelativeDates(bool $a_status)
set use relative dates
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
setId(string $a_val)
exportData(int $format, bool $send=false)
Export and optionally send current table data.
setExternalSorting(bool $a_val)
setShowRowsSelector(bool $a_value)
Toggle rows-per-page selector.
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
global $DIC
Definition: shib_login.php:26
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="")
__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)
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)