ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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
310 if ($old_sel != serialize($this->selected_column) && $set) {
311 $this->storeProperty("selfields", serialize($this->selected_column));
312 }
313
314 $this->columns_determined = true;
315 }
316
323 public function isColumnSelected($a_col)
324 {
325 return $this->selected_column[$a_col];
326 }
327
334 public function getSelectedColumns()
335 {
336 $scol = array();
337 foreach ($this->selected_column as $k => $v) {
338 if ($v) {
339 $scol[$k] = $k;
340 }
341 }
342 return $scol;
343 }
344
348 public function executeCommand()
349 {
351
352 $next_class = $ilCtrl->getNextClass($this);
353 $cmd = $ilCtrl->getCmd();
354
355 switch ($next_class) {
356 case 'ilformpropertydispatchgui':
357 include_once './Services/Form/classes/class.ilFormPropertyDispatchGUI.php';
358 $form_prop_dispatch = new ilFormPropertyDispatchGUI();
359 $this->initFilter();
360 $item = $this->getFilterItemByPostVar($_GET["postvar"]);
361 $form_prop_dispatch->setItem($item);
362 return $ilCtrl->forwardCommand($form_prop_dispatch);
363 break;
364
365 }
366 return false;
367 }
368
372 public function resetOffset($a_in_determination = false)
373 {
374 if (!$this->nav_determined && !$a_in_determination) {
376 }
377 $this->nav_value = $this->getOrderField() . ":" . $this->getOrderDirection() . ":0";
378 $_GET[$this->getNavParameter()] =
379 $_POST[$this->getNavParameter() . "1"] =
380 $this->nav_value;
381 //echo $this->nav_value;
382 $this->setOffset(0);
383 }
384
389 public function initFilter()
390 {
391 }
392
398 public function getParentObject()
399 {
400 return $this->parent_obj;
401 }
402
408 public function getParentCmd()
409 {
410 return $this->parent_cmd;
411 }
412
418 public function setTopAnchor($a_val)
419 {
420 $this->top_anchor = $a_val;
421 }
422
428 public function getTopAnchor()
429 {
430 return $this->top_anchor;
431 }
432
438 public function setNoEntriesText($a_text)
439 {
440 $this->noentriestext = $a_text;
441 }
442
448 public function getNoEntriesText()
449 {
450 return $this->noentriestext;
451 }
452
458 public function setIsDataTable($a_val)
459 {
460 $this->datatable = $a_val;
461 }
462
468 public function getIsDataTable()
469 {
470 return $this->datatable;
471 }
472
478 public function setEnableTitle($a_enabletitle)
479 {
480 $this->enabled["title"] = $a_enabletitle;
481 }
482
488 public function getEnableTitle()
489 {
490 return $this->enabled["title"];
491 }
492
498 public function setEnableHeader($a_enableheader)
499 {
500 $this->enabled["header"] = $a_enableheader;
501 }
502
508 public function getEnableHeader()
509 {
510 return $this->enabled["header"];
511 }
512
518 public function setEnableNumInfo($a_val)
519 {
520 $this->num_info = $a_val;
521 }
522
528 public function getEnableNumInfo()
529 {
530 return $this->num_info;
531 }
532
536 final public function setTitle($a_title, $a_icon = 0, $a_icon_alt = 0)
537 {
538 parent::setTitle($a_title, $a_icon, $a_icon_alt);
539 }
540
546 public function setDescription($a_val)
547 {
548 $this->description = $a_val;
549 }
550
556 public function getDescription()
557 {
558 return $this->description;
559 }
560
566 public function setOrderField($a_order_field)
567 {
568 $this->order_field = $a_order_field;
569 }
570
571 public function getOrderField()
572 {
573 return $this->order_field;
574 }
575
576 final public function setData($a_data)
577 {
578 // check column names against given data (to ensure proper sorting)
579 if (defined('DEVMODE') && DEVMODE &&
580 $this->enabled["header"] && $this->enabled["sort"] &&
581 $this->columns_determined && is_array($this->column) &&
582 is_array($a_data) && sizeof($a_data) && !$this->getExternalSorting()) {
583 $check = $a_data;
584 $check = array_keys(array_shift($check));
585 foreach ($this->column as $col) {
586 if ($col["sort_field"] && !in_array($col["sort_field"], $check)) {
587 $invalid[] = $col["sort_field"];
588 }
589 }
590
591 // this triggers an error, if some columns are not set for some rows
592 // which may just be a representation of "null" values, e.g.
593 // ilAdvancedMDValues:queryForRecords works that way.
594/* if(sizeof($invalid))
595 {
596 trigger_error("The following columns are defined as sortable but".
597 " cannot be found in the given data: ".implode(", ", $invalid).
598 ". Sorting will not work properly.", E_USER_WARNING);
599 }*/
600 }
601
602 $this->row_data = $a_data;
603 if (!is_array($this->row_data)) {
604 $this->row_data = [];
605 }
606 }
607
608 final public function getData()
609 {
610 return $this->row_data;
611 }
612
613 final public function dataExists()
614 {
615 if (is_array($this->row_data)) {
616 if (count($this->row_data) > 0) {
617 return true;
618 }
619 }
620 return false;
621 }
622
623 final public function setPrefix($a_prefix)
624 {
625 $this->prefix = $a_prefix;
626 }
627
628 final public function getPrefix()
629 {
630 return $this->prefix;
631 }
632
637 final public function addFilterItem($a_input_item, $a_optional = false)
638 {
639 $a_input_item->setParent($this);
640 if (!$a_optional) {
641 $this->filters[] = $a_input_item;
642 } else {
643 $this->optional_filters[] = $a_input_item;
644 }
645
646 // restore filter values (from stored view)
647 if ($this->restore_filter) {
648 if (array_key_exists($a_input_item->getFieldId(), $this->restore_filter_values)) {
649 $this->setFilterValue($a_input_item, $this->restore_filter_values[$a_input_item->getFieldId()]);
650 } else {
651 $this->setFilterValue($a_input_item, null); // #14949
652 }
653 }
654 }
655
665 public function addFilterItemByMetaType($id, $type = self::FILTER_TEXT, $a_optional = false, $caption = null)
666 {
667 global $DIC;
668
669 $lng = $DIC->language(); // constructor may not be called here, if initFilter is being called in subclasses before parent::__construct
670
671 if (!$caption) {
672 $caption = $lng->txt($id);
673 }
674
675 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
676
677 switch ($type) {
679 $item = new ilCheckboxInputGUI($caption, $id);
680 break;
681
683 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
684 $item = new ilSelectInputGUI($caption, $id);
685 break;
686
688 include_once("./Services/Form/classes/class.ilDateTimeInputGUI.php");
689 $item = new ilDateTimeInputGUI($caption, $id);
690 break;
691
693 include_once("./Services/Form/classes/class.ilTextInputGUI.php");
694 $item = new ilTextInputGUI($caption, $id);
695 $item->setMaxLength(64);
696 $item->setSize(20);
697 // $item->setSubmitFormOnEnter(true);
698 break;
699
701 $lng->loadLanguageModule("meta");
702 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
703 $item = new ilSelectInputGUI($caption, $id);
704 $options = array("" => $lng->txt("trac_all"));
705 foreach ($lng->getInstalledLanguages() as $lang_key) {
706 $options[$lang_key] = $lng->txt("meta_l_" . $lang_key);
707 }
708 $item->setOptions($options);
709 break;
710
712 include_once("./Services/Form/classes/class.ilCombinationInputGUI.php");
713 include_once("./Services/Form/classes/class.ilNumberInputGUI.php");
714 $item = new ilCombinationInputGUI($caption, $id);
715 $combi_item = new ilNumberInputGUI("", $id . "_from");
716 $item->addCombinationItem("from", $combi_item, $lng->txt("from"));
717 $combi_item = new ilNumberInputGUI("", $id . "_to");
718 $item->addCombinationItem("to", $combi_item, $lng->txt("to"));
719 $item->setComparisonMode(ilCombinationInputGUI::COMPARISON_ASCENDING);
720 $item->setMaxLength(7);
721 $item->setSize(20);
722 break;
723
725 include_once("./Services/Form/classes/class.ilCombinationInputGUI.php");
726 include_once("./Services/Form/classes/class.ilDateTimeInputGUI.php");
727 $item = new ilCombinationInputGUI($caption, $id);
728 $combi_item = new ilDateTimeInputGUI("", $id . "_from");
729 $item->addCombinationItem("from", $combi_item, $lng->txt("from"));
730 $combi_item = new ilDateTimeInputGUI("", $id . "_to");
731 $item->addCombinationItem("to", $combi_item, $lng->txt("to"));
732 $item->setComparisonMode(ilCombinationInputGUI::COMPARISON_ASCENDING);
733 break;
734
736 include_once("./Services/Form/classes/class.ilCombinationInputGUI.php");
737 include_once("./Services/Form/classes/class.ilDateTimeInputGUI.php");
738 $item = new ilCombinationInputGUI($caption, $id);
739 $combi_item = new ilDateTimeInputGUI("", $id . "_from");
740 $combi_item->setShowTime(true);
741 $item->addCombinationItem("from", $combi_item, $lng->txt("from"));
742 $combi_item = new ilDateTimeInputGUI("", $id . "_to");
743 $combi_item->setShowTime(true);
744 $item->addCombinationItem("to", $combi_item, $lng->txt("to"));
745 $item->setComparisonMode(ilCombinationInputGUI::COMPARISON_ASCENDING);
746 break;
747
749 $lng->loadLanguageModule("form");
750 include_once("./Services/Form/classes/class.ilCombinationInputGUI.php");
751 include_once("./Services/Form/classes/class.ilDurationInputGUI.php");
752 $item = new ilCombinationInputGUI($caption, $id);
753 $combi_item = new ilDurationInputGUI("", $id . "_from");
754 $combi_item->setShowMonths(false);
755 $combi_item->setShowDays(true);
756 $combi_item->setShowSeconds(true);
757 $item->addCombinationItem("from", $combi_item, $lng->txt("from"));
758 $combi_item = new ilDurationInputGUI("", $id . "_to");
759 $combi_item->setShowMonths(false);
760 $combi_item->setShowDays(true);
761 $combi_item->setShowSeconds(true);
762 $item->addCombinationItem("to", $combi_item, $lng->txt("to"));
763 $item->setComparisonMode(ilCombinationInputGUI::COMPARISON_ASCENDING);
764 break;
765
766 default:
767 return false;
768 }
769
770 $this->addFilterItem($item, $a_optional);
771 $item->readFromSession();
772 return $item;
773 }
774
778 final public function getFilterItems($a_optionals = false)
779 {
780 if (!$a_optionals) {
781 return $this->filters;
782 }
784 }
785
786 final public function getFilterItemByPostVar($a_post_var)
787 {
788 foreach ($this->getFilterItems() as $item) {
789 if ($item->getPostVar() == $a_post_var) {
790 return $item;
791 }
792 }
793 foreach ($this->getFilterItems(true) as $item) {
794 if ($item->getPostVar() == $a_post_var) {
795 return $item;
796 }
797 }
798 return false;
799 }
800
806 public function setFilterCols($a_val)
807 {
808 $this->filter_cols = $a_val;
809 }
810
816 public function getFilterCols()
817 {
818 return $this->filter_cols;
819 }
820
826 public function setDisableFilterHiding($a_val = true)
827 {
828 $this->disable_filter_hiding = $a_val;
829 }
830
836 public function getDisableFilterHiding()
837 {
839 }
840
847 public function isFilterSelected($a_col)
848 {
849 return $this->selected_filter[$a_col];
850 }
851
858 public function getSelectedFilters()
859 {
860 $sfil = array();
861 foreach ($this->selected_filter as $k => $v) {
862 if ($v) {
863 $sfil[$k] = $k;
864 }
865 }
866 return $sfil;
867 }
868
875 public function determineSelectedFilters()
876 {
877 if ($this->filters_determined) {
878 return;
879 }
880
881 $old_sel = $this->loadProperty("selfilters");
882 $stored = false;
883 if ($old_sel != "") {
884 $sel_filters =
885 @unserialize($old_sel);
886 $stored = true;
887 }
888 if (!is_array($sel_filters)) {
889 $stored = false;
890 $sel_filters = array();
891 }
892
893 $this->selected_filter = array();
894 $set = false;
895 foreach ($this->getFilterItems(true) as $item) {
896 $k = $item->getPostVar();
897
898 $this->selected_filter[$k] = false;
899
900 if ($_POST["tblfsf" . $this->getId()]) {
901 $set = true;
902 if (is_array($_POST["tblff" . $this->getId()]) && in_array($k, $_POST["tblff" . $this->getId()])) {
903 $this->selected_filter[$k] = true;
904 } else {
905 $item->setValue(null);
906 $item->writeToSession();
907 }
908 } elseif ($stored) { // take stored values
909 $this->selected_filter[$k] = $sel_filters[$k];
910 }
911 }
912
913 if ($old_sel != serialize($this->selected_filter) && $set) {
914 $this->storeProperty("selfilters", serialize($this->selected_filter));
915 }
916
917 $this->filters_determined = true;
918 }
919
923 public function setCustomPreviousNext($a_prev_link, $a_next_link)
924 {
925 $this->custom_prev_next = true;
926 $this->custom_prev = $a_prev_link;
927 $this->custom_next = $a_next_link;
928 }
929
936 final public function setFormAction($a_form_action, $a_multipart = false)
937 {
938 $this->form_action = $a_form_action;
939 $this->form_multipart = (bool) $a_multipart;
940 }
941
947 final public function getFormAction()
948 {
949 return $this->form_action;
950 }
951
957 public function setFormName($a_formname = "")
958 {
959 $this->formname = $a_formname;
960 }
961
967 public function getFormName()
968 {
969 return $this->formname;
970 }
971
977 public function setId($a_val)
978 {
979 $this->id = $a_val;
980 if ($this->getPrefix() == "") {
981 $this->setPrefix($a_val);
982 }
983 }
984
990 public function getId()
991 {
992 return $this->id;
993 }
994
1000 public function setDisplayAsBlock($a_val)
1001 {
1002 $this->display_as_block = $a_val;
1003 }
1004
1010 public function getDisplayAsBlock()
1011 {
1012 return $this->display_as_block;
1013 }
1014
1020 public function getSelectAllCheckbox()
1021 {
1023 }
1024
1031 public function setSelectAllCheckbox($a_select_all_checkbox, $a_select_all_on_top = false)
1032 {
1033 $this->select_all_checkbox = $a_select_all_checkbox;
1034 $this->select_all_on_top = $a_select_all_on_top;
1035 }
1036
1042 public function setExternalSorting($a_val)
1043 {
1044 $this->ext_sort = $a_val;
1045 }
1046
1052 public function getExternalSorting()
1053 {
1054 return $this->ext_sort;
1055 }
1056
1063 public function setFilterCommand($a_val, $a_caption = null)
1064 {
1065 $this->filter_cmd = $a_val;
1066 $this->filter_cmd_txt = $a_caption;
1067 }
1068
1074 public function getFilterCommand()
1075 {
1076 return $this->filter_cmd;
1077 }
1078
1085 public function setResetCommand($a_val, $a_caption = null)
1086 {
1087 $this->reset_cmd = $a_val;
1088 $this->reset_cmd_txt = $a_caption;
1089 }
1090
1096 public function getResetCommand()
1097 {
1098 return $this->reset_cmd;
1099 }
1100
1106 public function setExternalSegmentation($a_val)
1107 {
1108 $this->ext_seg = $a_val;
1109 }
1110
1116 public function getExternalSegmentation()
1117 {
1118 return $this->ext_seg;
1119 }
1120
1127 final public function setRowTemplate($a_template, $a_template_dir = "")
1128 {
1129 $this->row_template = $a_template;
1130 $this->row_template_dir = $a_template_dir;
1131 }
1132
1138 public function setDefaultOrderField($a_defaultorderfield)
1139 {
1140 $this->defaultorderfield = $a_defaultorderfield;
1141 }
1142
1148 public function getDefaultOrderField()
1149 {
1150 return $this->defaultorderfield;
1151 }
1152
1158 public function setDefaultOrderDirection($a_defaultorderdirection)
1159 {
1160 $this->defaultorderdirection = $a_defaultorderdirection;
1161 }
1162
1169 {
1170 return $this->defaultorderdirection;
1171 }
1172
1177 public function setDefaultFilterVisiblity($a_status)
1178 {
1179 $this->default_filter_visibility = $a_status;
1180 }
1181
1187 {
1189 }
1190
1191 /*
1192 * Removes all command buttons from the table
1193 *
1194 * @access public
1195 */
1196 public function clearCommandButtons()
1197 {
1198 $this->buttons = array();
1199 }
1200
1207 public function addCommandButton($a_cmd, $a_text, $a_onclick = '', $a_id = "", $a_class = null)
1208 {
1209 $this->buttons[] = array("cmd" => $a_cmd, "text" => $a_text, 'onclick' => $a_onclick,
1210 "id" => $a_id, "class" => $a_class);
1211 }
1212
1218 public function addCommandButtonInstance(ilButtonBase $a_button)
1219 {
1220 $this->buttons[] = $a_button;
1221 }
1222
1233 public function addSelectionButton($a_sel_var, $a_options, $a_cmd, $a_text, $a_default_selection = '')
1234 {
1235 echo "ilTabl2GUI->addSelectionButton() has been deprecated with 4.2. Please try to move the drop-down to ilToolbarGUI.";
1236 // $this->sel_buttons[] = array("sel_var" => $a_sel_var, "options" => $a_options, "selected" => $a_default_selection, "cmd" => $a_cmd, "text" => $a_text);
1237 }
1238
1248 public function addMultiItemSelectionButton($a_sel_var, $a_options, $a_cmd, $a_text, $a_default_selection = '')
1249 {
1250 $this->mi_sel_buttons[] = array("sel_var" => $a_sel_var, "options" => $a_options, "selected" => $a_default_selection, "cmd" => $a_cmd, "text" => $a_text);
1251 $this->addHiddenInput("cmd_sv[" . $a_cmd . "]", $a_sel_var);
1252 }
1253
1254
1255
1262 public function setCloseCommand($a_link)
1263 {
1264 $this->close_command = $a_link;
1265 }
1266
1273 public function addMultiCommand($a_cmd, $a_text)
1274 {
1275 $this->multi[] = array("cmd" => $a_cmd, "text" => $a_text);
1276 }
1277
1284 public function addHiddenInput($a_name, $a_value)
1285 {
1286 $this->hidden_inputs[] = array("name" => $a_name, "value" => $a_value);
1287 }
1288
1295 public function addHeaderCommand($a_href, $a_text, $a_target = "", $a_img = "")
1296 {
1297 $this->header_commands[] = array("href" => $a_href, "text" => $a_text,
1298 "target" => $a_target, "img" => $a_img);
1299 }
1300
1306 public function setTopCommands($a_val)
1307 {
1308 $this->top_commands = $a_val;
1309 }
1310
1316 public function getTopCommands()
1317 {
1318 return $this->top_commands;
1319 }
1320
1328 final public function addColumn(
1329 $a_text,
1330 $a_sort_field = "",
1331 $a_width = "",
1332 $a_is_checkbox_action_column = false,
1333 $a_class = "",
1334 $a_tooltip = "",
1335 $a_tooltip_with_html = false
1336 ) {
1337 $this->column[] = array(
1338 "text" => $a_text,
1339 "sort_field" => $a_sort_field,
1340 "width" => $a_width,
1341 "is_checkbox_action_column" => $a_is_checkbox_action_column,
1342 "class" => $a_class,
1343 "tooltip" => $a_tooltip,
1344 "tooltip_html" => (bool) $a_tooltip_with_html
1345 );
1346 if ($a_sort_field != "") {
1347 $this->sortable_fields[] = $a_sort_field;
1348 }
1349 $this->column_count = count($this->column);
1350 }
1351
1352
1353 final public function getNavParameter()
1354 {
1355 return $this->prefix . "_table_nav";
1356 }
1357
1358 public function setOrderLink($sort_field, $order_dir)
1359 {
1360 global $DIC;
1361
1362 $ilUser = $DIC->user();
1363
1365
1366 $hash = "";
1367 if (is_object($ilUser) && $ilUser->getPref("screen_reader_optimization")) {
1368 $hash = "#" . $this->getTopAnchor();
1369 }
1370
1371 $old = $_GET[$this->getNavParameter()];
1372
1373 // set order link
1374 $ilCtrl->setParameter(
1375 $this->parent_obj,
1376 $this->getNavParameter(),
1377 $sort_field . ":" . $order_dir . ":" . $this->offset
1378 );
1379 $this->tpl->setVariable(
1380 "TBL_ORDER_LINK",
1381 $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd) . $hash
1382 );
1383
1384 // set old value of nav variable
1385 $ilCtrl->setParameter(
1386 $this->parent_obj,
1387 $this->getNavParameter(),
1388 $old
1389 );
1390 }
1391
1392 public function fillHeader()
1393 {
1394 $lng = $this->lng;
1395
1396 $allcolumnswithwidth = true;
1397 foreach ((array) $this->column as $idx => $column) {
1398 if (!strlen($column["width"])) {
1399 $allcolumnswithwidth = false;
1400 } elseif ($column["width"] == "1") {
1401 // IE does not like 1 but seems to work with 1%
1402 $this->column[$idx]["width"] = "1%";
1403 }
1404 }
1405 if ($allcolumnswithwidth) {
1406 foreach ((array) $this->column as $column) {
1407 $this->tpl->setCurrentBlock("tbl_colgroup_column");
1408 $width = (is_numeric($column["width"]))
1409 ? $column["width"]."px"
1410 : $column["width"];
1411 $this->tpl->setVariable("COLGROUP_COLUMN_WIDTH", " style=\"width:" . $width . "\"");
1412 $this->tpl->parseCurrentBlock();
1413 }
1414 }
1415 $ccnt = 0;
1416 foreach ((array) $this->column as $column) {
1417 $ccnt++;
1418 //tooltip
1419 if ($column["tooltip"] != "") {
1420 include_once("./Services/UIComponent/Tooltip/classes/class.ilTooltipGUI.php");
1422 "thc_" . $this->getId() . "_" . $ccnt,
1423 $column["tooltip"],
1424 "",
1425 "bottom center",
1426 "top center",
1427 !$column["tooltip_html"]
1428 );
1429 }
1430
1431 if ($column['is_checkbox_action_column'] && $this->select_all_on_top) {
1432 $this->tpl->setCurrentBlock('tbl_header_top_select_all');
1433 $this->tpl->setVariable("HEAD_SELECT_ALL_TXT_SELECT_ALL", $lng->txt("select_all"));
1434 $this->tpl->setVariable("HEAD_SELECT_ALL_CHECKBOX_NAME", $this->getSelectAllCheckbox());
1435 $this->tpl->setVariable("HEAD_SELECT_ALL_FORM_NAME", $this->getFormName());
1436 $this->tpl->setVariable("HEAD_CHECKBOXNAME", "chb_select_all_" . $this->unique_id . '_top');
1437 $this->tpl->parseCurrentBlock();
1438 continue;
1439 }
1440 if (
1441 !$this->enabled["sort"] ||
1442 $column["sort_field"] == "" &&
1443 !($column["is_checkbox_action_column"] && $this->select_all_on_top)
1444 ) {
1445 $this->tpl->setCurrentBlock("tbl_header_no_link");
1446 if ($column["width"] != "") {
1447 $width = (is_numeric($column["width"]))
1448 ? $column["width"]."px"
1449 : $column["width"];
1450 $this->tpl->setVariable("TBL_COLUMN_WIDTH_NO_LINK", " style=\"width:" . $width . "\"");
1451 }
1452 if ($column["class"] != "") {
1453 $this->tpl->setVariable("TBL_COLUMN_CLASS_NO_LINK", " class=\"" . $column["class"] . "\"");
1454 }
1455 if (!$column["is_checkbox_action_column"]) {
1456 $this->tpl->setVariable(
1457 "TBL_HEADER_CELL_NO_LINK",
1458 $column["text"]
1459 );
1460 } else {
1461 $this->tpl->setVariable(
1462 "TBL_HEADER_CELL_NO_LINK",
1463 ilUtil::img(ilUtil::getImagePath("spacer.png"), $lng->txt("action"))
1464 );
1465 }
1466 $this->tpl->setVariable("HEAD_CELL_NL_ID", "thc_" . $this->getId() . "_" . $ccnt);
1467 if ($column["class"] != "") {
1468 $this->tpl->setVariable("TBL_HEADER_CLASS", " " . $column["class"]);
1469 }
1470 $this->tpl->parseCurrentBlock();
1471 $this->tpl->touchBlock("tbl_header_th");
1472 continue;
1473 }
1474 if (($column["sort_field"] == $this->order_field) && ($this->order_direction != "")) {
1475 $this->tpl->setCurrentBlock("tbl_order_image");
1476 if ($this->order_direction == "asc") {
1477 $this->tpl->setVariable("ORDER_CLASS", "glyphicon glyphicon-arrow-up");
1478 } else {
1479 $this->tpl->setVariable("ORDER_CLASS", "glyphicon glyphicon-arrow-down");
1480 }
1481 $this->tpl->setVariable("IMG_ORDER_ALT", $this->lng->txt("change_sort_direction"));
1482 $this->tpl->parseCurrentBlock();
1483 }
1484
1485 $this->tpl->setCurrentBlock("tbl_header_cell");
1486 $this->tpl->setVariable("TBL_HEADER_CELL", $column["text"]);
1487 $this->tpl->setVariable("HEAD_CELL_ID", "thc_" . $this->getId() . "_" . $ccnt);
1488
1489 // only set width if a value is given for that column
1490 if ($column["width"] != "") {
1491 $width = (is_numeric($column["width"]))
1492 ? $column["width"]."px"
1493 : $column["width"];
1494 $this->tpl->setVariable("TBL_COLUMN_WIDTH", " style=\"width:" . $width . "\"");
1495 }
1496 if ($column["class"] != "") {
1497 $this->tpl->setVariable("TBL_COLUMN_CLASS", " class=\"" . $column["class"] . "\"");
1498 }
1499
1500 $lng_sort_column = $this->lng->txt("sort_by_this_column");
1501 $this->tpl->setVariable("TBL_ORDER_ALT", $lng_sort_column);
1502
1503 $order_dir = "asc";
1504
1505 if ($column["sort_field"] == $this->order_field) {
1506 $order_dir = $this->sort_order;
1507
1508 $lng_change_sort = $this->lng->txt("change_sort_direction");
1509 $this->tpl->setVariable("TBL_ORDER_ALT", $lng_change_sort);
1510 }
1511
1512 if ($column["class"] != "") {
1513 $this->tpl->setVariable("TBL_HEADER_CLASS", " " . $column["class"]);
1514 }
1515 $this->setOrderLink($column["sort_field"], $order_dir);
1516 $this->tpl->parseCurrentBlock();
1517 $this->tpl->touchBlock("tbl_header_th");
1518 }
1519
1520 $this->tpl->setCurrentBlock("tbl_header");
1521 $this->tpl->parseCurrentBlock();
1522 }
1523
1527 protected function prepareOutput()
1528 {
1529 }
1530
1531
1535 public function determineOffsetAndOrder($a_omit_offset = false)
1536 {
1537 global $DIC;
1538
1539 $ilUser = null;
1540 if (isset($DIC["ilUser"])) {
1541 $ilUser = $DIC["ilUser"];
1542 }
1543
1544 if ($this->nav_determined) {
1545 return true;
1546 }
1547
1548 if ($_POST[$this->getNavParameter() . "1"] != "") {
1549 if ($_POST[$this->getNavParameter() . "1"] != $_POST[$this->getNavParameter()]) {
1550 $this->nav_value = $_POST[$this->getNavParameter() . "1"];
1551 } elseif ($_POST[$this->getNavParameter() . "2"] != $_POST[$this->getNavParameter()]) {
1552 $this->nav_value = $_POST[$this->getNavParameter() . "2"];
1553 }
1554 } elseif ($_GET[$this->getNavParameter()]) {
1555 $this->nav_value = $_GET[$this->getNavParameter()];
1556 } elseif ($_SESSION[$this->getNavParameter()] != "") {
1557 $this->nav_value = $_SESSION[$this->getNavParameter()];
1558 }
1559
1560 if ($this->nav_value == "" && $this->getId() != "" && $ilUser->getId() != ANONYMOUS_USER_ID) {
1561 $order = $this->loadProperty("order");
1562 if (in_array($order, $this->sortable_fields)) {
1563 $direction = $this->loadProperty("direction");
1564 } else {
1565 $direction = $this->getDefaultOrderDirection();
1566 }
1567 // get order and direction from db
1568 $this->nav_value =
1569 $order . ":" .
1570 $direction . ":" .
1571 $this->loadProperty("offset");
1572 }
1573 $nav = explode(":", $this->nav_value);
1574
1575 // $nav[0] is order by
1576 $this->setOrderField(($nav[0] != "") ? $nav[0] : $this->getDefaultOrderField());
1577 $this->setOrderDirection(($nav[1] != "") ? $nav[1] : $this->getDefaultOrderDirection());
1578
1579 if (!$a_omit_offset) {
1580 // #8904: offset must be discarded when no limit is given
1581 if (!$this->getExternalSegmentation() && $this->limit_determined && $this->limit == 9999) {
1582 $this->resetOffset(true);
1583 } elseif (!$this->getExternalSegmentation() && $nav[2] >= $this->max_count) {
1584 $this->resetOffset(true);
1585 } else {
1586 $this->setOffset($nav[2]);
1587 }
1588 }
1589
1590 if (!$a_omit_offset) {
1591 $this->nav_determined = true;
1592 }
1593 }
1594
1595 public function storeNavParameter()
1596 {
1597 if ($this->getOrderField() != "") {
1598 $this->storeProperty("order", $this->getOrderField());
1599 }
1600 if ($this->getOrderDirection() != "") {
1601 $this->storeProperty("direction", $this->getOrderDirection());
1602 }
1603 //echo "-".$this->getOffset()."-";
1604 if ($this->getOffset() !== "") {
1605 $this->storeProperty("offset", $this->getOffset());
1606 }
1607 }
1608
1609
1613 public function getHTML()
1614 {
1615 global $DIC;
1616
1617 $ilUser = null;
1618 if (isset($DIC["ilUser"])) {
1619 $ilUser = $DIC["ilUser"];
1620 }
1621
1622 $lng = $this->lng;
1624
1625
1626 if ($this->getExportMode()) {
1627 $this->exportData($this->getExportMode(), true);
1628 }
1629
1630 $this->prepareOutput();
1631
1632 if (is_object($ilCtrl) && $this->getId() == "") {
1633 $ilCtrl->saveParameter($this->getParentObject(), $this->getNavParameter());
1634 }
1635
1636 if (!$this->getPrintMode()) {
1637 // set form action
1638 if ($this->form_action != "" && $this->getOpenFormTag()) {
1639 $hash = "";
1640 if (is_object($ilUser) && $ilUser->getPref("screen_reader_optimization")) {
1641 $hash = "#" . $this->getTopAnchor();
1642 }
1643
1644 if ((bool) $this->form_multipart) {
1645 $this->tpl->touchBlock("form_multipart_bl");
1646 }
1647
1648 if ($this->getPreventDoubleSubmission()) {
1649 $this->tpl->touchBlock("pdfs");
1650 }
1651
1652 $this->tpl->setCurrentBlock("tbl_form_header");
1653 $this->tpl->setVariable("FORMACTION", $this->getFormAction() . $hash);
1654 $this->tpl->setVariable("FORMNAME", $this->getFormName());
1655 $this->tpl->parseCurrentBlock();
1656 }
1657
1658 if ($this->form_action != "" && $this->getCloseFormTag()) {
1659 $this->tpl->touchBlock("tbl_form_footer");
1660 }
1661 }
1662
1663 if (!$this->enabled['content']) {
1664 return $this->render();
1665 }
1666
1667 if (!$this->getExternalSegmentation()) {
1668 $this->setMaxCount(count($this->row_data));
1669 }
1670
1671 $this->determineOffsetAndOrder();
1672
1673 $this->setFooter("tblfooter", $this->lng->txt("previous"), $this->lng->txt("next"));
1674
1675 $data = $this->getData();
1676 if ($this->dataExists()) {
1677 // sort
1678 if (!$this->getExternalSorting() && $this->enabled["sort"]) {
1680 $data,
1681 $this->getOrderField(),
1682 $this->getOrderDirection(),
1683 $this->numericOrdering($this->getOrderField())
1684 );
1685 }
1686
1687 // slice
1688 if (!$this->getExternalSegmentation()) {
1689 $data = array_slice($data, $this->getOffset(), $this->getLimit());
1690 }
1691 }
1692
1693 // fill rows
1694 if ($this->dataExists()) {
1695 if ($this->getPrintMode()) {
1697 }
1698
1699 $this->tpl->addBlockFile(
1700 "TBL_CONTENT",
1701 "tbl_content",
1702 $this->row_template,
1703 $this->row_template_dir
1704 );
1705
1706 foreach ($data as $set) {
1707 $this->tpl->setCurrentBlock("tbl_content");
1708 $this->css_row = ($this->css_row != "tblrow1")
1709 ? "tblrow1"
1710 : "tblrow2";
1711 $this->tpl->setVariable("CSS_ROW", $this->css_row);
1712
1713 $this->fillRow($set);
1714 $this->tpl->setCurrentBlock("tbl_content");
1715 $this->tpl->parseCurrentBlock();
1716 }
1717 } else {
1718 // add standard no items text (please tell me, if it messes something up, alex, 29.8.2008)
1719 $no_items_text = (trim($this->getNoEntriesText()) != '')
1720 ? $this->getNoEntriesText()
1721 : $lng->txt("no_items");
1722
1723 $this->css_row = ($this->css_row != "tblrow1")
1724 ? "tblrow1"
1725 : "tblrow2";
1726
1727 $this->tpl->setCurrentBlock("tbl_no_entries");
1728 $this->tpl->setVariable('TBL_NO_ENTRY_CSS_ROW', $this->css_row);
1729 $this->tpl->setVariable('TBL_NO_ENTRY_COLUMN_COUNT', $this->column_count);
1730 $this->tpl->setVariable('TBL_NO_ENTRY_TEXT', trim($no_items_text));
1731 $this->tpl->parseCurrentBlock();
1732 }
1733
1734
1735 if (!$this->getPrintMode()) {
1736 $this->fillFooter();
1737
1738 $this->fillHiddenRow();
1739
1740 $this->fillActionRow();
1741
1742 $this->storeNavParameter();
1743 }
1744
1745 return $this->render();
1746 }
1747
1753 public function numericOrdering($a_field)
1754 {
1755 return false;
1756 }
1757
1762 public function render()
1763 {
1764 $lng = $this->lng;
1766
1767 $this->tpl->setVariable("CSS_TABLE", $this->getStyle("table"));
1768 //$this->tpl->setVariable("DATA_TABLE", (int) $this->getIsDataTable());
1769 if ($this->getId() != "") {
1770 $this->tpl->setVariable("ID", 'id="' . $this->getId() . '"');
1771 }
1772
1773 // description
1774 if ($this->getDescription() != "") {
1775 $this->tpl->setCurrentBlock("tbl_header_description");
1776 $this->tpl->setVariable("TBL_DESCRIPTION", $this->getDescription());
1777 $this->tpl->parseCurrentBlock();
1778 }
1779
1780 if (!$this->getPrintMode()) {
1781 $this->renderFilter();
1782 }
1783
1784 if ($this->getDisplayAsBlock()) {
1785 $this->tpl->touchBlock("outer_start_1");
1786 $this->tpl->touchBlock("outer_end_1");
1787 } else {
1788 $this->tpl->touchBlock("outer_start_2");
1789 $this->tpl->touchBlock("outer_end_2");
1790 }
1791
1792 // table title and icon
1793 if ($this->enabled["title"] && ($this->title != ""
1794 || $this->icon != "" || count($this->header_commands) > 0 ||
1795 $this->headerHTML != "" || $this->close_command != "")) {
1796 if ($this->enabled["icon"]) {
1797 $this->tpl->setCurrentBlock("tbl_header_title_icon");
1798 $this->tpl->setVariable("TBL_TITLE_IMG", ilUtil::getImagePath($this->icon));
1799 $this->tpl->setVariable("TBL_TITLE_IMG_ALT", $this->icon_alt);
1800 $this->tpl->parseCurrentBlock();
1801 }
1802
1803 if (!$this->getPrintMode()) {
1804 foreach ($this->header_commands as $command) {
1805 if ($command["img"] != "") {
1806 $this->tpl->setCurrentBlock("tbl_header_img_link");
1807 if ($command["target"] != "") {
1808 $this->tpl->setVariable(
1809 "TARGET_IMG_LINK",
1810 'target="' . $command["target"] . '"'
1811 );
1812 }
1813 $this->tpl->setVariable("ALT_IMG_LINK", $command["text"]);
1814 $this->tpl->setVariable("HREF_IMG_LINK", $command["href"]);
1815 $this->tpl->setVariable(
1816 "SRC_IMG_LINK",
1817 $command["img"]
1818 );
1819 $this->tpl->parseCurrentBlock();
1820 } else {
1821 $this->tpl->setCurrentBlock("head_cmd");
1822 $this->tpl->setVariable("TXT_HEAD_CMD", $command["text"]);
1823 $this->tpl->setVariable("HREF_HEAD_CMD", $command["href"]);
1824 $this->tpl->parseCurrentBlock();
1825 }
1826 }
1827 }
1828
1829 if (isset($this->headerHTML)) {
1830 $this->tpl->setCurrentBlock("tbl_header_html");
1831 $this->tpl->setVariable("HEADER_HTML", $this->headerHTML);
1832 $this->tpl->parseCurrentBlock();
1833 }
1834
1835 // close command
1836 if ($this->close_command != "") {
1837 $this->tpl->setCurrentBlock("tbl_header_img_link");
1838 $this->tpl->setVariable("ALT_IMG_LINK", $lng->txt("close"));
1839 $this->tpl->setVariable("HREF_IMG_LINK", $this->close_command);
1840 $this->tpl->parseCurrentBlock();
1841 }
1842
1843 $this->tpl->setCurrentBlock("tbl_header_title");
1844 $this->tpl->setVariable("TBL_TITLE", $this->title);
1845 $this->tpl->setVariable("TOP_ANCHOR", $this->getTopAnchor());
1846 if ($this->getDisplayAsBlock()) {
1847 $this->tpl->setVariable("BLK_CLASS", "Block");
1848 }
1849 $this->tpl->parseCurrentBlock();
1850 }
1851
1852 // table header
1853 if ($this->enabled["header"]) {
1854 $this->fillHeader();
1855 }
1856
1857 $this->tpl->touchBlock("tbl_table_end");
1858
1859 return $this->tpl->get();
1860 }
1861
1865 private function renderFilter()
1866 {
1867 global $DIC;
1868
1869 $lng = $this->lng;
1870 $main_tpl = $DIC["tpl"];
1871
1872 $filter = $this->getFilterItems();
1873 $opt_filter = $this->getFilterItems(true);
1874
1875 $main_tpl->addJavascript("./Services/Table/js/ServiceTable.js");
1876
1877 if (count($filter) == 0 && count($opt_filter) == 0) {
1878 return;
1879 }
1880
1881 include_once("./Services/YUI/classes/class.ilYuiUtil.php");
1883
1884 $ccnt = 0;
1885
1886 // render standard filter
1887 if (count($filter) > 0) {
1888 foreach ($filter as $item) {
1889 if ($ccnt >= $this->getFilterCols()) {
1890 $this->tpl->setCurrentBlock("filter_row");
1891 $this->tpl->parseCurrentBlock();
1892 $ccnt = 0;
1893 }
1894 $this->tpl->setCurrentBlock("filter_item");
1895 $this->tpl->setVariable(
1896 "OPTION_NAME",
1897 $item->getTitle()
1898 );
1899 $this->tpl->setVariable(
1900 "F_INPUT_ID",
1901 $item->getTableFilterLabelFor()
1902 );
1903 $this->tpl->setVariable(
1904 "INPUT_HTML",
1905 $item->getTableFilterHTML()
1906 );
1907 $this->tpl->parseCurrentBlock();
1908 $ccnt++;
1909 }
1910 }
1911
1912 // render optional filter
1913 if (count($opt_filter) > 0) {
1914 $this->determineSelectedFilters();
1915
1916 foreach ($opt_filter as $item) {
1917 if ($this->isFilterSelected($item->getPostVar())) {
1918 if ($ccnt >= $this->getFilterCols()) {
1919 $this->tpl->setCurrentBlock("filter_row");
1920 $this->tpl->parseCurrentBlock();
1921 $ccnt = 0;
1922 }
1923 $this->tpl->setCurrentBlock("filter_item");
1924 $this->tpl->setVariable(
1925 "OPTION_NAME",
1926 $item->getTitle()
1927 );
1928 $this->tpl->setVariable(
1929 "F_INPUT_ID",
1930 $item->getFieldId()
1931 );
1932 $this->tpl->setVariable(
1933 "INPUT_HTML",
1934 $item->getTableFilterHTML()
1935 );
1936 $this->tpl->parseCurrentBlock();
1937 $ccnt++;
1938 }
1939 }
1940
1941 // filter selection
1942 $items = array();
1943 foreach ($opt_filter as $item) {
1944 $k = $item->getPostVar();
1945 $items[$k] = array("txt" => $item->getTitle(),
1946 "selected" => $this->isFilterSelected($k));
1947 }
1948
1949 include_once("./Services/UIComponent/CheckboxListOverlay/classes/class.ilCheckboxListOverlayGUI.php");
1950 $cb_over = new ilCheckboxListOverlayGUI("tbl_filters_" . $this->getId());
1951 $cb_over->setLinkTitle($lng->txt("optional_filters"));
1952 $cb_over->setItems($items);
1953
1954 $cb_over->setFormCmd($this->getParentCmd());
1955 $cb_over->setFieldVar("tblff" . $this->getId());
1956 $cb_over->setHiddenVar("tblfsf" . $this->getId());
1957
1958 $cb_over->setSelectionHeaderClass("ilTableMenuItem");
1959 $this->tpl->setCurrentBlock("filter_select");
1960
1961 // apply should be the first submit because of enter/return, inserting hidden submit
1962 $this->tpl->setVariable("HIDDEN_CMD_APPLY", $this->filter_cmd);
1963
1964 $this->tpl->setVariable("FILTER_SELECTOR", $cb_over->getHTML());
1965 $this->tpl->parseCurrentBlock();
1966 }
1967
1968 // if any filter
1969 if ($ccnt > 0 || count($opt_filter) > 0) {
1970 $this->tpl->setVariable("TXT_FILTER", $lng->txt("filter"));
1971
1972 if ($ccnt > 0) {
1973 if ($ccnt < $this->getFilterCols()) {
1974 for ($i = $ccnt; $i <= $this->getFilterCols(); $i++) {
1975 $this->tpl->touchBlock("filter_empty_cell");
1976 }
1977 }
1978 $this->tpl->setCurrentBlock("filter_row");
1979 $this->tpl->parseCurrentBlock();
1980
1981 $this->tpl->setCurrentBlock("filter_buttons");
1982 $this->tpl->setVariable("CMD_APPLY", $this->filter_cmd);
1983 $this->tpl->setVariable("TXT_APPLY", $this->filter_cmd_txt
1984 ? $this->filter_cmd_txt
1985 : $lng->txt("apply_filter"));
1986 $this->tpl->setVariable("CMD_RESET", $this->reset_cmd);
1987 $this->tpl->setVariable("TXT_RESET", $this->reset_cmd_txt
1988 ? $this->reset_cmd_txt
1989 : $lng->txt("reset_filter"));
1990 } elseif (count($opt_filter) > 0) {
1991 $this->tpl->setCurrentBlock("optional_filter_hint");
1992 $this->tpl->setVariable('TXT_OPT_HINT', $lng->txt('optional_filter_hint'));
1993 $this->tpl->parseCurrentBlock();
1994 }
1995
1996 $this->tpl->setCurrentBlock("filter_section");
1997 $this->tpl->setVariable("FIL_ID", $this->getId());
1998 $this->tpl->parseCurrentBlock();
1999
2000 // (keep) filter hidden?
2001 if (!$this->isFilterVisible()) {
2002 if (!$this->getDisableFilterHiding()) {
2003 $this->tpl->setCurrentBlock("filter_hidden");
2004 $this->tpl->setVariable("FI_ID", $this->getId());
2005 $this->tpl->parseCurrentBlock();
2006 }
2007 }
2008 }
2009 }
2010
2015 protected function isFilterVisible()
2016 {
2017 $prop = $this->loadProperty('filter');
2018 if ($prop === '0' || $prop === '1') {
2019 return (bool) $prop;
2020 }
2021 return $this->getDefaultFilterVisibility();
2022 }
2023
2031 protected function isAdvMDFilter(ilAdvancedMDRecordGUI $a_gui, $a_element)
2032 {
2033 foreach ($a_gui->getFilterElements(false) as $item) {
2034 if ($item === $a_element) {
2035 return true;
2036 }
2037 }
2038 return false;
2039 }
2040
2044 public function writeFilterToSession()
2045 {
2046 $advmd_record_gui = null;
2047 if (method_exists($this, "getAdvMDRecordGUI")) {
2048 $advmd_record_gui = $this->getAdvMDRecordGUI();
2049 }
2050
2051 foreach ($this->getFilterItems() as $item) {
2052 if ($advmd_record_gui &&
2053 $this->isAdvMDFilter($advmd_record_gui, $item)) {
2054 continue;
2055 }
2056
2057 if ($item->checkInput()) {
2058 $item->setValueByArray($_POST);
2059 $item->writeToSession();
2060 }
2061 }
2062 foreach ($this->getFilterItems(true) as $item) {
2063 if ($advmd_record_gui &&
2064 $this->isAdvMDFilter($advmd_record_gui, $item)) {
2065 continue;
2066 }
2067
2068 if ($item->checkInput()) {
2069 $item->setValueByArray($_POST);
2070 $item->writeToSession();
2071 }
2072 }
2073
2074 if ($advmd_record_gui) {
2075 $advmd_record_gui->importFilter();
2076 }
2077
2078 // #13209
2079 unset($_REQUEST["tbltplcrt"]);
2080 unset($_REQUEST["tbltpldel"]);
2081 }
2082
2086 public function resetFilter()
2087 {
2088 $lng = $this->lng;
2089
2090 $filter = $this->getFilterItems();
2091 $opt_filter = $this->getFilterItems(true);
2092
2093 foreach ($filter as $item) {
2094 if ($item->checkInput()) {
2095 $item->setValueByArray($_POST);
2096 $item->clearFromSession();
2097 }
2098 }
2099 foreach ($opt_filter as $item) {
2100 if ($item->checkInput()) {
2101 $item->setValueByArray($_POST);
2102 $item->clearFromSession();
2103 }
2104 }
2105
2106 // #13209
2107 unset($_REQUEST["tbltplcrt"]);
2108 unset($_REQUEST["tbltpldel"]);
2109 }
2110
2117 protected function fillRow($a_set)
2118 {
2119 foreach ($a_set as $key => $value) {
2120 $this->tpl->setVariable("VAL_" . strtoupper($key), $value);
2121 }
2122 }
2123
2127 public function fillFooter()
2128 {
2129 global $DIC;
2130
2131 $ilUser = null;
2132 if (isset($DIC["ilUser"])) {
2133 $ilUser = $DIC["ilUser"];
2134 }
2135
2136 $lng = $this->lng;
2138
2139 $footer = false;
2140
2141 // select all checkbox
2142 if ((strlen($this->getFormName())) && (strlen($this->getSelectAllCheckbox())) && $this->dataExists()) {
2143 $this->tpl->setCurrentBlock("select_all_checkbox");
2144 $this->tpl->setVariable("SELECT_ALL_TXT_SELECT_ALL", $lng->txt("select_all"));
2145 $this->tpl->setVariable("SELECT_ALL_CHECKBOX_NAME", $this->getSelectAllCheckbox());
2146 $this->tpl->setVariable("SELECT_ALL_FORM_NAME", $this->getFormName());
2147 $this->tpl->setVariable("CHECKBOXNAME", "chb_select_all_" . $this->unique_id);
2148 $this->tpl->parseCurrentBlock();
2149 }
2150
2151 // table footer numinfo
2152 if ($this->enabled["numinfo"] && $this->enabled["footer"]) {
2153 $start = $this->offset + 1; // compute num info
2154 if (!$this->dataExists()) {
2155 $start = 0;
2156 }
2157 $end = $this->offset + $this->limit;
2158
2159 if ($end > $this->max_count or $this->limit == 0) {
2161 }
2162
2163 if ($this->max_count > 0) {
2164 if ($this->lang_support) {
2165 $numinfo = "(" . $start . " - " . $end . " " . strtolower($this->lng->txt("of")) . " " . $this->max_count . ")";
2166 } else {
2167 $numinfo = "(" . $start . " - " . $end . " of " . $this->max_count . ")";
2168 }
2169 }
2170 if ($this->max_count > 0) {
2171 if ($this->getEnableNumInfo()) {
2172 $this->tpl->setCurrentBlock("tbl_footer_numinfo");
2173 $this->tpl->setVariable("NUMINFO", $numinfo);
2174 $this->tpl->parseCurrentBlock();
2175 }
2176 }
2177 $footer = true;
2178 }
2179
2180 // table footer linkbar
2181 if ($this->enabled["linkbar"] && $this->enabled["footer"] && $this->limit != 0
2182 && $this->max_count > 0) {
2183 $layout = array(
2184 "link" => $this->footer_style,
2185 "prev" => $this->footer_previous,
2186 "next" => $this->footer_next,
2187 );
2188 //if (!$this->getDisplayAsBlock())
2189 //{
2190 $linkbar = $this->getLinkbar("1");
2191 $this->tpl->setCurrentBlock("tbl_footer_linkbar");
2192 $this->tpl->setVariable("LINKBAR", $linkbar);
2193 $this->tpl->parseCurrentBlock();
2194 $linkbar = true;
2195 //}
2196 $footer = true;
2197 }
2198
2199 // column selector
2200 if (is_array($this->getSelectableColumns()) && count($this->getSelectableColumns()) > 0) {
2201 $items = array();
2202 foreach ($this->getSelectableColumns() as $k => $c) {
2203 $items[$k] = array("txt" => $c["txt"],
2204 "selected" => $this->isColumnSelected($k));
2205 }
2206 include_once("./Services/UIComponent/CheckboxListOverlay/classes/class.ilCheckboxListOverlayGUI.php");
2207 $cb_over = new ilCheckboxListOverlayGUI("tbl_" . $this->getId());
2208 $cb_over->setLinkTitle($lng->txt("columns"));
2209 $cb_over->setItems($items);
2210 //$cb_over->setUrl("./ilias.php?baseClass=ilTablePropertiesStorage&table_id=".
2211 // $this->getId()."&cmd=saveSelectedFields&user_id=".$ilUser->getId());
2212 $cb_over->setFormCmd($this->getParentCmd());
2213 $cb_over->setFieldVar("tblfs" . $this->getId());
2214 $cb_over->setHiddenVar("tblfsh" . $this->getId());
2215 $cb_over->setSelectionHeaderClass("ilTableMenuItem");
2216 $column_selector = $cb_over->getHTML();
2217 $footer = true;
2218 }
2219
2220 if ($this->getShowTemplates() && is_object($ilUser)) {
2221 // template handling
2222 if (isset($_REQUEST["tbltplcrt"]) && $_REQUEST["tbltplcrt"]) {
2223 if ($this->saveTemplate($_REQUEST["tbltplcrt"])) {
2224 ilUtil::sendSuccess($lng->txt("tbl_template_created"));
2225 }
2226 } elseif (isset($_REQUEST["tbltpldel"]) && $_REQUEST["tbltpldel"]) {
2227 if ($this->deleteTemplate($_REQUEST["tbltpldel"])) {
2228 ilUtil::sendSuccess($lng->txt("tbl_template_deleted"));
2229 }
2230 }
2231
2232 $create_id = "template_create_overlay_" . $this->getId();
2233 $delete_id = "template_delete_overlay_" . $this->getId();
2234 $list_id = "template_stg_" . $this->getId();
2235
2236 include_once("./Services/Table/classes/class.ilTableTemplatesStorage.php");
2237 $storage = new ilTableTemplatesStorage();
2238 $templates = $storage->getNames($this->getContext(), $ilUser->getId());
2239
2240 include_once("./Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php");
2241
2242 // form to delete template
2243 if (sizeof($templates)) {
2244 $overlay = new ilOverlayGUI($delete_id);
2245 $overlay->setTrigger($list_id . "_delete");
2246 $overlay->setAnchor("ilAdvSelListAnchorElement_" . $list_id);
2247 $overlay->setAutoHide(false);
2248 $overlay->add();
2249
2250 $lng->loadLanguageModule("form");
2251 $this->tpl->setCurrentBlock("template_editor_delete_item");
2252 $this->tpl->setVariable("TEMPLATE_DELETE_OPTION_VALUE", "");
2253 $this->tpl->setVariable("TEMPLATE_DELETE_OPTION", "- " . $lng->txt("form_please_select") . " -");
2254 $this->tpl->parseCurrentBlock();
2255 foreach ($templates as $name) {
2256 $this->tpl->setVariable("TEMPLATE_DELETE_OPTION_VALUE", $name);
2257 $this->tpl->setVariable("TEMPLATE_DELETE_OPTION", $name);
2258 $this->tpl->parseCurrentBlock();
2259 }
2260
2261 $this->tpl->setCurrentBlock("template_editor_delete");
2262 $this->tpl->setVariable("TEMPLATE_DELETE_ID", $delete_id);
2263 $this->tpl->setVariable("TXT_TEMPLATE_DELETE", $lng->txt("tbl_template_delete"));
2264 $this->tpl->setVariable("TXT_TEMPLATE_DELETE_SUBMIT", $lng->txt("delete"));
2265 $this->tpl->setVariable("TEMPLATE_DELETE_CMD", $this->parent_cmd);
2266 $this->tpl->parseCurrentBlock();
2267 }
2268
2269
2270 // form to save new template
2271 $overlay = new ilOverlayGUI($create_id);
2272 $overlay->setTrigger($list_id . "_create");
2273 $overlay->setAnchor("ilAdvSelListAnchorElement_" . $list_id);
2274 $overlay->setAutoHide(false);
2275 $overlay->add();
2276
2277 $this->tpl->setCurrentBlock("template_editor");
2278 $this->tpl->setVariable("TEMPLATE_CREATE_ID", $create_id);
2279 $this->tpl->setVariable("TXT_TEMPLATE_CREATE", $lng->txt("tbl_template_create"));
2280 $this->tpl->setVariable("TXT_TEMPLATE_CREATE_SUBMIT", $lng->txt("save"));
2281 $this->tpl->setVariable("TEMPLATE_CREATE_CMD", $this->parent_cmd);
2282 $this->tpl->parseCurrentBlock();
2283
2284 // load saved template
2285 include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
2286 $alist = new ilAdvancedSelectionListGUI();
2287 $alist->setId($list_id);
2288 $alist->addItem($lng->txt("tbl_template_create"), "create", "#");
2289 if (sizeof($templates)) {
2290 $alist->addItem($lng->txt("tbl_template_delete"), "delete", "#");
2291 foreach ($templates as $name) {
2292 $ilCtrl->setParameter($this->parent_obj, $this->prefix . "_tpl", urlencode($name));
2293 $alist->addItem($name, $name, $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd));
2294 $ilCtrl->setParameter($this->parent_obj, $this->prefix . "_tpl", "");
2295 }
2296 }
2297 $alist->setListTitle($lng->txt("tbl_templates"));
2299 $this->tpl->setVariable("TEMPLATE_SELECTOR", "&nbsp;" . $alist->getHTML());
2300 }
2301
2302 if ($footer) {
2303 $this->tpl->setCurrentBlock("tbl_footer");
2304 $this->tpl->setVariable("COLUMN_COUNT", $this->getColumnCount());
2305 if ($this->getDisplayAsBlock()) {
2306 $this->tpl->setVariable("BLK_CLASS", "Block");
2307 }
2308 $this->tpl->parseCurrentBlock();
2309
2310 // top navigation, if number info or linkbar given
2311 if ($numinfo != "" || $linkbar != "" || $column_selector != "" ||
2312 count($this->filters) > 0 || count($this->optional_filters) > 0) {
2313 if (is_object($ilUser) && (count($this->filters) || count($this->optional_filters))) {
2314 $this->tpl->setCurrentBlock("filter_activation");
2315 $this->tpl->setVariable("TXT_ACTIVATE_FILTER", $lng->txt("show_filter"));
2316 $this->tpl->setVariable("FILA_ID", $this->getId());
2317 if ($this->getId() != "") {
2318 $this->tpl->setVariable("SAVE_URLA", "./ilias.php?baseClass=ilTablePropertiesStorage&table_id=" .
2319 $this->getId() . "&cmd=showFilter&user_id=" . $ilUser->getId());
2320 }
2321 $this->tpl->parseCurrentBlock();
2322
2323
2324 if (!$this->getDisableFilterHiding()) {
2325 $this->tpl->setCurrentBlock("filter_deactivation");
2326 $this->tpl->setVariable("TXT_HIDE", $lng->txt("hide_filter"));
2327 if ($this->getId() != "") {
2328 $this->tpl->setVariable("SAVE_URL", "./ilias.php?baseClass=ilTablePropertiesStorage&table_id=" .
2329 $this->getId() . "&cmd=hideFilter&user_id=" . $ilUser->getId());
2330 $this->tpl->setVariable("FILD_ID", $this->getId());
2331 }
2332 $this->tpl->parseCurrentBlock();
2333 }
2334 }
2335
2336 if ($numinfo != "" && $this->getEnableNumInfo()) {
2337 $this->tpl->setCurrentBlock("top_numinfo");
2338 $this->tpl->setVariable("NUMINFO", $numinfo);
2339 $this->tpl->parseCurrentBlock();
2340 }
2341 if ($linkbar != "" && !$this->getDisplayAsBlock()) {
2342 $linkbar = $this->getLinkbar("2");
2343 $this->tpl->setCurrentBlock("top_linkbar");
2344 $this->tpl->setVariable("LINKBAR", $linkbar);
2345 $this->tpl->parseCurrentBlock();
2346 }
2347
2348 // column selector
2349 $this->tpl->setVariable("COLUMN_SELECTOR", $column_selector);
2350
2351 // row selector
2352 if ($this->getShowRowsSelector() &&
2353 is_object($ilUser) &&
2354 $this->getId() &&
2355 !$this->rows_selector_off) { // JF, 2014-10-27
2356 include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
2357 $alist = new ilAdvancedSelectionListGUI();
2359 $alist->setId("sellst_rows_" . $this->getId());
2360 $hpp = ($ilUser->getPref("hits_per_page") != 9999)
2361 ? $ilUser->getPref("hits_per_page")
2362 : $lng->txt("no_limit");
2363
2364 $options = array(0 => $lng->txt("default") . " (" . $hpp . ")",5 => 5, 10 => 10, 15 => 15, 20 => 20,
2365 30 => 30, 40 => 40, 50 => 50,
2366 100 => 100, 200 => 200, 400 => 400, 800 => 800);
2367 foreach ($options as $k => $v) {
2368 $ilCtrl->setParameter($this->parent_obj, $this->prefix . "_trows", $k);
2369 $alist->addItem($v, $k, $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd));
2370 $ilCtrl->setParameter($this->parent_obj, $this->prefix . "_trows", "");
2371 }
2372 $alist->setListTitle($this->getRowSelectorLabel() ? $this->getRowSelectorLabel() : $lng->txt("rows"));
2373 $this->tpl->setVariable("ROW_SELECTOR", $alist->getHTML());
2374 }
2375
2376 // export
2377 if (sizeof($this->export_formats) && $this->dataExists()) {
2378 include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
2379 $alist = new ilAdvancedSelectionListGUI();
2381 $alist->setId("sellst_xpt");
2382 foreach ($this->export_formats as $format => $caption_lng_id) {
2383 $ilCtrl->setParameter($this->parent_obj, $this->prefix . "_xpt", $format);
2384 $url = $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd);
2385 $ilCtrl->setParameter($this->parent_obj, $this->prefix . "_xpt", "");
2386 $alist->addItem($lng->txt($caption_lng_id), $format, $url);
2387 }
2388 $alist->setListTitle($lng->txt("export"));
2389 $this->tpl->setVariable("EXPORT_SELECTOR", "&nbsp;" . $alist->getHTML());
2390 }
2391
2392 $this->tpl->setCurrentBlock("top_navigation");
2393 $this->tpl->setVariable("COLUMN_COUNT", $this->getColumnCount());
2394 if ($this->getDisplayAsBlock()) {
2395 $this->tpl->setVariable("BLK_CLASS", "Block");
2396 }
2397 $this->tpl->parseCurrentBlock();
2398 }
2399 }
2400 }
2401
2409 public function getLinkbar($a_num)
2410 {
2411 global $DIC;
2412
2413 $ilUser = $DIC->user();
2414
2416 $lng = $this->lng;
2417
2418 $hash = "";
2419 if (is_object($ilUser) && $ilUser->getPref("screen_reader_optimization")) {
2420 $hash = "#" . $this->getTopAnchor();
2421 }
2422
2423 $link = $ilCtrl->getLinkTargetByClass(get_class($this->parent_obj), $this->parent_cmd) .
2424 "&" . $this->getNavParameter() . "=" .
2425 $this->getOrderField() . ":" . $this->getOrderDirection() . ":";
2426
2427 $LinkBar = "";
2428 $layout_prev = $lng->txt("previous");
2429 $layout_next = $lng->txt("next");
2430
2431 // if more entries then entries per page -> show link bar
2432 if ($this->max_count > $this->getLimit() || $this->custom_prev_next) {
2433 $sep = "<span>&nbsp;&nbsp;|&nbsp;&nbsp;</span>";
2434
2435 // calculate number of pages
2436 $pages = intval($this->max_count / $this->getLimit());
2437
2438 // add a page if a rest remains
2439 if (($this->max_count % $this->getLimit())) {
2440 $pages++;
2441 }
2442
2443 // links to other pages
2444 $offset_arr = array();
2445 for ($i = 1 ;$i <= $pages ; $i++) {
2446 $newoffset = $this->getLimit() * ($i - 1);
2447
2448 $nav_value = $this->getOrderField() . ":" . $this->getOrderDirection() . ":" . $newoffset;
2449 $offset_arr[$nav_value] = $i;
2450 }
2451
2452 $sep = "<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>";
2453
2454 // previous link
2455 if ($this->custom_prev_next && $this->custom_prev != "") {
2456 if ($LinkBar != "") {
2457 $LinkBar .= $sep;
2458 }
2459 $LinkBar .= "<a href=\"" . $this->custom_prev . $hash . "\">" . $layout_prev . "</a>";
2460 } elseif ($this->getOffset() >= 1 && !$this->custom_prev_next) {
2461 if ($LinkBar != "") {
2462 $LinkBar .= $sep;
2463 }
2464 $prevoffset = $this->getOffset() - $this->getLimit();
2465 $LinkBar .= "<a href=\"" . $link . $prevoffset . $hash . "\">" . $layout_prev . "</a>";
2466 } else {
2467 if ($LinkBar != "") {
2468 $LinkBar .= $sep;
2469 }
2470 $LinkBar .= '<span class="ilTableFootLight">' . $layout_prev . "</span>";
2471 }
2472
2473 // current value
2474 if ($a_num == "1") {
2475 $LinkBar .= '<input type="hidden" name="' . $this->getNavParameter() .
2476 '" value="' . $this->getOrderField() . ":" . $this->getOrderDirection() . ":" . $this->getOffset() . '" />';
2477 }
2478
2479 $sep = "<span>&nbsp;&nbsp;|&nbsp;&nbsp;</span>";
2480
2481 // show next link (if not last page)
2482 if ($this->custom_prev_next && $this->custom_next != "") {
2483 if ($LinkBar != "") {
2484 $LinkBar .= $sep;
2485 }
2486 $LinkBar .= "<a href=\"" . $this->custom_next . $hash . "\">" . $layout_next . "</a>";
2487 } elseif (!(($this->getOffset() / $this->getLimit()) == ($pages - 1)) && ($pages != 1) &&
2488 !$this->custom_prev_next) {
2489 if ($LinkBar != "") {
2490 $LinkBar .= $sep;
2491 }
2492 $newoffset = $this->getOffset() + $this->getLimit();
2493 $LinkBar .= "<a href=\"" . $link . $newoffset . $hash . "\">" . $layout_next . "</a>";
2494 } else {
2495 if ($LinkBar != "") {
2496 $LinkBar .= $sep;
2497 }
2498 $LinkBar .= '<span class="ilTableFootLight">' . $layout_next . "</span>";
2499 }
2500
2501 $sep = "<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>";
2502
2503 if (count($offset_arr) && !$this->getDisplayAsBlock() && !$this->custom_prev_next) {
2504 if ($LinkBar != "") {
2505 $LinkBar .= $sep;
2506 }
2507 $LinkBar .= "" .
2508 '<label for="tab_page_sel_' . $a_num . '">' . $lng->txt("page") . '</label> ' .
2510 $this->nav_value,
2511 $this->getNavParameter() . $a_num,
2512 $offset_arr,
2513 false,
2514 true,
2515 0,
2516 "small",
2517 array("id" => "tab_page_sel_" . $a_num,
2518 "onchange" => "ilTablePageSelection(this, 'cmd[" . $this->parent_cmd . "]')")
2519 );
2520 //' <input class="submit" type="submit" name="cmd['.$this->parent_cmd.']" value="'.
2521 //$lng->txt("ok").'" />';
2522 }
2523
2524 return $LinkBar;
2525 } else {
2526 return false;
2527 }
2528 }
2529
2530 public function fillHiddenRow()
2531 {
2532 $hidden_row = false;
2533 if (count($this->hidden_inputs)) {
2534 foreach ($this->hidden_inputs as $hidden_input) {
2535 $this->tpl->setCurrentBlock("tbl_hidden_field");
2536 $this->tpl->setVariable("FIELD_NAME", $hidden_input["name"]);
2537 $this->tpl->setVariable("FIELD_VALUE", $hidden_input["value"]);
2538 $this->tpl->parseCurrentBlock();
2539 }
2540
2541 $this->tpl->setCurrentBlock("tbl_hidden_row");
2542 $this->tpl->parseCurrentBlock();
2543 }
2544 }
2545
2549 public function fillActionRow()
2550 {
2551 $lng = $this->lng;
2552
2553 // action row
2554 $action_row = false;
2555 $arrow = false;
2556
2557 // add selection buttons
2558 if (count($this->sel_buttons) > 0) {
2559 foreach ($this->sel_buttons as $button) {
2560 $this->tpl->setCurrentBlock("sel_button");
2561 $this->tpl->setVariable(
2562 "SBUTTON_SELECT",
2564 $button["selected"],
2565 $button["sel_var"],
2566 $button["options"],
2567 false,
2568 true
2569 )
2570 );
2571 $this->tpl->setVariable("SBTN_NAME", $button["cmd"]);
2572 $this->tpl->setVariable("SBTN_VALUE", $button["text"]);
2573 $this->tpl->parseCurrentBlock();
2574
2575 if ($this->getTopCommands()) {
2576 $this->tpl->setCurrentBlock("sel_top_button");
2577 $this->tpl->setVariable(
2578 "SBUTTON_SELECT",
2580 $button["selected"],
2581 $button["sel_var"],
2582 $button["options"],
2583 false,
2584 true
2585 )
2586 );
2587 $this->tpl->setVariable("SBTN_NAME", $button["cmd"]);
2588 $this->tpl->setVariable("SBTN_VALUE", $button["text"]);
2589 $this->tpl->parseCurrentBlock();
2590 }
2591 }
2592 $buttons = true;
2593 $action_row = true;
2594 }
2595 $this->sel_buttons[] = array("options" => $a_options, "cmd" => $a_cmd, "text" => $a_text);
2596
2597 // add buttons
2598 if (count($this->buttons) > 0) {
2599 foreach ($this->buttons as $button) {
2600 if (!is_array($button)) {
2601 if ($button instanceof ilButtonBase) {
2602 $this->tpl->setVariable('BUTTON_OBJ', $button->render());
2603
2604 // this will remove id - should be unique
2605 $button = clone $button;
2606
2607 $this->tpl->setVariable('BUTTON_TOP_OBJ', $button->render());
2608 }
2609 continue;
2610 }
2611
2612 if (strlen($button['onclick'])) {
2613 $this->tpl->setCurrentBlock('cmdonclick');
2614 $this->tpl->setVariable('CMD_ONCLICK', $button['onclick']);
2615 $this->tpl->parseCurrentBlock();
2616 }
2617 $this->tpl->setCurrentBlock("plain_button");
2618 if ($button["id"] != "") {
2619 $this->tpl->setVariable("PBID", ' id="' . $button["id"] . '" ');
2620 }
2621 if ($button["class"] != "") {
2622 $this->tpl->setVariable("PBBT_CLASS", ' ' . $button["class"]);
2623 }
2624 $this->tpl->setVariable("PBTN_NAME", $button["cmd"]);
2625 $this->tpl->setVariable("PBTN_VALUE", $button["text"]);
2626 $this->tpl->parseCurrentBlock();
2627
2628 if ($this->getTopCommands()) {
2629 if (strlen($button['onclick'])) {
2630 $this->tpl->setCurrentBlock('top_cmdonclick');
2631 $this->tpl->setVariable('CMD_ONCLICK', $button['onclick']);
2632 $this->tpl->parseCurrentBlock();
2633 }
2634 $this->tpl->setCurrentBlock("plain_top_button");
2635 $this->tpl->setVariable("PBTN_NAME", $button["cmd"]);
2636 $this->tpl->setVariable("PBTN_VALUE", $button["text"]);
2637 if ($button["class"] != "") {
2638 $this->tpl->setVariable("PBBT_CLASS", ' ' . $button["class"]);
2639 }
2640 $this->tpl->parseCurrentBlock();
2641 }
2642 }
2643
2644 $buttons = true;
2645 $action_row = true;
2646 }
2647
2648 // multi selection
2649 if (count($this->mi_sel_buttons)) {
2650 foreach ($this->mi_sel_buttons as $button) {
2651 $this->tpl->setCurrentBlock("mi_sel_button");
2652 $this->tpl->setVariable(
2653 "MI_BUTTON_SELECT",
2655 $button["selected"],
2656 $button["sel_var"],
2657 $button["options"],
2658 false,
2659 true
2660 )
2661 );
2662 $this->tpl->setVariable("MI_BTN_NAME", $button["cmd"]);
2663 $this->tpl->setVariable("MI_BTN_VALUE", $button["text"]);
2664 $this->tpl->parseCurrentBlock();
2665
2666 if ($this->getTopCommands()) {
2667 $this->tpl->setCurrentBlock("mi_top_sel_button");
2668 $this->tpl->setVariable(
2669 "MI_BUTTON_SELECT",
2671 $button["selected"],
2672 $button["sel_var"] . "_2",
2673 $button["options"],
2674 false,
2675 true
2676 )
2677 );
2678 $this->tpl->setVariable("MI_BTN_NAME", $button["cmd"]);
2679 $this->tpl->setVariable("MI_BTN_VALUE", $button["text"]);
2680 $this->tpl->parseCurrentBlock();
2681 }
2682 }
2683 $arrow = true;
2684 $action_row = true;
2685 }
2686
2687
2688 if (count($this->multi) > 1 && $this->dataExists()) {
2689 if ($this->enable_command_for_all && $this->max_count <= self::getAllCommandLimit()) {
2690 $this->tpl->setCurrentBlock("tbl_cmd_select_all");
2691 $this->tpl->setVariable("TXT_SELECT_CMD_ALL", $lng->txt("all_objects"));
2692 $this->tpl->parseCurrentBlock();
2693 }
2694
2695 $this->tpl->setCurrentBlock("tbl_cmd_select");
2696 $sel = array();
2697 foreach ($this->multi as $mc) {
2698 $sel[$mc["cmd"]] = $mc["text"];
2699 }
2700 $this->tpl->setVariable(
2701 "SELECT_CMDS",
2702 ilUtil::formSelect("", "selected_cmd", $sel, false, true)
2703 );
2704 $this->tpl->setVariable("TXT_EXECUTE", $lng->txt("execute"));
2705 $this->tpl->parseCurrentBlock();
2706 $arrow = true;
2707 $action_row = true;
2708
2709 if ($this->getTopCommands()) {
2710 if ($this->enable_command_for_all && $this->max_count <= self::getAllCommandLimit()) {
2711 $this->tpl->setCurrentBlock("tbl_top_cmd_select_all");
2712 $this->tpl->setVariable("TXT_SELECT_CMD_ALL", $lng->txt("all_objects"));
2713 $this->tpl->parseCurrentBlock();
2714 }
2715
2716 $this->tpl->setCurrentBlock("tbl_top_cmd_select");
2717 $sel = array();
2718 foreach ($this->multi as $mc) {
2719 $sel[$mc["cmd"]] = $mc["text"];
2720 }
2721 $this->tpl->setVariable(
2722 "SELECT_CMDS",
2723 ilUtil::formSelect("", "selected_cmd2", $sel, false, true)
2724 );
2725 $this->tpl->setVariable("TXT_EXECUTE", $lng->txt("execute"));
2726 $this->tpl->parseCurrentBlock();
2727 }
2728 } elseif (count($this->multi) == 1 && $this->dataExists()) {
2729 $this->tpl->setCurrentBlock("tbl_single_cmd");
2730 $sel = array();
2731 foreach ($this->multi as $mc) {
2732 $cmd = $mc['cmd'];
2733 $txt = $mc['text'];
2734 }
2735 $this->tpl->setVariable("TXT_SINGLE_CMD", $txt);
2736 $this->tpl->setVariable("SINGLE_CMD", $cmd);
2737 $this->tpl->parseCurrentBlock();
2738 $arrow = true;
2739 $action_row = true;
2740
2741 if ($this->getTopCommands()) {
2742 $this->tpl->setCurrentBlock("tbl_top_single_cmd");
2743 $sel = array();
2744 foreach ($this->multi as $mc) {
2745 $cmd = $mc['cmd'];
2746 $txt = $mc['text'];
2747 }
2748 $this->tpl->setVariable("TXT_SINGLE_CMD", $txt);
2749 $this->tpl->setVariable("SINGLE_CMD", $cmd);
2750 $this->tpl->parseCurrentBlock();
2751 }
2752 }
2753
2754 if ($arrow) {
2755 $this->tpl->setCurrentBlock("tbl_action_img_arrow");
2756 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.svg"));
2757 $this->tpl->setVariable("ALT_ARROW", $lng->txt("action"));
2758 $this->tpl->parseCurrentBlock();
2759
2760 if ($this->getTopCommands()) {
2761 $this->tpl->setCurrentBlock("tbl_top_action_img_arrow");
2762 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_upright.svg"));
2763 $this->tpl->setVariable("ALT_ARROW", $lng->txt("action"));
2764 $this->tpl->parseCurrentBlock();
2765 }
2766 }
2767
2768 if ($action_row) {
2769 $this->tpl->setCurrentBlock("tbl_action_row");
2770 $this->tpl->parseCurrentBlock();
2771 if ($this->getTopCommands()) {
2772 $this->tpl->setCurrentBlock("tbl_top_action_row");
2773 $this->tpl->parseCurrentBlock();
2774 }
2775 }
2776 }
2777
2783 public function setHeaderHTML($html)
2784 {
2785 $this->headerHTML = $html;
2786 }
2787
2794 public function storeProperty($type, $value)
2795 {
2796 global $DIC;
2797
2798 $ilUser = null;
2799 if (isset($DIC["ilUser"])) {
2800 $ilUser = $DIC["ilUser"];
2801 }
2802
2803 if (is_object($ilUser) && $this->getId() != "") {
2804 include_once("./Services/Table/classes/class.ilTablePropertiesStorage.php");
2805 $tab_prop = new ilTablePropertiesStorage();
2806
2807 $tab_prop->storeProperty($this->getId(), $ilUser->getId(), $type, $value);
2808 }
2809 }
2810
2817 public function loadProperty($type)
2818 {
2819 global $DIC;
2820
2821 $ilUser = null;
2822 if (isset($DIC["ilUser"])) {
2823 $ilUser = $DIC["ilUser"];
2824 }
2825
2826 if (is_object($ilUser) && $this->getId() != "") {
2827 include_once("./Services/Table/classes/class.ilTablePropertiesStorage.php");
2828 $tab_prop = new ilTablePropertiesStorage();
2829
2830 return $tab_prop->getProperty($this->getId(), $ilUser->getId(), $type);
2831 }
2832 return null;
2833 }
2834
2840 public function getCurrentState()
2841 {
2842 $this->determineOffsetAndOrder();
2843 $this->determineLimit();
2844 $this->determineSelectedColumns();
2845 $this->determineSelectedFilters();
2846
2847 // "filter" show/hide is not saved
2848
2849 $result = array();
2850 $result["order"] = $this->getOrderField();
2851 $result["direction"] = $this->getOrderDirection();
2852 $result["offset"] = $this->getOffset();
2853 $result["rows"] = $this->getLimit();
2854 $result["selfilters"] = $this->getSelectedFilters();
2855
2856 // #9514 - $this->getSelectedColumns() will omit deselected, leading to
2857 // confusion on restoring template
2858 $result["selfields"] = $this->selected_column;
2859
2860 // gather filter values
2861 if ($this->filters) {
2862 foreach ($this->filters as $item) {
2863 $result["filter_values"][$item->getFieldId()] = $this->getFilterValue($item);
2864 }
2865 }
2866 if ($this->optional_filters && $result["selfilters"]) {
2867 foreach ($this->optional_filters as $item) {
2868 if (in_array($item->getFieldId(), $result["selfilters"])) {
2869 $result["filter_values"][$item->getFieldId()] = $this->getFilterValue($item);
2870 }
2871 }
2872 }
2873
2874 return $result;
2875 }
2876
2883 protected function getFilterValue(ilFormPropertyGUI $a_item)
2884 {
2885 if (method_exists($a_item, "getChecked")) {
2886 return $a_item->getChecked();
2887 } elseif (method_exists($a_item, "getValue")) {
2888 return $a_item->getValue();
2889 } elseif (method_exists($a_item, "getDate")) {
2890 return $a_item->getDate()->get(IL_CAL_DATE);
2891 }
2892 }
2893
2900 protected function SetFilterValue(ilFormPropertyGUI $a_item, $a_value)
2901 {
2902 if (method_exists($a_item, "setChecked")) {
2903 $a_item->setChecked($a_value);
2904 } elseif (method_exists($a_item, "setValue")) {
2905 $a_item->setValue($a_value);
2906 } elseif (method_exists($a_item, "setDate")) {
2907 $a_item->setDate(new ilDate($a_value, IL_CAL_DATE));
2908 }
2909 $a_item->writeToSession();
2910 }
2911
2917 public function setContext($id)
2918 {
2919 if (trim($id)) {
2920 $this->context = $id;
2921 }
2922 }
2923
2929 public function getContext()
2930 {
2931 return $this->context;
2932 }
2933
2939 public function setShowRowsSelector($a_value)
2940 {
2941 $this->show_rows_selector = (bool) $a_value;
2942 }
2943
2949 public function getShowRowsSelector()
2950 {
2952 }
2953
2959 public function setShowTemplates($a_value)
2960 {
2961 $this->show_templates = (bool) $a_value;
2962 }
2963
2969 public function getShowTemplates()
2970 {
2971 return $this->show_templates;
2972 }
2973
2980 public function restoreTemplate($a_name)
2981 {
2982 global $DIC;
2983
2984 $ilUser = $DIC->user();
2985
2986 $a_name = ilUtil::stripSlashes($a_name);
2987
2988 if (trim($a_name) && $this->getContext() != "" && is_object($ilUser) && $ilUser->getId() != ANONYMOUS_USER_ID) {
2989 include_once("./Services/Table/classes/class.ilTableTemplatesStorage.php");
2990 $storage = new ilTableTemplatesStorage();
2991
2992 $data = $storage->load($this->getContext(), $ilUser->getId(), $a_name);
2993 if (is_array($data)) {
2994 foreach ($data as $property => $value) {
2995 $this->storeProperty($property, $value);
2996 }
2997 }
2998
2999 $data["filter_values"] = unserialize($data["filter_values"]);
3000 if ($data["filter_values"]) {
3001 $this->restore_filter_values = $data["filter_values"];
3002 }
3003
3004 $this->restore_filter = true;
3005
3006 return true;
3007 }
3008 return false;
3009 }
3010
3017 public function saveTemplate($a_name)
3018 {
3019 global $DIC;
3020
3021 $ilUser = $DIC->user();
3022
3023 $a_name = ilUtil::prepareFormOutput($a_name, true);
3024
3025 if (trim($a_name) && $this->getContext() != "" && is_object($ilUser) && $ilUser->getId() != ANONYMOUS_USER_ID) {
3026 include_once("./Services/Table/classes/class.ilTableTemplatesStorage.php");
3027 $storage = new ilTableTemplatesStorage();
3028
3029 $state = $this->getCurrentState();
3030 $state["filter_values"] = serialize($state["filter_values"]);
3031 $state["selfields"] = serialize($state["selfields"]);
3032 $state["selfilters"] = serialize($state["selfilters"]);
3033
3034 $storage->store($this->getContext(), $ilUser->getId(), $a_name, $state);
3035 return true;
3036 }
3037 return false;
3038 }
3039
3046 public function deleteTemplate($a_name)
3047 {
3048 global $DIC;
3049
3050 $ilUser = $DIC->user();
3051
3052 $a_name = ilUtil::prepareFormOutput($a_name, true);
3053
3054 if (trim($a_name) && $this->getContext() != "" && is_object($ilUser) && $ilUser->getId() != ANONYMOUS_USER_ID) {
3055 include_once("./Services/Table/classes/class.ilTableTemplatesStorage.php");
3056 $storage = new ilTableTemplatesStorage();
3057 $storage->delete($this->getContext(), $ilUser->getId(), $a_name);
3058 return true;
3059 }
3060 return false;
3061 }
3062
3066 public function getLimit()
3067 {
3068 if ($this->getExportMode() || $this->getPrintMode()) {
3069 return 9999;
3070 }
3071 return parent::getLimit();
3072 }
3073
3077 public function getOffset()
3078 {
3079 if ($this->getExportMode() || $this->getPrintMode()) {
3080 return 0;
3081 }
3082 return parent::getOffset();
3083 }
3084
3090 public function setExportFormats(array $formats)
3091 {
3092 $this->export_formats = array();
3093
3094 // #11339
3095 $valid = array(self::EXPORT_EXCEL => "tbl_export_excel",
3096 self::EXPORT_CSV => "tbl_export_csv");
3097
3098 foreach ($formats as $format) {
3099 if (array_key_exists($format, $valid)) {
3100 $this->export_formats[$format] = $valid[$format];
3101 }
3102 }
3103 }
3104
3109 public function setPrintMode($a_value = false)
3110 {
3111 $this->print_mode = (bool) $a_value;
3112 }
3113
3118 public function getPrintMode()
3119 {
3120 return $this->print_mode;
3121 }
3122
3128 public function getExportMode()
3129 {
3130 return $this->export_mode;
3131 }
3132
3138 public function exportData($format, $send = false)
3139 {
3140 if ($this->dataExists()) {
3141 // #9640: sort
3142 if (!$this->getExternalSorting() && $this->enabled["sort"]) {
3143 $this->determineOffsetAndOrder(true);
3144
3145 $this->row_data = ilUtil::sortArray(
3146 $this->row_data,
3147 $this->getOrderField(),
3148 $this->getOrderDirection(),
3149 $this->numericOrdering($this->getOrderField())
3150 );
3151 }
3152
3153 $filename = "export";
3154
3155 switch ($format) {
3156 case self::EXPORT_EXCEL:
3157 include_once "./Services/Excel/classes/class.ilExcel.php";
3158 $excel = new ilExcel();
3159 $excel->addSheet($this->title
3160 ? $this->title
3161 : $this->lng->txt("export"));
3162 $row = 1;
3163
3164 ob_start();
3165 $this->fillMetaExcel($excel, $row); // row must be increment in fillMetaExcel()! (optional method)
3166
3167 // #14813
3168 $pre = $row;
3169 $this->fillHeaderExcel($excel, $row); // row should NOT be incremented in fillHeaderExcel()! (required method)
3170 if ($pre == $row) {
3171 $row++;
3172 }
3173
3174 foreach ($this->row_data as $set) {
3175 $this->fillRowExcel($excel, $row, $set);
3176 $row++; // #14760
3177 }
3178 ob_end_clean();
3179
3180 if ($send) {
3181 $excel->sendToClient($filename);
3182 } else {
3183 $excel->writeToFile($filename);
3184 }
3185 break;
3186
3187 case self::EXPORT_CSV:
3188 include_once "./Services/Utilities/classes/class.ilCSVWriter.php";
3189 $csv = new ilCSVWriter();
3190 $csv->setSeparator(";");
3191
3192 ob_start();
3193 $this->fillMetaCSV($csv);
3194 $this->fillHeaderCSV($csv);
3195 foreach ($this->row_data as $set) {
3196 $this->fillRowCSV($csv, $set);
3197 }
3198 ob_end_clean();
3199
3200 if ($send) {
3201 $filename .= ".csv";
3202 header("Content-type: text/comma-separated-values");
3203 header("Content-Disposition: attachment; filename=\"" . $filename . "\"");
3204 header("Expires: 0");
3205 header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
3206 header("Pragma: public");
3207 echo $csv->getCSVString();
3208 } else {
3209 file_put_contents($filename, $csv->getCSVString());
3210 }
3211 break;
3212 }
3213
3214 if ($send) {
3215 exit();
3216 }
3217 }
3218 }
3219
3227 protected function fillMetaExcel(ilExcel $a_excel, &$a_row)
3228 {
3229 }
3230
3238 protected function fillHeaderExcel(ilExcel $a_excel, &$a_row)
3239 {
3240 $col = 0;
3241 foreach ($this->column as $column) {
3242 $title = strip_tags($column["text"]);
3243 if ($title) {
3244 $a_excel->setCell($a_row, $col++, $title);
3245 }
3246 }
3247 $a_excel->setBold("A" . $a_row . ":" . $a_excel->getColumnCoord($col - 1) . $a_row);
3248 }
3249
3258 protected function fillRowExcel(ilExcel $a_excel, &$a_row, $a_set)
3259 {
3260 $col = 0;
3261 foreach ($a_set as $value) {
3262 if (is_array($value)) {
3263 $value = implode(', ', $value);
3264 }
3265 $a_excel->setCell($a_row, $col++, $value);
3266 }
3267 }
3268
3275 protected function fillMetaCSV($a_csv)
3276 {
3277 }
3278
3285 protected function fillHeaderCSV($a_csv)
3286 {
3287 foreach ($this->column as $column) {
3288 $title = strip_tags($column["text"]);
3289 if ($title) {
3290 $a_csv->addColumn($title);
3291 }
3292 }
3293 $a_csv->addRow();
3294 }
3295
3303 protected function fillRowCSV($a_csv, $a_set)
3304 {
3305 foreach ($a_set as $key => $value) {
3306 if (is_array($value)) {
3307 $value = implode(', ', $value);
3308 }
3309 $a_csv->addColumn(strip_tags($value));
3310 }
3311 $a_csv->addRow();
3312 }
3313
3319 public function setEnableAllCommand($a_value)
3320 {
3321 $this->enable_command_for_all = (bool) $a_value;
3322 }
3323
3329 public static function getAllCommandLimit()
3330 {
3331 global $DIC;
3332
3333 $ilClientIniFile = $DIC["ilClientIniFile"];
3334
3335 $limit = $ilClientIniFile->readVariable("system", "TABLE_ACTION_ALL_LIMIT");
3336 if (!$limit) {
3338 }
3339
3340 return $limit;
3341 }
3342
3347 {
3348 $this->row_selector_label = $row_selector_label;
3349 return $this;
3350 }
3351
3355 public function getRowSelectorLabel()
3356 {
3358 }
3359
3365 public function setPreventDoubleSubmission($a_val)
3366 {
3367 $this->prevent_double_submission = $a_val;
3368 }
3369
3376 {
3378 }
3379
3380 public function setLimit($a_limit = 0, $a_default_limit = 0)
3381 {
3382 parent::setLimit($a_limit, $a_default_limit);
3383
3384 // #17077 - if limit is set "manually" to 9999, force rows selector off
3385 if ($a_limit == 9999 &&
3386 $this->limit_determined) {
3387 $this->rows_selector_off = true;
3388 }
3389 }
3390}
$result
if(!array_key_exists('stateid', $_REQUEST)) $state
Handle linkback() response from LinkedIn.
Definition: linkback.php:10
exit
Definition: backend.php:16
$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(ilTemplate $a_main_tpl=null)
Init YUI Connection module.
$key
Definition: croninfo.php:18
$formats
Definition: date.php:77
$i
Definition: disco.tpl.php:19
$valid
$txt
Definition: error.php:11
$html
Definition: example_001.php:87
if(!array_key_exists('StateId', $_REQUEST)) $id
global $ilCtrl
Definition: ilias.php:18
$format
Definition: metadata.php:141
$row
$type
$url
global $DIC
Definition: saml.php:7
$ilUser
Definition: imgupload.php:18
$start
Definition: bench.php:8
$rows
Definition: xhr_table.php:10