ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
class.ilTable2GUI.php
Go to the documentation of this file.
1 <?php
2 
25 class ilTable2GUI extends ilTableGUI
26 {
27  public const FILTER_TEXT = 1;
28  public const FILTER_SELECT = 2;
29  public const FILTER_DATE = 3;
30  public const FILTER_LANGUAGE = 4;
31  public const FILTER_NUMBER_RANGE = 5;
32  public const FILTER_DATE_RANGE = 6;
33  public const FILTER_DURATION_RANGE = 7;
34  public const FILTER_DATETIME_RANGE = 8;
35  public const FILTER_CHECKBOX = 9;
36  public const EXPORT_EXCEL = 1;
37  public const EXPORT_CSV = 2;
38  public const ACTION_ALL_LIMIT = 1000;
39  private \ILIAS\DI\UIServices $ui;
40  protected string $requested_tmpl_delete;
41  protected string $requested_tmpl_create;
42  protected string $requested_nav_par2 = "";
43  protected string $requested_nav_par = "";
44  protected string $requested_nav_par1 = "";
45  protected ?\ILIAS\Table\TableGUIRequest $table_request = null;
46  protected array $selected_columns = [];
47 
48  protected ilCtrl $ctrl;
49  protected ?object $parent_obj = null;
50  protected string $parent_cmd = "";
51  protected string $close_command = "";
52  private string $unique_id = "";
53  private string $headerHTML = "";
54  protected string $top_anchor = "il_table_top";
55  protected array $filters = array();
56  protected array $optional_filters = array();
57  protected string $filter_cmd = 'applyFilter';
58  protected string $reset_cmd = 'resetFilter';
59  protected int $filter_cols = 5;
60  protected bool $ext_sort = false;
61  protected bool $ext_seg = false;
62  protected string $context = "";
63 
64  protected array $mi_sel_buttons = [];
65  protected bool $disable_filter_hiding = false;
66  protected bool $top_commands = true;
67  protected array $selectable_columns = array();
68  protected array $selected_column = array();
69  protected bool $show_templates = false;
70  protected bool $show_rows_selector = true; // JF, 2014-10-27
71  protected bool $rows_selector_off = false;
72 
73  protected bool $nav_determined = false;
74  protected bool $limit_determined = false;
75  protected bool $filters_determined = false;
76  protected bool $columns_determined = false;
77  protected bool $open_form_tag = true;
78  protected bool $close_form_tag = true;
79  protected array $export_formats = [];
80  protected int $export_mode = 0;
81  protected bool $print_mode = false;
82  protected bool $enable_command_for_all = false;
83  protected bool $restore_filter = false;
84  protected array $restore_filter_values = [];
85  protected bool $default_filter_visibility = false;
86  protected array $sortable_fields = array();
87  protected bool $prevent_double_submission = true;
88  protected string $row_selector_label = "";
89  protected bool $select_all_on_top = false;
90  protected array $sel_buttons = [];
91  protected string $nav_value = '';
92  protected string $noentriestext = '';
93  protected string $css_row = '';
94  protected bool $display_as_block = false;
95  protected string $description = '';
96  protected string $id = "";
97  protected bool $custom_prev_next = false;
98  protected string $reset_cmd_txt = "";
99  protected string $defaultorderfield = "";
100  protected string $defaultorderdirection = "";
101  protected array $column = [];
102  protected bool $datatable = false;
103  protected bool $num_info = false;
104  protected bool $form_multipart = false;
105  protected array $row_data = [];
106  protected string $order_field = "";
107  protected array $selected_filter = [];
108  protected string $form_action = "";
109  protected string $formname = "";
110  protected string $sort_order = "";
111  protected array $buttons = [];
112  protected array $multi = [];
113  protected array $hidden_inputs = [];
114  protected array $header_commands = [];
115  protected string $row_template = "";
116  protected string $row_template_dir = "";
117  protected string $filter_cmd_txt = "";
118  protected string $custom_prev = "";
119  protected string $custom_next = "";
120  protected ?array $raw_post_data = null;
121  protected \ilGlobalTemplateInterface $main_tpl;
122 
126  public function __construct(
127  ?object $a_parent_obj,
128  string $a_parent_cmd = "",
129  string $a_template_context = ""
130  ) {
131  global $DIC;
132  $this->main_tpl = $DIC->ui()->mainTemplate();
133  $this->ui = $DIC->ui();
134 
135  $this->lng = $DIC->language();
136  $this->ctrl = $DIC->ctrl();
137  $lng = $DIC->language();
138 
139  if (isset($DIC["http"])) {
140  $this->table_request = new \ILIAS\Table\TableGUIRequest(
141  $DIC->http(),
142  $DIC->refinery()
143  );
144  }
145  $this->getRequestedValues();
146  parent::__construct([], false);
147  $this->unique_id = md5(uniqid('', true));
148  $this->parent_obj = $a_parent_obj;
149  $this->parent_cmd = $a_parent_cmd;
150  $this->buttons = array();
151  $this->header_commands = array();
152  $this->multi = array();
153  $this->hidden_inputs = array();
154  $this->formname = "table_" . $this->unique_id;
155  $this->tpl = new ilTemplate("tpl.table2.html", true, true, "components/ILIAS/Table");
156 
157  $lng->loadLanguageModule('tbl');
158 
159  if (!$a_template_context) {
160  $a_template_context = $this->getId();
161  }
162  $this->setContext($a_template_context);
163 
164  // activate export mode
165  if (isset($this->table_request)) {
166  $this->export_mode = $this->table_request->getExportMode($this->prefix);
167 
168  // template handling
169  if ($this->table_request->getTemplate($this->prefix) != "") {
170  $this->restoreTemplate($this->table_request->getTemplate($this->prefix));
171  }
172  }
173 
174  $this->determineLimit();
175  $this->setIsDataTable(true);
176  $this->setEnableNumInfo(true);
177  $this->determineSelectedColumns();
178 
179  $this->raw_post_data = [];
180  if (isset($DIC["http"])) {
181  $this->raw_post_data = $DIC->http()->request()->getParsedBody();
182  }
183  }
184 
185  protected function getRequestedValues(): void
186  {
187  if (is_null($this->table_request)) {
188  return;
189  }
190  $this->requested_nav_par = $this->table_request->getNavPar($this->getNavParameter());
191  $this->requested_nav_par1 = $this->table_request->getNavPar($this->getNavParameter(), 1);
192  $this->requested_nav_par2 = $this->table_request->getNavPar($this->getNavParameter(), 2);
193  $this->requested_tmpl_create = $this->table_request->getTemplCreate();
194  $this->requested_tmpl_delete = $this->table_request->getTemplDelete();
195  }
196 
197  public function setOpenFormTag(bool $a_val): void
198  {
199  $this->open_form_tag = $a_val;
200  }
201 
202  public function getOpenFormTag(): bool
203  {
204  return $this->open_form_tag;
205  }
206 
207  public function setCloseFormTag(bool $a_val): void
208  {
209  $this->close_form_tag = $a_val;
210  }
211 
212  public function getCloseFormTag(): bool
213  {
214  return $this->close_form_tag;
215  }
216 
217  public function determineLimit(): void
218  {
219  global $DIC;
220 
221  $ilUser = null;
222  if (isset($DIC["ilUser"])) {
223  $ilUser = $DIC["ilUser"];
224  }
225 
226  if ($this->limit_determined) {
227  return;
228  }
229 
230  $limit = 0;
231  if (isset($this->table_request) && !is_null($this->table_request->getRows($this->prefix))) {
232  $this->storeProperty("rows", $this->table_request->getRows($this->prefix));
233  $limit = $this->table_request->getRows($this->prefix) ?? 0;
234  $this->resetOffset();
235  }
236 
237  if ($limit == 0) {
238  $rows = (int) $this->loadProperty("rows");
239  if ($rows > 0) {
240  $limit = $rows;
241  } else {
242  $limit = 40;
243  }
244  }
245 
246  $this->setLimit($limit);
247  $this->limit_determined = true;
248  }
249 
254  public function getSelectableColumns(): array
255  {
256  return [];
257  }
258 
259  public function determineSelectedColumns(): void
260  {
261  if ($this->columns_determined) {
262  return;
263  }
264 
265  $old_sel = $this->loadProperty("selfields");
266  $sel_fields = [];
267  $stored = false;
268  if ($old_sel != "") {
269  $sel_fields = unserialize((string) $old_sel);
270  $stored = true;
271  }
272  if (!is_array($sel_fields)) {
273  $stored = false;
274  $sel_fields = array();
275  }
276 
277  $this->selected_columns = array();
278  $set = false;
279 
280  $fsh = false;
281  $fs = [];
282  if (isset($this->table_request)) {
283  $fs = $this->table_request->getFS($this->getId());
284  $fsh = $this->table_request->getFSH($this->getId());
285  }
286 
287  foreach ($this->getSelectableColumns() as $k => $c) {
288  $this->selected_column[$k] = false;
289 
290  $new_column = (!isset($sel_fields[$k]));
291 
292  if ($fsh) {
293  $set = true;
294  if (in_array($k, $fs)) {
295  $this->selected_column[$k] = true;
296  }
297  } elseif ($stored && !$new_column) { // take stored values
298  $this->selected_column[$k] = $sel_fields[$k];
299  } else { // take default values
300  if ($new_column) {
301  $set = true;
302  }
303  if (isset($c["default"]) && $c["default"]) {
304  $this->selected_column[$k] = true;
305  }
306  }
307 
308  // Optional filters
309  $ff = [];
310  if (isset($this->table_request)) {
311  $ff = $this->table_request->getFF($this->getId());
312  }
313  if (count($ff) > 0) {
314  $set = true;
315  if (in_array($k, $ff)) {
316  $this->selected_column[$k] = true;
317  }
318  }
319  }
320 
321  if ($old_sel != serialize($this->selected_column) && $set) {
322  $this->storeProperty("selfields", serialize($this->selected_column));
323  }
324 
325  $this->columns_determined = true;
326  }
327 
328  public function isColumnSelected(string $col): bool
329  {
330  return $this->selected_column[$col] ?? false;
331  }
332 
333  public function getSelectedColumns(): array
334  {
335  $scol = array();
336  foreach ($this->selected_column as $k => $v) {
337  if ($v) {
338  $scol[$k] = $k;
339  }
340  }
341  return $scol;
342  }
343 
344  public function executeCommand(): bool
345  {
346  $ilCtrl = $this->ctrl;
347 
348  $next_class = $ilCtrl->getNextClass($this);
349 
350  switch ($next_class) {
351  case 'ilformpropertydispatchgui':
352  $form_prop_dispatch = new ilFormPropertyDispatchGUI();
353  $this->initFilter();
355  $item = $this->getFilterItemByPostVar(
356  $this->table_request->getPostVar()
357  );
358  $form_prop_dispatch->setItem($item);
359  return (bool) $ilCtrl->forwardCommand($form_prop_dispatch);
360  }
361  return false;
362  }
363 
364  public function resetOffset(bool $a_in_determination = false): void
365  {
366  if (!$this->nav_determined && !$a_in_determination) {
367  $this->determineOffsetAndOrder();
368  }
369  $this->nav_value = $this->getOrderField() . ":" . $this->getOrderDirection() . ":0";
370  $this->requested_nav_par = $this->requested_nav_par1 = $this->nav_value;
371  $this->setOffset(0);
372  }
373 
374  public function initFilter(): void
375  {
376  }
377 
378  public function getParentObject(): ?object
379  {
380  return $this->parent_obj;
381  }
382 
383  public function getParentCmd(): string
384  {
385  return $this->parent_cmd;
386  }
387 
388  public function setTopAnchor(string $a_val): void
389  {
390  $this->top_anchor = $a_val;
391  }
392 
393  public function getTopAnchor(): string
394  {
395  return $this->top_anchor;
396  }
397 
398  public function setNoEntriesText(string $a_text): void
399  {
400  $this->noentriestext = $a_text;
401  }
402 
403  public function getNoEntriesText(): string
404  {
405  return $this->noentriestext;
406  }
407 
408  public function setIsDataTable(bool $a_val): void
409  {
410  $this->datatable = $a_val;
411  }
412 
413  public function getIsDataTable(): bool
414  {
415  return $this->datatable;
416  }
417 
418  public function setEnableTitle(bool $a_enabletitle): void
419  {
420  $this->enabled["title"] = $a_enabletitle;
421  }
422 
423  public function getEnableTitle(): bool
424  {
425  return $this->enabled["title"];
426  }
427 
428  public function setEnableHeader(bool $a_enableheader): void
429  {
430  $this->enabled["header"] = $a_enableheader;
431  }
432 
433  public function getEnableHeader(): bool
434  {
435  return $this->enabled["header"];
436  }
437 
438  public function setEnableNumInfo(bool $a_val): void
439  {
440  $this->num_info = $a_val;
441  }
442 
443  public function getEnableNumInfo(): bool
444  {
445  return $this->num_info;
446  }
447 
448  final public function setTitle(
449  string $a_title,
450  string $a_icon = "",
451  string $a_icon_alt = ""
452  ): void {
453  parent::setTitle($a_title, $a_icon, $a_icon_alt);
454  }
455 
456  public function setDescription(string $a_val): void
457  {
458  $this->description = $a_val;
459  }
460 
461  public function getDescription(): string
462  {
463  return $this->description;
464  }
465 
466  public function setOrderField(string $a_order_field): void
467  {
468  $this->order_field = $a_order_field;
469  }
470 
471  public function getOrderField(): string
472  {
473  return $this->order_field;
474  }
475 
476  final public function setData(array $a_data): void
477  {
478  $this->row_data = $a_data;
479  }
480 
481  final public function getData(): array
482  {
483  return $this->row_data;
484  }
485 
486  final public function dataExists(): bool
487  {
488  return count($this->row_data) > 0;
489  }
490 
491  final public function setPrefix(string $a_prefix): void
492  {
493  $this->prefix = $a_prefix;
494  $this->getRequestedValues();
495  }
496 
497  final public function getPrefix(): string
498  {
499  return $this->prefix;
500  }
501 
502  final public function addFilterItem(
503  ilTableFilterItem $a_input_item,
504  bool $a_optional = false
505  ): void {
506  $a_input_item->setParentTable($this);
507  if (!$a_optional) {
508  $this->filters[] = $a_input_item;
509  } else {
510  $this->optional_filters[] = $a_input_item;
511  }
512 
513  // restore filter values (from stored view)
514  if ($this->restore_filter) {
515  if (array_key_exists($a_input_item->getFieldId(), $this->restore_filter_values ?? [])) {
516  $this->setFilterValue($a_input_item, $this->restore_filter_values[$a_input_item->getFieldId()]);
517  } else {
518  $this->setFilterValue($a_input_item, null); // #14949
519  }
520  }
521  }
522 
527  public function addFilterItemByMetaType(
528  string $id,
529  int $type = self::FILTER_TEXT,
530  bool $a_optional = false,
531  string $caption = ""
532  ): ?ilTableFilterItem {
533  global $DIC;
534 
535  $lng = $DIC->language(); // constructor may not be called here, if initFilter is being called in subclasses before parent::__construct
536 
537  if (!$caption) {
538  $caption = $lng->txt($id);
539  }
540 
541  switch ($type) {
542  case self::FILTER_CHECKBOX:
543  $item = new ilCheckboxInputGUI($caption, $id);
544  break;
545 
546  case self::FILTER_SELECT:
547  $item = new ilSelectInputGUI($caption, $id);
548  break;
549 
550  case self::FILTER_DATE:
551  $item = new ilDateTimeInputGUI($caption, $id);
552  break;
553 
554  case self::FILTER_TEXT:
555  $item = new ilTextInputGUI($caption, $id);
556  $item->setMaxLength(64);
557  $item->setSize(20);
558  // $item->setSubmitFormOnEnter(true);
559  break;
560 
561  case self::FILTER_LANGUAGE:
562  $lng->loadLanguageModule("meta");
563  $item = new ilSelectInputGUI($caption, $id);
564  $options = array("" => $lng->txt("trac_all"));
565  foreach ($lng->getInstalledLanguages() as $lang_key) {
566  $options[$lang_key] = $lng->txt("meta_l_" . $lang_key);
567  }
568  $item->setOptions($options);
569  break;
570 
571  case self::FILTER_NUMBER_RANGE:
572  $item = new ilCombinationInputGUI($caption, $id);
573  $combi_item = new ilNumberInputGUI("", $id . "_from");
574  $combi_item->setSize(5);
575  $item->addCombinationItem("from", $combi_item, $lng->txt("from"));
576  $combi_item = new ilNumberInputGUI("", $id . "_to");
577  $combi_item->setSize(5);
578  $item->addCombinationItem("to", $combi_item, $lng->txt("to"));
579  $item->setComparisonMode(ilCombinationInputGUI::COMPARISON_ASCENDING);
580  //$item->setMaxLength(7);
581  //$item->setSize(20);
582  break;
583 
584  case self::FILTER_DATE_RANGE:
585  $item = new ilCombinationInputGUI($caption, $id);
586  $combi_item = new ilDateTimeInputGUI("", $id . "_from");
587  $item->addCombinationItem("from", $combi_item, $lng->txt("from"));
588  $combi_item = new ilDateTimeInputGUI("", $id . "_to");
589  $item->addCombinationItem("to", $combi_item, $lng->txt("to"));
590  $item->setComparisonMode(ilCombinationInputGUI::COMPARISON_ASCENDING);
591  break;
592 
593  case self::FILTER_DATETIME_RANGE:
594  $item = new ilCombinationInputGUI($caption, $id);
595  $combi_item = new ilDateTimeInputGUI("", $id . "_from");
596  $combi_item->setShowTime(true);
597  $item->addCombinationItem("from", $combi_item, $lng->txt("from"));
598  $combi_item = new ilDateTimeInputGUI("", $id . "_to");
599  $combi_item->setShowTime(true);
600  $item->addCombinationItem("to", $combi_item, $lng->txt("to"));
601  $item->setComparisonMode(ilCombinationInputGUI::COMPARISON_ASCENDING);
602  break;
603 
604  case self::FILTER_DURATION_RANGE:
605  $lng->loadLanguageModule("form");
606  $item = new ilCombinationInputGUI($caption, $id);
607  $combi_item = new ilDurationInputGUI("", $id . "_from");
608  $combi_item->setShowMonths(false);
609  $combi_item->setShowDays(true);
610  $combi_item->setShowSeconds(true);
611  $item->addCombinationItem("from", $combi_item, $lng->txt("from"));
612  $combi_item = new ilDurationInputGUI("", $id . "_to");
613  $combi_item->setShowMonths(false);
614  $combi_item->setShowDays(true);
615  $combi_item->setShowSeconds(true);
616  $item->addCombinationItem("to", $combi_item, $lng->txt("to"));
617  $item->setComparisonMode(ilCombinationInputGUI::COMPARISON_ASCENDING);
618  break;
619 
620  default:
621  return null;
622  }
623 
624  $this->addFilterItem($item, $a_optional);
625  $item->readFromSession();
626  return $item;
627  }
628 
629  final public function getFilterItems(bool $a_optionals = false): array
630  {
631  if (!$a_optionals) {
632  return $this->filters;
633  }
635  }
636 
637  final public function getFilterItemByPostVar(string $a_post_var): ?ilTableFilterItem
638  {
639  foreach ($this->getFilterItems() as $item) {
640  if ($item->getPostVar() == $a_post_var) {
641  return $item;
642  }
643  }
644  foreach ($this->getFilterItems(true) as $item) {
645  if ($item->getPostVar() == $a_post_var) {
646  return $item;
647  }
648  }
649  return null;
650  }
651 
652  public function setFilterCols(int $a_val): void
653  {
654  $this->filter_cols = $a_val;
655  }
656 
657  public function getFilterCols(): int
658  {
659  return $this->filter_cols;
660  }
661 
662  public function setDisableFilterHiding(bool $a_val = true): void
663  {
664  $this->disable_filter_hiding = $a_val;
665  }
666 
667  public function getDisableFilterHiding(): bool
668  {
670  }
671 
675  public function isFilterSelected(string $a_col): bool
676  {
677  return (bool) $this->selected_filter[$a_col];
678  }
679 
680  public function getSelectedFilters(): array
681  {
682  $sfil = array();
683  foreach ($this->selected_filter as $k => $v) {
684  if ($v) {
685  $sfil[$k] = $k;
686  }
687  }
688  return $sfil;
689  }
690 
691  public function determineSelectedFilters(): void
692  {
693  if ($this->filters_determined) {
694  return;
695  }
696 
697  $old_sel = $this->loadProperty("selfilters");
698  $stored = false;
699  $sel_filters = null;
700  if ($old_sel != "") {
701  $sel_filters =
702  unserialize((string) $old_sel);
703  $stored = true;
704  }
705  if (!is_array($sel_filters)) {
706  $stored = false;
707  $sel_filters = array();
708  }
709 
710  $this->selected_filter = array();
711  $set = false;
712  foreach ($this->getFilterItems(true) as $item) {
713  $k = $item->getPostVar();
714 
715  $this->selected_filter[$k] = false;
716 
717  if ($this->table_request->getFSF($this->getId())) {
718  $set = true;
719  if (in_array($k, $this->table_request->getFF($this->getId()))) {
720  $this->selected_filter[$k] = true;
721  } else {
722  $item->setValue(null);
723  $item->writeToSession();
724  }
725  } elseif ($stored) { // take stored values
726  $this->selected_filter[$k] = $sel_filters[$k] ?? "";
727  }
728  }
729 
730  if ($old_sel != serialize($this->selected_filter) && $set) {
731  $this->storeProperty("selfilters", serialize($this->selected_filter));
732  }
733 
734  $this->filters_determined = true;
735  }
736 
737  public function setCustomPreviousNext(
738  string $a_prev_link,
739  string $a_next_link
740  ): void {
741  $this->custom_prev_next = true;
742  $this->custom_prev = $a_prev_link;
743  $this->custom_next = $a_next_link;
744  }
745 
746  final public function setFormAction(
747  string $a_form_action,
748  bool $a_multipart = false
749  ): void {
750  $this->form_action = $a_form_action;
751  $this->form_multipart = $a_multipart;
752  }
753 
754  final public function getFormAction(): string
755  {
756  return $this->form_action;
757  }
758 
759  public function setFormName(string $a_name = ""): void
760  {
761  $this->formname = $a_name;
762  }
763 
764  public function getFormName(): string
765  {
766  return $this->formname;
767  }
768 
769  public function setId(string $a_val): void
770  {
771  $this->id = $a_val;
772  if ($this->getPrefix() == "") {
773  $this->setPrefix($a_val);
774  }
775  if (strlen($this->id) > 30) {
776  throw new ilException("Table ID to long (max. 30 char): " . $this->id);
777  }
778  }
779 
780  public function getId(): string
781  {
782  return $this->id;
783  }
784 
785  public function setDisplayAsBlock(bool $a_val): void
786  {
787  $this->display_as_block = $a_val;
788  }
789 
790  public function getDisplayAsBlock(): bool
791  {
793  }
794 
795  public function setSelectAllCheckbox(
796  string $a_select_all_checkbox,
797  bool $a_select_all_on_top = false
798  ): void {
799  $this->select_all_checkbox = $a_select_all_checkbox;
800  $this->select_all_on_top = $a_select_all_on_top;
801  }
802 
803  public function setExternalSorting(bool $a_val): void
804  {
805  $this->ext_sort = $a_val;
806  }
807 
808  public function getExternalSorting(): bool
809  {
810  return $this->ext_sort;
811  }
812 
813  public function setFilterCommand(
814  string $a_val,
815  string $a_caption = ""
816  ): void {
817  $this->filter_cmd = $a_val;
818  $this->filter_cmd_txt = $a_caption;
819  }
820 
821  public function getFilterCommand(): string
822  {
823  return $this->filter_cmd;
824  }
825 
826  public function setResetCommand(
827  string $a_val,
828  string $a_caption = ""
829  ): void {
830  $this->reset_cmd = $a_val;
831  $this->reset_cmd_txt = $a_caption;
832  }
833 
834  public function getResetCommand(): string
835  {
836  return $this->reset_cmd;
837  }
838 
839  public function setExternalSegmentation(bool $a_val): void
840  {
841  $this->ext_seg = $a_val;
842  }
843 
844  public function getExternalSegmentation(): bool
845  {
846  return $this->ext_seg;
847  }
848 
854  final public function setRowTemplate(string $a_template, string $a_template_dir = ""): void
855  {
856  $this->row_template = $a_template;
857  $this->row_template_dir = $a_template_dir;
858  }
859 
860  public function setDefaultOrderField(string $a_defaultorderfield): void
861  {
862  $this->defaultorderfield = $a_defaultorderfield;
863  }
864 
865  public function getDefaultOrderField(): string
866  {
868  }
869 
870 
871  public function setDefaultOrderDirection(string $a_defaultorderdirection): void
872  {
873  $this->defaultorderdirection = $a_defaultorderdirection;
874  }
875 
876  public function getDefaultOrderDirection(): string
877  {
879  }
880 
881  public function setDefaultFilterVisiblity(bool $a_status): void
882  {
883  $this->default_filter_visibility = $a_status;
884  }
885 
886  public function getDefaultFilterVisibility(): bool
887  {
889  }
890 
891  public function clearCommandButtons(): void
892  {
893  $this->buttons = array();
894  }
895 
896  public function addCommandButton(
897  string $a_cmd,
898  string $a_text,
899  string $a_onclick = '',
900  string $a_id = "",
901  string $a_class = ""
902  ): void {
903  $this->buttons[] = array("cmd" => $a_cmd, "text" => $a_text, 'onclick' => $a_onclick,
904  "id" => $a_id, "class" => $a_class);
905  }
906 
907  public function addCommandButtonInstance(ilButtonBase $a_button): void
908  {
909  $this->buttons[] = $a_button;
910  }
911 
921  string $a_sel_var,
922  array $a_options,
923  string $a_cmd,
924  string $a_text,
925  string $a_default_selection = ''
926  ): void {
927  $this->mi_sel_buttons[] = array("sel_var" => $a_sel_var, "options" => $a_options, "selected" => $a_default_selection, "cmd" => $a_cmd, "text" => $a_text);
928  $this->addHiddenInput("cmd_sv[" . $a_cmd . "]", $a_sel_var);
929  }
930 
931  public function setCloseCommand(string $a_link): void
932  {
933  $this->close_command = $a_link;
934  }
935 
936  public function addMultiCommand(string $a_cmd, string $a_text): void
937  {
938  $this->multi[] = array("cmd" => $a_cmd, "text" => $a_text);
939  }
940 
941  public function addHiddenInput(string $a_name, string $a_value): void
942  {
943  $this->hidden_inputs[] = array("name" => $a_name, "value" => $a_value);
944  }
945 
946  public function addHeaderCommand(
947  string $a_href,
948  string $a_text,
949  string $a_target = "",
950  string $a_img = ""
951  ): void {
952  $this->header_commands[] = array("href" => $a_href, "text" => $a_text,
953  "target" => $a_target, "img" => $a_img);
954  }
955 
956  public function setTopCommands(bool $a_val): void
957  {
958  $this->top_commands = $a_val;
959  }
960 
961  public function getTopCommands(): bool
962  {
963  return $this->top_commands;
964  }
965 
966  final public function addColumn(
967  string $a_text,
968  string $a_sort_field = "",
969  string $a_width = "",
970  bool $a_is_checkbox_action_column = false,
971  string $a_class = "",
972  string $a_tooltip = "",
973  bool $a_tooltip_with_html = false
974  ): void {
975  $this->column[] = array(
976  "text" => $a_text,
977  "sort_field" => $a_sort_field,
978  "width" => $a_width,
979  "is_checkbox_action_column" => $a_is_checkbox_action_column,
980  "class" => $a_class,
981  "tooltip" => $a_tooltip,
982  "tooltip_html" => $a_tooltip_with_html
983  );
984  if ($a_sort_field != "") {
985  $this->sortable_fields[] = $a_sort_field;
986  }
987  $this->column_count = count($this->column);
988  }
989 
990 
991  final public function getNavParameter(): string
992  {
993  return $this->prefix . "_table_nav";
994  }
995 
996  public function setOrderLink(string $key, string $order_dir): void
997  {
998  global $DIC;
999 
1000  $ilUser = $DIC->user();
1001 
1002  $ilCtrl = $this->ctrl;
1003 
1004  $hash = "";
1005 
1006  $old = $this->requested_nav_par ?? '';
1007 
1008  // set order link
1009  $ilCtrl->setParameter(
1010  $this->parent_obj,
1011  $this->getNavParameter(),
1012  urlencode($key) . ":" . $order_dir . ":" . $this->offset
1013  );
1014  $this->tpl->setVariable(
1015  "TBL_ORDER_LINK",
1016  $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd) . $hash
1017  );
1018 
1019  // set old value of nav variable
1020  $ilCtrl->setParameter(
1021  $this->parent_obj,
1022  $this->getNavParameter(),
1023  $old
1024  );
1025  }
1026 
1027  public function fillHeader(): void
1028  {
1029  $lng = $this->lng;
1030 
1031  $allcolumnswithwidth = true;
1032  foreach ($this->column as $idx => $column) {
1033  if (!strlen($column["width"])) {
1034  $allcolumnswithwidth = false;
1035  } elseif ($column["width"] == "1") {
1036  // IE does not like 1 but seems to work with 1%
1037  $this->column[$idx]["width"] = "1%";
1038  }
1039  }
1040  if ($allcolumnswithwidth) {
1041  foreach ($this->column as $column) {
1042  $this->tpl->setCurrentBlock("tbl_colgroup_column");
1043  $width = (is_numeric($column["width"]))
1044  ? $column["width"] . "px"
1045  : $column["width"];
1046  $this->tpl->setVariable("COLGROUP_COLUMN_WIDTH", " style=\"width:" . $width . "\"");
1047  $this->tpl->parseCurrentBlock();
1048  }
1049  }
1050  $ccnt = 0;
1051  foreach ($this->column as $column) {
1052  $ccnt++;
1053  //tooltip
1054  if ($column["tooltip"] != "") {
1056  "thc_" . $this->getId() . "_" . $ccnt,
1057  $column["tooltip"],
1058  "",
1059  "bottom center",
1060  "top center",
1061  !$column["tooltip_html"]
1062  );
1063  }
1064 
1065  if ($column['is_checkbox_action_column'] && $this->select_all_on_top) {
1066  $this->tpl->setCurrentBlock('tbl_header_top_select_all');
1067  $this->tpl->setVariable("HEAD_SELECT_ALL_TXT_SELECT_ALL", $lng->txt("select_all"));
1068  $this->tpl->setVariable("HEAD_SELECT_ALL_CHECKBOX_NAME", $this->getSelectAllCheckbox());
1069  $this->tpl->setVariable("HEAD_SELECT_ALL_FORM_NAME", $this->getFormName());
1070  $this->tpl->setVariable("HEAD_CHECKBOXNAME", "chb_select_all_" . $this->unique_id . '_top');
1071  $this->tpl->parseCurrentBlock();
1072  continue;
1073  }
1074 
1075  if ($column['is_checkbox_action_column'] && !$this->select_all_on_top) {
1076  $this->tpl->setCurrentBlock('tbl_header_top_select_column');
1077  if ($column["width"] != "") {
1078  $width = (is_numeric($column["width"]))
1079  ? $column["width"] . "px"
1080  : $column["width"];
1081  $this->tpl->setVariable("TBL_COLUMN_WIDTH", " style=\"width:" . $width . "\"");
1082  }
1083  $this->tpl->parseCurrentBlock();
1084  continue;
1085  }
1086 
1087  if (
1088  !$this->enabled["sort"] ||
1089  (($column["sort_field"] == "") &&
1090  !($column["is_checkbox_action_column"] && $this->select_all_on_top))
1091  ) {
1092  $this->tpl->setCurrentBlock("tbl_header_no_link");
1093  if ($column["width"] != "") {
1094  $width = (is_numeric($column["width"]))
1095  ? $column["width"] . "px"
1096  : $column["width"];
1097  $this->tpl->setVariable("TBL_COLUMN_WIDTH_NO_LINK", " style=\"width:" . $width . "\"");
1098  }
1099  if ($column["class"] != "") {
1100  $this->tpl->setVariable("TBL_COLUMN_CLASS_NO_LINK", " class=\"" . $column["class"] . "\"");
1101  }
1102  if (!$column["is_checkbox_action_column"]) {
1103  $this->tpl->setVariable(
1104  "TBL_HEADER_CELL_NO_LINK",
1105  $column["text"]
1106  );
1107  } else {
1108  $this->tpl->setVariable(
1109  "TBL_HEADER_CELL_NO_LINK",
1110  ilUtil::img(ilUtil::getImagePath("media/spacer.png"), $lng->txt("action"))
1111  );
1112  }
1113  $this->tpl->setVariable("HEAD_CELL_NL_ID", "thc_" . $this->getId() . "_" . $ccnt);
1114  if ($column["class"] != "") {
1115  $this->tpl->setVariable("TBL_HEADER_CLASS", " " . $column["class"]);
1116  }
1117  $this->tpl->parseCurrentBlock();
1118  $this->tpl->touchBlock("tbl_header_th");
1119  continue;
1120  }
1121  if (($column["sort_field"] == $this->order_field) && ($this->order_direction != "")) {
1122  $this->tpl->setCurrentBlock("tbl_order_image");
1123  if ($this->order_direction === "asc") {
1124  $this->tpl->setVariable("ORDER_CLASS", "glyphicon glyphicon-arrow-up");
1125  $this->tpl->setVariable("ORDER_TXT", $this->lng->txt("sorting_asc"));
1126  } else {
1127  $this->tpl->setVariable("ORDER_CLASS", "glyphicon glyphicon-arrow-down");
1128  $this->tpl->setVariable("ORDER_TXT", $this->lng->txt("sorting_desc"));
1129  }
1130  $this->tpl->setVariable("IMG_ORDER_ALT", $this->lng->txt("change_sort_direction"));
1131  $this->tpl->parseCurrentBlock();
1132  }
1133 
1134  $this->tpl->setCurrentBlock("tbl_header_cell");
1135  $this->tpl->setVariable("TBL_HEADER_CELL", $column["text"]);
1136  $this->tpl->setVariable("HEAD_CELL_ID", "thc_" . $this->getId() . "_" . $ccnt);
1137 
1138  // only set width if a value is given for that column
1139  if ($column["width"] != "") {
1140  $width = (is_numeric($column["width"]))
1141  ? $column["width"] . "px"
1142  : $column["width"];
1143  $this->tpl->setVariable("TBL_COLUMN_WIDTH", " style=\"width:" . $width . "\"");
1144  }
1145  if ($column["class"] != "") {
1146  $this->tpl->setVariable("TBL_COLUMN_CLASS", " class=\"" . $column["class"] . "\"");
1147  }
1148 
1149  $lng_sort_column = $this->lng->txt("sort_by_this_column");
1150  $this->tpl->setVariable("TBL_ORDER_ALT", $lng_sort_column);
1151 
1152  $order_dir = "asc";
1153 
1154  if ($column["sort_field"] == $this->order_field) {
1155  $order_dir = $this->sort_order;
1156 
1157  if ($order_dir === "asc") {
1158  $lng_change_sort = $this->lng->txt("sort_ascending_long");
1159  } else {
1160  $lng_change_sort = $this->lng->txt("sort_descending_long");
1161  }
1162  $this->tpl->setVariable("TBL_ORDER_ALT", $lng_change_sort);
1163  }
1164 
1165  if ($column["class"] != "") {
1166  $this->tpl->setVariable("TBL_HEADER_CLASS", " " . $column["class"]);
1167  }
1168  $this->setOrderLink($column["sort_field"], $order_dir);
1169  $this->tpl->parseCurrentBlock();
1170  $this->tpl->touchBlock("tbl_header_th");
1171  }
1172 
1173  $this->tpl->setCurrentBlock("tbl_header");
1174  $this->tpl->parseCurrentBlock();
1175  }
1176 
1180  protected function prepareOutput(): void
1181  {
1182  }
1183 
1184  public function determineOffsetAndOrder(bool $a_omit_offset = false): void
1185  {
1186  global $DIC;
1187 
1188  $ilUser = null;
1189  if (isset($DIC["ilUser"])) {
1190  $ilUser = $DIC["ilUser"];
1191  }
1192 
1193  if ($this->nav_determined) {
1194  return;
1195  }
1196 
1197  if ($this->requested_nav_par1 != "") {
1198  if ($this->requested_nav_par1 != ($this->requested_nav_par ?? "")) {
1199  $this->nav_value = $this->requested_nav_par1;
1200  } elseif (
1201  $this->requested_nav_par2 != "" &&
1202  $this->requested_nav_par2 != $this->requested_nav_par
1203  ) {
1204  $this->nav_value = $this->requested_nav_par2;
1205  }
1206  } elseif ($this->requested_nav_par != "") {
1207  $this->nav_value = $this->requested_nav_par;
1208  }
1209 
1210  if ($this->nav_value == "" && $this->getId() != "" && $ilUser->getId() != ANONYMOUS_USER_ID) {
1211  $order = $this->loadProperty("order");
1212  if (in_array($order, $this->sortable_fields)) {
1213  $direction = $this->loadProperty("direction");
1214  } else {
1215  $direction = $this->getDefaultOrderDirection();
1216  }
1217  // get order and direction from db
1218  $this->nav_value =
1219  $order . ":" .
1220  $direction . ":" .
1221  $this->loadProperty("offset");
1222  }
1223  $nav = explode(":", $this->nav_value);
1224 
1225  // $nav[0] is order by
1226  $req_order_field = $nav[0] ?? "";
1227  $req_order_dir = $nav[1] ?? "";
1228  $req_offset = (int) ($nav[2] ?? 0);
1229  $this->setOrderField(($req_order_field != "") ? $req_order_field : $this->getDefaultOrderField());
1230  $this->setOrderDirection(($req_order_dir != "") ? $req_order_dir : $this->getDefaultOrderDirection());
1231 
1232  if (!$a_omit_offset) {
1233  // #8904: offset must be discarded when no limit is given
1234  if (!$this->getExternalSegmentation() && $this->limit_determined && $this->limit == 9999) {
1235  $this->resetOffset(true);
1236  } elseif (!$this->getExternalSegmentation() && $req_offset >= $this->max_count) {
1237  $this->resetOffset(true);
1238  } else {
1239  $this->setOffset($req_offset);
1240  }
1241  }
1242 
1243  if (!$a_omit_offset) {
1244  $this->nav_determined = true;
1245  }
1246  }
1247 
1248  public function storeNavParameter(): void
1249  {
1250  if ($this->getOrderField() != "") {
1251  $this->storeProperty("order", $this->getOrderField());
1252  }
1253  if ($this->getOrderDirection() != "") {
1254  $this->storeProperty("direction", $this->getOrderDirection());
1255  }
1256  if ($this->getOffset() >= 0) {
1257  $this->storeProperty("offset", (string) $this->getOffset());
1258  }
1259  }
1260 
1261 
1265  public function getHTML(): string
1266  {
1267  global $DIC;
1268 
1269  $ilUser = null;
1270  if (isset($DIC["ilUser"])) {
1271  $ilUser = $DIC["ilUser"];
1272  }
1273 
1274  $lng = $this->lng;
1275  $ilCtrl = $this->ctrl;
1276 
1277 
1278  if ($this->getExportMode() > 0) {
1279  $this->exportData($this->getExportMode(), true);
1280  }
1281 
1282  $this->prepareOutput();
1283 
1284  if (is_object($ilCtrl) && is_object($this->getParentObject()) && $this->getId() == "") {
1285  $ilCtrl->saveParameter($this->getParentObject(), $this->getNavParameter());
1286  }
1287 
1288  if (!$this->getPrintMode()) {
1289  // set form action
1290  if ($this->form_action != "" && $this->getOpenFormTag()) {
1291  $hash = "";
1292 
1293  if ($this->form_multipart) {
1294  $this->tpl->touchBlock("form_multipart_bl");
1295  }
1296 
1297  if ($this->getPreventDoubleSubmission()) {
1298  $this->tpl->touchBlock("pdfs");
1299  }
1300 
1301  $this->tpl->setCurrentBlock("tbl_form_header");
1302  $this->tpl->setVariable("FORMACTION", $this->getFormAction() . $hash);
1303  $this->tpl->setVariable("FORMNAME", $this->getFormName());
1304  $this->tpl->parseCurrentBlock();
1305  }
1306 
1307  if ($this->form_action != "" && $this->getCloseFormTag()) {
1308  $this->tpl->touchBlock("tbl_form_footer");
1309  }
1310  }
1311 
1312  if (!$this->enabled['content']) {
1313  return $this->render();
1314  }
1315 
1316  if (!$this->getExternalSegmentation()) {
1317  $this->setMaxCount(count($this->row_data));
1318  }
1319 
1320  $this->determineOffsetAndOrder();
1321 
1322  $this->setFooter("tblfooter", $this->lng->txt("previous"), $this->lng->txt("next"));
1323 
1324  $data = $this->getData();
1325  if ($this->dataExists()) {
1326  // sort
1327  if (!$this->getExternalSorting() && $this->enabled["sort"]) {
1328  $data = ilArrayUtil::sortArray(
1329  $data,
1330  $this->getOrderField(),
1331  $this->getOrderDirection(),
1332  $this->numericOrdering($this->getOrderField())
1333  );
1334  }
1335 
1336  // slice
1337  if (!$this->getExternalSegmentation()) {
1338  $data = array_slice($data, $this->getOffset(), $this->getLimit());
1339  }
1340  }
1341 
1342  // fill rows
1343  if ($this->dataExists()) {
1344  if ($this->getPrintMode()) {
1346  }
1347 
1348  $this->tpl->addBlockFile(
1349  "TBL_CONTENT",
1350  "tbl_content",
1351  $this->row_template,
1352  $this->row_template_dir
1353  );
1354 
1355  foreach ($data as $set) {
1356  $this->tpl->setCurrentBlock("tbl_content");
1357  $this->css_row = ($this->css_row !== "tblrow1")
1358  ? "tblrow1"
1359  : "tblrow2";
1360  $this->tpl->setVariable("CSS_ROW", $this->css_row);
1361 
1362  $this->fillRow($set);
1363  $this->tpl->setCurrentBlock("tbl_content");
1364  $this->tpl->parseCurrentBlock();
1365  }
1366  } else {
1367  // add standard no items text (please tell me, if it messes something up, alex, 29.8.2008)
1368  $no_items_text = (trim($this->getNoEntriesText()) != '')
1369  ? $this->getNoEntriesText()
1370  : $lng->txt("no_items");
1371 
1372  $this->css_row = ($this->css_row !== "tblrow1")
1373  ? "tblrow1"
1374  : "tblrow2";
1375 
1376  $this->tpl->setCurrentBlock("tbl_no_entries");
1377  $this->tpl->setVariable('TBL_NO_ENTRY_CSS_ROW', $this->css_row);
1378  $this->tpl->setVariable('TBL_NO_ENTRY_COLUMN_COUNT', $this->column_count);
1379  $this->tpl->setVariable('TBL_NO_ENTRY_TEXT', trim($no_items_text));
1380  $this->tpl->parseCurrentBlock();
1381  }
1382 
1383 
1384  if (!$this->getPrintMode()) {
1385  $this->fillFooter();
1386 
1387  $this->fillHiddenRow();
1388 
1389  $this->fillActionRow();
1390 
1391  $this->storeNavParameter();
1392  }
1393 
1394  return $this->render();
1395  }
1396 
1400  public function numericOrdering(string $a_field): bool
1401  {
1402  return false;
1403  }
1404 
1405  public function render(): string
1406  {
1407  $lng = $this->lng;
1408 
1409  $this->tpl->setVariable("CSS_TABLE", $this->getStyle("table"));
1410  if ($this->getId() != "") {
1411  $this->tpl->setVariable("ID", 'id="' . $this->getId() . '"');
1412  }
1413 
1414  // description
1415  if ($this->getDescription() != "") {
1416  $this->tpl->setCurrentBlock("tbl_header_description");
1417  $this->tpl->setVariable("TBL_DESCRIPTION", $this->getDescription());
1418  $this->tpl->parseCurrentBlock();
1419  }
1420 
1421  if (!$this->getPrintMode()) {
1422  $this->renderFilter();
1423  }
1424 
1425  if ($this->getDisplayAsBlock()) {
1426  $this->tpl->touchBlock("outer_start_1");
1427  $this->tpl->touchBlock("outer_end_1");
1428  } else {
1429  $this->tpl->touchBlock("outer_start_2");
1430  $this->tpl->touchBlock("outer_end_2");
1431  }
1432 
1433  // table title and icon
1434  if ($this->enabled["title"] && ($this->title != ""
1435  || $this->icon != "" || count($this->header_commands) > 0 ||
1436  $this->headerHTML != "" || $this->close_command != "")) {
1437  if ($this->enabled["icon"]) {
1438  $this->tpl->setCurrentBlock("tbl_header_title_icon");
1439  $this->tpl->setVariable("TBL_TITLE_IMG", ilUtil::getImagePath($this->icon));
1440  $this->tpl->setVariable("TBL_TITLE_IMG_ALT", $this->icon_alt);
1441  $this->tpl->parseCurrentBlock();
1442  }
1443 
1444  if (!$this->getPrintMode()) {
1445  foreach ($this->header_commands as $command) {
1446  if ($command["img"] != "") {
1447  $this->tpl->setCurrentBlock("tbl_header_img_link");
1448  if ($command["target"] != "") {
1449  $this->tpl->setVariable(
1450  "TARGET_IMG_LINK",
1451  'target="' . $command["target"] . '"'
1452  );
1453  }
1454  $this->tpl->setVariable("ALT_IMG_LINK", $command["text"]);
1455  $this->tpl->setVariable("HREF_IMG_LINK", $command["href"]);
1456  $this->tpl->setVariable(
1457  "SRC_IMG_LINK",
1458  $command["img"]
1459  );
1460  } else {
1461  $this->tpl->setCurrentBlock("head_cmd");
1462  $this->tpl->setVariable("TXT_HEAD_CMD", $command["text"]);
1463  $this->tpl->setVariable("HREF_HEAD_CMD", $command["href"]);
1464  }
1465  $this->tpl->parseCurrentBlock();
1466  }
1467  }
1468 
1469  if (isset($this->headerHTML)) {
1470  $this->tpl->setCurrentBlock("tbl_header_html");
1471  $this->tpl->setVariable("HEADER_HTML", $this->headerHTML);
1472  $this->tpl->parseCurrentBlock();
1473  }
1474 
1475  // close command
1476  if ($this->close_command != "") {
1477  $this->tpl->setCurrentBlock("tbl_header_img_link");
1478  $this->tpl->setVariable("ALT_IMG_LINK", $lng->txt("close"));
1479  $this->tpl->setVariable("HREF_IMG_LINK", $this->close_command);
1480  $this->tpl->parseCurrentBlock();
1481  }
1482 
1483  $this->tpl->setCurrentBlock("tbl_header_title");
1484  $this->tpl->setVariable("TBL_TITLE", $this->title);
1485  if ($this->getDisplayAsBlock()) {
1486  $this->tpl->setVariable("BLK_CLASS", "Block");
1487  }
1488  $this->tpl->parseCurrentBlock();
1489  }
1490 
1491  // table header
1492  if ($this->enabled["header"]) {
1493  $this->fillHeader();
1494  }
1495 
1496  $this->tpl->touchBlock("tbl_table_end");
1497 
1498  return $this->tpl->get();
1499  }
1500 
1504  private function renderFilter(): void
1505  {
1506  global $DIC;
1507 
1508  $lng = $this->lng;
1509  $main_tpl = $DIC["tpl"];
1510 
1511  $filter = $this->getFilterItems();
1512  $opt_filter = $this->getFilterItems(true);
1513 
1514  $main_tpl->addJavascript("assets/js/ServiceTable.js");
1515 
1516  if (count($filter) == 0 && count($opt_filter) == 0) {
1517  return;
1518  }
1519 
1521 
1522  $ccnt = 0;
1523 
1524  // render standard filter
1525  if (count($filter) > 0) {
1526  foreach ($filter as $item) {
1527  if ($ccnt >= $this->getFilterCols()) {
1528  $this->tpl->setCurrentBlock("filter_row");
1529  $this->tpl->parseCurrentBlock();
1530  $ccnt = 0;
1531  }
1532  $this->tpl->setCurrentBlock("filter_item");
1533  $this->tpl->setVariable(
1534  "OPTION_NAME",
1535  $item->getTitle()
1536  );
1537  $this->tpl->setVariable(
1538  "F_INPUT_ID",
1539  $item->getTableFilterLabelFor()
1540  );
1541  $this->tpl->setVariable(
1542  "INPUT_HTML",
1543  $item->getTableFilterHTML()
1544  );
1545  $this->tpl->parseCurrentBlock();
1546  $ccnt++;
1547  }
1548  }
1549 
1550  // render optional filter
1551  if (count($opt_filter) > 0) {
1552  $this->determineSelectedFilters();
1553 
1554  foreach ($opt_filter as $item) {
1555  if ($this->isFilterSelected($item->getPostVar())) {
1556  if ($ccnt >= $this->getFilterCols()) {
1557  $this->tpl->setCurrentBlock("filter_row");
1558  $this->tpl->parseCurrentBlock();
1559  $ccnt = 0;
1560  }
1561  $this->tpl->setCurrentBlock("filter_item");
1562  $this->tpl->setVariable(
1563  "OPTION_NAME",
1564  $item->getTitle()
1565  );
1566  $this->tpl->setVariable(
1567  "F_INPUT_ID",
1568  $item->getFieldId()
1569  );
1570  $this->tpl->setVariable(
1571  "INPUT_HTML",
1572  $item->getTableFilterHTML()
1573  );
1574  $this->tpl->parseCurrentBlock();
1575  $ccnt++;
1576  }
1577  }
1578 
1579  // filter selection
1580  $items = array();
1581  foreach ($opt_filter as $item) {
1582  $k = $item->getPostVar();
1583  $items[$k] = array("txt" => $item->getTitle(),
1584  "selected" => $this->isFilterSelected($k));
1585  }
1586 
1587  $cb_over = new ilCheckboxListOverlayGUI("tbl_filters_" . $this->getId());
1588  $cb_over->setLinkTitle($lng->txt("optional_filters"));
1589  $cb_over->setItems($items);
1590 
1591  $cb_over->setFormCmd($this->getParentCmd());
1592  $cb_over->setFieldVar("tblff" . $this->getId());
1593  $cb_over->setHiddenVar("tblfsf" . $this->getId());
1594 
1595  $cb_over->setSelectionHeaderClass("ilTableMenuItem");
1596  $this->tpl->setCurrentBlock("filter_select");
1597 
1598  // apply should be the first submit because of enter/return, inserting hidden submit
1599  $this->tpl->setVariable("HIDDEN_CMD_APPLY", $this->filter_cmd);
1600 
1601  $this->tpl->setVariable("FILTER_SELECTOR", $cb_over->getHTML(false));
1602  $this->tpl->parseCurrentBlock();
1603  }
1604 
1605  // if any filter
1606  if ($ccnt > 0 || count($opt_filter) > 0) {
1607  $this->tpl->setVariable("TXT_FILTER", $lng->txt("filter"));
1608 
1609  if ($ccnt > 0) {
1610  if ($ccnt < $this->getFilterCols()) {
1611  for ($i = $ccnt; $i <= $this->getFilterCols(); $i++) {
1612  $this->tpl->touchBlock("filter_empty_cell");
1613  }
1614  }
1615  $this->tpl->setCurrentBlock("filter_row");
1616  $this->tpl->parseCurrentBlock();
1617 
1618  $this->tpl->setCurrentBlock("filter_buttons");
1619  $this->tpl->setVariable("CMD_APPLY", $this->filter_cmd);
1620  $this->tpl->setVariable("TXT_APPLY", $this->filter_cmd_txt
1621  ?: $lng->txt("apply_filter"));
1622  $this->tpl->setVariable("CMD_RESET", $this->reset_cmd);
1623  $this->tpl->setVariable("TXT_RESET", $this->reset_cmd_txt
1624  ?: $lng->txt("reset_filter"));
1625  } elseif (count($opt_filter) > 0) {
1626  $this->tpl->setCurrentBlock("optional_filter_hint");
1627  $this->tpl->setVariable('TXT_OPT_HINT', $lng->txt('optional_filter_hint'));
1628  $this->tpl->parseCurrentBlock();
1629  }
1630 
1631  $this->tpl->setCurrentBlock("filter_section");
1632  $this->tpl->setVariable("FIL_ID", $this->getId());
1633  $this->tpl->parseCurrentBlock();
1634 
1635  // (keep) filter hidden?
1636  if (!$this->isFilterVisible() && !$this->getDisableFilterHiding()) {
1637  $id = $this->getId();
1638  $this->main_tpl->addOnLoadCode("
1639  ilTableHideFilter['atfil_$id'] = true;
1640  ilTableHideFilter['tfil_$id'] = true;
1641  ilTableHideFilter['dtfil_$id'] = true;
1642  ");
1643  }
1644  /*
1645  * BT 35757: filter has to be initialized after it has a chance to get hidden,
1646  * moving this here from ServiceTable.js to avoid timing weirdness with onLoadCode.
1647  */
1648  $this->main_tpl->addOnLoadCode("ilInitTableFilters()");
1649  }
1650  }
1651 
1655  protected function isFilterVisible(): bool
1656  {
1657  $prop = $this->loadProperty('filter');
1658  if ($prop === '0' || $prop === '1') {
1659  return (bool) $prop;
1660  }
1661  return $this->getDefaultFilterVisibility();
1662  }
1663 
1667  protected function isAdvMDFilter(
1668  ilAdvancedMDRecordGUI $a_gui,
1669  ilTableFilterItem $a_element
1670  ): bool {
1671  foreach ($a_gui->getFilterElements(false) as $item) {
1672  if ($item === $a_element) {
1673  return true;
1674  }
1675  }
1676  return false;
1677  }
1678 
1679  public function writeFilterToSession(): void
1680  {
1681  $advmd_record_gui = null;
1682  if (method_exists($this, "getAdvMDRecordGUI")) {
1683  $advmd_record_gui = $this->getAdvMDRecordGUI();
1684  }
1685 
1686  foreach ($this->getFilterItems() as $item) {
1687  if ($advmd_record_gui &&
1688  $this->isAdvMDFilter($advmd_record_gui, $item)) {
1689  continue;
1690  }
1691 
1692  if ($item->checkInput()) {
1693  $item->setValueByArray($this->raw_post_data);
1694  $item->writeToSession();
1695  }
1696  }
1697  foreach ($this->getFilterItems(true) as $item) {
1698  if ($advmd_record_gui &&
1699  $this->isAdvMDFilter($advmd_record_gui, $item)) {
1700  continue;
1701  }
1702 
1703  if ($item->checkInput()) {
1704  $item->setValueByArray($this->raw_post_data);
1705  $item->writeToSession();
1706  }
1707  }
1708 
1709  if ($advmd_record_gui) {
1710  $advmd_record_gui->importFilter();
1711  }
1712 
1713  // #13209
1714  $this->requested_tmpl_create = "";
1715  $this->requested_tmpl_delete = "";
1716  }
1717 
1718  public function resetFilter(): void
1719  {
1720  $filter = $this->getFilterItems();
1721  $opt_filter = $this->getFilterItems(true);
1722 
1723  foreach ($filter as $item) {
1724  if ($item->checkInput()) {
1725  // see #26490
1726  $item->setValueByArray([]);
1727  $item->clearFromSession();
1728  }
1729  }
1730  foreach ($opt_filter as $item) {
1731  if ($item->checkInput()) {
1732  // see #26490
1733  $item->setValueByArray([]);
1734  $item->clearFromSession();
1735  }
1736  }
1737 
1738  // #13209
1739  $this->requested_tmpl_create = "";
1740  $this->requested_tmpl_delete = "";
1741  }
1742 
1748  protected function fillRow(array $a_set): void
1749  {
1750  foreach ($a_set as $key => $value) {
1751  $this->tpl->setVariable("VAL_" . strtoupper($key), $value);
1752  }
1753  }
1754 
1755  public function fillFooter(): void
1756  {
1757  global $DIC;
1758 
1759  $ilUser = null;
1760  if (isset($DIC["ilUser"])) {
1761  $ilUser = $DIC["ilUser"];
1762  }
1763 
1764  $ui_factory = $this->ui->factory();
1765  $ui_renderer = $this->ui->renderer();
1766 
1767  $lng = $this->lng;
1768  $ilCtrl = $this->ctrl;
1769 
1770  $footer = false;
1771  $numinfo = '';
1772  $linkbar = '';
1773  $column_selector = '';
1774 
1775  // select all checkbox
1776  if ((strlen($this->getFormName())) && (strlen($this->getSelectAllCheckbox())) && $this->dataExists()) {
1777  $this->tpl->setCurrentBlock("select_all_checkbox");
1778  $this->tpl->setVariable("SELECT_ALL_TXT_SELECT_ALL", $lng->txt("select_all"));
1779  $this->tpl->setVariable("SELECT_ALL_CHECKBOX_NAME", $this->getSelectAllCheckbox());
1780  $this->tpl->setVariable("SELECT_ALL_FORM_NAME", $this->getFormName());
1781  $this->tpl->setVariable("CHECKBOXNAME", "chb_select_all_" . $this->unique_id);
1782  $this->tpl->parseCurrentBlock();
1783  }
1784 
1785  // table footer numinfo
1786  if ($this->enabled["numinfo"] && $this->enabled["footer"]) {
1787  $start = $this->offset + 1; // compute num info
1788  if (!$this->dataExists()) {
1789  $start = 0;
1790  }
1791  $end = $this->offset + $this->limit;
1792 
1793  if ($end > $this->max_count or $this->limit == 0) {
1794  $end = $this->max_count;
1795  }
1796 
1797  if ($this->max_count > 0) {
1798  if ($this->lang_support) {
1799  $numinfo = "(" . $start . " - " . $end . " " . strtolower($this->lng->txt("of")) . " " . $this->max_count . ")";
1800  } else {
1801  $numinfo = "(" . $start . " - " . $end . " of " . $this->max_count . ")";
1802  }
1803  }
1804  if ($this->max_count > 0) {
1805  if ($this->getEnableNumInfo()) {
1806  $this->tpl->setCurrentBlock("tbl_footer_numinfo");
1807  $this->tpl->setVariable("NUMINFO", $numinfo);
1808  $this->tpl->parseCurrentBlock();
1809  }
1810  }
1811  $footer = true;
1812  }
1813 
1814  // table footer linkbar
1815  if ($this->enabled["linkbar"] && $this->enabled["footer"] && $this->limit != 0
1816  && $this->max_count > 0) {
1817  $linkbar = $this->getLinkbar("1");
1818  $this->tpl->setCurrentBlock("tbl_footer_linkbar");
1819  $this->tpl->setVariable("LINKBAR", $linkbar);
1820  $this->tpl->parseCurrentBlock();
1821  $linkbar = true;
1822  $footer = true;
1823  }
1824 
1825  // column selector
1826  if (is_array($this->getSelectableColumns()) && count($this->getSelectableColumns()) > 0) {
1827  $items = array();
1828  foreach ($this->getSelectableColumns() as $k => $c) {
1829  $items[$k] = array("txt" => $c["txt"],
1830  "selected" => $this->isColumnSelected($k));
1831  }
1832  $cb_over = new ilCheckboxListOverlayGUI("tbl_" . $this->getId());
1833  $cb_over->setLinkTitle($lng->txt("columns"));
1834  $cb_over->setItems($items);
1835  //$cb_over->setUrl("./ilias.php?baseClass=ilTablePropertiesStorage&table_id=".
1836  // $this->getId()."&cmd=saveSelectedFields&user_id=".$ilUser->getId());
1837  $cb_over->setFormCmd($this->getParentCmd());
1838  $cb_over->setFieldVar("tblfs" . $this->getId());
1839  $cb_over->setHiddenVar("tblfsh" . $this->getId());
1840  $cb_over->setSelectionHeaderClass("ilTableMenuItem");
1841  $column_selector = $cb_over->getHTML();
1842  $footer = true;
1843  }
1844  if ($this->getShowTemplates() && is_object($ilUser)) {
1845  // template handling
1846  if ($this->requested_tmpl_create != "") {
1847  if ($this->saveTemplate($this->requested_tmpl_create)) {
1848  $this->main_tpl->setOnScreenMessage('success', $lng->txt("tbl_template_created"));
1849  }
1850  } elseif ($this->requested_tmpl_delete != "") {
1851  if ($this->deleteTemplate($this->requested_tmpl_delete)) {
1852  $this->main_tpl->setOnScreenMessage('success', $lng->txt("tbl_template_deleted"));
1853  }
1854  }
1855 
1856  $create_id = "template_create_overlay_" . $this->getId();
1857  $delete_id = "template_delete_overlay_" . $this->getId();
1858  $list_id = "template_stg_" . $this->getId();
1859 
1860  $storage = new ilTableTemplatesStorage();
1861  $templates = $storage->getNames($this->getContext(), $ilUser->getId());
1862 
1863  // form to delete template
1864  if (count($templates) > 0) {
1865  $lng->loadLanguageModule("form");
1866  $this->tpl->setCurrentBlock("template_editor_delete_item");
1867  $this->tpl->setVariable("TEMPLATE_DELETE_OPTION_VALUE", "");
1868  $this->tpl->setVariable("TEMPLATE_DELETE_OPTION", "- " . $lng->txt("form_please_select") . " -");
1869  $this->tpl->parseCurrentBlock();
1870  foreach ($templates as $name) {
1871  $this->tpl->setVariable("TEMPLATE_DELETE_OPTION_VALUE", $name);
1872  $this->tpl->setVariable("TEMPLATE_DELETE_OPTION", $name);
1873  $this->tpl->parseCurrentBlock();
1874  }
1875 
1876  $this->tpl->setCurrentBlock("template_editor_delete");
1877  $this->tpl->setVariable("TEMPLATE_DELETE_ID", $delete_id);
1878  $this->tpl->setVariable("TXT_TEMPLATE_DELETE", $lng->txt("tbl_template_delete"));
1879  $this->tpl->setVariable("TXT_TEMPLATE_DELETE_SUBMIT", $lng->txt("delete"));
1880  $this->tpl->setVariable("TEMPLATE_DELETE_CMD", $this->parent_cmd);
1881  $this->tpl->parseCurrentBlock();
1882  }
1883 
1884  $this->tpl->setCurrentBlock("template_editor");
1885  $this->tpl->setVariable("TEMPLATE_CREATE_ID", $create_id);
1886  $this->tpl->setVariable("TXT_TEMPLATE_CREATE", $lng->txt("tbl_template_create"));
1887  $this->tpl->setVariable("TXT_TEMPLATE_CREATE_SUBMIT", $lng->txt("save"));
1888  $this->tpl->setVariable("TEMPLATE_CREATE_CMD", $this->parent_cmd);
1889  $this->tpl->parseCurrentBlock();
1890 
1891  // load saved template
1892  $actions = [];
1893  $actions[] = $ui_factory->button()->shy(
1894  $lng->txt("tbl_template_create"),
1895  ""
1896  )->withOnLoadCode(static function ($id) use ($list_id) {
1897  return "document.getElementById('$id').id = '" . $list_id . "_create';";
1898  });
1899  if (count($templates) > 0) {
1900  $actions[] = $ui_factory->button()->shy(
1901  $lng->txt("tbl_template_delete"),
1902  ""
1903  )->withOnLoadCode(static function ($id) use ($list_id) {
1904  return "document.getElementById('$id').id = '" . $list_id . "_delete';";
1905  });
1906  foreach ($templates as $name) {
1907  $ilCtrl->setParameter($this->parent_obj, $this->prefix . "_tpl", urlencode($name));
1908  $actions[] = $ui_factory->link()->standard(
1909  $name,
1910  $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd)
1911  );
1912  $ilCtrl->setParameter($this->parent_obj, $this->prefix . "_tpl", "");
1913  }
1914  }
1915  $dd = $ui_factory->dropdown()->standard(
1916  $actions
1917  )->withLabel($lng->txt("tbl_templates"));
1918  $this->tpl->setVariable("TEMPLATE_SELECTOR", "&nbsp;" . $ui_renderer->render($dd));
1919 
1920  // form to save new template
1921  $overlay = new ilOverlayGUI($create_id);
1922  $overlay->setTrigger($list_id . "_create");
1923  $overlay->setAnchor("ilAdvSelListAnchorElement_" . $list_id);
1924  $overlay->setAutoHide(false);
1925  $overlay->add();
1926 
1927  if (count($templates) > 0) {
1928  $overlay = new ilOverlayGUI($delete_id);
1929  $overlay->setTrigger($list_id . "_delete");
1930  $overlay->setAnchor("ilAdvSelListAnchorElement_" . $list_id);
1931  $overlay->setAutoHide(false);
1932  $overlay->add();
1933  }
1934  }
1935 
1936  if ($footer) {
1937  $this->tpl->setCurrentBlock("tbl_footer");
1938  $this->tpl->setVariable("COLUMN_COUNT", $this->getColumnCount());
1939  if ($this->getDisplayAsBlock()) {
1940  $this->tpl->setVariable("BLK_CLASS", "Block");
1941  }
1942  $this->tpl->parseCurrentBlock();
1943 
1944  // top navigation, if number info or linkbar given
1945  if ($numinfo != "" || $linkbar != "" || $column_selector != "" ||
1946  count($this->filters) > 0 || count($this->optional_filters) > 0) {
1947  if (is_object($ilUser) && (count($this->filters) || count($this->optional_filters))) {
1948  $this->tpl->setCurrentBlock("filter_activation");
1949  $this->tpl->setVariable("TXT_ACTIVATE_FILTER", $lng->txt("show_filter"));
1950  $this->tpl->setVariable("FILA_ID", $this->getId());
1951  if ($this->getId() != "") {
1952  $this->tpl->setVariable("SAVE_URLA", "./ilias.php?baseClass=ilTablePropertiesStorageGUI&table_id=" .
1953  $this->getId() . "&cmd=showFilter&user_id=" . $ilUser->getId());
1954  }
1955  $this->tpl->parseCurrentBlock();
1956 
1957 
1958  if (!$this->getDisableFilterHiding()) {
1959  $this->tpl->setCurrentBlock("filter_deactivation");
1960  $this->tpl->setVariable("TXT_HIDE", $lng->txt("hide_filter"));
1961  if ($this->getId() != "") {
1962  $this->tpl->setVariable("SAVE_URL", "./ilias.php?baseClass=ilTablePropertiesStorageGUI&table_id=" .
1963  $this->getId() . "&cmd=hideFilter&user_id=" . $ilUser->getId());
1964  $this->tpl->setVariable("FILD_ID", $this->getId());
1965  }
1966  $this->tpl->parseCurrentBlock();
1967  }
1968  }
1969 
1970  if ($numinfo != "" && $this->getEnableNumInfo()) {
1971  $this->tpl->setCurrentBlock("top_numinfo");
1972  $this->tpl->setVariable("NUMINFO", $numinfo);
1973  $this->tpl->parseCurrentBlock();
1974  }
1975  if ($linkbar != "" && !$this->getDisplayAsBlock()) {
1976  $linkbar = $this->getLinkbar("2");
1977  $this->tpl->setCurrentBlock("top_linkbar");
1978  $this->tpl->setVariable("LINKBAR", $linkbar);
1979  $this->tpl->parseCurrentBlock();
1980  }
1981 
1982  // column selector
1983  $this->tpl->setVariable("COLUMN_SELECTOR", $column_selector);
1984 
1985  // row selector
1986  if ($this->getShowRowsSelector() &&
1987  is_object($ilUser) &&
1988  $this->getId() &&
1989  !$this->rows_selector_off) { // JF, 2014-10-27
1990  $actions = [];
1991 
1992  $options = array(5 => 5, 10 => 10, 15 => 15, 20 => 20,
1993  30 => 30, 40 => 40, 50 => 50,
1994  100 => 100, 200 => 200, 400 => 400, 800 => 800);
1995  foreach ($options as $k => $v) {
1996  $ilCtrl->setParameter($this->parent_obj, $this->prefix . "_trows", $k);
1997  $actions[] = $ui_factory->link()->standard(
1998  $v,
1999  $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd)
2000  );
2001  $ilCtrl->setParameter($this->parent_obj, $this->prefix . "_trows", "");
2002  }
2003  $dd = $ui_factory->dropdown()->standard($actions)->withLabel(
2004  $this->getRowSelectorLabel() ?: $lng->txt("rows")
2005  );
2006  $this->tpl->setVariable("ROW_SELECTOR", $ui_renderer->render($dd));
2007  }
2008 
2009  // export
2010  if (count($this->export_formats) > 0 && $this->dataExists()) {
2011  $actions = [];
2012  foreach ($this->export_formats as $format => $caption_lng_id) {
2013  $ilCtrl->setParameter($this->parent_obj, $this->prefix . "_xpt", $format);
2014  $url = $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd);
2015  $ilCtrl->setParameter($this->parent_obj, $this->prefix . "_xpt", "");
2016  $actions[] = $ui_factory->link()->standard(
2017  $lng->txt($caption_lng_id),
2018  $url
2019  );
2020  }
2021  $dd = $ui_factory->dropdown()->standard($actions)->withLabel($lng->txt("export"));
2022  $this->tpl->setVariable("EXPORT_SELECTOR", "&nbsp;" . $ui_renderer->render($dd));
2023  }
2024 
2025  $this->tpl->setCurrentBlock("top_navigation");
2026  $this->tpl->setVariable("COLUMN_COUNT", $this->getColumnCount());
2027  if ($this->getDisplayAsBlock()) {
2028  $this->tpl->setVariable("BLK_CLASS", "Block");
2029  }
2030  $this->tpl->parseCurrentBlock();
2031  }
2032  }
2033  }
2034 
2035  public function getLinkbar(string $a_num): ?string
2036  {
2037  global $DIC;
2038 
2039  $ilUser = $DIC->user();
2040 
2041  $ilCtrl = $this->ctrl;
2042  $lng = $this->lng;
2043 
2044  $hash = "";
2045 
2046  $link = $ilCtrl->getLinkTargetByClass(get_class($this->parent_obj), $this->parent_cmd) .
2047  "&" . $this->getNavParameter() . "=" .
2048  $this->getOrderField() . ":" . $this->getOrderDirection() . ":";
2049 
2050  $LinkBar = "";
2051  $layout_prev = $lng->txt("previous");
2052  $layout_next = $lng->txt("next");
2053 
2054  // if more entries then entries per page -> show link bar
2055  if ($this->max_count > $this->getLimit() || $this->custom_prev_next) {
2056  $sep = "<span>&nbsp;&nbsp;|&nbsp;&nbsp;</span>";
2057 
2058  // calculate number of pages
2059  $pages = intval($this->max_count / $this->getLimit());
2060 
2061  // add a page if a rest remains
2062  if (($this->max_count % $this->getLimit())) {
2063  $pages++;
2064  }
2065 
2066  // links to other pages
2067  $offset_arr = array();
2068  for ($i = 1 ;$i <= $pages ; $i++) {
2069  $newoffset = $this->getLimit() * ($i - 1);
2070 
2071  $nav_value = $this->getOrderField() . ":" . $this->getOrderDirection() . ":" . $newoffset;
2072  $offset_arr[$nav_value] = $i;
2073  }
2074 
2075  $sep = "<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>";
2076 
2077  // previous link
2078  if ($this->custom_prev_next && $this->custom_prev != "") {
2079  $LinkBar .= "<a href=\"" . $this->custom_prev . $hash . "\">" . $layout_prev . "</a>";
2080  } elseif ($this->getOffset() >= 1 && !$this->custom_prev_next) {
2081  $prevoffset = $this->getOffset() - $this->getLimit();
2082  $LinkBar .= "<a href=\"" . $link . $prevoffset . $hash . "\">" . $layout_prev . "</a>";
2083  } else {
2084  $LinkBar .= '<span class="ilTableFootLight">' . $layout_prev . "</span>";
2085  }
2086 
2087  // current value
2088  if ($a_num == "1") {
2089  $LinkBar .= '<input type="hidden" name="' . $this->getNavParameter() .
2090  '" value="' . $this->getOrderField() . ":" . $this->getOrderDirection() . ":" . $this->getOffset() . '" />';
2091  }
2092 
2093  $sep = "<span>&nbsp;&nbsp;|&nbsp;&nbsp;</span>";
2094 
2095  // show next link (if not last page)
2096  $LinkBar .= $sep;
2097  if ($this->custom_prev_next && $this->custom_next != "") {
2098  $LinkBar .= "<a href=\"" . $this->custom_next . $hash . "\">" . $layout_next . "</a>";
2099  } elseif (!(($this->getOffset() / $this->getLimit()) == ($pages - 1)) && ($pages != 1) &&
2100  !$this->custom_prev_next) {
2101  $newoffset = $this->getOffset() + $this->getLimit();
2102  $LinkBar .= "<a href=\"" . $link . $newoffset . $hash . "\">" . $layout_next . "</a>";
2103  } else {
2104  $LinkBar .= '<span class="ilTableFootLight">' . $layout_next . "</span>";
2105  }
2106 
2107  $sep = "<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>";
2108 
2109  if (count($offset_arr) && !$this->getDisplayAsBlock() && !$this->custom_prev_next) {
2110  $LinkBar .= $sep;
2111 
2112  $LinkBar .=
2113  '<label for="tab_page_sel_' . $a_num . '">' . $lng->txt("page") . '</label> ' .
2115  $this->nav_value,
2116  $this->getNavParameter() . $a_num,
2117  $offset_arr,
2118  false,
2119  true,
2120  0,
2121  "small",
2122  array("id" => "tab_page_sel_" . $a_num,
2123  "onchange" => "ilTablePageSelection(this, 'cmd[" . $this->parent_cmd . "]')")
2124  );
2125  }
2126 
2127  return $LinkBar;
2128  } else {
2129  return null;
2130  }
2131  }
2132 
2133  public function fillHiddenRow(): void
2134  {
2135  $hidden_row = false;
2136  if (count($this->hidden_inputs)) {
2137  foreach ($this->hidden_inputs as $hidden_input) {
2138  $this->tpl->setCurrentBlock("tbl_hidden_field");
2139  $this->tpl->setVariable("FIELD_NAME", $hidden_input["name"]);
2140  $this->tpl->setVariable("FIELD_VALUE", $hidden_input["value"]);
2141  $this->tpl->parseCurrentBlock();
2142  }
2143 
2144  $this->tpl->setCurrentBlock("tbl_hidden_row");
2145  $this->tpl->parseCurrentBlock();
2146  }
2147  }
2148 
2149  public function fillActionRow(): void
2150  {
2151  $lng = $this->lng;
2152 
2153  // action row
2154  $action_row = false;
2155  $arrow = false;
2156  $txt = "";
2157  $cmd = "";
2158 
2159  // add selection buttons
2160  if (count($this->sel_buttons) > 0) {
2161  foreach ($this->sel_buttons as $button) {
2162  $this->tpl->setCurrentBlock("sel_button");
2163  $this->tpl->setVariable(
2164  "SBUTTON_SELECT",
2166  $button["selected"],
2167  $button["sel_var"],
2168  $button["options"],
2169  false,
2170  true
2171  )
2172  );
2173  $this->tpl->setVariable("SBTN_NAME", $button["cmd"]);
2174  $this->tpl->setVariable("SBTN_VALUE", $button["text"]);
2175  $this->tpl->parseCurrentBlock();
2176 
2177  if ($this->getTopCommands()) {
2178  $this->tpl->setCurrentBlock("sel_top_button");
2179  $this->tpl->setVariable(
2180  "SBUTTON_SELECT",
2182  $button["selected"],
2183  $button["sel_var"],
2184  $button["options"],
2185  false,
2186  true
2187  )
2188  );
2189  $this->tpl->setVariable("SBTN_NAME", $button["cmd"]);
2190  $this->tpl->setVariable("SBTN_VALUE", $button["text"]);
2191  $this->tpl->parseCurrentBlock();
2192  }
2193  }
2194  $buttons = true;
2195  $action_row = true;
2196  }
2197  $this->sel_buttons[] = array("options" => [], "cmd" => '', "text" => '');
2198 
2199  // add buttons
2200  if (count($this->buttons) > 0) {
2201  foreach ($this->buttons as $button) {
2202  if (!is_array($button)) {
2203  if ($button instanceof ilButtonBase) {
2204  $this->tpl->setVariable('BUTTON_OBJ', $button->render());
2205 
2206  // this will remove id - should be unique
2207  $button = clone $button;
2208 
2209  $this->tpl->setVariable('BUTTON_TOP_OBJ', $button->render());
2210  }
2211  continue;
2212  }
2213 
2214  if (strlen($button['onclick'])) {
2215  $this->tpl->setCurrentBlock('cmdonclick');
2216  $this->tpl->setVariable('CMD_ONCLICK', $button['onclick']);
2217  $this->tpl->parseCurrentBlock();
2218  }
2219  $this->tpl->setCurrentBlock("plain_button");
2220  if ($button["id"] != "") {
2221  $this->tpl->setVariable("PBID", ' id="' . $button["id"] . '" ');
2222  }
2223  if ($button["class"] != "") {
2224  $this->tpl->setVariable("PBBT_CLASS", ' ' . $button["class"]);
2225  }
2226  $this->tpl->setVariable("PBTN_NAME", $button["cmd"]);
2227  $this->tpl->setVariable("PBTN_VALUE", $button["text"]);
2228  $this->tpl->parseCurrentBlock();
2229 
2230  if ($this->getTopCommands()) {
2231  if (strlen($button['onclick'])) {
2232  $this->tpl->setCurrentBlock('top_cmdonclick');
2233  $this->tpl->setVariable('CMD_ONCLICK', $button['onclick']);
2234  $this->tpl->parseCurrentBlock();
2235  }
2236  $this->tpl->setCurrentBlock("plain_top_button");
2237  $this->tpl->setVariable("PBTN_NAME", $button["cmd"]);
2238  $this->tpl->setVariable("PBTN_VALUE", $button["text"]);
2239  if ($button["class"] != "") {
2240  $this->tpl->setVariable("PBBT_CLASS", ' ' . $button["class"]);
2241  }
2242  $this->tpl->parseCurrentBlock();
2243  }
2244  }
2245 
2246  $buttons = true;
2247  $action_row = true;
2248  }
2249 
2250  // multi selection
2251  if (count($this->mi_sel_buttons)) {
2252  foreach ($this->mi_sel_buttons as $button) {
2253  $this->tpl->setCurrentBlock("mi_sel_button");
2254  $this->tpl->setVariable(
2255  "MI_BUTTON_SELECT",
2257  $button["selected"],
2258  $button["sel_var"],
2259  $button["options"],
2260  false,
2261  true
2262  )
2263  );
2264  $this->tpl->setVariable("MI_BTN_NAME", $button["cmd"]);
2265  $this->tpl->setVariable("MI_BTN_VALUE", $button["text"]);
2266  $this->tpl->parseCurrentBlock();
2267 
2268  if ($this->getTopCommands()) {
2269  $this->tpl->setCurrentBlock("mi_top_sel_button");
2270  $this->tpl->setVariable(
2271  "MI_BUTTON_SELECT",
2273  $button["selected"],
2274  $button["sel_var"] . "_2",
2275  $button["options"],
2276  false,
2277  true
2278  )
2279  );
2280  $this->tpl->setVariable("MI_BTN_NAME", $button["cmd"]);
2281  $this->tpl->setVariable("MI_BTN_VALUE", $button["text"]);
2282  $this->tpl->parseCurrentBlock();
2283  }
2284  }
2285  $arrow = true;
2286  $action_row = true;
2287  }
2288 
2289 
2290  if (count($this->multi) > 1 && $this->dataExists()) {
2291  if ($this->enable_command_for_all && $this->max_count <= self::getAllCommandLimit()) {
2292  $this->tpl->setCurrentBlock("tbl_cmd_select_all");
2293  $this->tpl->setVariable("TXT_SELECT_CMD_ALL", $lng->txt("all_objects"));
2294  $this->tpl->parseCurrentBlock();
2295  }
2296 
2297  $this->tpl->setCurrentBlock("tbl_cmd_select");
2298  $sel = array();
2299  foreach ($this->multi as $mc) {
2300  $sel[$mc["cmd"]] = $mc["text"];
2301  }
2302  $this->tpl->setVariable(
2303  "SELECT_CMDS",
2304  ilLegacyFormElementsUtil::formSelect("", "selected_cmd", $sel, false, true)
2305  );
2306  $this->tpl->setVariable("TXT_EXECUTE", $lng->txt("execute"));
2307  $this->tpl->parseCurrentBlock();
2308  $arrow = true;
2309  $action_row = true;
2310 
2311  if ($this->getTopCommands()) {
2312  if ($this->enable_command_for_all && $this->max_count <= self::getAllCommandLimit()) {
2313  $this->tpl->setCurrentBlock("tbl_top_cmd_select_all");
2314  $this->tpl->setVariable("TXT_SELECT_CMD_ALL", $lng->txt("all_objects"));
2315  $this->tpl->parseCurrentBlock();
2316  }
2317 
2318  $this->tpl->setCurrentBlock("tbl_top_cmd_select");
2319  $sel = array();
2320  foreach ($this->multi as $mc) {
2321  $sel[$mc["cmd"]] = $mc["text"];
2322  }
2323  $this->tpl->setVariable(
2324  "SELECT_CMDS",
2325  ilLegacyFormElementsUtil::formSelect("", "selected_cmd2", $sel, false, true)
2326  );
2327  $this->tpl->setVariable("TXT_EXECUTE", $lng->txt("execute"));
2328  $this->tpl->parseCurrentBlock();
2329  }
2330  } elseif (count($this->multi) == 1 && $this->dataExists()) {
2331  $this->tpl->setCurrentBlock("tbl_single_cmd");
2332  foreach ($this->multi as $mc) {
2333  $cmd = $mc['cmd'];
2334  $txt = $mc['text'];
2335  }
2336  $this->tpl->setVariable("TXT_SINGLE_CMD", $txt);
2337  $this->tpl->setVariable("SINGLE_CMD", $cmd);
2338  $this->tpl->parseCurrentBlock();
2339  $arrow = true;
2340  $action_row = true;
2341 
2342  if ($this->getTopCommands()) {
2343  $this->tpl->setCurrentBlock("tbl_top_single_cmd");
2344  foreach ($this->multi as $mc) {
2345  $cmd = $mc['cmd'];
2346  $txt = $mc['text'];
2347  }
2348  $this->tpl->setVariable("TXT_SINGLE_CMD", $txt);
2349  $this->tpl->setVariable("SINGLE_CMD", $cmd);
2350  $this->tpl->parseCurrentBlock();
2351  }
2352  }
2353 
2354  if ($arrow) {
2355  $this->tpl->setCurrentBlock("tbl_action_img_arrow");
2356  $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("nav/arrow_downright.svg"));
2357  $this->tpl->setVariable("ALT_ARROW", $lng->txt("action"));
2358  $this->tpl->parseCurrentBlock();
2359 
2360  if ($this->getTopCommands()) {
2361  $this->tpl->setCurrentBlock("tbl_top_action_img_arrow");
2362  $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("nav/arrow_upright.svg"));
2363  $this->tpl->setVariable("ALT_ARROW", $lng->txt("action"));
2364  $this->tpl->parseCurrentBlock();
2365  }
2366  }
2367 
2368  if ($action_row) {
2369  $this->tpl->setCurrentBlock("tbl_action_row");
2370  $this->tpl->parseCurrentBlock();
2371  if ($this->getTopCommands()) {
2372  $this->tpl->setCurrentBlock("tbl_top_action_row");
2373  $this->tpl->parseCurrentBlock();
2374  }
2375  }
2376  }
2377 
2378  public function setHeaderHTML(string $html): void
2379  {
2380  $this->headerHTML = $html;
2381  }
2382 
2383  public function storeProperty(string $type, string $value): void
2384  {
2385  global $DIC;
2386 
2387  $ilUser = null;
2388  if (isset($DIC["ilUser"])) {
2389  $ilUser = $DIC["ilUser"];
2390  }
2391 
2392  if (is_object($ilUser) && $this->getId() != "") {
2393  $tab_prop = new ilTablePropertiesStorageGUI();
2394 
2395  $tab_prop->storeProperty($this->getId(), $ilUser->getId(), $type, $value);
2396  }
2397  }
2398 
2399  public function loadProperty(string $type): ?string
2400  {
2401  global $DIC;
2402 
2403  $ilUser = null;
2404  if (isset($DIC["ilUser"])) {
2405  $ilUser = $DIC["ilUser"];
2406  }
2407 
2408  if (is_object($ilUser) && $this->getId() != "") {
2409  $tab_prop = new ilTablePropertiesStorageGUI();
2410 
2411  return $tab_prop->getProperty($this->getId(), $ilUser->getId(), $type);
2412  }
2413  return null;
2414  }
2415 
2419  public function getCurrentState(): array
2420  {
2421  $this->determineOffsetAndOrder();
2422  $this->determineLimit();
2423  $this->determineSelectedColumns();
2424  $this->determineSelectedFilters();
2425 
2426  // "filter" show/hide is not saved
2427 
2428  $result = array();
2429  $result["order"] = $this->getOrderField();
2430  $result["direction"] = $this->getOrderDirection();
2431  $result["offset"] = $this->getOffset();
2432  $result["rows"] = $this->getLimit();
2433  $result["selfilters"] = $this->getSelectedFilters();
2434 
2435  // #9514 - $this->getSelectedColumns() will omit deselected, leading to
2436  // confusion on restoring template
2437  $result["selfields"] = $this->selected_column;
2438 
2439  // gather filter values
2440  if ($this->filters) {
2441  foreach ($this->filters as $item) {
2442  $result["filter_values"][$item->getFieldId()] = $this->getFilterValue($item);
2443  }
2444  }
2445  if ($this->optional_filters && $result["selfilters"]) {
2446  foreach ($this->optional_filters as $item) {
2447  if (in_array($item->getFieldId(), $result["selfilters"])) {
2448  $result["filter_values"][$item->getFieldId()] = $this->getFilterValue($item);
2449  }
2450  }
2451  }
2452 
2453  return $result;
2454  }
2455 
2460  protected function getFilterValue(ilTableFilterItem $a_item)
2461  {
2462  if (method_exists($a_item, "getChecked")) {
2463  return (string) $a_item->getChecked();
2464  } elseif (method_exists($a_item, "getValue")) {
2465  return $a_item->getValue() ?: "";
2466  } elseif (method_exists($a_item, "getDate")) {
2467  return $a_item->getDate()?->get(IL_CAL_DATE) ?? "";
2468  }
2469  return "";
2470  }
2471 
2476  protected function setFilterValue(ilTableFilterItem $a_item, $a_value): void
2477  {
2478  if (method_exists($a_item, "setChecked")) {
2479  $a_item->setChecked((bool) $a_value);
2480  } elseif (method_exists($a_item, "setValue")) {
2481  $a_item->setValue($a_value);
2482  } elseif (method_exists($a_item, "setDate")) {
2483  $a_item->setDate(new ilDate($a_value, IL_CAL_DATE));
2484  }
2485  $a_item->writeToSession();
2486  }
2487 
2488  public function setContext(string $id): void
2489  {
2490  if (trim($id)) {
2491  $this->context = $id;
2492  }
2493  }
2494 
2495  public function getContext(): string
2496  {
2497  return $this->context;
2498  }
2499 
2503  public function setShowRowsSelector(bool $a_value): void
2504  {
2505  $this->show_rows_selector = $a_value;
2506  }
2507 
2508  public function getShowRowsSelector(): bool
2509  {
2511  }
2512 
2513  public function setShowTemplates(bool $a_value): void
2514  {
2515  $this->show_templates = $a_value;
2516  }
2517 
2518  public function getShowTemplates(): bool
2519  {
2520  return $this->show_templates;
2521  }
2522 
2526  public function restoreTemplate(string $a_name): bool
2527  {
2528  global $DIC;
2529 
2530  $ilUser = $DIC->user();
2531 
2532  $a_name = ilUtil::stripSlashes($a_name);
2533 
2534  if (trim($a_name) && $this->getContext() != "" && is_object($ilUser) && $ilUser->getId() != ANONYMOUS_USER_ID) {
2535  $storage = new ilTableTemplatesStorage();
2536 
2537  $data = $storage->load($this->getContext(), $ilUser->getId(), $a_name);
2538  if (is_array($data)) {
2539  foreach ($data as $property => $value) {
2540  $this->storeProperty($property, $value);
2541  }
2542  }
2543 
2544  $data["filter_values"] = unserialize((string) $data["filter_values"]);
2545  if ($data["filter_values"]) {
2546  $this->restore_filter_values = $data["filter_values"];
2547  }
2548 
2549  $this->restore_filter = true;
2550 
2551  return true;
2552  }
2553  return false;
2554  }
2555 
2559  public function saveTemplate(string $a_name): bool
2560  {
2561  global $DIC;
2562 
2563  $ilUser = $DIC->user();
2564 
2565  $a_name = ilLegacyFormElementsUtil::prepareFormOutput($a_name, true);
2566 
2567  if (trim($a_name) && $this->getContext() != "" && is_object($ilUser) && $ilUser->getId() != ANONYMOUS_USER_ID) {
2568  $storage = new ilTableTemplatesStorage();
2569 
2570  $state = $this->getCurrentState();
2571  $state["filter_values"] = serialize($state["filter_values"] ?? null);
2572  $state["selfields"] = serialize($state["selfields"] ?? null);
2573  $state["selfilters"] = serialize($state["selfilters"] ?? null);
2574 
2575  $storage->store($this->getContext(), $ilUser->getId(), $a_name, $state);
2576  return true;
2577  }
2578  return false;
2579  }
2580 
2581  public function deleteTemplate(string $a_name): bool
2582  {
2583  global $DIC;
2584 
2585  $ilUser = $DIC->user();
2586 
2587  $a_name = ilLegacyFormElementsUtil::prepareFormOutput($a_name, true);
2588 
2589  if (trim($a_name) && $this->getContext() != "" && is_object($ilUser) && $ilUser->getId() != ANONYMOUS_USER_ID) {
2590  $storage = new ilTableTemplatesStorage();
2591  $storage->delete($this->getContext(), $ilUser->getId(), $a_name);
2592  return true;
2593  }
2594  return false;
2595  }
2596 
2597  public function getLimit(): int
2598  {
2599  if ($this->getExportMode() || $this->getPrintMode()) {
2600  return 9999;
2601  }
2602  return parent::getLimit();
2603  }
2604 
2605  public function getOffset(): int
2606  {
2607  if ($this->getExportMode() || $this->getPrintMode()) {
2608  return 0;
2609  }
2610  return parent::getOffset();
2611  }
2612 
2616  public function setExportFormats(array $formats): void
2617  {
2618  $this->export_formats = array();
2619 
2620  // #11339
2621  $valid = array(self::EXPORT_EXCEL => "tbl_export_excel",
2622  self::EXPORT_CSV => "tbl_export_csv");
2623 
2624  foreach ($formats as $format) {
2625  if (array_key_exists($format, $valid)) {
2626  $this->export_formats[$format] = $valid[$format];
2627  }
2628  }
2629  }
2630 
2631  public function setPrintMode(bool $a_value = false): void
2632  {
2633  $this->print_mode = $a_value;
2634  }
2635 
2636  public function getPrintMode(): bool
2637  {
2638  return $this->print_mode;
2639  }
2640 
2641  public function getExportMode(): int
2642  {
2643  return $this->export_mode;
2644  }
2645 
2649  public function exportData(int $format, bool $send = false): void
2650  {
2651  if ($this->dataExists()) {
2652  // #9640: sort
2653  if (!$this->getExternalSorting() && $this->enabled["sort"]) {
2654  $this->determineOffsetAndOrder(true);
2655 
2656  $this->row_data = ilArrayUtil::sortArray(
2657  $this->row_data,
2658  $this->getOrderField(),
2659  $this->getOrderDirection(),
2660  $this->numericOrdering($this->getOrderField())
2661  );
2662  }
2663 
2664  $filename = "export";
2665  switch ($format) {
2666  case self::EXPORT_EXCEL:
2667  $excel = new ilExcel();
2668  $excel->addSheet($this->title
2669  ?: $this->lng->txt("export"));
2670  $row = 1;
2671 
2672  ob_start();
2673  $this->fillMetaExcel($excel, $row); // row must be increment in fillMetaExcel()! (optional method)
2674 
2675  // #14813
2676  $pre = $row;
2677  $this->fillHeaderExcel($excel, $row); // row should NOT be incremented in fillHeaderExcel()! (required method)
2678  if ($pre == $row) {
2679  $row++;
2680  }
2681 
2682  foreach ($this->row_data as $set) {
2683  $this->fillRowExcel($excel, $row, $set);
2684  $row++; // #14760
2685  }
2686  ob_end_clean();
2687 
2688  if ($send) {
2689  $excel->sendToClient($filename);
2690  } else {
2691  $excel->writeToFile($filename);
2692  }
2693  break;
2694 
2695  case self::EXPORT_CSV:
2696  $csv = new ilCSVWriter();
2697  $csv->setSeparator(";");
2698 
2699  ob_start();
2700  $this->fillMetaCSV($csv);
2701  $this->fillHeaderCSV($csv);
2702  foreach ($this->row_data as $set) {
2703  $this->fillRowCSV($csv, $set);
2704  }
2705  ob_end_clean();
2706 
2707  if ($send) {
2708  $filename .= ".csv";
2709  header("Content-type: text/comma-separated-values");
2710  header("Content-Disposition: attachment; filename=\"" . $filename . "\"");
2711  header("Expires: 0");
2712  header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
2713  header("Pragma: public");
2714  echo $csv->getCSVString();
2715  } else {
2716  file_put_contents($filename, $csv->getCSVString());
2717  }
2718  break;
2719  }
2720 
2721  if ($send) {
2722  exit();
2723  }
2724  }
2725  }
2726 
2733  protected function fillMetaExcel(ilExcel $a_excel, int &$a_row): void
2734  {
2735  }
2736 
2743  protected function fillHeaderExcel(ilExcel $a_excel, int &$a_row): void
2744  {
2745  $col = 0;
2746  foreach ($this->column as $column) {
2747  $title = strip_tags($column["text"]);
2748  if ($title) {
2749  $a_excel->setCell($a_row, $col++, $title);
2750  }
2751  }
2752  $a_excel->setBold("A" . $a_row . ":" . $a_excel->getColumnCoord($col - 1) . $a_row);
2753  }
2754 
2762  protected function fillRowExcel(ilExcel $a_excel, int &$a_row, array $a_set): void
2763  {
2764  $col = 0;
2765  foreach ($a_set as $value) {
2766  if (is_array($value)) {
2767  $value = implode(', ', $value);
2768  }
2769  $a_excel->setCell($a_row, $col++, $value);
2770  }
2771  }
2772 
2778  protected function fillMetaCSV(ilCSVWriter $a_csv): void
2779  {
2780  }
2781 
2787  protected function fillHeaderCSV(ilCSVWriter $a_csv): void
2788  {
2789  foreach ($this->column as $column) {
2790  $title = strip_tags($column["text"]);
2791  if ($title) {
2792  $a_csv->addColumn($title);
2793  }
2794  }
2795  $a_csv->addRow();
2796  }
2797 
2804  protected function fillRowCSV(ilCSVWriter $a_csv, array $a_set): void
2805  {
2806  foreach ($a_set as $key => $value) {
2807  if (is_array($value)) {
2808  $value = implode(', ', $value);
2809  }
2810  $a_csv->addColumn(strip_tags($value));
2811  }
2812  $a_csv->addRow();
2813  }
2814 
2815  public function setEnableAllCommand(bool $a_value): void
2816  {
2817  $this->enable_command_for_all = $a_value;
2818  }
2819 
2820  public static function getAllCommandLimit(): int
2821  {
2822  global $DIC;
2823 
2824  $ilClientIniFile = $DIC["ilClientIniFile"];
2825 
2826  $limit = $ilClientIniFile->readVariable("system", "TABLE_ACTION_ALL_LIMIT");
2827  if (!$limit) {
2828  $limit = self::ACTION_ALL_LIMIT;
2829  }
2830 
2831  return $limit;
2832  }
2833 
2834  public function setRowSelectorLabel(string $row_selector_label): void
2835  {
2836  $this->row_selector_label = $row_selector_label;
2837  }
2838 
2839  public function getRowSelectorLabel(): string
2840  {
2842  }
2843 
2844  public function setPreventDoubleSubmission(bool $a_val): void
2845  {
2846  $this->prevent_double_submission = $a_val;
2847  }
2848 
2849  public function getPreventDoubleSubmission(): bool
2850  {
2852  }
2853 
2854  public function setLimit(int $a_limit = 0, int $a_default_limit = 0): void
2855  {
2856  parent::setLimit($a_limit, $a_default_limit);
2857 
2858  // #17077 - if limit is set "manually" to 9999, force rows selector off
2859  if ($a_limit == 9999 &&
2860  $this->limit_determined) {
2861  $this->rows_selector_off = true;
2862  }
2863  }
2864 }
saveTemplate(string $a_name)
Save current state as template.
setNoEntriesText(string $a_text)
setOffset(int $a_offset)
set dataset offset
array $restore_filter_values
setData(array $a_data)
numericOrdering(string $a_field)
Should this field be sorted numeric?
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static array static setUseRelativeDates(bool $a_status)
set use relative dates
addColumn(string $a_col)
ILIAS DI UIServices $ui
prepareOutput()
Anything that must be done before HTML is generated.
string $row_selector_label
setTopCommands(bool $a_val)
bool $enable_command_for_all
fillMetaCSV(ilCSVWriter $a_csv)
Add meta information to csv export.
setExportFormats(array $formats)
Set available export formats.
addCommandButtonInstance(ilButtonBase $a_button)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const ANONYMOUS_USER_ID
Definition: constants.php:27
getStyle(string $a_element)
bool $disable_filter_hiding
This class represents a selection list property in a property form.
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)
addFilterItem(ilTableFilterItem $a_input_item, bool $a_optional=false)
setOrderLink(string $key, string $order_dir)
string $defaultorderdirection
string $requested_nav_par2
fillRowCSV(ilCSVWriter $a_csv, array $a_set)
CSV Version of Fill Row.
getSelectableColumns()
Get selectable columns.
setEnableTitle(bool $a_enabletitle)
renderFilter()
Render Filter section.
ILIAS Table TableGUIRequest $table_request
loadProperty(string $type)
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
setResetCommand(string $a_val, string $a_caption="")
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
$valid
getColumnCoord(int $a_col)
Get column "name" from number.
setCloseFormTag(bool $a_val)
setShowTemplates(bool $a_value)
setDescription(string $a_val)
string $requested_tmpl_create
setDisableFilterHiding(bool $a_val=true)
string $requested_nav_par1
static formSelect( $selected, string $varname, array $options, bool $multiple=false, bool $direct_text=false, int $size=0, string $style_class="", array $attribs=[], bool $disabled=false)
Builds a select form field with options and shows the selected option first.
setPrintMode(bool $a_value=false)
isAdvMDFilter(ilAdvancedMDRecordGUI $a_gui, ilTableFilterItem $a_element)
Check if filter element is based on adv md.
loadLanguageModule(string $a_module)
Load language module.
$url
Definition: shib_logout.php:63
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static prepareFormOutput($a_str, bool $a_strip=false)
$c
Definition: deliver.php:9
setFormName(string $a_name="")
static img(string $a_src, ?string $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
ilLanguage $lng
const FILTER_NUMBER_RANGE
array $selectable_columns
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setId(string $a_val)
getFilterValue(ilTableFilterItem $a_item)
Get current filter value.
getFilterItemByPostVar(string $a_post_var)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a date/time property in a property form.
exportData(int $format, bool $send=false)
Export and optionally send current table data.
ilGlobalTemplateInterface $main_tpl
setIsDataTable(bool $a_val)
addMultiItemSelectionButton(string $a_sel_var, array $a_options, string $a_cmd, string $a_text, string $a_default_selection='')
isFilterSelected(string $a_col)
Is given filter selected?
resetOffset(bool $a_in_determination=false)
getHTML()
Get HTML.
setExternalSorting(bool $a_val)
bool $default_filter_visibility
isColumnSelected(string $col)
setCell(int $a_row, int $col, $value, ?string $datatype=null, bool $disable_strip_tags_for_strings=false)
Set cell value.
setShowRowsSelector(bool $a_value)
Toggle rows-per-page selector.
addFilterItemByMetaType(string $id, int $type=self::FILTER_TEXT, bool $a_optional=false, string $caption="")
Add filter by standard type.
setBold(string $a_coords)
Set cell(s) to bold.
getNextClass($a_gui_class=null)
fillRow(array $a_set)
Standard Version of Fill Row.
const FILTER_DATETIME_RANGE
addHiddenInput(string $a_name, string $a_value)
isFilterVisible()
Check if filter is visible: manually shown (session, db) or default value set.
setOrderDirection(string $a_order_direction)
setDefaultOrderField(string $a_defaultorderfield)
const FILTER_DURATION_RANGE
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setContext(string $id)
setFilterCommand(string $a_val, string $a_caption="")
global $DIC
Definition: shib_login.php:25
static getAllCommandLimit()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
fillMetaExcel(ilExcel $a_excel, int &$a_row)
Add meta information to excel export.
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
setDefaultOrderDirection(string $a_defaultorderdirection)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
fillRowExcel(ilExcel $a_excel, int &$a_row, array $a_set)
Excel Version of Fill Row.
setEnableAllCommand(bool $a_value)
string $row_template_dir
setTopAnchor(string $a_val)
restoreTemplate(string $a_name)
Restore state from template.
addHeaderCommand(string $a_href, string $a_text, string $a_target="", string $a_img="")
getInstalledLanguages()
Get installed languages.
deleteTemplate(string $a_name)
$txt
Definition: error.php:30
setCloseCommand(string $a_link)
static addTooltip(string $a_el_id, string $a_text, string $a_container="", string $a_my="bottom center", string $a_at="top center", bool $a_use_htmlspecialchars=true)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
fillHeaderCSV(ilCSVWriter $a_csv)
CSV Version of Fill Header.
setOrderField(string $a_order_field)
getLinkbar(string $a_num)
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
$filename
Definition: buildRTE.php:78
setFilterValue(ilTableFilterItem $a_item, $a_value)
string $requested_tmpl_delete
fillHeaderExcel(ilExcel $a_excel, int &$a_row)
Excel Version of Fill Header.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const IL_CAL_DATE
setRowSelectorLabel(string $row_selector_label)
setEnableNumInfo(bool $a_val)
setPreventDoubleSubmission(bool $a_val)
setFooter(string $a_style, string $a_previous="", string $a_next="")
__construct(Container $dic, ilPlugin $plugin)
setLimit(int $a_limit=0, int $a_default_limit=0)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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)
getCurrentState()
get current settings for order, limit, columns and filter
getFilterElements(bool $a_only_non_empty=true)
Get SQL conditions for current filter value(s)
string $requested_nav_par
__construct(?object $a_parent_obj, string $a_parent_cmd="", string $a_template_context="")
setParameter(object $a_gui_obj, string $a_parameter, $a_value)
setDisplayAsBlock(bool $a_val)
setHeaderHTML(string $html)
string $defaultorderfield
getFilterItems(bool $a_optionals=false)
setOpenFormTag(bool $a_val)
setDefaultFilterVisiblity(bool $a_status)
addMultiCommand(string $a_cmd, string $a_text)
header()
expected output: > ILIAS shows the rendered Component.
Definition: header.php:13
setCustomPreviousNext(string $a_prev_link, string $a_next_link)
static initConnection(?ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Connection module.
determineOffsetAndOrder(bool $a_omit_offset=false)
getSelectAllCheckbox()
get the name of the checkbox that should be toggled with a select all button
storeProperty(string $type, string $value)
setEnableHeader(bool $a_enableheader)
setMaxCount(int $a_max_count)
set max.
bool $prevent_double_submission
setFilterCols(int $a_val)
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)
setPrefix(string $a_prefix)