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