ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilTable2GUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once("Services/Table/classes/class.ilTableGUI.php");
5
16{
17
21 protected $ctrl;
22
26 protected $tpl;
27
31 protected $parent_obj;
32
36 protected $parent_cmd;
37
38 protected $close_command = "";
39 private $unique_id;
40 private $headerHTML;
41 protected $top_anchor = "il_table_top";
42 protected $filters = array();
43 protected $optional_filters = array();
44 protected $filter_cmd = 'applyFilter';
45 protected $reset_cmd = 'resetFilter';
46 protected $filter_cols = 5;
47 protected $ext_sort = false;
48 protected $ext_seg = false;
49 protected $context = "";
50
51 protected $mi_sel_buttons = [];
52 protected $disable_filter_hiding = false;
53 protected $selected_filter = false;
54 protected $top_commands = true;
55 protected $selectable_columns = array();
56 protected $selected_column = array();
57 protected $show_templates = false;
58 protected $show_rows_selector = true; // JF, 2014-10-27
59 protected $rows_selector_off = false;
60
61 protected $nav_determined = false;
62 protected $limit_determined = false;
63 protected $filters_determined = false;
64 protected $columns_determined = false;
65 protected $open_form_tag = true;
66 protected $close_form_tag = true;
67
68 protected $export_formats = [];
69 protected $export_mode;
70 protected $print_mode;
71
73 protected $restore_filter; // [bool]
74 protected $restore_filter_values; // [bool]
75
79 protected $default_filter_visibility = false;
80
81 protected $sortable_fields = array();
86
91
95 protected $select_all_on_top = false;
96
97 protected $sel_buttons = [];
98
99
100 const FILTER_TEXT = 1;
101 const FILTER_SELECT = 2;
102 const FILTER_DATE = 3;
109
110 const EXPORT_EXCEL = 1;
111 const EXPORT_CSV = 2;
112
113 const ACTION_ALL_LIMIT = 1000;
114
115
123 public function __construct($a_parent_obj, $a_parent_cmd = "", $a_template_context = "")
124 {
125 global $DIC;
126
127 $this->lng = $DIC->language();
128 $this->ctrl = $DIC->ctrl();
129 $lng = $DIC->language();
130
131 parent::__construct(0, false);
132 $this->unique_id = md5(uniqid());
133 $this->parent_obj = $a_parent_obj;
134 $this->parent_cmd = $a_parent_cmd;
135 $this->buttons = array();
136 $this->header_commands = array();
137 $this->multi = array();
138 $this->hidden_inputs = array();
139 $this->formname = "table_" . $this->unique_id;
140 $this->tpl = new ilTemplate("tpl.table2.html", true, true, "Services/Table");
141
142 $lng->loadLanguageModule('tbl');
143
144 if (!$a_template_context) {
145 $a_template_context = $this->getId();
146 }
147 $this->setContext($a_template_context);
148
149 // activate export mode
150 if (isset($_GET[$this->prefix . "_xpt"])) {
151 $this->export_mode = (int) $_GET[$this->prefix . "_xpt"];
152 }
153
154 // template handling
155 if (isset($_GET[$this->prefix . "_tpl"])) {
156 $this->restoreTemplate($_GET[$this->prefix . "_tpl"]);
157 }
158
159 $this->determineLimit();
160 $this->setIsDataTable(true);
161 $this->setEnableNumInfo(true);
163 }
164
170 public function setOpenFormTag($a_val)
171 {
172 $this->open_form_tag = $a_val;
173 }
174
180 public function getOpenFormTag()
181 {
183 }
184
190 public function setCloseFormTag($a_val)
191 {
192 $this->close_form_tag = $a_val;
193 }
194
200 public function getCloseFormTag()
201 {
203 }
204
208 public function determineLimit()
209 {
210 global $DIC;
211
212 $ilUser = null;
213 if (isset($DIC["ilUser"])) {
214 $ilUser = $DIC["ilUser"];
215 }
216
217 if ($this->limit_determined) {
218 return;
219 }
220
221 $limit = 0;
222 if (isset($_GET[$this->prefix . "_trows"])) {
223 $this->storeProperty("rows", $_GET[$this->prefix . "_trows"]);
224 $limit = $_GET[$this->prefix . "_trows"];
225 $this->resetOffset();
226 }
227
228 if ($limit == 0) {
229 $rows = $this->loadProperty("rows");
230 if ($rows > 0) {
231 $limit = $rows;
232 } else {
233 if (is_object($ilUser)) {
234 $limit = $ilUser->getPref("hits_per_page");
235 } else {
236 $limit = 40;
237 }
238 }
239 }
240
241 $this->setLimit($limit);
242 $this->limit_determined = true;
243 }
244
250 public function getSelectableColumns()
251 {
252 return array();
253 }
254
258 public function determineSelectedColumns()
259 {
260 if ($this->columns_determined) {
261 return;
262 }
263
264 $old_sel = $this->loadProperty("selfields");
265
266 $stored = false;
267 if ($old_sel != "") {
268 $sel_fields =
269 @unserialize($old_sel);
270 $stored = true;
271 }
272 if (!is_array($sel_fields)) {
273 $stored = false;
274 $sel_fields = array();
275 }
276
277 $this->selected_columns = array();
278 $set = false;
279 foreach ($this->getSelectableColumns() as $k => $c) {
280 $this->selected_column[$k] = false;
281
282 $new_column = ($sel_fields[$k] === null);
283
284 if (isset($_POST["tblfsh" . $this->getId()]) && $_POST["tblfsh" . $this->getId()]) {
285 $set = true;
286 if (is_array($_POST["tblfs" . $this->getId()]) && in_array($k, $_POST["tblfs" . $this->getId()])) {
287 $this->selected_column[$k] = true;
288 }
289 } elseif ($stored && !$new_column) { // take stored values
290 $this->selected_column[$k] = $sel_fields[$k];
291 } else { // take default values
292 if ($new_column) {
293 $set = true;
294 }
295 if (isset($c["default"]) && $c["default"]) {
296 $this->selected_column[$k] = true;
297 }
298 }
299
300 // Optional filters
301 if (isset($_POST["tblff" . $this->getId()]) && $_POST["tblff" . $this->getId()]) {
302 $set = true;
303 if (is_array($_POST["tblff" . $this->getId()]) && in_array($k, $_POST["tblff" . $this->getId()])) {
304 $this->selected_column[$k] = true;
305 }
306 }
307 }
308
309 if ($old_sel != serialize($this->selected_column) && $set) {
310 $this->storeProperty("selfields", serialize($this->selected_column));
311 }
312
313 $this->columns_determined = true;
314 }
315
322 public function isColumnSelected($a_col)
323 {
324 return $this->selected_column[$a_col];
325 }
326
333 public function getSelectedColumns()
334 {
335 $scol = array();
336 foreach ($this->selected_column as $k => $v) {
337 if ($v) {
338 $scol[$k] = $k;
339 }
340 }
341 return $scol;
342 }
343
347 public function executeCommand()
348 {
349 $ilCtrl = $this->ctrl;
350
351 $next_class = $ilCtrl->getNextClass($this);
352 $cmd = $ilCtrl->getCmd();
353
354 switch ($next_class) {
355 case 'ilformpropertydispatchgui':
356 include_once './Services/Form/classes/class.ilFormPropertyDispatchGUI.php';
357 $form_prop_dispatch = new ilFormPropertyDispatchGUI();
358 $this->initFilter();
359 $item = $this->getFilterItemByPostVar($_GET["postvar"]);
360 $form_prop_dispatch->setItem($item);
361 return $ilCtrl->forwardCommand($form_prop_dispatch);
362 break;
363
364 }
365 return false;
366 }
367
371 public function resetOffset($a_in_determination = false)
372 {
373 if (!$this->nav_determined && !$a_in_determination) {
375 }
376 $this->nav_value = $this->getOrderField() . ":" . $this->getOrderDirection() . ":0";
377 $_GET[$this->getNavParameter()] =
378 $_POST[$this->getNavParameter() . "1"] =
379 $this->nav_value;
380 //echo $this->nav_value;
381 $this->setOffset(0);
382 }
383
388 public function initFilter()
389 {
390 }
391
397 public function getParentObject()
398 {
399 return $this->parent_obj;
400 }
401
407 public function getParentCmd()
408 {
409 return $this->parent_cmd;
410 }
411
417 public function setTopAnchor($a_val)
418 {
419 $this->top_anchor = $a_val;
420 }
421
427 public function getTopAnchor()
428 {
429 return $this->top_anchor;
430 }
431
437 public function setNoEntriesText($a_text)
438 {
439 $this->noentriestext = $a_text;
440 }
441
447 public function getNoEntriesText()
448 {
449 return $this->noentriestext;
450 }
451
457 public function setIsDataTable($a_val)
458 {
459 $this->datatable = $a_val;
460 }
461
467 public function getIsDataTable()
468 {
469 return $this->datatable;
470 }
471
477 public function setEnableTitle($a_enabletitle)
478 {
479 $this->enabled["title"] = $a_enabletitle;
480 }
481
487 public function getEnableTitle()
488 {
489 return $this->enabled["title"];
490 }
491
497 public function setEnableHeader($a_enableheader)
498 {
499 $this->enabled["header"] = $a_enableheader;
500 }
501
507 public function getEnableHeader()
508 {
509 return $this->enabled["header"];
510 }
511
517 public function setEnableNumInfo($a_val)
518 {
519 $this->num_info = $a_val;
520 }
521
527 public function getEnableNumInfo()
528 {
529 return $this->num_info;
530 }
531
535 final public function setTitle($a_title, $a_icon = 0, $a_icon_alt = 0)
536 {
537 parent::setTitle($a_title, $a_icon, $a_icon_alt);
538 }
539
545 public function setDescription($a_val)
546 {
547 $this->description = $a_val;
548 }
549
555 public function getDescription()
556 {
557 return $this->description;
558 }
559
565 public function setOrderField($a_order_field)
566 {
567 $this->order_field = $a_order_field;
568 }
569
570 public function getOrderField()
571 {
572 return $this->order_field;
573 }
574
575 final public function setData($a_data)
576 {
577 // check column names against given data (to ensure proper sorting)
578 if (defined('DEVMODE') && DEVMODE &&
579 $this->enabled["header"] && $this->enabled["sort"] &&
580 $this->columns_determined && is_array($this->column) &&
581 is_array($a_data) && sizeof($a_data) && !$this->getExternalSorting()) {
582 $check = $a_data;
583 $check = array_keys(array_shift($check));
584 foreach ($this->column as $col) {
585 if ($col["sort_field"] && !in_array($col["sort_field"], $check)) {
586 $invalid[] = $col["sort_field"];
587 }
588 }
589
590 // this triggers an error, if some columns are not set for some rows
591 // which may just be a representation of "null" values, e.g.
592 // ilAdvancedMDValues:queryForRecords works that way.
593/* if(sizeof($invalid))
594 {
595 trigger_error("The following columns are defined as sortable but".
596 " cannot be found in the given data: ".implode(", ", $invalid).
597 ". Sorting will not work properly.", E_USER_WARNING);
598 }*/
599 }
600
601 $this->row_data = $a_data;
602 if (!is_array($this->row_data)) {
603 $this->row_data = [];
604 }
605 }
606
607 final public function getData()
608 {
609 return $this->row_data;
610 }
611
612 final public function dataExists()
613 {
614 if (is_array($this->row_data)) {
615 if (count($this->row_data) > 0) {
616 return true;
617 }
618 }
619 return false;
620 }
621
622 final public function setPrefix($a_prefix)
623 {
624 $this->prefix = $a_prefix;
625 }
626
627 final public function getPrefix()
628 {
629 return $this->prefix;
630 }
631
636 final public function addFilterItem($a_input_item, $a_optional = false)
637 {
638 $a_input_item->setParent($this);
639 if (!$a_optional) {
640 $this->filters[] = $a_input_item;
641 } else {
642 $this->optional_filters[] = $a_input_item;
643 }
644
645 // restore filter values (from stored view)
646 if ($this->restore_filter) {
647 if (array_key_exists($a_input_item->getFieldId(), $this->restore_filter_values ?? [])) {
648 $this->setFilterValue($a_input_item, $this->restore_filter_values[$a_input_item->getFieldId()]);
649 } else {
650 $this->setFilterValue($a_input_item, null); // #14949
651 }
652 }
653 }
654
664 public function addFilterItemByMetaType($id, $type = self::FILTER_TEXT, $a_optional = false, $caption = null)
665 {
666 global $DIC;
667
668 $lng = $DIC->language(); // constructor may not be called here, if initFilter is being called in subclasses before parent::__construct
669
670 if (!$caption) {
671 $caption = $lng->txt($id);
672 }
673
674 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
675
676 switch ($type) {
678 $item = new ilCheckboxInputGUI($caption, $id);
679 break;
680
682 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
683 $item = new ilSelectInputGUI($caption, $id);
684 break;
685
687 include_once("./Services/Form/classes/class.ilDateTimeInputGUI.php");
688 $item = new ilDateTimeInputGUI($caption, $id);
689 break;
690
692 include_once("./Services/Form/classes/class.ilTextInputGUI.php");
693 $item = new ilTextInputGUI($caption, $id);
694 $item->setMaxLength(64);
695 $item->setSize(20);
696 // $item->setSubmitFormOnEnter(true);
697 break;
698
700 $lng->loadLanguageModule("meta");
701 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
702 $item = new ilSelectInputGUI($caption, $id);
703 $options = array("" => $lng->txt("trac_all"));
704 foreach ($lng->getInstalledLanguages() as $lang_key) {
705 $options[$lang_key] = $lng->txt("meta_l_" . $lang_key);
706 }
707 $item->setOptions($options);
708 break;
709
711 include_once("./Services/Form/classes/class.ilCombinationInputGUI.php");
712 include_once("./Services/Form/classes/class.ilNumberInputGUI.php");
713 $item = new ilCombinationInputGUI($caption, $id);
714 $combi_item = new ilNumberInputGUI("", $id . "_from");
715 $item->addCombinationItem("from", $combi_item, $lng->txt("from"));
716 $combi_item = new ilNumberInputGUI("", $id . "_to");
717 $item->addCombinationItem("to", $combi_item, $lng->txt("to"));
718 $item->setComparisonMode(ilCombinationInputGUI::COMPARISON_ASCENDING);
719 $item->setMaxLength(7);
720 $item->setSize(20);
721 break;
722
724 include_once("./Services/Form/classes/class.ilCombinationInputGUI.php");
725 include_once("./Services/Form/classes/class.ilDateTimeInputGUI.php");
726 $item = new ilCombinationInputGUI($caption, $id);
727 $combi_item = new ilDateTimeInputGUI("", $id . "_from");
728 $item->addCombinationItem("from", $combi_item, $lng->txt("from"));
729 $combi_item = new ilDateTimeInputGUI("", $id . "_to");
730 $item->addCombinationItem("to", $combi_item, $lng->txt("to"));
731 $item->setComparisonMode(ilCombinationInputGUI::COMPARISON_ASCENDING);
732 break;
733
735 include_once("./Services/Form/classes/class.ilCombinationInputGUI.php");
736 include_once("./Services/Form/classes/class.ilDateTimeInputGUI.php");
737 $item = new ilCombinationInputGUI($caption, $id);
738 $combi_item = new ilDateTimeInputGUI("", $id . "_from");
739 $combi_item->setShowTime(true);
740 $item->addCombinationItem("from", $combi_item, $lng->txt("from"));
741 $combi_item = new ilDateTimeInputGUI("", $id . "_to");
742 $combi_item->setShowTime(true);
743 $item->addCombinationItem("to", $combi_item, $lng->txt("to"));
744 $item->setComparisonMode(ilCombinationInputGUI::COMPARISON_ASCENDING);
745 break;
746
748 $lng->loadLanguageModule("form");
749 include_once("./Services/Form/classes/class.ilCombinationInputGUI.php");
750 include_once("./Services/Form/classes/class.ilDurationInputGUI.php");
751 $item = new ilCombinationInputGUI($caption, $id);
752 $combi_item = new ilDurationInputGUI("", $id . "_from");
753 $combi_item->setShowMonths(false);
754 $combi_item->setShowDays(true);
755 $combi_item->setShowSeconds(true);
756 $item->addCombinationItem("from", $combi_item, $lng->txt("from"));
757 $combi_item = new ilDurationInputGUI("", $id . "_to");
758 $combi_item->setShowMonths(false);
759 $combi_item->setShowDays(true);
760 $combi_item->setShowSeconds(true);
761 $item->addCombinationItem("to", $combi_item, $lng->txt("to"));
762 $item->setComparisonMode(ilCombinationInputGUI::COMPARISON_ASCENDING);
763 break;
764
765 default:
766 return false;
767 }
768
769 $this->addFilterItem($item, $a_optional);
770 $item->readFromSession();
771 return $item;
772 }
773
777 final public function getFilterItems($a_optionals = false)
778 {
779 if (!$a_optionals) {
780 return $this->filters;
781 }
783 }
784
785 final public function getFilterItemByPostVar($a_post_var)
786 {
787 foreach ($this->getFilterItems() as $item) {
788 if ($item->getPostVar() == $a_post_var) {
789 return $item;
790 }
791 }
792 foreach ($this->getFilterItems(true) as $item) {
793 if ($item->getPostVar() == $a_post_var) {
794 return $item;
795 }
796 }
797 return false;
798 }
799
805 public function setFilterCols($a_val)
806 {
807 $this->filter_cols = $a_val;
808 }
809
815 public function getFilterCols()
816 {
817 return $this->filter_cols;
818 }
819
825 public function setDisableFilterHiding($a_val = true)
826 {
827 $this->disable_filter_hiding = $a_val;
828 }
829
835 public function getDisableFilterHiding()
836 {
838 }
839
846 public function isFilterSelected($a_col)
847 {
848 return $this->selected_filter[$a_col];
849 }
850
857 public function getSelectedFilters()
858 {
859 $sfil = array();
860 foreach ($this->selected_filter as $k => $v) {
861 if ($v) {
862 $sfil[$k] = $k;
863 }
864 }
865 return $sfil;
866 }
867
874 public function determineSelectedFilters()
875 {
876 if ($this->filters_determined) {
877 return;
878 }
879
880 $old_sel = $this->loadProperty("selfilters");
881 $stored = false;
882 if ($old_sel != "") {
883 $sel_filters =
884 @unserialize($old_sel);
885 $stored = true;
886 }
887 if (!is_array($sel_filters)) {
888 $stored = false;
889 $sel_filters = array();
890 }
891
892 $this->selected_filter = array();
893 $set = false;
894 foreach ($this->getFilterItems(true) as $item) {
895 $k = $item->getPostVar();
896
897 $this->selected_filter[$k] = false;
898
899 if ($_POST["tblfsf" . $this->getId()]) {
900 $set = true;
901 if (is_array($_POST["tblff" . $this->getId()]) && in_array($k, $_POST["tblff" . $this->getId()])) {
902 $this->selected_filter[$k] = true;
903 } else {
904 $item->setValue(null);
905 $item->writeToSession();
906 }
907 } elseif ($stored) { // take stored values
908 $this->selected_filter[$k] = $sel_filters[$k];
909 }
910 }
911
912 if ($old_sel != serialize($this->selected_filter) && $set) {
913 $this->storeProperty("selfilters", serialize($this->selected_filter));
914 }
915
916 $this->filters_determined = true;
917 }
918
922 public function setCustomPreviousNext($a_prev_link, $a_next_link)
923 {
924 $this->custom_prev_next = true;
925 $this->custom_prev = $a_prev_link;
926 $this->custom_next = $a_next_link;
927 }
928
935 final public function setFormAction($a_form_action, $a_multipart = false)
936 {
937 $this->form_action = $a_form_action;
938 $this->form_multipart = (bool) $a_multipart;
939 }
940
946 final public function getFormAction()
947 {
948 return $this->form_action;
949 }
950
956 public function setFormName($a_formname = "")
957 {
958 $this->formname = $a_formname;
959 }
960
966 public function getFormName()
967 {
968 return $this->formname;
969 }
970
976 public function setId($a_val)
977 {
978 $this->id = $a_val;
979 if ($this->getPrefix() == "") {
980 $this->setPrefix($a_val);
981 }
982 }
983
989 public function getId()
990 {
991 return $this->id;
992 }
993
999 public function setDisplayAsBlock($a_val)
1000 {
1001 $this->display_as_block = $a_val;
1002 }
1003
1009 public function getDisplayAsBlock()
1010 {
1011 return $this->display_as_block;
1012 }
1013
1019 public function getSelectAllCheckbox()
1020 {
1022 }
1023
1030 public function setSelectAllCheckbox($a_select_all_checkbox, $a_select_all_on_top = false)
1031 {
1032 $this->select_all_checkbox = $a_select_all_checkbox;
1033 $this->select_all_on_top = $a_select_all_on_top;
1034 }
1035
1041 public function setExternalSorting($a_val)
1042 {
1043 $this->ext_sort = $a_val;
1044 }
1045
1051 public function getExternalSorting()
1052 {
1053 return $this->ext_sort;
1054 }
1055
1062 public function setFilterCommand($a_val, $a_caption = null)
1063 {
1064 $this->filter_cmd = $a_val;
1065 $this->filter_cmd_txt = $a_caption;
1066 }
1067
1073 public function getFilterCommand()
1074 {
1075 return $this->filter_cmd;
1076 }
1077
1084 public function setResetCommand($a_val, $a_caption = null)
1085 {
1086 $this->reset_cmd = $a_val;
1087 $this->reset_cmd_txt = $a_caption;
1088 }
1089
1095 public function getResetCommand()
1096 {
1097 return $this->reset_cmd;
1098 }
1099
1105 public function setExternalSegmentation($a_val)
1106 {
1107 $this->ext_seg = $a_val;
1108 }
1109
1115 public function getExternalSegmentation()
1116 {
1117 return $this->ext_seg;
1118 }
1119
1126 final public function setRowTemplate($a_template, $a_template_dir = "")
1127 {
1128 $this->row_template = $a_template;
1129 $this->row_template_dir = $a_template_dir;
1130 }
1131
1137 public function setDefaultOrderField($a_defaultorderfield)
1138 {
1139 $this->defaultorderfield = $a_defaultorderfield;
1140 }
1141
1147 public function getDefaultOrderField()
1148 {
1149 return $this->defaultorderfield;
1150 }
1151
1157 public function setDefaultOrderDirection($a_defaultorderdirection)
1158 {
1159 $this->defaultorderdirection = $a_defaultorderdirection;
1160 }
1161
1168 {
1169 return $this->defaultorderdirection;
1170 }
1171
1176 public function setDefaultFilterVisiblity($a_status)
1177 {
1178 $this->default_filter_visibility = $a_status;
1179 }
1180
1186 {
1188 }
1189
1190 /*
1191 * Removes all command buttons from the table
1192 *
1193 * @access public
1194 */
1195 public function clearCommandButtons()
1196 {
1197 $this->buttons = array();
1198 }
1199
1206 public function addCommandButton($a_cmd, $a_text, $a_onclick = '', $a_id = "", $a_class = null)
1207 {
1208 $this->buttons[] = array("cmd" => $a_cmd, "text" => $a_text, 'onclick' => $a_onclick,
1209 "id" => $a_id, "class" => $a_class);
1210 }
1211
1217 public function addCommandButtonInstance(ilButtonBase $a_button)
1218 {
1219 $this->buttons[] = $a_button;
1220 }
1221
1232 public function addSelectionButton($a_sel_var, $a_options, $a_cmd, $a_text, $a_default_selection = '')
1233 {
1234 echo "ilTabl2GUI->addSelectionButton() has been deprecated with 4.2. Please try to move the drop-down to ilToolbarGUI.";
1235 // $this->sel_buttons[] = array("sel_var" => $a_sel_var, "options" => $a_options, "selected" => $a_default_selection, "cmd" => $a_cmd, "text" => $a_text);
1236 }
1237
1247 public function addMultiItemSelectionButton($a_sel_var, $a_options, $a_cmd, $a_text, $a_default_selection = '')
1248 {
1249 $this->mi_sel_buttons[] = array("sel_var" => $a_sel_var, "options" => $a_options, "selected" => $a_default_selection, "cmd" => $a_cmd, "text" => $a_text);
1250 $this->addHiddenInput("cmd_sv[" . $a_cmd . "]", $a_sel_var);
1251 }
1252
1253
1254
1261 public function setCloseCommand($a_link)
1262 {
1263 $this->close_command = $a_link;
1264 }
1265
1272 public function addMultiCommand($a_cmd, $a_text)
1273 {
1274 $this->multi[] = array("cmd" => $a_cmd, "text" => $a_text);
1275 }
1276
1283 public function addHiddenInput($a_name, $a_value)
1284 {
1285 $this->hidden_inputs[] = array("name" => $a_name, "value" => $a_value);
1286 }
1287
1294 public function addHeaderCommand($a_href, $a_text, $a_target = "", $a_img = "")
1295 {
1296 $this->header_commands[] = array("href" => $a_href, "text" => $a_text,
1297 "target" => $a_target, "img" => $a_img);
1298 }
1299
1305 public function setTopCommands($a_val)
1306 {
1307 $this->top_commands = $a_val;
1308 }
1309
1315 public function getTopCommands()
1316 {
1317 return $this->top_commands;
1318 }
1319
1327 final public function addColumn(
1328 $a_text,
1329 $a_sort_field = "",
1330 $a_width = "",
1331 $a_is_checkbox_action_column = false,
1332 $a_class = "",
1333 $a_tooltip = "",
1334 $a_tooltip_with_html = false
1335 ) {
1336 $this->column[] = array(
1337 "text" => $a_text,
1338 "sort_field" => $a_sort_field,
1339 "width" => $a_width,
1340 "is_checkbox_action_column" => $a_is_checkbox_action_column,
1341 "class" => $a_class,
1342 "tooltip" => $a_tooltip,
1343 "tooltip_html" => (bool) $a_tooltip_with_html
1344 );
1345 if ($a_sort_field != "") {
1346 $this->sortable_fields[] = $a_sort_field;
1347 }
1348 $this->column_count = count($this->column);
1349 }
1350
1351
1352 final public function getNavParameter()
1353 {
1354 return $this->prefix . "_table_nav";
1355 }
1356
1357 public function setOrderLink($sort_field, $order_dir)
1358 {
1359 global $DIC;
1360
1361 $ilUser = $DIC->user();
1362
1363 $ilCtrl = $this->ctrl;
1364
1365 $hash = "";
1366 if (is_object($ilUser) && $ilUser->getPref("screen_reader_optimization")) {
1367 $hash = "#" . $this->getTopAnchor();
1368 }
1369
1370 $old = $_GET[$this->getNavParameter()];
1371
1372 // set order link
1373 $ilCtrl->setParameter(
1374 $this->parent_obj,
1375 $this->getNavParameter(),
1376 urlencode($sort_field) . ":" . $order_dir . ":" . $this->offset
1377 );
1378 $this->tpl->setVariable(
1379 "TBL_ORDER_LINK",
1380 $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd) . $hash
1381 );
1382
1383 // set old value of nav variable
1384 $ilCtrl->setParameter(
1385 $this->parent_obj,
1386 $this->getNavParameter(),
1387 $old
1388 );
1389 }
1390
1391 public function fillHeader()
1392 {
1393 $lng = $this->lng;
1394
1395 $allcolumnswithwidth = true;
1396 foreach ((array) $this->column as $idx => $column) {
1397 if (!strlen($column["width"])) {
1398 $allcolumnswithwidth = false;
1399 } elseif ($column["width"] == "1") {
1400 // IE does not like 1 but seems to work with 1%
1401 $this->column[$idx]["width"] = "1%";
1402 }
1403 }
1404 if ($allcolumnswithwidth) {
1405 foreach ((array) $this->column as $column) {
1406 $this->tpl->setCurrentBlock("tbl_colgroup_column");
1407 $width = (is_numeric($column["width"]))
1408 ? $column["width"] . "px"
1409 : $column["width"];
1410 $this->tpl->setVariable("COLGROUP_COLUMN_WIDTH", " style=\"width:" . $width . "\"");
1411 $this->tpl->parseCurrentBlock();
1412 }
1413 }
1414 $ccnt = 0;
1415 foreach ((array) $this->column as $column) {
1416 $ccnt++;
1417 //tooltip
1418 if ($column["tooltip"] != "") {
1419 include_once("./Services/UIComponent/Tooltip/classes/class.ilTooltipGUI.php");
1421 "thc_" . $this->getId() . "_" . $ccnt,
1422 $column["tooltip"],
1423 "",
1424 "bottom center",
1425 "top center",
1426 !$column["tooltip_html"]
1427 );
1428 }
1429
1430 if ($column['is_checkbox_action_column'] && $this->select_all_on_top) {
1431 $this->tpl->setCurrentBlock('tbl_header_top_select_all');
1432 $this->tpl->setVariable("HEAD_SELECT_ALL_TXT_SELECT_ALL", $lng->txt("select_all"));
1433 $this->tpl->setVariable("HEAD_SELECT_ALL_CHECKBOX_NAME", $this->getSelectAllCheckbox());
1434 $this->tpl->setVariable("HEAD_SELECT_ALL_FORM_NAME", $this->getFormName());
1435 $this->tpl->setVariable("HEAD_CHECKBOXNAME", "chb_select_all_" . $this->unique_id . '_top');
1436 $this->tpl->parseCurrentBlock();
1437 continue;
1438 }
1439 if (
1440 !$this->enabled["sort"] ||
1441 $column["sort_field"] == "" &&
1442 !($column["is_checkbox_action_column"] && $this->select_all_on_top)
1443 ) {
1444 $this->tpl->setCurrentBlock("tbl_header_no_link");
1445 if ($column["width"] != "") {
1446 $width = (is_numeric($column["width"]))
1447 ? $column["width"] . "px"
1448 : $column["width"];
1449 $this->tpl->setVariable("TBL_COLUMN_WIDTH_NO_LINK", " style=\"width:" . $width . "\"");
1450 }
1451 if ($column["class"] != "") {
1452 $this->tpl->setVariable("TBL_COLUMN_CLASS_NO_LINK", " class=\"" . $column["class"] . "\"");
1453 }
1454 if (!$column["is_checkbox_action_column"]) {
1455 $this->tpl->setVariable(
1456 "TBL_HEADER_CELL_NO_LINK",
1457 $column["text"]
1458 );
1459 } else {
1460 $this->tpl->setVariable(
1461 "TBL_HEADER_CELL_NO_LINK",
1462 ilUtil::img(ilUtil::getImagePath("spacer.png"), $lng->txt("action"))
1463 );
1464 }
1465 $this->tpl->setVariable("HEAD_CELL_NL_ID", "thc_" . $this->getId() . "_" . $ccnt);
1466 if ($column["class"] != "") {
1467 $this->tpl->setVariable("TBL_HEADER_CLASS", " " . $column["class"]);
1468 }
1469 $this->tpl->parseCurrentBlock();
1470 $this->tpl->touchBlock("tbl_header_th");
1471 continue;
1472 }
1473 if (($column["sort_field"] == $this->order_field) && ($this->order_direction != "")) {
1474 $this->tpl->setCurrentBlock("tbl_order_image");
1475 if ($this->order_direction == "asc") {
1476 $this->tpl->setVariable("ORDER_CLASS", "glyphicon glyphicon-arrow-up");
1477 $this->tpl->setVariable("ORDER_TXT", $this->lng->txt("sorting_asc"));
1478 } else {
1479 $this->tpl->setVariable("ORDER_CLASS", "glyphicon glyphicon-arrow-down");
1480 $this->tpl->setVariable("ORDER_TXT", $this->lng->txt("sorting_desc"));
1481 }
1482 $this->tpl->setVariable("IMG_ORDER_ALT", $this->lng->txt("change_sort_direction"));
1483 $this->tpl->parseCurrentBlock();
1484 }
1485
1486 $this->tpl->setCurrentBlock("tbl_header_cell");
1487 $this->tpl->setVariable("TBL_HEADER_CELL", $column["text"]);
1488 $this->tpl->setVariable("HEAD_CELL_ID", "thc_" . $this->getId() . "_" . $ccnt);
1489
1490 // only set width if a value is given for that column
1491 if ($column["width"] != "") {
1492 $width = (is_numeric($column["width"]))
1493 ? $column["width"] . "px"
1494 : $column["width"];
1495 $this->tpl->setVariable("TBL_COLUMN_WIDTH", " style=\"width:" . $width . "\"");
1496 }
1497 if ($column["class"] != "") {
1498 $this->tpl->setVariable("TBL_COLUMN_CLASS", " class=\"" . $column["class"] . "\"");
1499 }
1500
1501 $lng_sort_column = $this->lng->txt("sort_by_this_column");
1502 $this->tpl->setVariable("TBL_ORDER_ALT", $lng_sort_column);
1503
1504 $order_dir = "asc";
1505
1506 if ($column["sort_field"] == $this->order_field) {
1507 $order_dir = $this->sort_order;
1508
1509 if ($order_dir === "asc") {
1510 $lng_change_sort = $this->lng->txt("sort_ascending_long");
1511 } else {
1512 $lng_change_sort = $this->lng->txt("sort_descending_long");
1513 }
1514 $this->tpl->setVariable("TBL_ORDER_ALT", $lng_change_sort);
1515 }
1516
1517 if ($column["class"] != "") {
1518 $this->tpl->setVariable("TBL_HEADER_CLASS", " " . $column["class"]);
1519 }
1520 $this->setOrderLink($column["sort_field"], $order_dir);
1521 $this->tpl->parseCurrentBlock();
1522 $this->tpl->touchBlock("tbl_header_th");
1523 }
1524
1525 $this->tpl->setCurrentBlock("tbl_header");
1526 $this->tpl->parseCurrentBlock();
1527 }
1528
1532 protected function prepareOutput()
1533 {
1534 }
1535
1536
1540 public function determineOffsetAndOrder($a_omit_offset = false)
1541 {
1542 global $DIC;
1543
1544 $ilUser = null;
1545 if (isset($DIC["ilUser"])) {
1546 $ilUser = $DIC["ilUser"];
1547 }
1548
1549 if ($this->nav_determined) {
1550 return true;
1551 }
1552
1553 if ($_POST[$this->getNavParameter() . "1"] != "") {
1554 if ($_POST[$this->getNavParameter() . "1"] != $_POST[$this->getNavParameter()]) {
1555 $this->nav_value = $_POST[$this->getNavParameter() . "1"];
1556 } elseif ($_POST[$this->getNavParameter() . "2"] != $_POST[$this->getNavParameter()]) {
1557 $this->nav_value = $_POST[$this->getNavParameter() . "2"];
1558 }
1559 } elseif ($_GET[$this->getNavParameter()]) {
1560 $this->nav_value = $_GET[$this->getNavParameter()];
1561 } elseif ($_SESSION[$this->getNavParameter()] != "") {
1562 $this->nav_value = $_SESSION[$this->getNavParameter()];
1563 }
1564
1565 if ($this->nav_value == "" && $this->getId() != "" && $ilUser->getId() != ANONYMOUS_USER_ID) {
1566 $order = $this->loadProperty("order");
1567 if (in_array($order, $this->sortable_fields)) {
1568 $direction = $this->loadProperty("direction");
1569 } else {
1570 $direction = $this->getDefaultOrderDirection();
1571 }
1572 // get order and direction from db
1573 $this->nav_value =
1574 $order . ":" .
1575 $direction . ":" .
1576 $this->loadProperty("offset");
1577 }
1578 $nav = explode(":", $this->nav_value);
1579
1580 // $nav[0] is order by
1581 $this->setOrderField(($nav[0] != "") ? $nav[0] : $this->getDefaultOrderField());
1582 $this->setOrderDirection(($nav[1] != "") ? $nav[1] : $this->getDefaultOrderDirection());
1583
1584 if (!$a_omit_offset) {
1585 // #8904: offset must be discarded when no limit is given
1586 if (!$this->getExternalSegmentation() && $this->limit_determined && $this->limit == 9999) {
1587 $this->resetOffset(true);
1588 } elseif (!$this->getExternalSegmentation() && $nav[2] >= $this->max_count) {
1589 $this->resetOffset(true);
1590 } else {
1591 $this->setOffset($nav[2]);
1592 }
1593 }
1594
1595 if (!$a_omit_offset) {
1596 $this->nav_determined = true;
1597 }
1598 }
1599
1600 public function storeNavParameter()
1601 {
1602 if ($this->getOrderField() != "") {
1603 $this->storeProperty("order", $this->getOrderField());
1604 }
1605 if ($this->getOrderDirection() != "") {
1606 $this->storeProperty("direction", $this->getOrderDirection());
1607 }
1608 //echo "-".$this->getOffset()."-";
1609 if ($this->getOffset() !== "") {
1610 $this->storeProperty("offset", $this->getOffset());
1611 }
1612 }
1613
1614
1618 public function getHTML()
1619 {
1620 global $DIC;
1621
1622 $ilUser = null;
1623 if (isset($DIC["ilUser"])) {
1624 $ilUser = $DIC["ilUser"];
1625 }
1626
1627 $lng = $this->lng;
1628 $ilCtrl = $this->ctrl;
1629
1630
1631 if ($this->getExportMode()) {
1632 $this->exportData($this->getExportMode(), true);
1633 }
1634
1635 $this->prepareOutput();
1636
1637 if (is_object($ilCtrl) && $this->getId() == "") {
1638 $ilCtrl->saveParameter($this->getParentObject(), $this->getNavParameter());
1639 }
1640
1641 if (!$this->getPrintMode()) {
1642 // set form action
1643 if ($this->form_action != "" && $this->getOpenFormTag()) {
1644 $hash = "";
1645 if (is_object($ilUser) && $ilUser->getPref("screen_reader_optimization")) {
1646 $hash = "#" . $this->getTopAnchor();
1647 }
1648
1649 if ((bool) $this->form_multipart) {
1650 $this->tpl->touchBlock("form_multipart_bl");
1651 }
1652
1653 if ($this->getPreventDoubleSubmission()) {
1654 $this->tpl->touchBlock("pdfs");
1655 }
1656
1657 $this->tpl->setCurrentBlock("tbl_form_header");
1658 $this->tpl->setVariable("FORMACTION", $this->getFormAction() . $hash);
1659 $this->tpl->setVariable("FORMNAME", $this->getFormName());
1660 $this->tpl->parseCurrentBlock();
1661 }
1662
1663 if ($this->form_action != "" && $this->getCloseFormTag()) {
1664 $this->tpl->touchBlock("tbl_form_footer");
1665 }
1666 }
1667
1668 if (!$this->enabled['content']) {
1669 return $this->render();
1670 }
1671
1672 if (!$this->getExternalSegmentation()) {
1673 $this->setMaxCount(count($this->row_data));
1674 }
1675
1676 $this->determineOffsetAndOrder();
1677
1678 $this->setFooter("tblfooter", $this->lng->txt("previous"), $this->lng->txt("next"));
1679
1680 $data = $this->getData();
1681 if ($this->dataExists()) {
1682 // sort
1683 if (!$this->getExternalSorting() && $this->enabled["sort"]) {
1685 $data,
1686 $this->getOrderField(),
1687 $this->getOrderDirection(),
1688 $this->numericOrdering($this->getOrderField())
1689 );
1690 }
1691
1692 // slice
1693 if (!$this->getExternalSegmentation()) {
1694 $data = array_slice($data, $this->getOffset(), $this->getLimit());
1695 }
1696 }
1697
1698 // fill rows
1699 if ($this->dataExists()) {
1700 if ($this->getPrintMode()) {
1702 }
1703
1704 $this->tpl->addBlockFile(
1705 "TBL_CONTENT",
1706 "tbl_content",
1707 $this->row_template,
1708 $this->row_template_dir
1709 );
1710
1711 foreach ($data as $set) {
1712 $this->tpl->setCurrentBlock("tbl_content");
1713 $this->css_row = ($this->css_row != "tblrow1")
1714 ? "tblrow1"
1715 : "tblrow2";
1716 $this->tpl->setVariable("CSS_ROW", $this->css_row);
1717
1718 $this->fillRow($set);
1719 $this->tpl->setCurrentBlock("tbl_content");
1720 $this->tpl->parseCurrentBlock();
1721 }
1722 } else {
1723 // add standard no items text (please tell me, if it messes something up, alex, 29.8.2008)
1724 $no_items_text = (trim($this->getNoEntriesText()) != '')
1725 ? $this->getNoEntriesText()
1726 : $lng->txt("no_items");
1727
1728 $this->css_row = ($this->css_row != "tblrow1")
1729 ? "tblrow1"
1730 : "tblrow2";
1731
1732 $this->tpl->setCurrentBlock("tbl_no_entries");
1733 $this->tpl->setVariable('TBL_NO_ENTRY_CSS_ROW', $this->css_row);
1734 $this->tpl->setVariable('TBL_NO_ENTRY_COLUMN_COUNT', $this->column_count);
1735 $this->tpl->setVariable('TBL_NO_ENTRY_TEXT', trim($no_items_text));
1736 $this->tpl->parseCurrentBlock();
1737 }
1738
1739
1740 if (!$this->getPrintMode()) {
1741 $this->fillFooter();
1742
1743 $this->fillHiddenRow();
1744
1745 $this->fillActionRow();
1746
1747 $this->storeNavParameter();
1748 }
1749
1750 return $this->render();
1751 }
1752
1758 public function numericOrdering($a_field)
1759 {
1760 return false;
1761 }
1762
1767 public function render()
1768 {
1769 $lng = $this->lng;
1770 $ilCtrl = $this->ctrl;
1771
1772 $this->tpl->setVariable("CSS_TABLE", $this->getStyle("table"));
1773 //$this->tpl->setVariable("DATA_TABLE", (int) $this->getIsDataTable());
1774 if ($this->getId() != "") {
1775 $this->tpl->setVariable("ID", 'id="' . $this->getId() . '"');
1776 }
1777
1778 // description
1779 if ($this->getDescription() != "") {
1780 $this->tpl->setCurrentBlock("tbl_header_description");
1781 $this->tpl->setVariable("TBL_DESCRIPTION", $this->getDescription());
1782 $this->tpl->parseCurrentBlock();
1783 }
1784
1785 if (!$this->getPrintMode()) {
1786 $this->renderFilter();
1787 }
1788
1789 if ($this->getDisplayAsBlock()) {
1790 $this->tpl->touchBlock("outer_start_1");
1791 $this->tpl->touchBlock("outer_end_1");
1792 } else {
1793 $this->tpl->touchBlock("outer_start_2");
1794 $this->tpl->touchBlock("outer_end_2");
1795 }
1796
1797 // table title and icon
1798 if ($this->enabled["title"] && ($this->title != ""
1799 || $this->icon != "" || count($this->header_commands) > 0 ||
1800 $this->headerHTML != "" || $this->close_command != "")) {
1801 if ($this->enabled["icon"]) {
1802 $this->tpl->setCurrentBlock("tbl_header_title_icon");
1803 $this->tpl->setVariable("TBL_TITLE_IMG", ilUtil::getImagePath($this->icon));
1804 $this->tpl->setVariable("TBL_TITLE_IMG_ALT", $this->icon_alt);
1805 $this->tpl->parseCurrentBlock();
1806 }
1807
1808 if (!$this->getPrintMode()) {
1809 foreach ($this->header_commands as $command) {
1810 if ($command["img"] != "") {
1811 $this->tpl->setCurrentBlock("tbl_header_img_link");
1812 if ($command["target"] != "") {
1813 $this->tpl->setVariable(
1814 "TARGET_IMG_LINK",
1815 'target="' . $command["target"] . '"'
1816 );
1817 }
1818 $this->tpl->setVariable("ALT_IMG_LINK", $command["text"]);
1819 $this->tpl->setVariable("HREF_IMG_LINK", $command["href"]);
1820 $this->tpl->setVariable(
1821 "SRC_IMG_LINK",
1822 $command["img"]
1823 );
1824 $this->tpl->parseCurrentBlock();
1825 } else {
1826 $this->tpl->setCurrentBlock("head_cmd");
1827 $this->tpl->setVariable("TXT_HEAD_CMD", $command["text"]);
1828 $this->tpl->setVariable("HREF_HEAD_CMD", $command["href"]);
1829 $this->tpl->parseCurrentBlock();
1830 }
1831 }
1832 }
1833
1834 if (isset($this->headerHTML)) {
1835 $this->tpl->setCurrentBlock("tbl_header_html");
1836 $this->tpl->setVariable("HEADER_HTML", $this->headerHTML);
1837 $this->tpl->parseCurrentBlock();
1838 }
1839
1840 // close command
1841 if ($this->close_command != "") {
1842 $this->tpl->setCurrentBlock("tbl_header_img_link");
1843 $this->tpl->setVariable("ALT_IMG_LINK", $lng->txt("close"));
1844 $this->tpl->setVariable("HREF_IMG_LINK", $this->close_command);
1845 $this->tpl->parseCurrentBlock();
1846 }
1847
1848 $this->tpl->setCurrentBlock("tbl_header_title");
1849 $this->tpl->setVariable("TBL_TITLE", $this->title);
1850 $this->tpl->setVariable("TOP_ANCHOR", $this->getTopAnchor());
1851 if ($this->getDisplayAsBlock()) {
1852 $this->tpl->setVariable("BLK_CLASS", "Block");
1853 }
1854 $this->tpl->parseCurrentBlock();
1855 }
1856
1857 // table header
1858 if ($this->enabled["header"]) {
1859 $this->fillHeader();
1860 }
1861
1862 $this->tpl->touchBlock("tbl_table_end");
1863
1864 return $this->tpl->get();
1865 }
1866
1870 private function renderFilter()
1871 {
1872 global $DIC;
1873
1874 $lng = $this->lng;
1875 $main_tpl = $DIC["tpl"];
1876
1877 $filter = $this->getFilterItems();
1878 $opt_filter = $this->getFilterItems(true);
1879
1880 $main_tpl->addJavascript("./Services/Table/js/ServiceTable.js");
1881
1882 if (count($filter) == 0 && count($opt_filter) == 0) {
1883 return;
1884 }
1885
1886 include_once("./Services/YUI/classes/class.ilYuiUtil.php");
1888
1889 $ccnt = 0;
1890
1891 // render standard filter
1892 if (count($filter) > 0) {
1893 foreach ($filter as $item) {
1894 if ($ccnt >= $this->getFilterCols()) {
1895 $this->tpl->setCurrentBlock("filter_row");
1896 $this->tpl->parseCurrentBlock();
1897 $ccnt = 0;
1898 }
1899 $this->tpl->setCurrentBlock("filter_item");
1900 $this->tpl->setVariable(
1901 "OPTION_NAME",
1902 $item->getTitle()
1903 );
1904 $this->tpl->setVariable(
1905 "F_INPUT_ID",
1906 $item->getTableFilterLabelFor()
1907 );
1908 $this->tpl->setVariable(
1909 "INPUT_HTML",
1910 $item->getTableFilterHTML()
1911 );
1912 $this->tpl->parseCurrentBlock();
1913 $ccnt++;
1914 }
1915 }
1916
1917 // render optional filter
1918 if (count($opt_filter) > 0) {
1919 $this->determineSelectedFilters();
1920
1921 foreach ($opt_filter as $item) {
1922 if ($this->isFilterSelected($item->getPostVar())) {
1923 if ($ccnt >= $this->getFilterCols()) {
1924 $this->tpl->setCurrentBlock("filter_row");
1925 $this->tpl->parseCurrentBlock();
1926 $ccnt = 0;
1927 }
1928 $this->tpl->setCurrentBlock("filter_item");
1929 $this->tpl->setVariable(
1930 "OPTION_NAME",
1931 $item->getTitle()
1932 );
1933 $this->tpl->setVariable(
1934 "F_INPUT_ID",
1935 $item->getFieldId()
1936 );
1937 $this->tpl->setVariable(
1938 "INPUT_HTML",
1939 $item->getTableFilterHTML()
1940 );
1941 $this->tpl->parseCurrentBlock();
1942 $ccnt++;
1943 }
1944 }
1945
1946 // filter selection
1947 $items = array();
1948 foreach ($opt_filter as $item) {
1949 $k = $item->getPostVar();
1950 $items[$k] = array("txt" => $item->getTitle(),
1951 "selected" => $this->isFilterSelected($k));
1952 }
1953
1954 include_once("./Services/UIComponent/CheckboxListOverlay/classes/class.ilCheckboxListOverlayGUI.php");
1955 $cb_over = new ilCheckboxListOverlayGUI("tbl_filters_" . $this->getId());
1956 $cb_over->setLinkTitle($lng->txt("optional_filters"));
1957 $cb_over->setItems($items);
1958
1959 $cb_over->setFormCmd($this->getParentCmd());
1960 $cb_over->setFieldVar("tblff" . $this->getId());
1961 $cb_over->setHiddenVar("tblfsf" . $this->getId());
1962
1963 $cb_over->setSelectionHeaderClass("ilTableMenuItem");
1964 $this->tpl->setCurrentBlock("filter_select");
1965
1966 // apply should be the first submit because of enter/return, inserting hidden submit
1967 $this->tpl->setVariable("HIDDEN_CMD_APPLY", $this->filter_cmd);
1968
1969 $this->tpl->setVariable("FILTER_SELECTOR", $cb_over->getHTML(false));
1970 $this->tpl->parseCurrentBlock();
1971 }
1972
1973 // if any filter
1974 if ($ccnt > 0 || count($opt_filter) > 0) {
1975 $this->tpl->setVariable("TXT_FILTER", $lng->txt("filter"));
1976
1977 if ($ccnt > 0) {
1978 if ($ccnt < $this->getFilterCols()) {
1979 for ($i = $ccnt; $i <= $this->getFilterCols(); $i++) {
1980 $this->tpl->touchBlock("filter_empty_cell");
1981 }
1982 }
1983 $this->tpl->setCurrentBlock("filter_row");
1984 $this->tpl->parseCurrentBlock();
1985
1986 $this->tpl->setCurrentBlock("filter_buttons");
1987 $this->tpl->setVariable("CMD_APPLY", $this->filter_cmd);
1988 $this->tpl->setVariable("TXT_APPLY", $this->filter_cmd_txt
1989 ? $this->filter_cmd_txt
1990 : $lng->txt("apply_filter"));
1991 $this->tpl->setVariable("CMD_RESET", $this->reset_cmd);
1992 $this->tpl->setVariable("TXT_RESET", $this->reset_cmd_txt
1993 ? $this->reset_cmd_txt
1994 : $lng->txt("reset_filter"));
1995 } elseif (count($opt_filter) > 0) {
1996 $this->tpl->setCurrentBlock("optional_filter_hint");
1997 $this->tpl->setVariable('TXT_OPT_HINT', $lng->txt('optional_filter_hint'));
1998 $this->tpl->parseCurrentBlock();
1999 }
2000
2001 $this->tpl->setCurrentBlock("filter_section");
2002 $this->tpl->setVariable("FIL_ID", $this->getId());
2003 $this->tpl->parseCurrentBlock();
2004
2005 // (keep) filter hidden?
2006 if (!$this->isFilterVisible()) {
2007 if (!$this->getDisableFilterHiding()) {
2008 $this->tpl->setCurrentBlock("filter_hidden");
2009 $this->tpl->setVariable("FI_ID", $this->getId());
2010 $this->tpl->parseCurrentBlock();
2011 }
2012 }
2013 }
2014 }
2015
2020 protected function isFilterVisible()
2021 {
2022 $prop = $this->loadProperty('filter');
2023 if ($prop === '0' || $prop === '1') {
2024 return (bool) $prop;
2025 }
2026 return $this->getDefaultFilterVisibility();
2027 }
2028
2036 protected function isAdvMDFilter(ilAdvancedMDRecordGUI $a_gui, $a_element)
2037 {
2038 foreach ($a_gui->getFilterElements(false) as $item) {
2039 if ($item === $a_element) {
2040 return true;
2041 }
2042 }
2043 return false;
2044 }
2045
2049 public function writeFilterToSession()
2050 {
2051 $advmd_record_gui = null;
2052 if (method_exists($this, "getAdvMDRecordGUI")) {
2053 $advmd_record_gui = $this->getAdvMDRecordGUI();
2054 }
2055
2056 foreach ($this->getFilterItems() as $item) {
2057 if ($advmd_record_gui &&
2058 $this->isAdvMDFilter($advmd_record_gui, $item)) {
2059 continue;
2060 }
2061
2062 if ($item->checkInput()) {
2063 $item->setValueByArray($_POST);
2064 $item->writeToSession();
2065 }
2066 }
2067 foreach ($this->getFilterItems(true) as $item) {
2068 if ($advmd_record_gui &&
2069 $this->isAdvMDFilter($advmd_record_gui, $item)) {
2070 continue;
2071 }
2072
2073 if ($item->checkInput()) {
2074 $item->setValueByArray($_POST);
2075 $item->writeToSession();
2076 }
2077 }
2078
2079 if ($advmd_record_gui) {
2080 $advmd_record_gui->importFilter();
2081 }
2082
2083 // #13209
2084 unset($_REQUEST["tbltplcrt"]);
2085 unset($_REQUEST["tbltpldel"]);
2086 }
2087
2091 public function resetFilter()
2092 {
2093 $lng = $this->lng;
2094
2095 $filter = $this->getFilterItems();
2096 $opt_filter = $this->getFilterItems(true);
2097
2098 foreach ($filter as $item) {
2099 if ($item->checkInput()) {
2100 // see #26490
2101 $item->setValueByArray([]);
2102 $item->clearFromSession();
2103 }
2104 }
2105 foreach ($opt_filter as $item) {
2106 if ($item->checkInput()) {
2107 // see #26490
2108 $item->setValueByArray([]);
2109 $item->clearFromSession();
2110 }
2111 }
2112
2113 // #13209
2114 unset($_REQUEST["tbltplcrt"]);
2115 unset($_REQUEST["tbltpldel"]);
2116 }
2117
2124 protected function fillRow($a_set)
2125 {
2126 foreach ($a_set as $key => $value) {
2127 $this->tpl->setVariable("VAL_" . strtoupper($key), $value);
2128 }
2129 }
2130
2134 public function fillFooter()
2135 {
2136 global $DIC;
2137
2138 $ilUser = null;
2139 if (isset($DIC["ilUser"])) {
2140 $ilUser = $DIC["ilUser"];
2141 }
2142
2143 $lng = $this->lng;
2144 $ilCtrl = $this->ctrl;
2145
2146 $footer = false;
2147
2148 // select all checkbox
2149 if ((strlen($this->getFormName())) && (strlen($this->getSelectAllCheckbox())) && $this->dataExists()) {
2150 $this->tpl->setCurrentBlock("select_all_checkbox");
2151 $this->tpl->setVariable("SELECT_ALL_TXT_SELECT_ALL", $lng->txt("select_all"));
2152 $this->tpl->setVariable("SELECT_ALL_CHECKBOX_NAME", $this->getSelectAllCheckbox());
2153 $this->tpl->setVariable("SELECT_ALL_FORM_NAME", $this->getFormName());
2154 $this->tpl->setVariable("CHECKBOXNAME", "chb_select_all_" . $this->unique_id);
2155 $this->tpl->parseCurrentBlock();
2156 }
2157
2158 // table footer numinfo
2159 if ($this->enabled["numinfo"] && $this->enabled["footer"]) {
2160 $start = $this->offset + 1; // compute num info
2161 if (!$this->dataExists()) {
2162 $start = 0;
2163 }
2164 $end = $this->offset + $this->limit;
2165
2166 if ($end > $this->max_count or $this->limit == 0) {
2167 $end = $this->max_count;
2168 }
2169
2170 if ($this->max_count > 0) {
2171 if ($this->lang_support) {
2172 $numinfo = "(" . $start . " - " . $end . " " . strtolower($this->lng->txt("of")) . " " . $this->max_count . ")";
2173 } else {
2174 $numinfo = "(" . $start . " - " . $end . " of " . $this->max_count . ")";
2175 }
2176 }
2177 if ($this->max_count > 0) {
2178 if ($this->getEnableNumInfo()) {
2179 $this->tpl->setCurrentBlock("tbl_footer_numinfo");
2180 $this->tpl->setVariable("NUMINFO", $numinfo);
2181 $this->tpl->parseCurrentBlock();
2182 }
2183 }
2184 $footer = true;
2185 }
2186
2187 // table footer linkbar
2188 if ($this->enabled["linkbar"] && $this->enabled["footer"] && $this->limit != 0
2189 && $this->max_count > 0) {
2190 $layout = array(
2191 "link" => $this->footer_style,
2192 "prev" => $this->footer_previous,
2193 "next" => $this->footer_next,
2194 );
2195 //if (!$this->getDisplayAsBlock())
2196 //{
2197 $linkbar = $this->getLinkbar("1");
2198 $this->tpl->setCurrentBlock("tbl_footer_linkbar");
2199 $this->tpl->setVariable("LINKBAR", $linkbar);
2200 $this->tpl->parseCurrentBlock();
2201 $linkbar = true;
2202 //}
2203 $footer = true;
2204 }
2205
2206 // column selector
2207 if (is_array($this->getSelectableColumns()) && count($this->getSelectableColumns()) > 0) {
2208 $items = array();
2209 foreach ($this->getSelectableColumns() as $k => $c) {
2210 $items[$k] = array("txt" => $c["txt"],
2211 "selected" => $this->isColumnSelected($k));
2212 }
2213 include_once("./Services/UIComponent/CheckboxListOverlay/classes/class.ilCheckboxListOverlayGUI.php");
2214 $cb_over = new ilCheckboxListOverlayGUI("tbl_" . $this->getId());
2215 $cb_over->setLinkTitle($lng->txt("columns"));
2216 $cb_over->setItems($items);
2217 //$cb_over->setUrl("./ilias.php?baseClass=ilTablePropertiesStorage&table_id=".
2218 // $this->getId()."&cmd=saveSelectedFields&user_id=".$ilUser->getId());
2219 $cb_over->setFormCmd($this->getParentCmd());
2220 $cb_over->setFieldVar("tblfs" . $this->getId());
2221 $cb_over->setHiddenVar("tblfsh" . $this->getId());
2222 $cb_over->setSelectionHeaderClass("ilTableMenuItem");
2223 $column_selector = $cb_over->getHTML();
2224 $footer = true;
2225 }
2226
2227 if ($this->getShowTemplates() && is_object($ilUser)) {
2228 // template handling
2229 if (isset($_REQUEST["tbltplcrt"]) && $_REQUEST["tbltplcrt"]) {
2230 if ($this->saveTemplate($_REQUEST["tbltplcrt"])) {
2231 ilUtil::sendSuccess($lng->txt("tbl_template_created"));
2232 }
2233 } elseif (isset($_REQUEST["tbltpldel"]) && $_REQUEST["tbltpldel"]) {
2234 if ($this->deleteTemplate($_REQUEST["tbltpldel"])) {
2235 ilUtil::sendSuccess($lng->txt("tbl_template_deleted"));
2236 }
2237 }
2238
2239 $create_id = "template_create_overlay_" . $this->getId();
2240 $delete_id = "template_delete_overlay_" . $this->getId();
2241 $list_id = "template_stg_" . $this->getId();
2242
2243 include_once("./Services/Table/classes/class.ilTableTemplatesStorage.php");
2244 $storage = new ilTableTemplatesStorage();
2245 $templates = $storage->getNames($this->getContext(), $ilUser->getId());
2246
2247 include_once("./Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php");
2248
2249 // form to delete template
2250 if (sizeof($templates)) {
2251 $overlay = new ilOverlayGUI($delete_id);
2252 $overlay->setTrigger($list_id . "_delete");
2253 $overlay->setAnchor("ilAdvSelListAnchorElement_" . $list_id);
2254 $overlay->setAutoHide(false);
2255 $overlay->add();
2256
2257 $lng->loadLanguageModule("form");
2258 $this->tpl->setCurrentBlock("template_editor_delete_item");
2259 $this->tpl->setVariable("TEMPLATE_DELETE_OPTION_VALUE", "");
2260 $this->tpl->setVariable("TEMPLATE_DELETE_OPTION", "- " . $lng->txt("form_please_select") . " -");
2261 $this->tpl->parseCurrentBlock();
2262 foreach ($templates as $name) {
2263 $this->tpl->setVariable("TEMPLATE_DELETE_OPTION_VALUE", $name);
2264 $this->tpl->setVariable("TEMPLATE_DELETE_OPTION", $name);
2265 $this->tpl->parseCurrentBlock();
2266 }
2267
2268 $this->tpl->setCurrentBlock("template_editor_delete");
2269 $this->tpl->setVariable("TEMPLATE_DELETE_ID", $delete_id);
2270 $this->tpl->setVariable("TXT_TEMPLATE_DELETE", $lng->txt("tbl_template_delete"));
2271 $this->tpl->setVariable("TXT_TEMPLATE_DELETE_SUBMIT", $lng->txt("delete"));
2272 $this->tpl->setVariable("TEMPLATE_DELETE_CMD", $this->parent_cmd);
2273 $this->tpl->parseCurrentBlock();
2274 }
2275
2276
2277 // form to save new template
2278 $overlay = new ilOverlayGUI($create_id);
2279 $overlay->setTrigger($list_id . "_create");
2280 $overlay->setAnchor("ilAdvSelListAnchorElement_" . $list_id);
2281 $overlay->setAutoHide(false);
2282 $overlay->add();
2283
2284 $this->tpl->setCurrentBlock("template_editor");
2285 $this->tpl->setVariable("TEMPLATE_CREATE_ID", $create_id);
2286 $this->tpl->setVariable("TXT_TEMPLATE_CREATE", $lng->txt("tbl_template_create"));
2287 $this->tpl->setVariable("TXT_TEMPLATE_CREATE_SUBMIT", $lng->txt("save"));
2288 $this->tpl->setVariable("TEMPLATE_CREATE_CMD", $this->parent_cmd);
2289 $this->tpl->parseCurrentBlock();
2290
2291 // load saved template
2292 include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
2293 $alist = new ilAdvancedSelectionListGUI();
2294 $alist->setId($list_id);
2295 $alist->addItem($lng->txt("tbl_template_create"), "create", "#");
2296 if (sizeof($templates)) {
2297 $alist->addItem($lng->txt("tbl_template_delete"), "delete", "#");
2298 foreach ($templates as $name) {
2299 $ilCtrl->setParameter($this->parent_obj, $this->prefix . "_tpl", urlencode($name));
2300 $alist->addItem($name, $name, $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd));
2301 $ilCtrl->setParameter($this->parent_obj, $this->prefix . "_tpl", "");
2302 }
2303 }
2304 $alist->setListTitle($lng->txt("tbl_templates"));
2306 $this->tpl->setVariable("TEMPLATE_SELECTOR", "&nbsp;" . $alist->getHTML());
2307 }
2308
2309 if ($footer) {
2310 $this->tpl->setCurrentBlock("tbl_footer");
2311 $this->tpl->setVariable("COLUMN_COUNT", $this->getColumnCount());
2312 if ($this->getDisplayAsBlock()) {
2313 $this->tpl->setVariable("BLK_CLASS", "Block");
2314 }
2315 $this->tpl->parseCurrentBlock();
2316
2317 // top navigation, if number info or linkbar given
2318 if ($numinfo != "" || $linkbar != "" || $column_selector != "" ||
2319 count($this->filters) > 0 || count($this->optional_filters) > 0) {
2320 if (is_object($ilUser) && (count($this->filters) || count($this->optional_filters))) {
2321 $this->tpl->setCurrentBlock("filter_activation");
2322 $this->tpl->setVariable("TXT_ACTIVATE_FILTER", $lng->txt("show_filter"));
2323 $this->tpl->setVariable("FILA_ID", $this->getId());
2324 if ($this->getId() != "") {
2325 $this->tpl->setVariable("SAVE_URLA", "./ilias.php?baseClass=ilTablePropertiesStorage&table_id=" .
2326 $this->getId() . "&cmd=showFilter&user_id=" . $ilUser->getId());
2327 }
2328 $this->tpl->parseCurrentBlock();
2329
2330
2331 if (!$this->getDisableFilterHiding()) {
2332 $this->tpl->setCurrentBlock("filter_deactivation");
2333 $this->tpl->setVariable("TXT_HIDE", $lng->txt("hide_filter"));
2334 if ($this->getId() != "") {
2335 $this->tpl->setVariable("SAVE_URL", "./ilias.php?baseClass=ilTablePropertiesStorage&table_id=" .
2336 $this->getId() . "&cmd=hideFilter&user_id=" . $ilUser->getId());
2337 $this->tpl->setVariable("FILD_ID", $this->getId());
2338 }
2339 $this->tpl->parseCurrentBlock();
2340 }
2341 }
2342
2343 if ($numinfo != "" && $this->getEnableNumInfo()) {
2344 $this->tpl->setCurrentBlock("top_numinfo");
2345 $this->tpl->setVariable("NUMINFO", $numinfo);
2346 $this->tpl->parseCurrentBlock();
2347 }
2348 if ($linkbar != "" && !$this->getDisplayAsBlock()) {
2349 $linkbar = $this->getLinkbar("2");
2350 $this->tpl->setCurrentBlock("top_linkbar");
2351 $this->tpl->setVariable("LINKBAR", $linkbar);
2352 $this->tpl->parseCurrentBlock();
2353 }
2354
2355 // column selector
2356 $this->tpl->setVariable("COLUMN_SELECTOR", $column_selector);
2357
2358 // row selector
2359 if ($this->getShowRowsSelector() &&
2360 is_object($ilUser) &&
2361 $this->getId() &&
2362 !$this->rows_selector_off) { // JF, 2014-10-27
2363 include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
2364 $alist = new ilAdvancedSelectionListGUI();
2366 $alist->setId("sellst_rows_" . $this->getId());
2367 $hpp = ($ilUser->getPref("hits_per_page") != 9999)
2368 ? $ilUser->getPref("hits_per_page")
2369 : $lng->txt("no_limit");
2370
2371 $options = array(0 => $lng->txt("default") . " (" . $hpp . ")",5 => 5, 10 => 10, 15 => 15, 20 => 20,
2372 30 => 30, 40 => 40, 50 => 50,
2373 100 => 100, 200 => 200, 400 => 400, 800 => 800);
2374 foreach ($options as $k => $v) {
2375 $ilCtrl->setParameter($this->parent_obj, $this->prefix . "_trows", $k);
2376 $alist->addItem($v, $k, $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd));
2377 $ilCtrl->setParameter($this->parent_obj, $this->prefix . "_trows", "");
2378 }
2379 $alist->setListTitle($this->getRowSelectorLabel() ? $this->getRowSelectorLabel() : $lng->txt("rows"));
2380 $this->tpl->setVariable("ROW_SELECTOR", $alist->getHTML());
2381 }
2382
2383 // export
2384 if (sizeof($this->export_formats) && $this->dataExists()) {
2385 include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
2386 $alist = new ilAdvancedSelectionListGUI();
2388 $alist->setId("sellst_xpt");
2389 foreach ($this->export_formats as $format => $caption_lng_id) {
2390 $ilCtrl->setParameter($this->parent_obj, $this->prefix . "_xpt", $format);
2391 $url = $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd);
2392 $ilCtrl->setParameter($this->parent_obj, $this->prefix . "_xpt", "");
2393 $alist->addItem($lng->txt($caption_lng_id), $format, $url);
2394 }
2395 $alist->setListTitle($lng->txt("export"));
2396 $this->tpl->setVariable("EXPORT_SELECTOR", "&nbsp;" . $alist->getHTML());
2397 }
2398
2399 $this->tpl->setCurrentBlock("top_navigation");
2400 $this->tpl->setVariable("COLUMN_COUNT", $this->getColumnCount());
2401 if ($this->getDisplayAsBlock()) {
2402 $this->tpl->setVariable("BLK_CLASS", "Block");
2403 }
2404 $this->tpl->parseCurrentBlock();
2405 }
2406 }
2407 }
2408
2416 public function getLinkbar($a_num)
2417 {
2418 global $DIC;
2419
2420 $ilUser = $DIC->user();
2421
2422 $ilCtrl = $this->ctrl;
2423 $lng = $this->lng;
2424
2425 $hash = "";
2426 if (is_object($ilUser) && $ilUser->getPref("screen_reader_optimization")) {
2427 $hash = "#" . $this->getTopAnchor();
2428 }
2429
2430 $link = $ilCtrl->getLinkTargetByClass(get_class($this->parent_obj), $this->parent_cmd) .
2431 "&" . $this->getNavParameter() . "=" .
2432 $this->getOrderField() . ":" . $this->getOrderDirection() . ":";
2433
2434 $LinkBar = "";
2435 $layout_prev = $lng->txt("previous");
2436 $layout_next = $lng->txt("next");
2437
2438 // if more entries then entries per page -> show link bar
2439 if ($this->max_count > $this->getLimit() || $this->custom_prev_next) {
2440 $sep = "<span>&nbsp;&nbsp;|&nbsp;&nbsp;</span>";
2441
2442 // calculate number of pages
2443 $pages = intval($this->max_count / $this->getLimit());
2444
2445 // add a page if a rest remains
2446 if (($this->max_count % $this->getLimit())) {
2447 $pages++;
2448 }
2449
2450 // links to other pages
2451 $offset_arr = array();
2452 for ($i = 1 ;$i <= $pages ; $i++) {
2453 $newoffset = $this->getLimit() * ($i - 1);
2454
2455 $nav_value = $this->getOrderField() . ":" . $this->getOrderDirection() . ":" . $newoffset;
2456 $offset_arr[$nav_value] = $i;
2457 }
2458
2459 $sep = "<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>";
2460
2461 // previous link
2462 if ($this->custom_prev_next && $this->custom_prev != "") {
2463 if ($LinkBar != "") {
2464 $LinkBar .= $sep;
2465 }
2466 $LinkBar .= "<a href=\"" . $this->custom_prev . $hash . "\">" . $layout_prev . "</a>";
2467 } elseif ($this->getOffset() >= 1 && !$this->custom_prev_next) {
2468 if ($LinkBar != "") {
2469 $LinkBar .= $sep;
2470 }
2471 $prevoffset = $this->getOffset() - $this->getLimit();
2472 $LinkBar .= "<a href=\"" . $link . $prevoffset . $hash . "\">" . $layout_prev . "</a>";
2473 } else {
2474 if ($LinkBar != "") {
2475 $LinkBar .= $sep;
2476 }
2477 $LinkBar .= '<span class="ilTableFootLight">' . $layout_prev . "</span>";
2478 }
2479
2480 // current value
2481 if ($a_num == "1") {
2482 $LinkBar .= '<input type="hidden" name="' . $this->getNavParameter() .
2483 '" value="' . $this->getOrderField() . ":" . $this->getOrderDirection() . ":" . $this->getOffset() . '" />';
2484 }
2485
2486 $sep = "<span>&nbsp;&nbsp;|&nbsp;&nbsp;</span>";
2487
2488 // show next link (if not last page)
2489 if ($this->custom_prev_next && $this->custom_next != "") {
2490 if ($LinkBar != "") {
2491 $LinkBar .= $sep;
2492 }
2493 $LinkBar .= "<a href=\"" . $this->custom_next . $hash . "\">" . $layout_next . "</a>";
2494 } elseif (!(($this->getOffset() / $this->getLimit()) == ($pages - 1)) && ($pages != 1) &&
2495 !$this->custom_prev_next) {
2496 if ($LinkBar != "") {
2497 $LinkBar .= $sep;
2498 }
2499 $newoffset = $this->getOffset() + $this->getLimit();
2500 $LinkBar .= "<a href=\"" . $link . $newoffset . $hash . "\">" . $layout_next . "</a>";
2501 } else {
2502 if ($LinkBar != "") {
2503 $LinkBar .= $sep;
2504 }
2505 $LinkBar .= '<span class="ilTableFootLight">' . $layout_next . "</span>";
2506 }
2507
2508 $sep = "<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>";
2509
2510 if (count($offset_arr) && !$this->getDisplayAsBlock() && !$this->custom_prev_next) {
2511 if ($LinkBar != "") {
2512 $LinkBar .= $sep;
2513 }
2514 $LinkBar .= "" .
2515 '<label for="tab_page_sel_' . $a_num . '">' . $lng->txt("page") . '</label> ' .
2517 $this->nav_value,
2518 $this->getNavParameter() . $a_num,
2519 $offset_arr,
2520 false,
2521 true,
2522 0,
2523 "small",
2524 array("id" => "tab_page_sel_" . $a_num,
2525 "onchange" => "ilTablePageSelection(this, 'cmd[" . $this->parent_cmd . "]')")
2526 );
2527 //' <input class="submit" type="submit" name="cmd['.$this->parent_cmd.']" value="'.
2528 //$lng->txt("ok").'" />';
2529 }
2530
2531 return $LinkBar;
2532 } else {
2533 return false;
2534 }
2535 }
2536
2537 public function fillHiddenRow()
2538 {
2539 $hidden_row = false;
2540 if (count($this->hidden_inputs)) {
2541 foreach ($this->hidden_inputs as $hidden_input) {
2542 $this->tpl->setCurrentBlock("tbl_hidden_field");
2543 $this->tpl->setVariable("FIELD_NAME", $hidden_input["name"]);
2544 $this->tpl->setVariable("FIELD_VALUE", $hidden_input["value"]);
2545 $this->tpl->parseCurrentBlock();
2546 }
2547
2548 $this->tpl->setCurrentBlock("tbl_hidden_row");
2549 $this->tpl->parseCurrentBlock();
2550 }
2551 }
2552
2556 public function fillActionRow()
2557 {
2558 $lng = $this->lng;
2559
2560 // action row
2561 $action_row = false;
2562 $arrow = false;
2563
2564 // add selection buttons
2565 if (count($this->sel_buttons) > 0) {
2566 foreach ($this->sel_buttons as $button) {
2567 $this->tpl->setCurrentBlock("sel_button");
2568 $this->tpl->setVariable(
2569 "SBUTTON_SELECT",
2571 $button["selected"],
2572 $button["sel_var"],
2573 $button["options"],
2574 false,
2575 true
2576 )
2577 );
2578 $this->tpl->setVariable("SBTN_NAME", $button["cmd"]);
2579 $this->tpl->setVariable("SBTN_VALUE", $button["text"]);
2580 $this->tpl->parseCurrentBlock();
2581
2582 if ($this->getTopCommands()) {
2583 $this->tpl->setCurrentBlock("sel_top_button");
2584 $this->tpl->setVariable(
2585 "SBUTTON_SELECT",
2587 $button["selected"],
2588 $button["sel_var"],
2589 $button["options"],
2590 false,
2591 true
2592 )
2593 );
2594 $this->tpl->setVariable("SBTN_NAME", $button["cmd"]);
2595 $this->tpl->setVariable("SBTN_VALUE", $button["text"]);
2596 $this->tpl->parseCurrentBlock();
2597 }
2598 }
2599 $buttons = true;
2600 $action_row = true;
2601 }
2602 $this->sel_buttons[] = array("options" => $a_options, "cmd" => $a_cmd, "text" => $a_text);
2603
2604 // add buttons
2605 if (count($this->buttons) > 0) {
2606 foreach ($this->buttons as $button) {
2607 if (!is_array($button)) {
2608 if ($button instanceof ilButtonBase) {
2609 $this->tpl->setVariable('BUTTON_OBJ', $button->render());
2610
2611 // this will remove id - should be unique
2612 $button = clone $button;
2613
2614 $this->tpl->setVariable('BUTTON_TOP_OBJ', $button->render());
2615 }
2616 continue;
2617 }
2618
2619 if (strlen($button['onclick'])) {
2620 $this->tpl->setCurrentBlock('cmdonclick');
2621 $this->tpl->setVariable('CMD_ONCLICK', $button['onclick']);
2622 $this->tpl->parseCurrentBlock();
2623 }
2624 $this->tpl->setCurrentBlock("plain_button");
2625 if ($button["id"] != "") {
2626 $this->tpl->setVariable("PBID", ' id="' . $button["id"] . '" ');
2627 }
2628 if ($button["class"] != "") {
2629 $this->tpl->setVariable("PBBT_CLASS", ' ' . $button["class"]);
2630 }
2631 $this->tpl->setVariable("PBTN_NAME", $button["cmd"]);
2632 $this->tpl->setVariable("PBTN_VALUE", $button["text"]);
2633 $this->tpl->parseCurrentBlock();
2634
2635 if ($this->getTopCommands()) {
2636 if (strlen($button['onclick'])) {
2637 $this->tpl->setCurrentBlock('top_cmdonclick');
2638 $this->tpl->setVariable('CMD_ONCLICK', $button['onclick']);
2639 $this->tpl->parseCurrentBlock();
2640 }
2641 $this->tpl->setCurrentBlock("plain_top_button");
2642 $this->tpl->setVariable("PBTN_NAME", $button["cmd"]);
2643 $this->tpl->setVariable("PBTN_VALUE", $button["text"]);
2644 if ($button["class"] != "") {
2645 $this->tpl->setVariable("PBBT_CLASS", ' ' . $button["class"]);
2646 }
2647 $this->tpl->parseCurrentBlock();
2648 }
2649 }
2650
2651 $buttons = true;
2652 $action_row = true;
2653 }
2654
2655 // multi selection
2656 if (count($this->mi_sel_buttons)) {
2657 foreach ($this->mi_sel_buttons as $button) {
2658 $this->tpl->setCurrentBlock("mi_sel_button");
2659 $this->tpl->setVariable(
2660 "MI_BUTTON_SELECT",
2662 $button["selected"],
2663 $button["sel_var"],
2664 $button["options"],
2665 false,
2666 true
2667 )
2668 );
2669 $this->tpl->setVariable("MI_BTN_NAME", $button["cmd"]);
2670 $this->tpl->setVariable("MI_BTN_VALUE", $button["text"]);
2671 $this->tpl->parseCurrentBlock();
2672
2673 if ($this->getTopCommands()) {
2674 $this->tpl->setCurrentBlock("mi_top_sel_button");
2675 $this->tpl->setVariable(
2676 "MI_BUTTON_SELECT",
2678 $button["selected"],
2679 $button["sel_var"] . "_2",
2680 $button["options"],
2681 false,
2682 true
2683 )
2684 );
2685 $this->tpl->setVariable("MI_BTN_NAME", $button["cmd"]);
2686 $this->tpl->setVariable("MI_BTN_VALUE", $button["text"]);
2687 $this->tpl->parseCurrentBlock();
2688 }
2689 }
2690 $arrow = true;
2691 $action_row = true;
2692 }
2693
2694
2695 if (count($this->multi) > 1 && $this->dataExists()) {
2696 if ($this->enable_command_for_all && $this->max_count <= self::getAllCommandLimit()) {
2697 $this->tpl->setCurrentBlock("tbl_cmd_select_all");
2698 $this->tpl->setVariable("TXT_SELECT_CMD_ALL", $lng->txt("all_objects"));
2699 $this->tpl->parseCurrentBlock();
2700 }
2701
2702 $this->tpl->setCurrentBlock("tbl_cmd_select");
2703 $sel = array();
2704 foreach ($this->multi as $mc) {
2705 $sel[$mc["cmd"]] = $mc["text"];
2706 }
2707 $this->tpl->setVariable(
2708 "SELECT_CMDS",
2709 ilUtil::formSelect("", "selected_cmd", $sel, false, true)
2710 );
2711 $this->tpl->setVariable("TXT_EXECUTE", $lng->txt("execute"));
2712 $this->tpl->parseCurrentBlock();
2713 $arrow = true;
2714 $action_row = true;
2715
2716 if ($this->getTopCommands()) {
2717 if ($this->enable_command_for_all && $this->max_count <= self::getAllCommandLimit()) {
2718 $this->tpl->setCurrentBlock("tbl_top_cmd_select_all");
2719 $this->tpl->setVariable("TXT_SELECT_CMD_ALL", $lng->txt("all_objects"));
2720 $this->tpl->parseCurrentBlock();
2721 }
2722
2723 $this->tpl->setCurrentBlock("tbl_top_cmd_select");
2724 $sel = array();
2725 foreach ($this->multi as $mc) {
2726 $sel[$mc["cmd"]] = $mc["text"];
2727 }
2728 $this->tpl->setVariable(
2729 "SELECT_CMDS",
2730 ilUtil::formSelect("", "selected_cmd2", $sel, false, true)
2731 );
2732 $this->tpl->setVariable("TXT_EXECUTE", $lng->txt("execute"));
2733 $this->tpl->parseCurrentBlock();
2734 }
2735 } elseif (count($this->multi) == 1 && $this->dataExists()) {
2736 $this->tpl->setCurrentBlock("tbl_single_cmd");
2737 $sel = array();
2738 foreach ($this->multi as $mc) {
2739 $cmd = $mc['cmd'];
2740 $txt = $mc['text'];
2741 }
2742 $this->tpl->setVariable("TXT_SINGLE_CMD", $txt);
2743 $this->tpl->setVariable("SINGLE_CMD", $cmd);
2744 $this->tpl->parseCurrentBlock();
2745 $arrow = true;
2746 $action_row = true;
2747
2748 if ($this->getTopCommands()) {
2749 $this->tpl->setCurrentBlock("tbl_top_single_cmd");
2750 $sel = array();
2751 foreach ($this->multi as $mc) {
2752 $cmd = $mc['cmd'];
2753 $txt = $mc['text'];
2754 }
2755 $this->tpl->setVariable("TXT_SINGLE_CMD", $txt);
2756 $this->tpl->setVariable("SINGLE_CMD", $cmd);
2757 $this->tpl->parseCurrentBlock();
2758 }
2759 }
2760
2761 if ($arrow) {
2762 $this->tpl->setCurrentBlock("tbl_action_img_arrow");
2763 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.svg"));
2764 $this->tpl->setVariable("ALT_ARROW", $lng->txt("action"));
2765 $this->tpl->parseCurrentBlock();
2766
2767 if ($this->getTopCommands()) {
2768 $this->tpl->setCurrentBlock("tbl_top_action_img_arrow");
2769 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_upright.svg"));
2770 $this->tpl->setVariable("ALT_ARROW", $lng->txt("action"));
2771 $this->tpl->parseCurrentBlock();
2772 }
2773 }
2774
2775 if ($action_row) {
2776 $this->tpl->setCurrentBlock("tbl_action_row");
2777 $this->tpl->parseCurrentBlock();
2778 if ($this->getTopCommands()) {
2779 $this->tpl->setCurrentBlock("tbl_top_action_row");
2780 $this->tpl->parseCurrentBlock();
2781 }
2782 }
2783 }
2784
2790 public function setHeaderHTML($html)
2791 {
2792 $this->headerHTML = $html;
2793 }
2794
2801 public function storeProperty($type, $value)
2802 {
2803 global $DIC;
2804
2805 $ilUser = null;
2806 if (isset($DIC["ilUser"])) {
2807 $ilUser = $DIC["ilUser"];
2808 }
2809
2810 if (is_object($ilUser) && $this->getId() != "") {
2811 include_once("./Services/Table/classes/class.ilTablePropertiesStorage.php");
2812 $tab_prop = new ilTablePropertiesStorage();
2813
2814 $tab_prop->storeProperty($this->getId(), $ilUser->getId(), $type, $value);
2815 }
2816 }
2817
2824 public function loadProperty($type)
2825 {
2826 global $DIC;
2827
2828 $ilUser = null;
2829 if (isset($DIC["ilUser"])) {
2830 $ilUser = $DIC["ilUser"];
2831 }
2832
2833 if (is_object($ilUser) && $this->getId() != "") {
2834 include_once("./Services/Table/classes/class.ilTablePropertiesStorage.php");
2835 $tab_prop = new ilTablePropertiesStorage();
2836
2837 return $tab_prop->getProperty($this->getId(), $ilUser->getId(), $type);
2838 }
2839 return null;
2840 }
2841
2847 public function getCurrentState()
2848 {
2849 $this->determineOffsetAndOrder();
2850 $this->determineLimit();
2851 $this->determineSelectedColumns();
2852 $this->determineSelectedFilters();
2853
2854 // "filter" show/hide is not saved
2855
2856 $result = array();
2857 $result["order"] = $this->getOrderField();
2858 $result["direction"] = $this->getOrderDirection();
2859 $result["offset"] = $this->getOffset();
2860 $result["rows"] = $this->getLimit();
2861 $result["selfilters"] = $this->getSelectedFilters();
2862
2863 // #9514 - $this->getSelectedColumns() will omit deselected, leading to
2864 // confusion on restoring template
2865 $result["selfields"] = $this->selected_column;
2866
2867 // gather filter values
2868 if ($this->filters) {
2869 foreach ($this->filters as $item) {
2870 $result["filter_values"][$item->getFieldId()] = $this->getFilterValue($item);
2871 }
2872 }
2873 if ($this->optional_filters && $result["selfilters"]) {
2874 foreach ($this->optional_filters as $item) {
2875 if (in_array($item->getFieldId(), $result["selfilters"])) {
2876 $result["filter_values"][$item->getFieldId()] = $this->getFilterValue($item);
2877 }
2878 }
2879 }
2880
2881 return $result;
2882 }
2883
2890 protected function getFilterValue(ilFormPropertyGUI $a_item)
2891 {
2892 if (method_exists($a_item, "getChecked")) {
2893 return $a_item->getChecked();
2894 } elseif (method_exists($a_item, "getValue")) {
2895 return $a_item->getValue();
2896 } elseif (method_exists($a_item, "getDate")) {
2897 return $a_item->getDate()->get(IL_CAL_DATE);
2898 }
2899 }
2900
2907 protected function SetFilterValue(ilFormPropertyGUI $a_item, $a_value)
2908 {
2909 if (method_exists($a_item, "setChecked")) {
2910 $a_item->setChecked($a_value);
2911 } elseif (method_exists($a_item, "setValue")) {
2912 $a_item->setValue($a_value);
2913 } elseif (method_exists($a_item, "setDate")) {
2914 $a_item->setDate(new ilDate($a_value, IL_CAL_DATE));
2915 }
2916 $a_item->writeToSession();
2917 }
2918
2924 public function setContext($id)
2925 {
2926 if (trim($id)) {
2927 $this->context = $id;
2928 }
2929 }
2930
2936 public function getContext()
2937 {
2938 return $this->context;
2939 }
2940
2946 public function setShowRowsSelector($a_value)
2947 {
2948 $this->show_rows_selector = (bool) $a_value;
2949 }
2950
2956 public function getShowRowsSelector()
2957 {
2959 }
2960
2966 public function setShowTemplates($a_value)
2967 {
2968 $this->show_templates = (bool) $a_value;
2969 }
2970
2976 public function getShowTemplates()
2977 {
2978 return $this->show_templates;
2979 }
2980
2987 public function restoreTemplate($a_name)
2988 {
2989 global $DIC;
2990
2991 $ilUser = $DIC->user();
2992
2993 $a_name = ilUtil::stripSlashes($a_name);
2994
2995 if (trim($a_name) && $this->getContext() != "" && is_object($ilUser) && $ilUser->getId() != ANONYMOUS_USER_ID) {
2996 include_once("./Services/Table/classes/class.ilTableTemplatesStorage.php");
2997 $storage = new ilTableTemplatesStorage();
2998
2999 $data = $storage->load($this->getContext(), $ilUser->getId(), $a_name);
3000 if (is_array($data)) {
3001 foreach ($data as $property => $value) {
3002 $this->storeProperty($property, $value);
3003 }
3004 }
3005
3006 $data["filter_values"] = unserialize($data["filter_values"]);
3007 if ($data["filter_values"]) {
3008 $this->restore_filter_values = $data["filter_values"];
3009 }
3010
3011 $this->restore_filter = true;
3012
3013 return true;
3014 }
3015 return false;
3016 }
3017
3024 public function saveTemplate($a_name)
3025 {
3026 global $DIC;
3027
3028 $ilUser = $DIC->user();
3029
3030 $a_name = ilUtil::prepareFormOutput($a_name, true);
3031
3032 if (trim($a_name) && $this->getContext() != "" && is_object($ilUser) && $ilUser->getId() != ANONYMOUS_USER_ID) {
3033 include_once("./Services/Table/classes/class.ilTableTemplatesStorage.php");
3034 $storage = new ilTableTemplatesStorage();
3035
3036 $state = $this->getCurrentState();
3037 $state["filter_values"] = serialize($state["filter_values"]);
3038 $state["selfields"] = serialize($state["selfields"]);
3039 $state["selfilters"] = serialize($state["selfilters"]);
3040
3041 $storage->store($this->getContext(), $ilUser->getId(), $a_name, $state);
3042 return true;
3043 }
3044 return false;
3045 }
3046
3053 public function deleteTemplate($a_name)
3054 {
3055 global $DIC;
3056
3057 $ilUser = $DIC->user();
3058
3059 $a_name = ilUtil::prepareFormOutput($a_name, true);
3060
3061 if (trim($a_name) && $this->getContext() != "" && is_object($ilUser) && $ilUser->getId() != ANONYMOUS_USER_ID) {
3062 include_once("./Services/Table/classes/class.ilTableTemplatesStorage.php");
3063 $storage = new ilTableTemplatesStorage();
3064 $storage->delete($this->getContext(), $ilUser->getId(), $a_name);
3065 return true;
3066 }
3067 return false;
3068 }
3069
3073 public function getLimit()
3074 {
3075 if ($this->getExportMode() || $this->getPrintMode()) {
3076 return 9999;
3077 }
3078 return parent::getLimit();
3079 }
3080
3084 public function getOffset()
3085 {
3086 if ($this->getExportMode() || $this->getPrintMode()) {
3087 return 0;
3088 }
3089 return parent::getOffset();
3090 }
3091
3097 public function setExportFormats(array $formats)
3098 {
3099 $this->export_formats = array();
3100
3101 // #11339
3102 $valid = array(self::EXPORT_EXCEL => "tbl_export_excel",
3103 self::EXPORT_CSV => "tbl_export_csv");
3104
3105 foreach ($formats as $format) {
3106 if (array_key_exists($format, $valid)) {
3107 $this->export_formats[$format] = $valid[$format];
3108 }
3109 }
3110 }
3111
3116 public function setPrintMode($a_value = false)
3117 {
3118 $this->print_mode = (bool) $a_value;
3119 }
3120
3125 public function getPrintMode()
3126 {
3127 return $this->print_mode;
3128 }
3129
3135 public function getExportMode()
3136 {
3137 return $this->export_mode;
3138 }
3139
3145 public function exportData($format, $send = false)
3146 {
3147 if ($this->dataExists()) {
3148 // #9640: sort
3149 if (!$this->getExternalSorting() && $this->enabled["sort"]) {
3150 $this->determineOffsetAndOrder(true);
3151
3152 $this->row_data = ilUtil::sortArray(
3153 $this->row_data,
3154 $this->getOrderField(),
3155 $this->getOrderDirection(),
3156 $this->numericOrdering($this->getOrderField())
3157 );
3158 }
3159
3160 $filename = "export";
3161
3162 switch ($format) {
3163 case self::EXPORT_EXCEL:
3164 include_once "./Services/Excel/classes/class.ilExcel.php";
3165 $excel = new ilExcel();
3166 $excel->addSheet($this->title
3167 ? $this->title
3168 : $this->lng->txt("export"));
3169 $row = 1;
3170
3171 ob_start();
3172 $this->fillMetaExcel($excel, $row); // row must be increment in fillMetaExcel()! (optional method)
3173
3174 // #14813
3175 $pre = $row;
3176 $this->fillHeaderExcel($excel, $row); // row should NOT be incremented in fillHeaderExcel()! (required method)
3177 if ($pre == $row) {
3178 $row++;
3179 }
3180
3181 foreach ($this->row_data as $set) {
3182 $this->fillRowExcel($excel, $row, $set);
3183 $row++; // #14760
3184 }
3185 ob_end_clean();
3186
3187 if ($send) {
3188 $excel->sendToClient($filename);
3189 } else {
3190 $excel->writeToFile($filename);
3191 }
3192 break;
3193
3194 case self::EXPORT_CSV:
3195 include_once "./Services/Utilities/classes/class.ilCSVWriter.php";
3196 $csv = new ilCSVWriter();
3197 $csv->setSeparator(";");
3198
3199 ob_start();
3200 $this->fillMetaCSV($csv);
3201 $this->fillHeaderCSV($csv);
3202 foreach ($this->row_data as $set) {
3203 $this->fillRowCSV($csv, $set);
3204 }
3205 ob_end_clean();
3206
3207 if ($send) {
3208 $filename .= ".csv";
3209 header("Content-type: text/comma-separated-values");
3210 header("Content-Disposition: attachment; filename=\"" . $filename . "\"");
3211 header("Expires: 0");
3212 header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
3213 header("Pragma: public");
3214 echo $csv->getCSVString();
3215 } else {
3216 file_put_contents($filename, $csv->getCSVString());
3217 }
3218 break;
3219 }
3220
3221 if ($send) {
3222 exit();
3223 }
3224 }
3225 }
3226
3234 protected function fillMetaExcel(ilExcel $a_excel, &$a_row)
3235 {
3236 }
3237
3245 protected function fillHeaderExcel(ilExcel $a_excel, &$a_row)
3246 {
3247 $col = 0;
3248 foreach ($this->column as $column) {
3249 $title = strip_tags($column["text"]);
3250 if ($title) {
3251 $a_excel->setCell($a_row, $col++, $title);
3252 }
3253 }
3254 $a_excel->setBold("A" . $a_row . ":" . $a_excel->getColumnCoord($col - 1) . $a_row);
3255 }
3256
3265 protected function fillRowExcel(ilExcel $a_excel, &$a_row, $a_set)
3266 {
3267 $col = 0;
3268 foreach ($a_set as $value) {
3269 if (is_array($value)) {
3270 $value = implode(', ', $value);
3271 }
3272 $a_excel->setCell($a_row, $col++, $value);
3273 }
3274 }
3275
3282 protected function fillMetaCSV($a_csv)
3283 {
3284 }
3285
3292 protected function fillHeaderCSV($a_csv)
3293 {
3294 foreach ($this->column as $column) {
3295 $title = strip_tags($column["text"]);
3296 if ($title) {
3297 $a_csv->addColumn($title);
3298 }
3299 }
3300 $a_csv->addRow();
3301 }
3302
3310 protected function fillRowCSV($a_csv, $a_set)
3311 {
3312 foreach ($a_set as $key => $value) {
3313 if (is_array($value)) {
3314 $value = implode(', ', $value);
3315 }
3316 $a_csv->addColumn(strip_tags($value));
3317 }
3318 $a_csv->addRow();
3319 }
3320
3326 public function setEnableAllCommand($a_value)
3327 {
3328 $this->enable_command_for_all = (bool) $a_value;
3329 }
3330
3336 public static function getAllCommandLimit()
3337 {
3338 global $DIC;
3339
3340 $ilClientIniFile = $DIC["ilClientIniFile"];
3341
3342 $limit = $ilClientIniFile->readVariable("system", "TABLE_ACTION_ALL_LIMIT");
3343 if (!$limit) {
3345 }
3346
3347 return $limit;
3348 }
3349
3354 {
3355 $this->row_selector_label = $row_selector_label;
3356 return $this;
3357 }
3358
3362 public function getRowSelectorLabel()
3363 {
3365 }
3366
3372 public function setPreventDoubleSubmission($a_val)
3373 {
3374 $this->prevent_double_submission = $a_val;
3375 }
3376
3383 {
3385 }
3386
3387 public function setLimit($a_limit = 0, $a_default_limit = 0)
3388 {
3389 parent::setLimit($a_limit, $a_default_limit);
3390
3391 // #17077 - if limit is set "manually" to 9999, force rows selector off
3392 if ($a_limit == 9999 &&
3393 $this->limit_determined) {
3394 $this->rows_selector_off = true;
3395 }
3396 }
3397}
$result
$filename
Definition: buildRTE.php:89
$_GET["client_id"]
$_POST["username"]
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_DATE
getFilterElements($a_only_non_empty=true)
Get SQL conditions for current filter value(s)
User interface class for advanced drop-down selection lists.
Helper class to generate CSV files.
This class represents a checkbox property in a property form.
User interface class for a checkbox list overlay.
This class represents a number property in a property form.
static setUseRelativeDates($a_status)
set use relative dates
This class represents a date/time property in a property form.
Class for single dates.
This class represents a duration (typical hh:mm:ss) property in a property form.
setCell($a_row, $a_col, $a_value, $a_datatype=null)
Set cell value.
setBold($a_coords)
Set cell(s) to bold.
getColumnCoord($a_col)
Get column "name" from number.
This class represents a property in a property form.
writeToSession()
Write to session.
This class represents a number property in a property form.
This is a utility class for the yui overlays.
This class represents a selection list property in a property form.
Class ilTable2GUI.
getParentCmd()
Get parent command.
getExportMode()
Was export activated?
addHiddenInput($a_name, $a_value)
Add Hidden Input field.
getDescription()
Get description.
getSelectedColumns()
Get selected columns.
getOpenFormTag()
Get open form tag.
fillHeaderCSV($a_csv)
CSV Version of Fill Header.
setTopCommands($a_val)
Set top commands (display command buttons on top of table, too)
getFormName()
Get Form name.
prepareOutput()
Anything that must be done before HTML is generated.
getEnableHeader()
Get Enable Header.
saveTemplate($a_name)
Save current state as template.
fillHeaderExcel(ilExcel $a_excel, &$a_row)
Excel Version of Fill Header.
restoreTemplate($a_name)
Restore state from template.
addSelectionButton($a_sel_var, $a_options, $a_cmd, $a_text, $a_default_selection='')
Add Selection List + Command button.
getDefaultFilterVisibility()
Get default filter visibility.
setEnableHeader($a_enableheader)
Set Enable Header.
determineSelectedColumns()
Determine selected columns.
getHTML()
Get HTML.
fillMetaCSV($a_csv)
Add meta information to csv export.
getFilterValue(ilFormPropertyGUI $a_item)
Get current filter value.
setDisableFilterHiding($a_val=true)
Set disable filter hiding.
getLinkbar($a_num)
Get previous/next linkbar.
setExternalSorting($a_val)
Set external sorting.
isAdvMDFilter(ilAdvancedMDRecordGUI $a_gui, $a_element)
Check if filter element is based on adv md.
getShowTemplates()
Get template state.
setDisplayAsBlock($a_val)
Set display as block.
getNoEntriesText()
Get text for an empty table.
setCloseFormTag($a_val)
Set close form tag.
getEnableTitle()
Get Enable Title.
setShowRowsSelector($a_value)
Toggle rows-per-page selector.
setExportFormats(array $formats)
Set available export formats.
getParentObject()
Get parent object.
setPrintMode($a_value=false)
Toogle print mode.
setDefaultFilterVisiblity($a_status)
Set default filter visiblity.
setPrefix($a_prefix)
set prefix for sort and offset fields (if you have two or more tables on a page that you want to sort...
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
fillRow($a_set)
Standard Version of Fill Row.
setNoEntriesText($a_text)
Set text for an empty table.
getFormAction()
Get Form action parameter.
initFilter()
Init filter.
SetFilterValue(ilFormPropertyGUI $a_item, $a_value)
Set current filter value.
exportData($format, $send=false)
Export and optionally send current table data.
getFilterItems($a_optionals=false)
Get filter items.
setIsDataTable($a_val)
Set is data table.
render()
render table @access public
determineOffsetAndOrder($a_omit_offset=false)
Determine offset and order.
setSelectAllCheckbox($a_select_all_checkbox, $a_select_all_on_top=false)
Set the name of the checkbox that should be toggled with a select all button.
getFilterCols()
Get filter columns.
getShowRowsSelector()
Get rows-per-page selector state.
fillRowCSV($a_csv, $a_set)
CSV Version of Fill Row.
getId()
Get element id.
setRowSelectorLabel($row_selector_label)
fillRowExcel(ilExcel $a_excel, &$a_row, $a_set)
Excel Version of Fill Row.
getContext()
Get context.
setEnableAllCommand($a_value)
Enable actions for all entries in current result.
setData($a_data)
set table data @access public
setHeaderHTML($html)
set header html
setResetCommand($a_val, $a_caption=null)
Set reset filter command.
__construct($a_parent_obj, $a_parent_cmd="", $a_template_context="")
ilTable2GUI constructor.
getExternalSorting()
Get external sorting.
setEnableTitle($a_enabletitle)
Set Enable Title.
setEnableNumInfo($a_val)
Set enable num info.
getDefaultOrderDirection()
Get Default order direction.
getDisableFilterHiding()
Get disable filter hiding.
renderFilter()
Render Filter section.
getDisplayAsBlock()
Get display as block.
getLimit()
Get limit.
isFilterVisible()
Check if filter is visible: manually shown (session, db) or default value set.
setPreventDoubleSubmission($a_val)
Set prevent double submission.
addCommandButtonInstance(ilButtonBase $a_button)
Add Command button instance.
storeProperty($type, $value)
Store table property.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setTopAnchor($a_val)
Set top anchor.
resetOffset($a_in_determination=false)
Reset offset.
loadProperty($type)
Load table property.
setLimit($a_limit=0, $a_default_limit=0)
set max.
getFilterItemByPostVar($a_post_var)
addMultiCommand($a_cmd, $a_text)
Add Command button.
getCurrentState()
get current settings for order, limit, columns and filter
getSelectableColumns()
Get selectable columns.
addFilterItem($a_input_item, $a_optional=false)
Add filter item.
getEnableNumInfo()
Get enable num info.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
fillFooter()
Fill footer row.
static getAllCommandLimit()
Get maximum number of entries to enable actions for all.
getExternalSegmentation()
Get external segmentation.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setCustomPreviousNext($a_prev_link, $a_next_link)
Set custom previous/next links.
setContext($id)
Set context.
addFilterItemByMetaType($id, $type=self::FILTER_TEXT, $a_optional=false, $caption=null)
Add filter by standard type.
getPrintMode()
Get print mode.
getSelectedFilters()
Get selected filters.
getCloseFormTag()
Get close form tag.
getTopAnchor()
Get top anchor.
getFilterCommand()
Get filter command.
getOffset()
Get offset.
const FILTER_DURATION_RANGE
setExternalSegmentation($a_val)
Set external segmentation.
resetFilter()
Reset filter.
setId($a_val)
Set id.
getTopCommands()
Get top commands (display command buttons on top of table, too)
writeFilterToSession()
Write filter values to session.
setDescription($a_val)
Set description.
setOrderField($a_order_field)
set order column
setFormName($a_formname="")
Set Form name.
setFilterCols($a_val)
Set filter columns.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
getIsDataTable()
Get is data table.
addMultiItemSelectionButton($a_sel_var, $a_options, $a_cmd, $a_text, $a_default_selection='')
Add Selection List + Command button for selected items.
determineLimit()
Determine the limit.
isFilterSelected($a_col)
Is given filter selected?
deleteTemplate($a_name)
Delete template.
fillMetaExcel(ilExcel $a_excel, &$a_row)
Add meta information to excel export.
fillActionRow()
Fill Action Row.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
executeCommand()
Execute command.
setOrderLink($sort_field, $order_dir)
getResetCommand()
Get reset filter command.
setFilterCommand($a_val, $a_caption=null)
Set filter command.
getDefaultOrderField()
Get Default order field.
setCloseCommand($a_link)
Add command for closing table.
setOpenFormTag($a_val)
Set open form tag.
isColumnSelected($a_col)
Is given column selected?
numericOrdering($a_field)
Should this field be sorted numeric?
getSelectAllCheckbox()
Get the name of the checkbox that should be toggled with a select all button.
getPreventDoubleSubmission()
Get prevent double submission.
addHeaderCommand($a_href, $a_text, $a_target="", $a_img="")
Add Header Command (Link) (Image needed for now)
setShowTemplates($a_value)
Toggle templates.
const FILTER_DATETIME_RANGE
determineSelectedFilters()
Determine selected filters.
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
Class ilTableGUI.
getOrderDirection()
Get order direction.
setMaxCount($a_max_count)
set max.
getStyle($a_element)
setOrderDirection($a_order_direction)
set order direction @access public
getColumnCount()
Returns the column count based on the number of the header row columns @access public.
setFooter($a_style, $a_previous=0, $a_next=0)
set order direction @access public
setOffset($a_offset)
set dataset offset @access public
Saves (mostly asynchronously) user properties of tables (e.g.
Saves (mostly asynchronously) user properties of tables (e.g.
special template class to simplify handling of ITX/PEAR
This class represents a text property in a property form.
static addTooltip( $a_el_id, $a_text, $a_container="", $a_my="bottom center", $a_at="top center", $a_use_htmlspecialchars=true)
Adds a tooltip to an HTML element.
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static img($a_src, $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static formSelect( $selected, $varname, $options, $multiple=false, $direct_text=false, $size="0", $style_class="", $attribs="", $disabled=false)
Builds a select form field with options and shows the selected option first.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
static initConnection(ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Connection module.
$c
Definition: cli.php:37
const ANONYMOUS_USER_ID
Definition: constants.php:25
$formats
Definition: date.php:77
$valid
$txt
Definition: error.php:13
global $DIC
Definition: goto.php:24
$ilUser
Definition: imgupload.php:18
exit
Definition: login.php:29
if($format !==null) $name
Definition: metadata.php:230
$format
Definition: metadata.php:218
$i
Definition: metadata.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$type
$url
$rows
Definition: xhr_table.php:10