ILIAS  release_8 Revision v8.24
class.ilTable2GUI.php
Go to the documentation of this file.
1<?php
2
24{
25 public const FILTER_TEXT = 1;
26 public const FILTER_SELECT = 2;
27 public const FILTER_DATE = 3;
28 public const FILTER_LANGUAGE = 4;
29 public const FILTER_NUMBER_RANGE = 5;
30 public const FILTER_DATE_RANGE = 6;
31 public const FILTER_DURATION_RANGE = 7;
32 public const FILTER_DATETIME_RANGE = 8;
33 public const FILTER_CHECKBOX = 9;
34 public const EXPORT_EXCEL = 1;
35 public const EXPORT_CSV = 2;
36 public const ACTION_ALL_LIMIT = 1000;
37 protected string $requested_tmpl_delete;
38 protected string $requested_tmpl_create;
39 protected string $requested_nav_par2 = "";
40 protected string $requested_nav_par = "";
41 protected string $requested_nav_par1 = "";
43 protected array $selected_columns = [];
44
45 protected ilCtrl $ctrl;
46 protected ?object $parent_obj = null;
47 protected string $parent_cmd = "";
48 protected string $close_command = "";
49 private string $unique_id = "";
50 private string $headerHTML = "";
51 protected string $top_anchor = "il_table_top";
52 protected array $filters = array();
53 protected array $optional_filters = array();
54 protected string $filter_cmd = 'applyFilter';
55 protected string $reset_cmd = 'resetFilter';
56 protected int $filter_cols = 5;
57 protected bool $ext_sort = false;
58 protected bool $ext_seg = false;
59 protected string $context = "";
60
61 protected array $mi_sel_buttons = [];
62 protected bool $disable_filter_hiding = false;
63 protected bool $top_commands = true;
64 protected array $selectable_columns = array();
65 protected array $selected_column = array();
66 protected bool $show_templates = false;
67 protected bool $show_rows_selector = true; // JF, 2014-10-27
68 protected bool $rows_selector_off = false;
69
70 protected bool $nav_determined = false;
71 protected bool $limit_determined = false;
72 protected bool $filters_determined = false;
73 protected bool $columns_determined = false;
74 protected bool $open_form_tag = true;
75 protected bool $close_form_tag = true;
76 protected array $export_formats = [];
77 protected int $export_mode = 0;
78 protected bool $print_mode = false;
79 protected bool $enable_command_for_all = false;
80 protected bool $restore_filter = false;
81 protected array $restore_filter_values = [];
82 protected bool $default_filter_visibility = false;
83 protected array $sortable_fields = array();
84 protected bool $prevent_double_submission = true;
85 protected string $row_selector_label = "";
86 protected bool $select_all_on_top = false;
87 protected array $sel_buttons = [];
88 protected string $nav_value = '';
89 protected string $noentriestext = '';
90 protected string $css_row = '';
91 protected bool $display_as_block = false;
92 protected string $description = '';
93 protected string $id = "";
94 protected bool $custom_prev_next = false;
95 protected string $reset_cmd_txt = "";
96 protected string $defaultorderfield = "";
97 protected string $defaultorderdirection = "";
98 protected array $column = [];
99 protected bool $datatable = false;
100 protected bool $num_info = false;
101 protected bool $form_multipart = false;
102 protected array $row_data = [];
103 protected string $order_field = "";
104 protected array $selected_filter = [];
105 protected string $form_action = "";
106 protected string $formname = "";
107 protected string $sort_order = "";
108 protected array $buttons = [];
109 protected array $multi = [];
110 protected array $hidden_inputs = [];
111 protected array $header_commands = [];
112 protected string $row_template = "";
113 protected string $row_template_dir = "";
114 protected string $filter_cmd_txt = "";
115 protected string $custom_prev = "";
116 protected string $custom_next = "";
117 protected ?array $raw_post_data = null;
118 protected \ilGlobalTemplateInterface $main_tpl;
119
123 public function __construct(
124 ?object $a_parent_obj,
125 string $a_parent_cmd = "",
126 string $a_template_context = ""
127 ) {
128 global $DIC;
129 $this->main_tpl = $DIC->ui()->mainTemplate();
130
131 $this->lng = $DIC->language();
132 $this->ctrl = $DIC->ctrl();
133 $lng = $DIC->language();
134
135 if (isset($DIC["http"])) {
136 $this->table_request = new \ILIAS\Table\TableGUIRequest(
137 $DIC->http(),
138 $DIC->refinery()
139 );
140 }
141 $this->getRequestedValues();
142 parent::__construct([], false);
143 $this->unique_id = md5(uniqid('', true));
144 $this->parent_obj = $a_parent_obj;
145 $this->parent_cmd = $a_parent_cmd;
146 $this->buttons = array();
147 $this->header_commands = array();
148 $this->multi = array();
149 $this->hidden_inputs = array();
150 $this->formname = "table_" . $this->unique_id;
151 $this->tpl = new ilTemplate("tpl.table2.html", true, true, "Services/Table");
152
153 $lng->loadLanguageModule('tbl');
154
155 if (!$a_template_context) {
156 $a_template_context = $this->getId();
157 }
158 $this->setContext($a_template_context);
159
160 // activate export mode
161 if (isset($this->table_request)) {
162 $this->export_mode = $this->table_request->getExportMode($this->prefix);
163
164 // template handling
165 if ($this->table_request->getTemplate($this->prefix) != "") {
166 $this->restoreTemplate($this->table_request->getTemplate($this->prefix));
167 }
168 }
169
170 $this->determineLimit();
171 $this->setIsDataTable(true);
172 $this->setEnableNumInfo(true);
174
175 $this->raw_post_data = [];
176 if (isset($DIC["http"])) {
177 $this->raw_post_data = $DIC->http()->request()->getParsedBody();
178 }
179 }
180
181 protected function getRequestedValues(): void
182 {
183 if (is_null($this->table_request)) {
184 return;
185 }
186 $this->requested_nav_par = $this->table_request->getNavPar($this->getNavParameter());
187 $this->requested_nav_par1 = $this->table_request->getNavPar($this->getNavParameter(), 1);
188 $this->requested_nav_par2 = $this->table_request->getNavPar($this->getNavParameter(), 2);
189 $this->requested_tmpl_create = $this->table_request->getTemplCreate();
190 $this->requested_tmpl_delete = $this->table_request->getTemplDelete();
191 }
192
193 public function setOpenFormTag(bool $a_val): void
194 {
195 $this->open_form_tag = $a_val;
196 }
197
198 public function getOpenFormTag(): bool
199 {
201 }
202
203 public function setCloseFormTag(bool $a_val): void
204 {
205 $this->close_form_tag = $a_val;
206 }
207
208 public function getCloseFormTag(): bool
209 {
211 }
212
213 public function determineLimit(): void
214 {
215 global $DIC;
216
217 $ilUser = null;
218 if (isset($DIC["ilUser"])) {
219 $ilUser = $DIC["ilUser"];
220 }
221
222 if ($this->limit_determined) {
223 return;
224 }
225
226 $limit = 0;
227 if (isset($this->table_request) && !is_null($this->table_request->getRows($this->prefix))) {
228 $this->storeProperty("rows", $this->table_request->getRows($this->prefix));
229 $limit = $this->table_request->getRows($this->prefix) ?? 0;
230 $this->resetOffset();
231 }
232
233 if ($limit == 0) {
234 $rows = (int) $this->loadProperty("rows");
235 if ($rows > 0) {
236 $limit = $rows;
237 } else {
238 if (is_object($ilUser)) {
239 $limit = (int) $ilUser->getPref("hits_per_page");
240 } else {
241 $limit = 40;
242 }
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($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) {
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 {
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 = ""
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 }
634 return $this->optional_filters;
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 {
669 return $this->disable_filter_hiding;
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($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 {
792 return $this->display_as_block;
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 {
867 return $this->defaultorderfield;
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 {
878 return $this->defaultorderdirection;
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 {
888 return $this->default_filter_visibility;
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("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"]) {
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("./Services/Table/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 $lng = $this->lng;
1765 $ilCtrl = $this->ctrl;
1766
1767 $footer = false;
1768 $numinfo = '';
1769 $linkbar = '';
1770 $column_selector = '';
1771
1772 // select all checkbox
1773 if ((strlen($this->getFormName())) && (strlen($this->getSelectAllCheckbox())) && $this->dataExists()) {
1774 $this->tpl->setCurrentBlock("select_all_checkbox");
1775 $this->tpl->setVariable("SELECT_ALL_TXT_SELECT_ALL", $lng->txt("select_all"));
1776 $this->tpl->setVariable("SELECT_ALL_CHECKBOX_NAME", $this->getSelectAllCheckbox());
1777 $this->tpl->setVariable("SELECT_ALL_FORM_NAME", $this->getFormName());
1778 $this->tpl->setVariable("CHECKBOXNAME", "chb_select_all_" . $this->unique_id);
1779 $this->tpl->parseCurrentBlock();
1780 }
1781
1782 // table footer numinfo
1783 if ($this->enabled["numinfo"] && $this->enabled["footer"]) {
1784 $start = $this->offset + 1; // compute num info
1785 if (!$this->dataExists()) {
1786 $start = 0;
1787 }
1788 $end = $this->offset + $this->limit;
1789
1790 if ($end > $this->max_count or $this->limit == 0) {
1791 $end = $this->max_count;
1792 }
1793
1794 if ($this->max_count > 0) {
1795 if ($this->lang_support) {
1796 $numinfo = "(" . $start . " - " . $end . " " . strtolower($this->lng->txt("of")) . " " . $this->max_count . ")";
1797 } else {
1798 $numinfo = "(" . $start . " - " . $end . " of " . $this->max_count . ")";
1799 }
1800 }
1801 if ($this->max_count > 0) {
1802 if ($this->getEnableNumInfo()) {
1803 $this->tpl->setCurrentBlock("tbl_footer_numinfo");
1804 $this->tpl->setVariable("NUMINFO", $numinfo);
1805 $this->tpl->parseCurrentBlock();
1806 }
1807 }
1808 $footer = true;
1809 }
1810
1811 // table footer linkbar
1812 if ($this->enabled["linkbar"] && $this->enabled["footer"] && $this->limit != 0
1813 && $this->max_count > 0) {
1814 $linkbar = $this->getLinkbar("1");
1815 $this->tpl->setCurrentBlock("tbl_footer_linkbar");
1816 $this->tpl->setVariable("LINKBAR", $linkbar);
1817 $this->tpl->parseCurrentBlock();
1818 $linkbar = true;
1819 $footer = true;
1820 }
1821
1822 // column selector
1823 if (is_array($this->getSelectableColumns()) && count($this->getSelectableColumns()) > 0) {
1824 $items = array();
1825 foreach ($this->getSelectableColumns() as $k => $c) {
1826 $items[$k] = array("txt" => $c["txt"],
1827 "selected" => $this->isColumnSelected($k));
1828 }
1829 $cb_over = new ilCheckboxListOverlayGUI("tbl_" . $this->getId());
1830 $cb_over->setLinkTitle($lng->txt("columns"));
1831 $cb_over->setItems($items);
1832 //$cb_over->setUrl("./ilias.php?baseClass=ilTablePropertiesStorage&table_id=".
1833 // $this->getId()."&cmd=saveSelectedFields&user_id=".$ilUser->getId());
1834 $cb_over->setFormCmd($this->getParentCmd());
1835 $cb_over->setFieldVar("tblfs" . $this->getId());
1836 $cb_over->setHiddenVar("tblfsh" . $this->getId());
1837 $cb_over->setSelectionHeaderClass("ilTableMenuItem");
1838 $column_selector = $cb_over->getHTML();
1839 $footer = true;
1840 }
1841
1842 if ($this->getShowTemplates() && is_object($ilUser)) {
1843 // template handling
1844 if ($this->requested_tmpl_create != "") {
1845 if ($this->saveTemplate($this->requested_tmpl_create)) {
1846 $this->main_tpl->setOnScreenMessage('success', $lng->txt("tbl_template_created"));
1847 }
1848 } elseif ($this->requested_tmpl_delete != "") {
1849 if ($this->deleteTemplate($this->requested_tmpl_delete)) {
1850 $this->main_tpl->setOnScreenMessage('success', $lng->txt("tbl_template_deleted"));
1851 }
1852 }
1853
1854 $create_id = "template_create_overlay_" . $this->getId();
1855 $delete_id = "template_delete_overlay_" . $this->getId();
1856 $list_id = "template_stg_" . $this->getId();
1857
1858 $storage = new ilTableTemplatesStorage();
1859 $templates = $storage->getNames($this->getContext(), $ilUser->getId());
1860
1861 // form to delete template
1862 if (count($templates) > 0) {
1863 $overlay = new ilOverlayGUI($delete_id);
1864 $overlay->setTrigger($list_id . "_delete");
1865 $overlay->setAnchor("ilAdvSelListAnchorElement_" . $list_id);
1866 $overlay->setAutoHide(false);
1867 $overlay->add();
1868
1869 $lng->loadLanguageModule("form");
1870 $this->tpl->setCurrentBlock("template_editor_delete_item");
1871 $this->tpl->setVariable("TEMPLATE_DELETE_OPTION_VALUE", "");
1872 $this->tpl->setVariable("TEMPLATE_DELETE_OPTION", "- " . $lng->txt("form_please_select") . " -");
1873 $this->tpl->parseCurrentBlock();
1874 foreach ($templates as $name) {
1875 $this->tpl->setVariable("TEMPLATE_DELETE_OPTION_VALUE", $name);
1876 $this->tpl->setVariable("TEMPLATE_DELETE_OPTION", $name);
1877 $this->tpl->parseCurrentBlock();
1878 }
1879
1880 $this->tpl->setCurrentBlock("template_editor_delete");
1881 $this->tpl->setVariable("TEMPLATE_DELETE_ID", $delete_id);
1882 $this->tpl->setVariable("TXT_TEMPLATE_DELETE", $lng->txt("tbl_template_delete"));
1883 $this->tpl->setVariable("TXT_TEMPLATE_DELETE_SUBMIT", $lng->txt("delete"));
1884 $this->tpl->setVariable("TEMPLATE_DELETE_CMD", $this->parent_cmd);
1885 $this->tpl->parseCurrentBlock();
1886 }
1887
1888
1889 // form to save new template
1890 $overlay = new ilOverlayGUI($create_id);
1891 $overlay->setTrigger($list_id . "_create");
1892 $overlay->setAnchor("ilAdvSelListAnchorElement_" . $list_id);
1893 $overlay->setAutoHide(false);
1894 $overlay->add();
1895
1896 $this->tpl->setCurrentBlock("template_editor");
1897 $this->tpl->setVariable("TEMPLATE_CREATE_ID", $create_id);
1898 $this->tpl->setVariable("TXT_TEMPLATE_CREATE", $lng->txt("tbl_template_create"));
1899 $this->tpl->setVariable("TXT_TEMPLATE_CREATE_SUBMIT", $lng->txt("save"));
1900 $this->tpl->setVariable("TEMPLATE_CREATE_CMD", $this->parent_cmd);
1901 $this->tpl->parseCurrentBlock();
1902
1903 // load saved template
1904 $alist = new ilAdvancedSelectionListGUI();
1905 $alist->setId($list_id);
1906 $alist->addItem($lng->txt("tbl_template_create"), "create", "#");
1907 if (count($templates) > 0) {
1908 $alist->addItem($lng->txt("tbl_template_delete"), "delete", "#");
1909 foreach ($templates as $name) {
1910 $ilCtrl->setParameter($this->parent_obj, $this->prefix . "_tpl", urlencode($name));
1911 $alist->addItem($name, $name, $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd));
1912 $ilCtrl->setParameter($this->parent_obj, $this->prefix . "_tpl", "");
1913 }
1914 }
1915 $alist->setListTitle($lng->txt("tbl_templates"));
1917 $this->tpl->setVariable("TEMPLATE_SELECTOR", "&nbsp;" . $alist->getHTML());
1918 }
1919
1920 if ($footer) {
1921 $this->tpl->setCurrentBlock("tbl_footer");
1922 $this->tpl->setVariable("COLUMN_COUNT", $this->getColumnCount());
1923 if ($this->getDisplayAsBlock()) {
1924 $this->tpl->setVariable("BLK_CLASS", "Block");
1925 }
1926 $this->tpl->parseCurrentBlock();
1927
1928 // top navigation, if number info or linkbar given
1929 if ($numinfo != "" || $linkbar != "" || $column_selector != "" ||
1930 count($this->filters) > 0 || count($this->optional_filters) > 0) {
1931 if (is_object($ilUser) && (count($this->filters) || count($this->optional_filters))) {
1932 $this->tpl->setCurrentBlock("filter_activation");
1933 $this->tpl->setVariable("TXT_ACTIVATE_FILTER", $lng->txt("show_filter"));
1934 $this->tpl->setVariable("FILA_ID", $this->getId());
1935 if ($this->getId() != "") {
1936 $this->tpl->setVariable("SAVE_URLA", "./ilias.php?baseClass=ilTablePropertiesStorageGUI&table_id=" .
1937 $this->getId() . "&cmd=showFilter&user_id=" . $ilUser->getId());
1938 }
1939 $this->tpl->parseCurrentBlock();
1940
1941
1942 if (!$this->getDisableFilterHiding()) {
1943 $this->tpl->setCurrentBlock("filter_deactivation");
1944 $this->tpl->setVariable("TXT_HIDE", $lng->txt("hide_filter"));
1945 if ($this->getId() != "") {
1946 $this->tpl->setVariable("SAVE_URL", "./ilias.php?baseClass=ilTablePropertiesStorageGUI&table_id=" .
1947 $this->getId() . "&cmd=hideFilter&user_id=" . $ilUser->getId());
1948 $this->tpl->setVariable("FILD_ID", $this->getId());
1949 }
1950 $this->tpl->parseCurrentBlock();
1951 }
1952 }
1953
1954 if ($numinfo != "" && $this->getEnableNumInfo()) {
1955 $this->tpl->setCurrentBlock("top_numinfo");
1956 $this->tpl->setVariable("NUMINFO", $numinfo);
1957 $this->tpl->parseCurrentBlock();
1958 }
1959 if ($linkbar != "" && !$this->getDisplayAsBlock()) {
1960 $linkbar = $this->getLinkbar("2");
1961 $this->tpl->setCurrentBlock("top_linkbar");
1962 $this->tpl->setVariable("LINKBAR", $linkbar);
1963 $this->tpl->parseCurrentBlock();
1964 }
1965
1966 // column selector
1967 $this->tpl->setVariable("COLUMN_SELECTOR", $column_selector);
1968
1969 // row selector
1970 if ($this->getShowRowsSelector() &&
1971 is_object($ilUser) &&
1972 $this->getId() &&
1973 !$this->rows_selector_off) { // JF, 2014-10-27
1974 $alist = new ilAdvancedSelectionListGUI();
1976 $alist->setId("sellst_rows_" . $this->getId());
1977 $hpp = ($ilUser->getPref("hits_per_page") != 9999)
1978 ? $ilUser->getPref("hits_per_page")
1979 : $lng->txt("no_limit");
1980
1981 $options = array(0 => $lng->txt("default") . " (" . $hpp . ")",5 => 5, 10 => 10, 15 => 15, 20 => 20,
1982 30 => 30, 40 => 40, 50 => 50,
1983 100 => 100, 200 => 200, 400 => 400, 800 => 800);
1984 foreach ($options as $k => $v) {
1985 $ilCtrl->setParameter($this->parent_obj, $this->prefix . "_trows", $k);
1986 $alist->addItem($v, $k, $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd));
1987 $ilCtrl->setParameter($this->parent_obj, $this->prefix . "_trows", "");
1988 }
1989 $alist->setListTitle($this->getRowSelectorLabel() ?: $lng->txt("rows"));
1990 $this->tpl->setVariable("ROW_SELECTOR", $alist->getHTML());
1991 }
1992
1993 // export
1994 if (count($this->export_formats) > 0 && $this->dataExists()) {
1995 $alist = new ilAdvancedSelectionListGUI();
1997 $alist->setId("sellst_xpt");
1998 foreach ($this->export_formats as $format => $caption_lng_id) {
1999 $ilCtrl->setParameter($this->parent_obj, $this->prefix . "_xpt", $format);
2000 $url = $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd);
2001 $ilCtrl->setParameter($this->parent_obj, $this->prefix . "_xpt", "");
2002 $alist->addItem($lng->txt($caption_lng_id), $format, $url);
2003 }
2004 $alist->setListTitle($lng->txt("export"));
2005 $this->tpl->setVariable("EXPORT_SELECTOR", "&nbsp;" . $alist->getHTML());
2006 }
2007
2008 $this->tpl->setCurrentBlock("top_navigation");
2009 $this->tpl->setVariable("COLUMN_COUNT", $this->getColumnCount());
2010 if ($this->getDisplayAsBlock()) {
2011 $this->tpl->setVariable("BLK_CLASS", "Block");
2012 }
2013 $this->tpl->parseCurrentBlock();
2014 }
2015 }
2016 }
2017
2018 public function getLinkbar(string $a_num): ?string
2019 {
2020 global $DIC;
2021
2022 $ilUser = $DIC->user();
2023
2024 $ilCtrl = $this->ctrl;
2025 $lng = $this->lng;
2026
2027 $hash = "";
2028
2029 $link = $ilCtrl->getLinkTargetByClass(get_class($this->parent_obj), $this->parent_cmd) .
2030 "&" . $this->getNavParameter() . "=" .
2031 $this->getOrderField() . ":" . $this->getOrderDirection() . ":";
2032
2033 $LinkBar = "";
2034 $layout_prev = $lng->txt("previous");
2035 $layout_next = $lng->txt("next");
2036
2037 // if more entries then entries per page -> show link bar
2038 if ($this->max_count > $this->getLimit() || $this->custom_prev_next) {
2039 $sep = "<span>&nbsp;&nbsp;|&nbsp;&nbsp;</span>";
2040
2041 // calculate number of pages
2042 $pages = intval($this->max_count / $this->getLimit());
2043
2044 // add a page if a rest remains
2045 if (($this->max_count % $this->getLimit())) {
2046 $pages++;
2047 }
2048
2049 // links to other pages
2050 $offset_arr = array();
2051 for ($i = 1 ;$i <= $pages ; $i++) {
2052 $newoffset = $this->getLimit() * ($i - 1);
2053
2054 $nav_value = $this->getOrderField() . ":" . $this->getOrderDirection() . ":" . $newoffset;
2055 $offset_arr[$nav_value] = $i;
2056 }
2057
2058 $sep = "<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>";
2059
2060 // previous link
2061 if ($this->custom_prev_next && $this->custom_prev != "") {
2062 $LinkBar .= "<a href=\"" . $this->custom_prev . $hash . "\">" . $layout_prev . "</a>";
2063 } elseif ($this->getOffset() >= 1 && !$this->custom_prev_next) {
2064 $prevoffset = $this->getOffset() - $this->getLimit();
2065 $LinkBar .= "<a href=\"" . $link . $prevoffset . $hash . "\">" . $layout_prev . "</a>";
2066 } else {
2067 $LinkBar .= '<span class="ilTableFootLight">' . $layout_prev . "</span>";
2068 }
2069
2070 // current value
2071 if ($a_num == "1") {
2072 $LinkBar .= '<input type="hidden" name="' . $this->getNavParameter() .
2073 '" value="' . $this->getOrderField() . ":" . $this->getOrderDirection() . ":" . $this->getOffset() . '" />';
2074 }
2075
2076 $sep = "<span>&nbsp;&nbsp;|&nbsp;&nbsp;</span>";
2077
2078 // show next link (if not last page)
2079 $LinkBar .= $sep;
2080 if ($this->custom_prev_next && $this->custom_next != "") {
2081 $LinkBar .= "<a href=\"" . $this->custom_next . $hash . "\">" . $layout_next . "</a>";
2082 } elseif (!(($this->getOffset() / $this->getLimit()) == ($pages - 1)) && ($pages != 1) &&
2083 !$this->custom_prev_next) {
2084 $newoffset = $this->getOffset() + $this->getLimit();
2085 $LinkBar .= "<a href=\"" . $link . $newoffset . $hash . "\">" . $layout_next . "</a>";
2086 } else {
2087 $LinkBar .= '<span class="ilTableFootLight">' . $layout_next . "</span>";
2088 }
2089
2090 $sep = "<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>";
2091
2092 if (count($offset_arr) && !$this->getDisplayAsBlock() && !$this->custom_prev_next) {
2093 $LinkBar .= $sep;
2094
2095 $LinkBar .=
2096 '<label for="tab_page_sel_' . $a_num . '">' . $lng->txt("page") . '</label> ' .
2098 $this->nav_value,
2099 $this->getNavParameter() . $a_num,
2100 $offset_arr,
2101 false,
2102 true,
2103 0,
2104 "small",
2105 array("id" => "tab_page_sel_" . $a_num,
2106 "onchange" => "ilTablePageSelection(this, 'cmd[" . $this->parent_cmd . "]')")
2107 );
2108 }
2109
2110 return $LinkBar;
2111 } else {
2112 return null;
2113 }
2114 }
2115
2116 public function fillHiddenRow(): void
2117 {
2118 $hidden_row = false;
2119 if (count($this->hidden_inputs)) {
2120 foreach ($this->hidden_inputs as $hidden_input) {
2121 $this->tpl->setCurrentBlock("tbl_hidden_field");
2122 $this->tpl->setVariable("FIELD_NAME", $hidden_input["name"]);
2123 $this->tpl->setVariable("FIELD_VALUE", $hidden_input["value"]);
2124 $this->tpl->parseCurrentBlock();
2125 }
2126
2127 $this->tpl->setCurrentBlock("tbl_hidden_row");
2128 $this->tpl->parseCurrentBlock();
2129 }
2130 }
2131
2132 public function fillActionRow(): void
2133 {
2134 $lng = $this->lng;
2135
2136 // action row
2137 $action_row = false;
2138 $arrow = false;
2139 $txt = "";
2140 $cmd = "";
2141
2142 // add selection buttons
2143 if (count($this->sel_buttons) > 0) {
2144 foreach ($this->sel_buttons as $button) {
2145 $this->tpl->setCurrentBlock("sel_button");
2146 $this->tpl->setVariable(
2147 "SBUTTON_SELECT",
2149 $button["selected"],
2150 $button["sel_var"],
2151 $button["options"],
2152 false,
2153 true
2154 )
2155 );
2156 $this->tpl->setVariable("SBTN_NAME", $button["cmd"]);
2157 $this->tpl->setVariable("SBTN_VALUE", $button["text"]);
2158 $this->tpl->parseCurrentBlock();
2159
2160 if ($this->getTopCommands()) {
2161 $this->tpl->setCurrentBlock("sel_top_button");
2162 $this->tpl->setVariable(
2163 "SBUTTON_SELECT",
2165 $button["selected"],
2166 $button["sel_var"],
2167 $button["options"],
2168 false,
2169 true
2170 )
2171 );
2172 $this->tpl->setVariable("SBTN_NAME", $button["cmd"]);
2173 $this->tpl->setVariable("SBTN_VALUE", $button["text"]);
2174 $this->tpl->parseCurrentBlock();
2175 }
2176 }
2177 $buttons = true;
2178 $action_row = true;
2179 }
2180 $this->sel_buttons[] = array("options" => [], "cmd" => '', "text" => '');
2181
2182 // add buttons
2183 if (count($this->buttons) > 0) {
2184 foreach ($this->buttons as $button) {
2185 if (!is_array($button)) {
2186 if ($button instanceof ilButtonBase) {
2187 $this->tpl->setVariable('BUTTON_OBJ', $button->render());
2188
2189 // this will remove id - should be unique
2190 $button = clone $button;
2191
2192 $this->tpl->setVariable('BUTTON_TOP_OBJ', $button->render());
2193 }
2194 continue;
2195 }
2196
2197 if (strlen($button['onclick'])) {
2198 $this->tpl->setCurrentBlock('cmdonclick');
2199 $this->tpl->setVariable('CMD_ONCLICK', $button['onclick']);
2200 $this->tpl->parseCurrentBlock();
2201 }
2202 $this->tpl->setCurrentBlock("plain_button");
2203 if ($button["id"] != "") {
2204 $this->tpl->setVariable("PBID", ' id="' . $button["id"] . '" ');
2205 }
2206 if ($button["class"] != "") {
2207 $this->tpl->setVariable("PBBT_CLASS", ' ' . $button["class"]);
2208 }
2209 $this->tpl->setVariable("PBTN_NAME", $button["cmd"]);
2210 $this->tpl->setVariable("PBTN_VALUE", $button["text"]);
2211 $this->tpl->parseCurrentBlock();
2212
2213 if ($this->getTopCommands()) {
2214 if (strlen($button['onclick'])) {
2215 $this->tpl->setCurrentBlock('top_cmdonclick');
2216 $this->tpl->setVariable('CMD_ONCLICK', $button['onclick']);
2217 $this->tpl->parseCurrentBlock();
2218 }
2219 $this->tpl->setCurrentBlock("plain_top_button");
2220 $this->tpl->setVariable("PBTN_NAME", $button["cmd"]);
2221 $this->tpl->setVariable("PBTN_VALUE", $button["text"]);
2222 if ($button["class"] != "") {
2223 $this->tpl->setVariable("PBBT_CLASS", ' ' . $button["class"]);
2224 }
2225 $this->tpl->parseCurrentBlock();
2226 }
2227 }
2228
2229 $buttons = true;
2230 $action_row = true;
2231 }
2232
2233 // multi selection
2234 if (count($this->mi_sel_buttons)) {
2235 foreach ($this->mi_sel_buttons as $button) {
2236 $this->tpl->setCurrentBlock("mi_sel_button");
2237 $this->tpl->setVariable(
2238 "MI_BUTTON_SELECT",
2240 $button["selected"],
2241 $button["sel_var"],
2242 $button["options"],
2243 false,
2244 true
2245 )
2246 );
2247 $this->tpl->setVariable("MI_BTN_NAME", $button["cmd"]);
2248 $this->tpl->setVariable("MI_BTN_VALUE", $button["text"]);
2249 $this->tpl->parseCurrentBlock();
2250
2251 if ($this->getTopCommands()) {
2252 $this->tpl->setCurrentBlock("mi_top_sel_button");
2253 $this->tpl->setVariable(
2254 "MI_BUTTON_SELECT",
2256 $button["selected"],
2257 $button["sel_var"] . "_2",
2258 $button["options"],
2259 false,
2260 true
2261 )
2262 );
2263 $this->tpl->setVariable("MI_BTN_NAME", $button["cmd"]);
2264 $this->tpl->setVariable("MI_BTN_VALUE", $button["text"]);
2265 $this->tpl->parseCurrentBlock();
2266 }
2267 }
2268 $arrow = true;
2269 $action_row = true;
2270 }
2271
2272
2273 if (count($this->multi) > 1 && $this->dataExists()) {
2274 if ($this->enable_command_for_all && $this->max_count <= self::getAllCommandLimit()) {
2275 $this->tpl->setCurrentBlock("tbl_cmd_select_all");
2276 $this->tpl->setVariable("TXT_SELECT_CMD_ALL", $lng->txt("all_objects"));
2277 $this->tpl->parseCurrentBlock();
2278 }
2279
2280 $this->tpl->setCurrentBlock("tbl_cmd_select");
2281 $sel = array();
2282 foreach ($this->multi as $mc) {
2283 $sel[$mc["cmd"]] = $mc["text"];
2284 }
2285 $this->tpl->setVariable(
2286 "SELECT_CMDS",
2287 ilLegacyFormElementsUtil::formSelect("", "selected_cmd", $sel, false, true)
2288 );
2289 $this->tpl->setVariable("TXT_EXECUTE", $lng->txt("execute"));
2290 $this->tpl->parseCurrentBlock();
2291 $arrow = true;
2292 $action_row = true;
2293
2294 if ($this->getTopCommands()) {
2295 if ($this->enable_command_for_all && $this->max_count <= self::getAllCommandLimit()) {
2296 $this->tpl->setCurrentBlock("tbl_top_cmd_select_all");
2297 $this->tpl->setVariable("TXT_SELECT_CMD_ALL", $lng->txt("all_objects"));
2298 $this->tpl->parseCurrentBlock();
2299 }
2300
2301 $this->tpl->setCurrentBlock("tbl_top_cmd_select");
2302 $sel = array();
2303 foreach ($this->multi as $mc) {
2304 $sel[$mc["cmd"]] = $mc["text"];
2305 }
2306 $this->tpl->setVariable(
2307 "SELECT_CMDS",
2308 ilLegacyFormElementsUtil::formSelect("", "selected_cmd2", $sel, false, true)
2309 );
2310 $this->tpl->setVariable("TXT_EXECUTE", $lng->txt("execute"));
2311 $this->tpl->parseCurrentBlock();
2312 }
2313 } elseif (count($this->multi) == 1 && $this->dataExists()) {
2314 $this->tpl->setCurrentBlock("tbl_single_cmd");
2315 foreach ($this->multi as $mc) {
2316 $cmd = $mc['cmd'];
2317 $txt = $mc['text'];
2318 }
2319 $this->tpl->setVariable("TXT_SINGLE_CMD", $txt);
2320 $this->tpl->setVariable("SINGLE_CMD", $cmd);
2321 $this->tpl->parseCurrentBlock();
2322 $arrow = true;
2323 $action_row = true;
2324
2325 if ($this->getTopCommands()) {
2326 $this->tpl->setCurrentBlock("tbl_top_single_cmd");
2327 foreach ($this->multi as $mc) {
2328 $cmd = $mc['cmd'];
2329 $txt = $mc['text'];
2330 }
2331 $this->tpl->setVariable("TXT_SINGLE_CMD", $txt);
2332 $this->tpl->setVariable("SINGLE_CMD", $cmd);
2333 $this->tpl->parseCurrentBlock();
2334 }
2335 }
2336
2337 if ($arrow) {
2338 $this->tpl->setCurrentBlock("tbl_action_img_arrow");
2339 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.svg"));
2340 $this->tpl->setVariable("ALT_ARROW", $lng->txt("action"));
2341 $this->tpl->parseCurrentBlock();
2342
2343 if ($this->getTopCommands()) {
2344 $this->tpl->setCurrentBlock("tbl_top_action_img_arrow");
2345 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_upright.svg"));
2346 $this->tpl->setVariable("ALT_ARROW", $lng->txt("action"));
2347 $this->tpl->parseCurrentBlock();
2348 }
2349 }
2350
2351 if ($action_row) {
2352 $this->tpl->setCurrentBlock("tbl_action_row");
2353 $this->tpl->parseCurrentBlock();
2354 if ($this->getTopCommands()) {
2355 $this->tpl->setCurrentBlock("tbl_top_action_row");
2356 $this->tpl->parseCurrentBlock();
2357 }
2358 }
2359 }
2360
2361 public function setHeaderHTML(string $html): void
2362 {
2363 $this->headerHTML = $html;
2364 }
2365
2366 public function storeProperty(string $type, string $value): void
2367 {
2368 global $DIC;
2369
2370 $ilUser = null;
2371 if (isset($DIC["ilUser"])) {
2372 $ilUser = $DIC["ilUser"];
2373 }
2374
2375 if (is_object($ilUser) && $this->getId() != "") {
2376 $tab_prop = new ilTablePropertiesStorageGUI();
2377
2378 $tab_prop->storeProperty($this->getId(), $ilUser->getId(), $type, $value);
2379 }
2380 }
2381
2382 public function loadProperty(string $type): ?string
2383 {
2384 global $DIC;
2385
2386 $ilUser = null;
2387 if (isset($DIC["ilUser"])) {
2388 $ilUser = $DIC["ilUser"];
2389 }
2390
2391 if (is_object($ilUser) && $this->getId() != "") {
2392 $tab_prop = new ilTablePropertiesStorageGUI();
2393
2394 return $tab_prop->getProperty($this->getId(), $ilUser->getId(), $type);
2395 }
2396 return null;
2397 }
2398
2402 public function getCurrentState(): array
2403 {
2404 $this->determineOffsetAndOrder();
2405 $this->determineLimit();
2406 $this->determineSelectedColumns();
2407 $this->determineSelectedFilters();
2408
2409 // "filter" show/hide is not saved
2410
2411 $result = array();
2412 $result["order"] = $this->getOrderField();
2413 $result["direction"] = $this->getOrderDirection();
2414 $result["offset"] = $this->getOffset();
2415 $result["rows"] = $this->getLimit();
2416 $result["selfilters"] = $this->getSelectedFilters();
2417
2418 // #9514 - $this->getSelectedColumns() will omit deselected, leading to
2419 // confusion on restoring template
2420 $result["selfields"] = $this->selected_column;
2421
2422 // gather filter values
2423 if ($this->filters) {
2424 foreach ($this->filters as $item) {
2425 $result["filter_values"][$item->getFieldId()] = $this->getFilterValue($item);
2426 }
2427 }
2428 if ($this->optional_filters && $result["selfilters"]) {
2429 foreach ($this->optional_filters as $item) {
2430 if (in_array($item->getFieldId(), $result["selfilters"])) {
2431 $result["filter_values"][$item->getFieldId()] = $this->getFilterValue($item);
2432 }
2433 }
2434 }
2435
2436 return $result;
2437 }
2438
2443 protected function getFilterValue(ilTableFilterItem $a_item)
2444 {
2445 if (method_exists($a_item, "getChecked")) {
2446 return (string) $a_item->getChecked();
2447 } elseif (method_exists($a_item, "getValue")) {
2448 return $a_item->getValue() ?: "";
2449 } elseif (method_exists($a_item, "getDate")) {
2450 return $a_item->getDate()->get(IL_CAL_DATE);
2451 }
2452 return "";
2453 }
2454
2459 protected function setFilterValue(ilTableFilterItem $a_item, $a_value): void
2460 {
2461 if (method_exists($a_item, "setChecked")) {
2462 $a_item->setChecked((bool) $a_value);
2463 } elseif (method_exists($a_item, "setValue")) {
2464 $a_item->setValue($a_value);
2465 } elseif (method_exists($a_item, "setDate")) {
2466 $a_item->setDate(new ilDate($a_value, IL_CAL_DATE));
2467 }
2468 $a_item->writeToSession();
2469 }
2470
2471 public function setContext(string $id): void
2472 {
2473 if (trim($id)) {
2474 $this->context = $id;
2475 }
2476 }
2477
2478 public function getContext(): string
2479 {
2480 return $this->context;
2481 }
2482
2486 public function setShowRowsSelector(bool $a_value): void
2487 {
2488 $this->show_rows_selector = $a_value;
2489 }
2490
2491 public function getShowRowsSelector(): bool
2492 {
2493 return $this->show_rows_selector;
2494 }
2495
2496 public function setShowTemplates(bool $a_value): void
2497 {
2498 $this->show_templates = $a_value;
2499 }
2500
2501 public function getShowTemplates(): bool
2502 {
2503 return $this->show_templates;
2504 }
2505
2509 public function restoreTemplate(string $a_name): bool
2510 {
2511 global $DIC;
2512
2513 $ilUser = $DIC->user();
2514
2515 $a_name = ilUtil::stripSlashes($a_name);
2516
2517 if (trim($a_name) && $this->getContext() != "" && is_object($ilUser) && $ilUser->getId() != ANONYMOUS_USER_ID) {
2518 $storage = new ilTableTemplatesStorage();
2519
2520 $data = $storage->load($this->getContext(), $ilUser->getId(), $a_name);
2521 if (is_array($data)) {
2522 foreach ($data as $property => $value) {
2523 $this->storeProperty($property, $value);
2524 }
2525 }
2526
2527 $data["filter_values"] = unserialize($data["filter_values"]);
2528 if ($data["filter_values"]) {
2529 $this->restore_filter_values = $data["filter_values"];
2530 }
2531
2532 $this->restore_filter = true;
2533
2534 return true;
2535 }
2536 return false;
2537 }
2538
2542 public function saveTemplate(string $a_name): bool
2543 {
2544 global $DIC;
2545
2546 $ilUser = $DIC->user();
2547
2548 $a_name = ilLegacyFormElementsUtil::prepareFormOutput($a_name, true);
2549
2550 if (trim($a_name) && $this->getContext() != "" && is_object($ilUser) && $ilUser->getId() != ANONYMOUS_USER_ID) {
2551 $storage = new ilTableTemplatesStorage();
2552
2553 $state = $this->getCurrentState();
2554 $state["filter_values"] = serialize($state["filter_values"] ?? null);
2555 $state["selfields"] = serialize($state["selfields"] ?? null);
2556 $state["selfilters"] = serialize($state["selfilters"] ?? null);
2557
2558 $storage->store($this->getContext(), $ilUser->getId(), $a_name, $state);
2559 return true;
2560 }
2561 return false;
2562 }
2563
2564 public function deleteTemplate(string $a_name): bool
2565 {
2566 global $DIC;
2567
2568 $ilUser = $DIC->user();
2569
2570 $a_name = ilLegacyFormElementsUtil::prepareFormOutput($a_name, true);
2571
2572 if (trim($a_name) && $this->getContext() != "" && is_object($ilUser) && $ilUser->getId() != ANONYMOUS_USER_ID) {
2573 $storage = new ilTableTemplatesStorage();
2574 $storage->delete($this->getContext(), $ilUser->getId(), $a_name);
2575 return true;
2576 }
2577 return false;
2578 }
2579
2580 public function getLimit(): int
2581 {
2582 if ($this->getExportMode() || $this->getPrintMode()) {
2583 return 9999;
2584 }
2585 return parent::getLimit();
2586 }
2587
2588 public function getOffset(): int
2589 {
2590 if ($this->getExportMode() || $this->getPrintMode()) {
2591 return 0;
2592 }
2593 return parent::getOffset();
2594 }
2595
2599 public function setExportFormats(array $formats): void
2600 {
2601 $this->export_formats = array();
2602
2603 // #11339
2604 $valid = array(self::EXPORT_EXCEL => "tbl_export_excel",
2605 self::EXPORT_CSV => "tbl_export_csv");
2606
2607 foreach ($formats as $format) {
2608 if (array_key_exists($format, $valid)) {
2609 $this->export_formats[$format] = $valid[$format];
2610 }
2611 }
2612 }
2613
2614 public function setPrintMode(bool $a_value = false): void
2615 {
2616 $this->print_mode = $a_value;
2617 }
2618
2619 public function getPrintMode(): bool
2620 {
2621 return $this->print_mode;
2622 }
2623
2624 public function getExportMode(): int
2625 {
2626 return $this->export_mode;
2627 }
2628
2632 public function exportData(int $format, bool $send = false): void
2633 {
2634 if ($this->dataExists()) {
2635 // #9640: sort
2636 if (!$this->getExternalSorting() && $this->enabled["sort"]) {
2637 $this->determineOffsetAndOrder(true);
2638
2639 $this->row_data = ilArrayUtil::sortArray(
2640 $this->row_data,
2641 $this->getOrderField(),
2642 $this->getOrderDirection(),
2643 $this->numericOrdering($this->getOrderField())
2644 );
2645 }
2646
2647 $filename = "export";
2648 switch ($format) {
2649 case self::EXPORT_EXCEL:
2650 $excel = new ilExcel();
2651 $excel->addSheet($this->title
2652 ?: $this->lng->txt("export"));
2653 $row = 1;
2654
2655 ob_start();
2656 $this->fillMetaExcel($excel, $row); // row must be increment in fillMetaExcel()! (optional method)
2657
2658 // #14813
2659 $pre = $row;
2660 $this->fillHeaderExcel($excel, $row); // row should NOT be incremented in fillHeaderExcel()! (required method)
2661 if ($pre == $row) {
2662 $row++;
2663 }
2664
2665 foreach ($this->row_data as $set) {
2666 $this->fillRowExcel($excel, $row, $set);
2667 $row++; // #14760
2668 }
2669 ob_end_clean();
2670
2671 if ($send) {
2672 $excel->sendToClient($filename);
2673 } else {
2674 $excel->writeToFile($filename);
2675 }
2676 break;
2677
2678 case self::EXPORT_CSV:
2679 $csv = new ilCSVWriter();
2680 $csv->setSeparator(";");
2681
2682 ob_start();
2683 $this->fillMetaCSV($csv);
2684 $this->fillHeaderCSV($csv);
2685 foreach ($this->row_data as $set) {
2686 $this->fillRowCSV($csv, $set);
2687 }
2688 ob_end_clean();
2689
2690 if ($send) {
2691 $filename .= ".csv";
2692 header("Content-type: text/comma-separated-values");
2693 header("Content-Disposition: attachment; filename=\"" . $filename . "\"");
2694 header("Expires: 0");
2695 header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
2696 header("Pragma: public");
2697 echo $csv->getCSVString();
2698 } else {
2699 file_put_contents($filename, $csv->getCSVString());
2700 }
2701 break;
2702 }
2703
2704 if ($send) {
2705 exit();
2706 }
2707 }
2708 }
2709
2716 protected function fillMetaExcel(ilExcel $a_excel, int &$a_row): void
2717 {
2718 }
2719
2726 protected function fillHeaderExcel(ilExcel $a_excel, int &$a_row): void
2727 {
2728 $col = 0;
2729 foreach ($this->column as $column) {
2730 $title = strip_tags($column["text"]);
2731 if ($title) {
2732 $a_excel->setCell($a_row, $col++, $title);
2733 }
2734 }
2735 $a_excel->setBold("A" . $a_row . ":" . $a_excel->getColumnCoord($col - 1) . $a_row);
2736 }
2737
2745 protected function fillRowExcel(ilExcel $a_excel, int &$a_row, array $a_set): void
2746 {
2747 $col = 0;
2748 foreach ($a_set as $value) {
2749 if (is_array($value)) {
2750 $value = implode(', ', $value);
2751 }
2752 $a_excel->setCell($a_row, $col++, $value);
2753 }
2754 }
2755
2761 protected function fillMetaCSV(ilCSVWriter $a_csv): void
2762 {
2763 }
2764
2770 protected function fillHeaderCSV(ilCSVWriter $a_csv): void
2771 {
2772 foreach ($this->column as $column) {
2773 $title = strip_tags($column["text"]);
2774 if ($title) {
2775 $a_csv->addColumn($title);
2776 }
2777 }
2778 $a_csv->addRow();
2779 }
2780
2787 protected function fillRowCSV(ilCSVWriter $a_csv, array $a_set): void
2788 {
2789 foreach ($a_set as $key => $value) {
2790 if (is_array($value)) {
2791 $value = implode(', ', $value);
2792 }
2793 $a_csv->addColumn(strip_tags($value));
2794 }
2795 $a_csv->addRow();
2796 }
2797
2798 public function setEnableAllCommand(bool $a_value): void
2799 {
2800 $this->enable_command_for_all = $a_value;
2801 }
2802
2803 public static function getAllCommandLimit(): int
2804 {
2805 global $DIC;
2806
2807 $ilClientIniFile = $DIC["ilClientIniFile"];
2808
2809 $limit = $ilClientIniFile->readVariable("system", "TABLE_ACTION_ALL_LIMIT");
2810 if (!$limit) {
2811 $limit = self::ACTION_ALL_LIMIT;
2812 }
2813
2814 return $limit;
2815 }
2816
2817 public function setRowSelectorLabel(string $row_selector_label): void
2818 {
2819 $this->row_selector_label = $row_selector_label;
2820 }
2821
2822 public function getRowSelectorLabel(): string
2823 {
2824 return $this->row_selector_label;
2825 }
2826
2827 public function setPreventDoubleSubmission(bool $a_val): void
2828 {
2829 $this->prevent_double_submission = $a_val;
2830 }
2831
2832 public function getPreventDoubleSubmission(): bool
2833 {
2834 return $this->prevent_double_submission;
2835 }
2836
2837 public function setLimit(int $a_limit = 0, int $a_default_limit = 0): void
2838 {
2839 parent::setLimit($a_limit, $a_default_limit);
2840
2841 // #17077 - if limit is set "manually" to 9999, force rows selector off
2842 if ($a_limit == 9999 &&
2843 $this->limit_determined) {
2844 $this->rows_selector_off = true;
2845 }
2846 }
2847}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
$filename
Definition: buildRTE.php:78
const IL_CAL_DATE
return true
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addColumn(string $a_col)
This class represents a checkbox property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilCtrl provides processing control methods.
getNextClass($a_gui_class=null)
@inheritDoc
static setUseRelativeDates(bool $a_status)
set use relative dates
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class for single dates.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setBold(string $a_coords)
Set cell(s) to bold.
getColumnCoord(int $a_col)
Get column "name" from number.
setCell(int $a_row, int $a_col, $a_value, ?string $a_datatype=null)
Set cell value.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
loadLanguageModule(string $a_module)
Load language module.
static prepareFormOutput($a_str, bool $a_strip=false)
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.
This class represents a number property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a selection list property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
string $defaultorderdirection
restoreTemplate(string $a_name)
Restore state from template.
setTopAnchor(string $a_val)
isFilterSelected(string $a_col)
Is given filter selected?
isColumnSelected(string $col)
array $restore_filter_values
__construct(?object $a_parent_obj, string $a_parent_cmd="", string $a_template_context="")
setOrderLink(string $key, string $order_dir)
bool $enable_command_for_all
setShowRowsSelector(bool $a_value)
Toggle rows-per-page selector.
setFilterCommand(string $a_val, string $a_caption="")
getFormName()
get the name of the parent form
prepareOutput()
Anything that must be done before HTML is generated.
setOrderField(string $a_order_field)
setPreventDoubleSubmission(bool $a_val)
getFilterItemByPostVar(string $a_post_var)
getHTML()
Get HTML.
loadProperty(string $type)
bool $disable_filter_hiding
setContext(string $id)
setEnableAllCommand(bool $a_value)
setLimit(int $a_limit=0, int $a_default_limit=0)
set max.
bool $prevent_double_submission
string $requested_nav_par1
fillRowCSV(ilCSVWriter $a_csv, array $a_set)
CSV Version of Fill Row.
setIsDataTable(bool $a_val)
setRowSelectorLabel(string $row_selector_label)
determineOffsetAndOrder(bool $a_omit_offset=false)
setCustomPreviousNext(string $a_prev_link, string $a_next_link)
setOpenFormTag(bool $a_val)
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
string $row_selector_label
setEnableNumInfo(bool $a_val)
setExportFormats(array $formats)
Set available export formats.
setExternalSegmentation(bool $a_val)
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
addFilterItem(ilTableFilterItem $a_input_item, bool $a_optional=false)
setEnableTitle(bool $a_enabletitle)
setFormName(string $a_name="")
getLinkbar(string $a_num)
setDescription(string $a_val)
addHiddenInput(string $a_name, string $a_value)
addMultiCommand(string $a_cmd, string $a_text)
setShowTemplates(bool $a_value)
addFilterItemByMetaType(string $id, int $type=self::FILTER_TEXT, bool $a_optional=false, string $caption="")
Add filter by standard type.
setPrefix(string $a_prefix)
set prefix for sort and offset fields (if you have two or more tables on a page that you want to sort...
setFormAction(string $a_form_action, bool $a_multipart=false)
saveTemplate(string $a_name)
Save current state as template.
resetOffset(bool $a_in_determination=false)
setHeaderHTML(string $html)
string $defaultorderfield
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)
ILIAS Table TableGUIRequest $table_request
fillHeaderCSV(ilCSVWriter $a_csv)
CSV Version of Fill Header.
setEnableHeader(bool $a_enableheader)
deleteTemplate(string $a_name)
string $requested_tmpl_delete
renderFilter()
Render Filter section.
fillRowExcel(ilExcel $a_excel, int &$a_row, array $a_set)
Excel Version of Fill Row.
isFilterVisible()
Check if filter is visible: manually shown (session, db) or default value set.
addCommandButtonInstance(ilButtonBase $a_button)
setDefaultOrderField(string $a_defaultorderfield)
string $row_template_dir
ilGlobalTemplateInterface $main_tpl
setPrintMode(bool $a_value=false)
setDisplayAsBlock(bool $a_val)
fillRow(array $a_set)
Standard Version of Fill Row.
getCurrentState()
get current settings for order, limit, columns and filter
getSelectableColumns()
Get selectable columns.
addHeaderCommand(string $a_href, string $a_text, string $a_target="", string $a_img="")
static getAllCommandLimit()
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
string $requested_nav_par
setDisableFilterHiding(bool $a_val=true)
numericOrdering(string $a_field)
Should this field be sorted numeric?
setNoEntriesText(string $a_text)
fillMetaExcel(ilExcel $a_excel, int &$a_row)
Add meta information to excel export.
setTopCommands(bool $a_val)
getFilterItems(bool $a_optionals=false)
setFilterValue(ilTableFilterItem $a_item, $a_value)
setExternalSorting(bool $a_val)
isAdvMDFilter(ilAdvancedMDRecordGUI $a_gui, ilTableFilterItem $a_element)
Check if filter element is based on adv md.
array $selectable_columns
const FILTER_DURATION_RANGE
string $requested_nav_par2
addMultiItemSelectionButton(string $a_sel_var, array $a_options, string $a_cmd, string $a_text, string $a_default_selection='')
string $requested_tmpl_create
setCloseCommand(string $a_link)
getFilterValue(ilTableFilterItem $a_item)
Get current filter value.
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
bool $default_filter_visibility
setDefaultOrderDirection(string $a_defaultorderdirection)
setFilterCols(int $a_val)
setResetCommand(string $a_val, string $a_caption="")
storeProperty(string $type, string $value)
setDefaultFilterVisiblity(bool $a_status)
setData(array $a_data)
Set table data.
const FILTER_NUMBER_RANGE
exportData(int $format, bool $send=false)
Export and optionally send current table data.
fillMetaCSV(ilCSVWriter $a_csv)
Add meta information to csv export.
fillHeaderExcel(ilExcel $a_excel, int &$a_row)
Excel Version of Fill Header.
setCloseFormTag(bool $a_val)
const FILTER_DATETIME_RANGE
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilLanguage $lng
setOffset(int $a_offset)
set dataset offset
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
special template class to simplify handling of ITX/PEAR
This class represents a text property in a property form.
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)
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
static img(string $a_src, ?string $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
static initConnection(?ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Connection module.
$c
Definition: cli.php:38
const ANONYMOUS_USER_ID
Definition: constants.php:27
$formats
Definition: date.php:77
$valid
$txt
Definition: error.php:13
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
exit
Definition: login.php:28
if($format !==null) $name
Definition: metadata.php:247
$format
Definition: metadata.php:235
$i
Definition: metadata.php:41
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
string $key
Consumer key/client ID value.
Definition: System.php:193
$type
$url
$lng
$context
Definition: webdav.php:29
$rows
Definition: xhr_table.php:10