ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 protected $sel_buttons = [];
92 const FILTER_TEXT = 1;
93 const FILTER_SELECT = 2;
94 const FILTER_DATE = 3;
95 const FILTER_LANGUAGE = 4;
101
102 const EXPORT_EXCEL = 1;
103 const EXPORT_CSV = 2;
104
105 const ACTION_ALL_LIMIT = 1000;
106
107
115 public function __construct($a_parent_obj, $a_parent_cmd = "", $a_template_context = "")
116 {
117 global $DIC;
118
119 $this->lng = $DIC->language();
120 $this->ctrl = $DIC->ctrl();
121 $lng = $DIC->language();
122
123 parent::__construct(0, false);
124 $this->unique_id = md5(uniqid());
125 $this->parent_obj = $a_parent_obj;
126 $this->parent_cmd = $a_parent_cmd;
127 $this->buttons = array();
128 $this->header_commands = array();
129 $this->multi = array();
130 $this->hidden_inputs = array();
131 $this->formname = "table_" . $this->unique_id;
132 $this->tpl = new ilTemplate("tpl.table2.html", true, true, "Services/Table");
133
134 $lng->loadLanguageModule('tbl');
135
136 if (!$a_template_context) {
137 $a_template_context = $this->getId();
138 }
139 $this->setContext($a_template_context);
140
141 // activate export mode
142 if (isset($_GET[$this->prefix . "_xpt"])) {
143 $this->export_mode = (int) $_GET[$this->prefix . "_xpt"];
144 }
145
146 // template handling
147 if (isset($_GET[$this->prefix . "_tpl"])) {
148 $this->restoreTemplate($_GET[$this->prefix . "_tpl"]);
149 }
150
151 $this->determineLimit();
152 $this->setIsDataTable(true);
153 $this->setEnableNumInfo(true);
155 }
156
162 public function setOpenFormTag($a_val)
163 {
164 $this->open_form_tag = $a_val;
165 }
166
172 public function getOpenFormTag()
173 {
175 }
176
182 public function setCloseFormTag($a_val)
183 {
184 $this->close_form_tag = $a_val;
185 }
186
192 public function getCloseFormTag()
193 {
195 }
196
200 public function determineLimit()
201 {
202 global $DIC;
203
204 $ilUser = null;
205 if (isset($DIC["ilUser"])) {
206 $ilUser = $DIC["ilUser"];
207 }
208
209 if ($this->limit_determined) {
210 return;
211 }
212
213 $limit = 0;
214 if (isset($_GET[$this->prefix . "_trows"])) {
215 $this->storeProperty("rows", $_GET[$this->prefix . "_trows"]);
216 $limit = $_GET[$this->prefix . "_trows"];
217 $this->resetOffset();
218 }
219
220 if ($limit == 0) {
221 $rows = $this->loadProperty("rows");
222 if ($rows > 0) {
223 $limit = $rows;
224 } else {
225 if (is_object($ilUser)) {
226 $limit = $ilUser->getPref("hits_per_page");
227 } else {
228 $limit = 40;
229 }
230 }
231 }
232
233 $this->setLimit($limit);
234 $this->limit_determined = true;
235 }
236
242 public function getSelectableColumns()
243 {
244 return array();
245 }
246
250 public function determineSelectedColumns()
251 {
252 if ($this->columns_determined) {
253 return;
254 }
255
256 $old_sel = $this->loadProperty("selfields");
257
258 $stored = false;
259 if ($old_sel != "") {
260 $sel_fields =
261 @unserialize($old_sel);
262 $stored = true;
263 }
264 if (!is_array($sel_fields)) {
265 $stored = false;
266 $sel_fields = array();
267 }
268
269 $this->selected_columns = array();
270 $set = false;
271 foreach ($this->getSelectableColumns() as $k => $c) {
272 $this->selected_column[$k] = false;
273
274 $new_column = ($sel_fields[$k] === null);
275
276 if ($_POST["tblfsh" . $this->getId()]) {
277 $set = true;
278 if (is_array($_POST["tblfs" . $this->getId()]) && in_array($k, $_POST["tblfs" . $this->getId()])) {
279 $this->selected_column[$k] = true;
280 }
281 } elseif ($stored && !$new_column) { // take stored values
282 $this->selected_column[$k] = $sel_fields[$k];
283 } else { // take default values
284 if ($new_column) {
285 $set = true;
286 }
287 if ($c["default"]) {
288 $this->selected_column[$k] = true;
289 }
290 }
291 }
292
293 if ($old_sel != serialize($this->selected_column) && $set) {
294 $this->storeProperty("selfields", serialize($this->selected_column));
295 }
296
297 $this->columns_determined = true;
298 }
299
306 public function isColumnSelected($a_col)
307 {
308 return $this->selected_column[$a_col];
309 }
310
317 public function getSelectedColumns()
318 {
319 $scol = array();
320 foreach ($this->selected_column as $k => $v) {
321 if ($v) {
322 $scol[$k] = $k;
323 }
324 }
325 return $scol;
326 }
327
331 public function executeCommand()
332 {
334
335 $next_class = $ilCtrl->getNextClass($this);
336 $cmd = $ilCtrl->getCmd();
337
338 switch ($next_class) {
339 case 'ilformpropertydispatchgui':
340 include_once './Services/Form/classes/class.ilFormPropertyDispatchGUI.php';
341 $form_prop_dispatch = new ilFormPropertyDispatchGUI();
342 $this->initFilter();
343 $item = $this->getFilterItemByPostVar($_GET["postvar"]);
344 $form_prop_dispatch->setItem($item);
345 return $ilCtrl->forwardCommand($form_prop_dispatch);
346 break;
347
348 }
349 return false;
350 }
351
355 public function resetOffset($a_in_determination = false)
356 {
357 if (!$this->nav_determined && !$a_in_determination) {
359 }
360 $this->nav_value = $this->getOrderField() . ":" . $this->getOrderDirection() . ":0";
361 $_GET[$this->getNavParameter()] =
362 $_POST[$this->getNavParameter() . "1"] =
363 $this->nav_value;
364 //echo $this->nav_value;
365 $this->setOffset(0);
366 }
367
372 public function initFilter()
373 {
374 }
375
381 public function getParentObject()
382 {
383 return $this->parent_obj;
384 }
385
391 public function getParentCmd()
392 {
393 return $this->parent_cmd;
394 }
395
401 public function setTopAnchor($a_val)
402 {
403 $this->top_anchor = $a_val;
404 }
405
411 public function getTopAnchor()
412 {
413 return $this->top_anchor;
414 }
415
421 public function setNoEntriesText($a_text)
422 {
423 $this->noentriestext = $a_text;
424 }
425
431 public function getNoEntriesText()
432 {
433 return $this->noentriestext;
434 }
435
441 public function setIsDataTable($a_val)
442 {
443 $this->datatable = $a_val;
444 }
445
451 public function getIsDataTable()
452 {
453 return $this->datatable;
454 }
455
461 public function setEnableTitle($a_enabletitle)
462 {
463 $this->enabled["title"] = $a_enabletitle;
464 }
465
471 public function getEnableTitle()
472 {
473 return $this->enabled["title"];
474 }
475
481 public function setEnableHeader($a_enableheader)
482 {
483 $this->enabled["header"] = $a_enableheader;
484 }
485
491 public function getEnableHeader()
492 {
493 return $this->enabled["header"];
494 }
495
501 public function setEnableNumInfo($a_val)
502 {
503 $this->num_info = $a_val;
504 }
505
511 public function getEnableNumInfo()
512 {
513 return $this->num_info;
514 }
515
519 final public function setTitle($a_title, $a_icon = 0, $a_icon_alt = 0)
520 {
521 parent::setTitle($a_title, $a_icon, $a_icon_alt);
522 }
523
529 public function setDescription($a_val)
530 {
531 $this->description = $a_val;
532 }
533
539 public function getDescription()
540 {
541 return $this->description;
542 }
543
549 public function setOrderField($a_order_field)
550 {
551 $this->order_field = $a_order_field;
552 }
553
554 public function getOrderField()
555 {
556 return $this->order_field;
557 }
558
559 final public function setData($a_data)
560 {
561 // check column names against given data (to ensure proper sorting)
562 if (defined('DEVMODE') && DEVMODE &&
563 $this->enabled["header"] && $this->enabled["sort"] &&
564 $this->columns_determined && is_array($this->column) &&
565 is_array($a_data) && sizeof($a_data) && !$this->getExternalSorting()) {
566 $check = $a_data;
567 $check = array_keys(array_shift($check));
568 foreach ($this->column as $col) {
569 if ($col["sort_field"] && !in_array($col["sort_field"], $check)) {
570 $invalid[] = $col["sort_field"];
571 }
572 }
573
574 // this triggers an error, if some columns are not set for some rows
575 // which may just be a representation of "null" values, e.g.
576 // ilAdvancedMDValues:queryForRecords works that way.
577/* if(sizeof($invalid))
578 {
579 trigger_error("The following columns are defined as sortable but".
580 " cannot be found in the given data: ".implode(", ", $invalid).
581 ". Sorting will not work properly.", E_USER_WARNING);
582 }*/
583 }
584
585 $this->row_data = $a_data;
586 if (!is_array($this->row_data)) {
587 $this->row_data = [];
588 }
589 }
590
591 final public function getData()
592 {
593 return $this->row_data;
594 }
595
596 final public function dataExists()
597 {
598 if (is_array($this->row_data)) {
599 if (count($this->row_data) > 0) {
600 return true;
601 }
602 }
603 return false;
604 }
605
606 final public function setPrefix($a_prefix)
607 {
608 $this->prefix = $a_prefix;
609 }
610
611 final public function getPrefix()
612 {
613 return $this->prefix;
614 }
615
620 final public function addFilterItem($a_input_item, $a_optional = false)
621 {
622 $a_input_item->setParent($this);
623 if (!$a_optional) {
624 $this->filters[] = $a_input_item;
625 } else {
626 $this->optional_filters[] = $a_input_item;
627 }
628
629 // restore filter values (from stored view)
630 if ($this->restore_filter) {
631 if (array_key_exists($a_input_item->getFieldId(), $this->restore_filter_values)) {
632 $this->setFilterValue($a_input_item, $this->restore_filter_values[$a_input_item->getFieldId()]);
633 } else {
634 $this->setFilterValue($a_input_item, null); // #14949
635 }
636 }
637 }
638
648 public function addFilterItemByMetaType($id, $type = self::FILTER_TEXT, $a_optional = false, $caption = null)
649 {
650 global $DIC;
651
652 $lng = $DIC->language(); // constructor may not be called here, if initFilter is being called in subclasses before parent::__construct
653
654 if (!$caption) {
655 $caption = $lng->txt($id);
656 }
657
658 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
659
660 switch ($type) {
662 $item = new ilCheckboxInputGUI($caption, $id);
663 break;
664
666 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
667 $item = new ilSelectInputGUI($caption, $id);
668 break;
669
671 include_once("./Services/Form/classes/class.ilDateTimeInputGUI.php");
672 $item = new ilDateTimeInputGUI($caption, $id);
673 break;
674
676 include_once("./Services/Form/classes/class.ilTextInputGUI.php");
677 $item = new ilTextInputGUI($caption, $id);
678 $item->setMaxLength(64);
679 $item->setSize(20);
680 // $item->setSubmitFormOnEnter(true);
681 break;
682
684 $lng->loadLanguageModule("meta");
685 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
686 $item = new ilSelectInputGUI($caption, $id);
687 $options = array("" => $lng->txt("trac_all"));
688 foreach ($lng->getInstalledLanguages() as $lang_key) {
689 $options[$lang_key] = $lng->txt("meta_l_" . $lang_key);
690 }
691 $item->setOptions($options);
692 break;
693
695 include_once("./Services/Form/classes/class.ilCombinationInputGUI.php");
696 include_once("./Services/Form/classes/class.ilNumberInputGUI.php");
697 $item = new ilCombinationInputGUI($caption, $id);
698 $combi_item = new ilNumberInputGUI("", $id . "_from");
699 $item->addCombinationItem("from", $combi_item, $lng->txt("from"));
700 $combi_item = new ilNumberInputGUI("", $id . "_to");
701 $item->addCombinationItem("to", $combi_item, $lng->txt("to"));
702 $item->setComparisonMode(ilCombinationInputGUI::COMPARISON_ASCENDING);
703 $item->setMaxLength(7);
704 $item->setSize(20);
705 break;
706
708 include_once("./Services/Form/classes/class.ilCombinationInputGUI.php");
709 include_once("./Services/Form/classes/class.ilDateTimeInputGUI.php");
710 $item = new ilCombinationInputGUI($caption, $id);
711 $combi_item = new ilDateTimeInputGUI("", $id . "_from");
712 $item->addCombinationItem("from", $combi_item, $lng->txt("from"));
713 $combi_item = new ilDateTimeInputGUI("", $id . "_to");
714 $item->addCombinationItem("to", $combi_item, $lng->txt("to"));
715 $item->setComparisonMode(ilCombinationInputGUI::COMPARISON_ASCENDING);
716 break;
717
719 include_once("./Services/Form/classes/class.ilCombinationInputGUI.php");
720 include_once("./Services/Form/classes/class.ilDateTimeInputGUI.php");
721 $item = new ilCombinationInputGUI($caption, $id);
722 $combi_item = new ilDateTimeInputGUI("", $id . "_from");
723 $combi_item->setShowTime(true);
724 $item->addCombinationItem("from", $combi_item, $lng->txt("from"));
725 $combi_item = new ilDateTimeInputGUI("", $id . "_to");
726 $combi_item->setShowTime(true);
727 $item->addCombinationItem("to", $combi_item, $lng->txt("to"));
728 $item->setComparisonMode(ilCombinationInputGUI::COMPARISON_ASCENDING);
729 break;
730
732 $lng->loadLanguageModule("form");
733 include_once("./Services/Form/classes/class.ilCombinationInputGUI.php");
734 include_once("./Services/Form/classes/class.ilDurationInputGUI.php");
735 $item = new ilCombinationInputGUI($caption, $id);
736 $combi_item = new ilDurationInputGUI("", $id . "_from");
737 $combi_item->setShowMonths(false);
738 $combi_item->setShowDays(true);
739 $combi_item->setShowSeconds(true);
740 $item->addCombinationItem("from", $combi_item, $lng->txt("from"));
741 $combi_item = new ilDurationInputGUI("", $id . "_to");
742 $combi_item->setShowMonths(false);
743 $combi_item->setShowDays(true);
744 $combi_item->setShowSeconds(true);
745 $item->addCombinationItem("to", $combi_item, $lng->txt("to"));
746 $item->setComparisonMode(ilCombinationInputGUI::COMPARISON_ASCENDING);
747 break;
748
749 default:
750 return false;
751 }
752
753 $this->addFilterItem($item, $a_optional);
754 $item->readFromSession();
755 return $item;
756 }
757
761 final public function getFilterItems($a_optionals = false)
762 {
763 if (!$a_optionals) {
764 return $this->filters;
765 }
767 }
768
769 final public function getFilterItemByPostVar($a_post_var)
770 {
771 foreach ($this->getFilterItems() as $item) {
772 if ($item->getPostVar() == $a_post_var) {
773 return $item;
774 }
775 }
776 foreach ($this->getFilterItems(true) as $item) {
777 if ($item->getPostVar() == $a_post_var) {
778 return $item;
779 }
780 }
781 return false;
782 }
783
789 public function setFilterCols($a_val)
790 {
791 $this->filter_cols = $a_val;
792 }
793
799 public function getFilterCols()
800 {
801 return $this->filter_cols;
802 }
803
809 public function setDisableFilterHiding($a_val = true)
810 {
811 $this->disable_filter_hiding = $a_val;
812 }
813
819 public function getDisableFilterHiding()
820 {
822 }
823
830 public function isFilterSelected($a_col)
831 {
832 return $this->selected_filter[$a_col];
833 }
834
841 public function getSelectedFilters()
842 {
843 $sfil = array();
844 foreach ($this->selected_filter as $k => $v) {
845 if ($v) {
846 $sfil[$k] = $k;
847 }
848 }
849 return $sfil;
850 }
851
858 public function determineSelectedFilters()
859 {
860 if ($this->filters_determined) {
861 return;
862 }
863
864 $old_sel = $this->loadProperty("selfilters");
865 $stored = false;
866 if ($old_sel != "") {
867 $sel_filters =
868 @unserialize($old_sel);
869 $stored = true;
870 }
871 if (!is_array($sel_filters)) {
872 $stored = false;
873 $sel_filters = array();
874 }
875
876 $this->selected_filter = array();
877 $set = false;
878 foreach ($this->getFilterItems(true) as $item) {
879 $k = $item->getPostVar();
880
881 $this->selected_filter[$k] = false;
882
883 if ($_POST["tblfsf" . $this->getId()]) {
884 $set = true;
885 if (is_array($_POST["tblff" . $this->getId()]) && in_array($k, $_POST["tblff" . $this->getId()])) {
886 $this->selected_filter[$k] = true;
887 } else {
888 $item->setValue(null);
889 $item->writeToSession();
890 }
891 } elseif ($stored) { // take stored values
892 $this->selected_filter[$k] = $sel_filters[$k];
893 }
894 }
895
896 if ($old_sel != serialize($this->selected_filter) && $set) {
897 $this->storeProperty("selfilters", serialize($this->selected_filter));
898 }
899
900 $this->filters_determined = true;
901 }
902
906 public function setCustomPreviousNext($a_prev_link, $a_next_link)
907 {
908 $this->custom_prev_next = true;
909 $this->custom_prev = $a_prev_link;
910 $this->custom_next = $a_next_link;
911 }
912
919 final public function setFormAction($a_form_action, $a_multipart = false)
920 {
921 $this->form_action = $a_form_action;
922 $this->form_multipart = (bool) $a_multipart;
923 }
924
930 final public function getFormAction()
931 {
932 return $this->form_action;
933 }
934
940 public function setFormName($a_formname = "")
941 {
942 $this->formname = $a_formname;
943 }
944
950 public function getFormName()
951 {
952 return $this->formname;
953 }
954
960 public function setId($a_val)
961 {
962 $this->id = $a_val;
963 if ($this->getPrefix() == "") {
964 $this->setPrefix($a_val);
965 }
966 }
967
973 public function getId()
974 {
975 return $this->id;
976 }
977
983 public function setDisplayAsBlock($a_val)
984 {
985 $this->display_as_block = $a_val;
986 }
987
993 public function getDisplayAsBlock()
994 {
995 return $this->display_as_block;
996 }
997
1003 public function getSelectAllCheckbox()
1004 {
1006 }
1007
1013 public function setSelectAllCheckbox($a_select_all_checkbox)
1014 {
1015 $this->select_all_checkbox = $a_select_all_checkbox;
1016 }
1017
1023 public function setExternalSorting($a_val)
1024 {
1025 $this->ext_sort = $a_val;
1026 }
1027
1033 public function getExternalSorting()
1034 {
1035 return $this->ext_sort;
1036 }
1037
1044 public function setFilterCommand($a_val, $a_caption = null)
1045 {
1046 $this->filter_cmd = $a_val;
1047 $this->filter_cmd_txt = $a_caption;
1048 }
1049
1055 public function getFilterCommand()
1056 {
1057 return $this->filter_cmd;
1058 }
1059
1066 public function setResetCommand($a_val, $a_caption = null)
1067 {
1068 $this->reset_cmd = $a_val;
1069 $this->reset_cmd_txt = $a_caption;
1070 }
1071
1077 public function getResetCommand()
1078 {
1079 return $this->reset_cmd;
1080 }
1081
1087 public function setExternalSegmentation($a_val)
1088 {
1089 $this->ext_seg = $a_val;
1090 }
1091
1097 public function getExternalSegmentation()
1098 {
1099 return $this->ext_seg;
1100 }
1101
1108 final public function setRowTemplate($a_template, $a_template_dir = "")
1109 {
1110 $this->row_template = $a_template;
1111 $this->row_template_dir = $a_template_dir;
1112 }
1113
1119 public function setDefaultOrderField($a_defaultorderfield)
1120 {
1121 $this->defaultorderfield = $a_defaultorderfield;
1122 }
1123
1129 public function getDefaultOrderField()
1130 {
1131 return $this->defaultorderfield;
1132 }
1133
1139 public function setDefaultOrderDirection($a_defaultorderdirection)
1140 {
1141 $this->defaultorderdirection = $a_defaultorderdirection;
1142 }
1143
1150 {
1151 return $this->defaultorderdirection;
1152 }
1153
1158 public function setDefaultFilterVisiblity($a_status)
1159 {
1160 $this->default_filter_visibility = $a_status;
1161 }
1162
1168 {
1170 }
1171
1172 /*
1173 * Removes all command buttons from the table
1174 *
1175 * @access public
1176 */
1177 public function clearCommandButtons()
1178 {
1179 $this->buttons = array();
1180 }
1181
1188 public function addCommandButton($a_cmd, $a_text, $a_onclick = '', $a_id = "", $a_class = null)
1189 {
1190 $this->buttons[] = array("cmd" => $a_cmd, "text" => $a_text, 'onclick' => $a_onclick,
1191 "id" => $a_id, "class" => $a_class);
1192 }
1193
1199 public function addCommandButtonInstance(ilButtonBase $a_button)
1200 {
1201 $this->buttons[] = $a_button;
1202 }
1203
1214 public function addSelectionButton($a_sel_var, $a_options, $a_cmd, $a_text, $a_default_selection = '')
1215 {
1216 echo "ilTabl2GUI->addSelectionButton() has been deprecated with 4.2. Please try to move the drop-down to ilToolbarGUI.";
1217 // $this->sel_buttons[] = array("sel_var" => $a_sel_var, "options" => $a_options, "selected" => $a_default_selection, "cmd" => $a_cmd, "text" => $a_text);
1218 }
1219
1229 public function addMultiItemSelectionButton($a_sel_var, $a_options, $a_cmd, $a_text, $a_default_selection = '')
1230 {
1231 $this->mi_sel_buttons[] = array("sel_var" => $a_sel_var, "options" => $a_options, "selected" => $a_default_selection, "cmd" => $a_cmd, "text" => $a_text);
1232 $this->addHiddenInput("cmd_sv[" . $a_cmd . "]", $a_sel_var);
1233 }
1234
1235
1236
1243 public function setCloseCommand($a_link)
1244 {
1245 $this->close_command = $a_link;
1246 }
1247
1254 public function addMultiCommand($a_cmd, $a_text)
1255 {
1256 $this->multi[] = array("cmd" => $a_cmd, "text" => $a_text);
1257 }
1258
1265 public function addHiddenInput($a_name, $a_value)
1266 {
1267 $this->hidden_inputs[] = array("name" => $a_name, "value" => $a_value);
1268 }
1269
1276 public function addHeaderCommand($a_href, $a_text, $a_target = "", $a_img = "")
1277 {
1278 $this->header_commands[] = array("href" => $a_href, "text" => $a_text,
1279 "target" => $a_target, "img" => $a_img);
1280 }
1281
1287 public function setTopCommands($a_val)
1288 {
1289 $this->top_commands = $a_val;
1290 }
1291
1297 public function getTopCommands()
1298 {
1299 return $this->top_commands;
1300 }
1301
1309 final public function addColumn(
1310 $a_text,
1311 $a_sort_field = "",
1312 $a_width = "",
1313 $a_is_checkbox_action_column = false,
1314 $a_class = "",
1315 $a_tooltip = "",
1316 $a_tooltip_with_html = false
1317 ) {
1318 $this->column[] = array(
1319 "text" => $a_text,
1320 "sort_field" => $a_sort_field,
1321 "width" => $a_width,
1322 "is_checkbox_action_column" => $a_is_checkbox_action_column,
1323 "class" => $a_class,
1324 "tooltip" => $a_tooltip,
1325 "tooltip_html" => (bool) $a_tooltip_with_html
1326 );
1327 if ($a_sort_field != "") {
1328 $this->sortable_fields[] = $a_sort_field;
1329 }
1330 $this->column_count = count($this->column);
1331 }
1332
1333
1334 final public function getNavParameter()
1335 {
1336 return $this->prefix . "_table_nav";
1337 }
1338
1339 public function setOrderLink($sort_field, $order_dir)
1340 {
1341 global $DIC;
1342
1343 $ilUser = $DIC->user();
1344
1346
1347 $hash = "";
1348 if (is_object($ilUser) && $ilUser->getPref("screen_reader_optimization")) {
1349 $hash = "#" . $this->getTopAnchor();
1350 }
1351
1352 $old = $_GET[$this->getNavParameter()];
1353
1354 // set order link
1355 $ilCtrl->setParameter(
1356 $this->parent_obj,
1357 $this->getNavParameter(),
1358 $sort_field . ":" . $order_dir . ":" . $this->offset
1359 );
1360 $this->tpl->setVariable(
1361 "TBL_ORDER_LINK",
1362 $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd) . $hash
1363 );
1364
1365 // set old value of nav variable
1366 $ilCtrl->setParameter(
1367 $this->parent_obj,
1368 $this->getNavParameter(),
1369 $old
1370 );
1371 }
1372
1373 public function fillHeader()
1374 {
1375 $lng = $this->lng;
1376
1377 $allcolumnswithwidth = true;
1378 foreach ((array) $this->column as $idx => $column) {
1379 if (!strlen($column["width"])) {
1380 $allcolumnswithwidth = false;
1381 } elseif ($column["width"] == "1") {
1382 // IE does not like 1 but seems to work with 1%
1383 $this->column[$idx]["width"] = "1%";
1384 }
1385 }
1386 if ($allcolumnswithwidth) {
1387 foreach ((array) $this->column as $column) {
1388 $this->tpl->setCurrentBlock("tbl_colgroup_column");
1389 $this->tpl->setVariable("COLGROUP_COLUMN_WIDTH", $column["width"]);
1390 $this->tpl->parseCurrentBlock();
1391 }
1392 }
1393 $ccnt = 0;
1394 foreach ((array) $this->column as $column) {
1395 $ccnt++;
1396 //tooltip
1397 if ($column["tooltip"] != "") {
1398 include_once("./Services/UIComponent/Tooltip/classes/class.ilTooltipGUI.php");
1400 "thc_" . $this->getId() . "_" . $ccnt,
1401 $column["tooltip"],
1402 "",
1403 "bottom center",
1404 "top center",
1405 !$column["tooltip_html"]
1406 );
1407 }
1408 if (!$this->enabled["sort"] || $column["sort_field"] == "" || $column["is_checkbox_action_column"]) {
1409 $this->tpl->setCurrentBlock("tbl_header_no_link");
1410 if ($column["width"] != "") {
1411 $this->tpl->setVariable("TBL_COLUMN_WIDTH_NO_LINK", " width=\"" . $column["width"] . "\"");
1412 }
1413 if ($column["class"] != "") {
1414 $this->tpl->setVariable("TBL_COLUMN_CLASS_NO_LINK", " class=\"" . $column["class"] . "\"");
1415 }
1416 if (!$column["is_checkbox_action_column"]) {
1417 $this->tpl->setVariable(
1418 "TBL_HEADER_CELL_NO_LINK",
1419 $column["text"]
1420 );
1421 } else {
1422 $this->tpl->setVariable(
1423 "TBL_HEADER_CELL_NO_LINK",
1424 ilUtil::img(ilUtil::getImagePath("spacer.png"), $lng->txt("action"))
1425 );
1426 }
1427 $this->tpl->setVariable("HEAD_CELL_NL_ID", "thc_" . $this->getId() . "_" . $ccnt);
1428 if ($column["class"] != "") {
1429 $this->tpl->setVariable("TBL_HEADER_CLASS", " " . $column["class"]);
1430 }
1431 $this->tpl->parseCurrentBlock();
1432 $this->tpl->touchBlock("tbl_header_th");
1433 continue;
1434 }
1435 if (($column["sort_field"] == $this->order_field) && ($this->order_direction != "")) {
1436 $this->tpl->setCurrentBlock("tbl_order_image");
1437 if ($this->order_direction == "asc") {
1438 $this->tpl->setVariable("ORDER_CLASS", "glyphicon glyphicon-arrow-up");
1439 } else {
1440 $this->tpl->setVariable("ORDER_CLASS", "glyphicon glyphicon-arrow-down");
1441 }
1442 $this->tpl->setVariable("IMG_ORDER_ALT", $this->lng->txt("change_sort_direction"));
1443 $this->tpl->parseCurrentBlock();
1444 }
1445
1446 $this->tpl->setCurrentBlock("tbl_header_cell");
1447 $this->tpl->setVariable("TBL_HEADER_CELL", $column["text"]);
1448 $this->tpl->setVariable("HEAD_CELL_ID", "thc_" . $this->getId() . "_" . $ccnt);
1449
1450 // only set width if a value is given for that column
1451 if ($column["width"] != "") {
1452 $this->tpl->setVariable("TBL_COLUMN_WIDTH", " width=\"" . $column["width"] . "\"");
1453 }
1454 if ($column["class"] != "") {
1455 $this->tpl->setVariable("TBL_COLUMN_CLASS", " class=\"" . $column["class"] . "\"");
1456 }
1457
1458 $lng_sort_column = $this->lng->txt("sort_by_this_column");
1459 $this->tpl->setVariable("TBL_ORDER_ALT", $lng_sort_column);
1460
1461 $order_dir = "asc";
1462
1463 if ($column["sort_field"] == $this->order_field) {
1464 $order_dir = $this->sort_order;
1465
1466 $lng_change_sort = $this->lng->txt("change_sort_direction");
1467 $this->tpl->setVariable("TBL_ORDER_ALT", $lng_change_sort);
1468 }
1469
1470 if ($column["class"] != "") {
1471 $this->tpl->setVariable("TBL_HEADER_CLASS", " " . $column["class"]);
1472 }
1473 $this->setOrderLink($column["sort_field"], $order_dir);
1474 $this->tpl->parseCurrentBlock();
1475 $this->tpl->touchBlock("tbl_header_th");
1476 }
1477
1478 $this->tpl->setCurrentBlock("tbl_header");
1479 $this->tpl->parseCurrentBlock();
1480 }
1481
1485 protected function prepareOutput()
1486 {
1487 }
1488
1489
1493 public function determineOffsetAndOrder($a_omit_offset = false)
1494 {
1495 global $DIC;
1496
1497 $ilUser = null;
1498 if (isset($DIC["ilUser"])) {
1499 $ilUser = $DIC["ilUser"];
1500 }
1501
1502 if ($this->nav_determined) {
1503 return true;
1504 }
1505
1506 if ($_POST[$this->getNavParameter() . "1"] != "") {
1507 if ($_POST[$this->getNavParameter() . "1"] != $_POST[$this->getNavParameter()]) {
1508 $this->nav_value = $_POST[$this->getNavParameter() . "1"];
1509 } elseif ($_POST[$this->getNavParameter() . "2"] != $_POST[$this->getNavParameter()]) {
1510 $this->nav_value = $_POST[$this->getNavParameter() . "2"];
1511 }
1512 } elseif ($_GET[$this->getNavParameter()]) {
1513 $this->nav_value = $_GET[$this->getNavParameter()];
1514 } elseif ($_SESSION[$this->getNavParameter()] != "") {
1515 $this->nav_value = $_SESSION[$this->getNavParameter()];
1516 }
1517
1518 if ($this->nav_value == "" && $this->getId() != "" && $ilUser->getId() != ANONYMOUS_USER_ID) {
1519 $order = $this->loadProperty("order");
1520 if (in_array($order, $this->sortable_fields)) {
1521 $direction = $this->loadProperty("direction");
1522 } else {
1523 $direction = $this->getDefaultOrderDirection();
1524 }
1525 // get order and direction from db
1526 $this->nav_value =
1527 $order . ":" .
1528 $direction . ":" .
1529 $this->loadProperty("offset");
1530 }
1531 $nav = explode(":", $this->nav_value);
1532
1533 // $nav[0] is order by
1534 $this->setOrderField(($nav[0] != "") ? $nav[0] : $this->getDefaultOrderField());
1535 $this->setOrderDirection(($nav[1] != "") ? $nav[1] : $this->getDefaultOrderDirection());
1536
1537 if (!$a_omit_offset) {
1538 // #8904: offset must be discarded when no limit is given
1539 if (!$this->getExternalSegmentation() && $this->limit_determined && $this->limit == 9999) {
1540 $this->resetOffset(true);
1541 } elseif (!$this->getExternalSegmentation() && $nav[2] >= $this->max_count) {
1542 $this->resetOffset(true);
1543 } else {
1544 $this->setOffset($nav[2]);
1545 }
1546 }
1547
1548 if (!$a_omit_offset) {
1549 $this->nav_determined = true;
1550 }
1551 }
1552
1553 public function storeNavParameter()
1554 {
1555 if ($this->getOrderField() != "") {
1556 $this->storeProperty("order", $this->getOrderField());
1557 }
1558 if ($this->getOrderDirection() != "") {
1559 $this->storeProperty("direction", $this->getOrderDirection());
1560 }
1561 //echo "-".$this->getOffset()."-";
1562 if ($this->getOffset() !== "") {
1563 $this->storeProperty("offset", $this->getOffset());
1564 }
1565 }
1566
1567
1571 public function getHTML()
1572 {
1573 global $DIC;
1574
1575 $ilUser = null;
1576 if (isset($DIC["ilUser"])) {
1577 $ilUser = $DIC["ilUser"];
1578 }
1579
1580 $lng = $this->lng;
1582
1583
1584 if ($this->getExportMode()) {
1585 $this->exportData($this->getExportMode(), true);
1586 }
1587
1588 $this->prepareOutput();
1589
1590 if (is_object($ilCtrl) && $this->getId() == "") {
1591 $ilCtrl->saveParameter($this->getParentObject(), $this->getNavParameter());
1592 }
1593
1594 if (!$this->getPrintMode()) {
1595 // set form action
1596 if ($this->form_action != "" && $this->getOpenFormTag()) {
1597 $hash = "";
1598 if (is_object($ilUser) && $ilUser->getPref("screen_reader_optimization")) {
1599 $hash = "#" . $this->getTopAnchor();
1600 }
1601
1602 if ((bool) $this->form_multipart) {
1603 $this->tpl->touchBlock("form_multipart_bl");
1604 }
1605
1606 if ($this->getPreventDoubleSubmission()) {
1607 $this->tpl->touchBlock("pdfs");
1608 }
1609
1610 $this->tpl->setCurrentBlock("tbl_form_header");
1611 $this->tpl->setVariable("FORMACTION", $this->getFormAction() . $hash);
1612 $this->tpl->setVariable("FORMNAME", $this->getFormName());
1613 $this->tpl->parseCurrentBlock();
1614 }
1615
1616 if ($this->form_action != "" && $this->getCloseFormTag()) {
1617 $this->tpl->touchBlock("tbl_form_footer");
1618 }
1619 }
1620
1621 if (!$this->enabled['content']) {
1622 return $this->render();
1623 }
1624
1625 if (!$this->getExternalSegmentation()) {
1626 $this->setMaxCount(count($this->row_data));
1627 }
1628
1629 $this->determineOffsetAndOrder();
1630
1631 $this->setFooter("tblfooter", $this->lng->txt("previous"), $this->lng->txt("next"));
1632
1633 $data = $this->getData();
1634 if ($this->dataExists()) {
1635 // sort
1636 if (!$this->getExternalSorting() && $this->enabled["sort"]) {
1638 $data,
1639 $this->getOrderField(),
1640 $this->getOrderDirection(),
1641 $this->numericOrdering($this->getOrderField())
1642 );
1643 }
1644
1645 // slice
1646 if (!$this->getExternalSegmentation()) {
1647 $data = array_slice($data, $this->getOffset(), $this->getLimit());
1648 }
1649 }
1650
1651 // fill rows
1652 if ($this->dataExists()) {
1653 if ($this->getPrintMode()) {
1655 }
1656
1657 $this->tpl->addBlockFile(
1658 "TBL_CONTENT",
1659 "tbl_content",
1660 $this->row_template,
1661 $this->row_template_dir
1662 );
1663
1664 foreach ($data as $set) {
1665 $this->tpl->setCurrentBlock("tbl_content");
1666 $this->css_row = ($this->css_row != "tblrow1")
1667 ? "tblrow1"
1668 : "tblrow2";
1669 $this->tpl->setVariable("CSS_ROW", $this->css_row);
1670
1671 $this->fillRow($set);
1672 $this->tpl->setCurrentBlock("tbl_content");
1673 $this->tpl->parseCurrentBlock();
1674 }
1675 } else {
1676 // add standard no items text (please tell me, if it messes something up, alex, 29.8.2008)
1677 $no_items_text = (trim($this->getNoEntriesText()) != '')
1678 ? $this->getNoEntriesText()
1679 : $lng->txt("no_items");
1680
1681 $this->css_row = ($this->css_row != "tblrow1")
1682 ? "tblrow1"
1683 : "tblrow2";
1684
1685 $this->tpl->setCurrentBlock("tbl_no_entries");
1686 $this->tpl->setVariable('TBL_NO_ENTRY_CSS_ROW', $this->css_row);
1687 $this->tpl->setVariable('TBL_NO_ENTRY_COLUMN_COUNT', $this->column_count);
1688 $this->tpl->setVariable('TBL_NO_ENTRY_TEXT', trim($no_items_text));
1689 $this->tpl->parseCurrentBlock();
1690 }
1691
1692
1693 if (!$this->getPrintMode()) {
1694 $this->fillFooter();
1695
1696 $this->fillHiddenRow();
1697
1698 $this->fillActionRow();
1699
1700 $this->storeNavParameter();
1701 }
1702
1703 return $this->render();
1704 }
1705
1711 public function numericOrdering($a_field)
1712 {
1713 return false;
1714 }
1715
1720 public function render()
1721 {
1722 $lng = $this->lng;
1724
1725 $this->tpl->setVariable("CSS_TABLE", $this->getStyle("table"));
1726 $this->tpl->setVariable("DATA_TABLE", (int) $this->getIsDataTable());
1727 if ($this->getId() != "") {
1728 $this->tpl->setVariable("ID", 'id="' . $this->getId() . '"');
1729 }
1730
1731 // description
1732 if ($this->getDescription() != "") {
1733 $this->tpl->setCurrentBlock("tbl_header_description");
1734 $this->tpl->setVariable("TBL_DESCRIPTION", $this->getDescription());
1735 $this->tpl->parseCurrentBlock();
1736 }
1737
1738 if (!$this->getPrintMode()) {
1739 $this->renderFilter();
1740 }
1741
1742 if ($this->getDisplayAsBlock()) {
1743 $this->tpl->touchBlock("outer_start_1");
1744 $this->tpl->touchBlock("outer_end_1");
1745 } else {
1746 $this->tpl->touchBlock("outer_start_2");
1747 $this->tpl->touchBlock("outer_end_2");
1748 }
1749
1750 // table title and icon
1751 if ($this->enabled["title"] && ($this->title != ""
1752 || $this->icon != "" || count($this->header_commands) > 0 ||
1753 $this->headerHTML != "" || $this->close_command != "")) {
1754 if ($this->enabled["icon"]) {
1755 $this->tpl->setCurrentBlock("tbl_header_title_icon");
1756 $this->tpl->setVariable("TBL_TITLE_IMG", ilUtil::getImagePath($this->icon));
1757 $this->tpl->setVariable("TBL_TITLE_IMG_ALT", $this->icon_alt);
1758 $this->tpl->parseCurrentBlock();
1759 }
1760
1761 if (!$this->getPrintMode()) {
1762 foreach ($this->header_commands as $command) {
1763 if ($command["img"] != "") {
1764 $this->tpl->setCurrentBlock("tbl_header_img_link");
1765 if ($command["target"] != "") {
1766 $this->tpl->setVariable(
1767 "TARGET_IMG_LINK",
1768 'target="' . $command["target"] . '"'
1769 );
1770 }
1771 $this->tpl->setVariable("ALT_IMG_LINK", $command["text"]);
1772 $this->tpl->setVariable("HREF_IMG_LINK", $command["href"]);
1773 $this->tpl->setVariable(
1774 "SRC_IMG_LINK",
1775 $command["img"]
1776 );
1777 $this->tpl->parseCurrentBlock();
1778 } else {
1779 $this->tpl->setCurrentBlock("head_cmd");
1780 $this->tpl->setVariable("TXT_HEAD_CMD", $command["text"]);
1781 $this->tpl->setVariable("HREF_HEAD_CMD", $command["href"]);
1782 $this->tpl->parseCurrentBlock();
1783 }
1784 }
1785 }
1786
1787 if (isset($this->headerHTML)) {
1788 $this->tpl->setCurrentBlock("tbl_header_html");
1789 $this->tpl->setVariable("HEADER_HTML", $this->headerHTML);
1790 $this->tpl->parseCurrentBlock();
1791 }
1792
1793 // close command
1794 if ($this->close_command != "") {
1795 $this->tpl->setCurrentBlock("tbl_header_img_link");
1796 $this->tpl->setVariable("ALT_IMG_LINK", $lng->txt("close"));
1797 $this->tpl->setVariable("HREF_IMG_LINK", $this->close_command);
1798 $this->tpl->parseCurrentBlock();
1799 }
1800
1801 $this->tpl->setCurrentBlock("tbl_header_title");
1802 $this->tpl->setVariable("TBL_TITLE", $this->title);
1803 $this->tpl->setVariable("TOP_ANCHOR", $this->getTopAnchor());
1804 if ($this->getDisplayAsBlock()) {
1805 $this->tpl->setVariable("BLK_CLASS", "Block");
1806 }
1807 $this->tpl->parseCurrentBlock();
1808 }
1809
1810 // table header
1811 if ($this->enabled["header"]) {
1812 $this->fillHeader();
1813 }
1814
1815 $this->tpl->touchBlock("tbl_table_end");
1816
1817 return $this->tpl->get();
1818 }
1819
1823 private function renderFilter()
1824 {
1825 global $DIC;
1826
1827 $lng = $this->lng;
1828 $main_tpl = $DIC["tpl"];
1829
1830 $filter = $this->getFilterItems();
1831 $opt_filter = $this->getFilterItems(true);
1832
1833 $main_tpl->addJavascript("./Services/Table/js/ServiceTable.js");
1834
1835 if (count($filter) == 0 && count($opt_filter) == 0) {
1836 return;
1837 }
1838
1839 include_once("./Services/YUI/classes/class.ilYuiUtil.php");
1841
1842 $ccnt = 0;
1843
1844 // render standard filter
1845 if (count($filter) > 0) {
1846 foreach ($filter as $item) {
1847 if ($ccnt >= $this->getFilterCols()) {
1848 $this->tpl->setCurrentBlock("filter_row");
1849 $this->tpl->parseCurrentBlock();
1850 $ccnt = 0;
1851 }
1852 $this->tpl->setCurrentBlock("filter_item");
1853 $this->tpl->setVariable(
1854 "OPTION_NAME",
1855 $item->getTitle()
1856 );
1857 $this->tpl->setVariable(
1858 "F_INPUT_ID",
1859 $item->getFieldId()
1860 );
1861 $this->tpl->setVariable(
1862 "INPUT_HTML",
1863 $item->getTableFilterHTML()
1864 );
1865 $this->tpl->parseCurrentBlock();
1866 $ccnt++;
1867 }
1868 }
1869
1870 // render optional filter
1871 if (count($opt_filter) > 0) {
1872 $this->determineSelectedFilters();
1873
1874 foreach ($opt_filter as $item) {
1875 if ($this->isFilterSelected($item->getPostVar())) {
1876 if ($ccnt >= $this->getFilterCols()) {
1877 $this->tpl->setCurrentBlock("filter_row");
1878 $this->tpl->parseCurrentBlock();
1879 $ccnt = 0;
1880 }
1881 $this->tpl->setCurrentBlock("filter_item");
1882 $this->tpl->setVariable(
1883 "OPTION_NAME",
1884 $item->getTitle()
1885 );
1886 $this->tpl->setVariable(
1887 "F_INPUT_ID",
1888 $item->getFieldId()
1889 );
1890 $this->tpl->setVariable(
1891 "INPUT_HTML",
1892 $item->getTableFilterHTML()
1893 );
1894 $this->tpl->parseCurrentBlock();
1895 $ccnt++;
1896 }
1897 }
1898
1899 // filter selection
1900 $items = array();
1901 foreach ($opt_filter as $item) {
1902 $k = $item->getPostVar();
1903 $items[$k] = array("txt" => $item->getTitle(),
1904 "selected" => $this->isFilterSelected($k));
1905 }
1906
1907 include_once("./Services/UIComponent/CheckboxListOverlay/classes/class.ilCheckboxListOverlayGUI.php");
1908 $cb_over = new ilCheckboxListOverlayGUI("tbl_filters_" . $this->getId());
1909 $cb_over->setLinkTitle($lng->txt("optional_filters"));
1910 $cb_over->setItems($items);
1911
1912 $cb_over->setFormCmd($this->getParentCmd());
1913 $cb_over->setFieldVar("tblff" . $this->getId());
1914 $cb_over->setHiddenVar("tblfsf" . $this->getId());
1915
1916 $cb_over->setSelectionHeaderClass("ilTableMenuItem");
1917 $this->tpl->setCurrentBlock("filter_select");
1918
1919 // apply should be the first submit because of enter/return, inserting hidden submit
1920 $this->tpl->setVariable("HIDDEN_CMD_APPLY", $this->filter_cmd);
1921
1922 $this->tpl->setVariable("FILTER_SELECTOR", $cb_over->getHTML());
1923 $this->tpl->parseCurrentBlock();
1924 }
1925
1926 // if any filter
1927 if ($ccnt > 0 || count($opt_filter) > 0) {
1928 $this->tpl->setVariable("TXT_FILTER", $lng->txt("filter"));
1929
1930 if ($ccnt > 0) {
1931 if ($ccnt < $this->getFilterCols()) {
1932 for ($i = $ccnt; $i<=$this->getFilterCols(); $i++) {
1933 $this->tpl->touchBlock("filter_empty_cell");
1934 }
1935 }
1936 $this->tpl->setCurrentBlock("filter_row");
1937 $this->tpl->parseCurrentBlock();
1938
1939 $this->tpl->setCurrentBlock("filter_buttons");
1940 $this->tpl->setVariable("CMD_APPLY", $this->filter_cmd);
1941 $this->tpl->setVariable("TXT_APPLY", $this->filter_cmd_txt
1942 ? $this->filter_cmd_txt
1943 : $lng->txt("apply_filter"));
1944 $this->tpl->setVariable("CMD_RESET", $this->reset_cmd);
1945 $this->tpl->setVariable("TXT_RESET", $this->reset_cmd_txt
1946 ? $this->reset_cmd_txt
1947 : $lng->txt("reset_filter"));
1948 } elseif (count($opt_filter) > 0) {
1949 $this->tpl->setCurrentBlock("optional_filter_hint");
1950 $this->tpl->setVariable('TXT_OPT_HINT', $lng->txt('optional_filter_hint'));
1951 $this->tpl->parseCurrentBlock();
1952 }
1953
1954 $this->tpl->setCurrentBlock("filter_section");
1955 $this->tpl->setVariable("FIL_ID", $this->getId());
1956 $this->tpl->parseCurrentBlock();
1957
1958 // (keep) filter hidden?
1959 if (!$this->isFilterVisible()) {
1960 if (!$this->getDisableFilterHiding()) {
1961 $this->tpl->setCurrentBlock("filter_hidden");
1962 $this->tpl->setVariable("FI_ID", $this->getId());
1963 $this->tpl->parseCurrentBlock();
1964 }
1965 }
1966 }
1967 }
1968
1973 protected function isFilterVisible()
1974 {
1975 $prop = $this->loadProperty('filter');
1976 if ($prop === '0' || $prop === '1') {
1977 return (bool) $prop;
1978 }
1979 return $this->getDefaultFilterVisibility();
1980 }
1981
1989 protected function isAdvMDFilter(ilAdvancedMDRecordGUI $a_gui, $a_element)
1990 {
1991 foreach ($a_gui->getFilterElements(false) as $item) {
1992 if ($item === $a_element) {
1993 return true;
1994 }
1995 }
1996 return false;
1997 }
1998
2002 public function writeFilterToSession()
2003 {
2004 $advmd_record_gui = null;
2005 if (method_exists($this, "getAdvMDRecordGUI")) {
2006 $advmd_record_gui = $this->getAdvMDRecordGUI();
2007 }
2008
2009 foreach ($this->getFilterItems() as $item) {
2010 if ($advmd_record_gui &&
2011 $this->isAdvMDFilter($advmd_record_gui, $item)) {
2012 continue;
2013 }
2014
2015 if ($item->checkInput()) {
2016 $item->setValueByArray($_POST);
2017 $item->writeToSession();
2018 }
2019 }
2020 foreach ($this->getFilterItems(true) as $item) {
2021 if ($advmd_record_gui &&
2022 $this->isAdvMDFilter($advmd_record_gui, $item)) {
2023 continue;
2024 }
2025
2026 if ($item->checkInput()) {
2027 $item->setValueByArray($_POST);
2028 $item->writeToSession();
2029 }
2030 }
2031
2032 if ($advmd_record_gui) {
2033 $advmd_record_gui->importFilter();
2034 }
2035
2036 // #13209
2037 unset($_REQUEST["tbltplcrt"]);
2038 unset($_REQUEST["tbltpldel"]);
2039 }
2040
2044 public function resetFilter()
2045 {
2046 $lng = $this->lng;
2047
2048 $filter = $this->getFilterItems();
2049 $opt_filter = $this->getFilterItems(true);
2050
2051 foreach ($filter as $item) {
2052 if ($item->checkInput()) {
2053 $item->setValueByArray($_POST);
2054 $item->clearFromSession();
2055 }
2056 }
2057 foreach ($opt_filter as $item) {
2058 if ($item->checkInput()) {
2059 $item->setValueByArray($_POST);
2060 $item->clearFromSession();
2061 }
2062 }
2063
2064 // #13209
2065 unset($_REQUEST["tbltplcrt"]);
2066 unset($_REQUEST["tbltpldel"]);
2067 }
2068
2075 protected function fillRow($a_set)
2076 {
2077 foreach ($a_set as $key => $value) {
2078 $this->tpl->setVariable("VAL_" . strtoupper($key), $value);
2079 }
2080 }
2081
2085 public function fillFooter()
2086 {
2087 global $DIC;
2088
2089 $ilUser = null;
2090 if (isset($DIC["ilUser"])) {
2091 $ilUser = $DIC["ilUser"];
2092 }
2093
2094 $lng = $this->lng;
2096
2097 $footer = false;
2098
2099 // select all checkbox
2100 if ((strlen($this->getFormName())) && (strlen($this->getSelectAllCheckbox())) && $this->dataExists()) {
2101 $this->tpl->setCurrentBlock("select_all_checkbox");
2102 $this->tpl->setVariable("SELECT_ALL_TXT_SELECT_ALL", $lng->txt("select_all"));
2103 $this->tpl->setVariable("SELECT_ALL_CHECKBOX_NAME", $this->getSelectAllCheckbox());
2104 $this->tpl->setVariable("SELECT_ALL_FORM_NAME", $this->getFormName());
2105 $this->tpl->setVariable("CHECKBOXNAME", "chb_select_all_" . $this->unique_id);
2106 $this->tpl->parseCurrentBlock();
2107 }
2108
2109 // table footer numinfo
2110 if ($this->enabled["numinfo"] && $this->enabled["footer"]) {
2111 $start = $this->offset + 1; // compute num info
2112 if (!$this->dataExists()) {
2113 $start = 0;
2114 }
2115 $end = $this->offset + $this->limit;
2116
2117 if ($end > $this->max_count or $this->limit == 0) {
2119 }
2120
2121 if ($this->max_count > 0) {
2122 if ($this->lang_support) {
2123 $numinfo = "(" . $start . " - " . $end . " " . strtolower($this->lng->txt("of")) . " " . $this->max_count . ")";
2124 } else {
2125 $numinfo = "(" . $start . " - " . $end . " of " . $this->max_count . ")";
2126 }
2127 }
2128 if ($this->max_count > 0) {
2129 if ($this->getEnableNumInfo()) {
2130 $this->tpl->setCurrentBlock("tbl_footer_numinfo");
2131 $this->tpl->setVariable("NUMINFO", $numinfo);
2132 $this->tpl->parseCurrentBlock();
2133 }
2134 }
2135 $footer = true;
2136 }
2137
2138 // table footer linkbar
2139 if ($this->enabled["linkbar"] && $this->enabled["footer"] && $this->limit != 0
2140 && $this->max_count > 0) {
2141 $layout = array(
2142 "link" => $this->footer_style,
2143 "prev" => $this->footer_previous,
2144 "next" => $this->footer_next,
2145 );
2146 //if (!$this->getDisplayAsBlock())
2147 //{
2148 $linkbar = $this->getLinkbar("1");
2149 $this->tpl->setCurrentBlock("tbl_footer_linkbar");
2150 $this->tpl->setVariable("LINKBAR", $linkbar);
2151 $this->tpl->parseCurrentBlock();
2152 $linkbar = true;
2153 //}
2154 $footer = true;
2155 }
2156
2157 // column selector
2158 if (is_array($this->getSelectableColumns()) && count($this->getSelectableColumns()) > 0) {
2159 $items = array();
2160 foreach ($this->getSelectableColumns() as $k => $c) {
2161 $items[$k] = array("txt" => $c["txt"],
2162 "selected" => $this->isColumnSelected($k));
2163 }
2164 include_once("./Services/UIComponent/CheckboxListOverlay/classes/class.ilCheckboxListOverlayGUI.php");
2165 $cb_over = new ilCheckboxListOverlayGUI("tbl_" . $this->getId());
2166 $cb_over->setLinkTitle($lng->txt("columns"));
2167 $cb_over->setItems($items);
2168 //$cb_over->setUrl("./ilias.php?baseClass=ilTablePropertiesStorage&table_id=".
2169 // $this->getId()."&cmd=saveSelectedFields&user_id=".$ilUser->getId());
2170 $cb_over->setFormCmd($this->getParentCmd());
2171 $cb_over->setFieldVar("tblfs" . $this->getId());
2172 $cb_over->setHiddenVar("tblfsh" . $this->getId());
2173 $cb_over->setSelectionHeaderClass("ilTableMenuItem");
2174 $column_selector = $cb_over->getHTML();
2175 $footer = true;
2176 }
2177
2178 if ($this->getShowTemplates() && is_object($ilUser)) {
2179 // template handling
2180 if (isset($_REQUEST["tbltplcrt"]) && $_REQUEST["tbltplcrt"]) {
2181 if ($this->saveTemplate($_REQUEST["tbltplcrt"])) {
2182 ilUtil::sendSuccess($lng->txt("tbl_template_created"));
2183 }
2184 } elseif (isset($_REQUEST["tbltpldel"]) && $_REQUEST["tbltpldel"]) {
2185 if ($this->deleteTemplate($_REQUEST["tbltpldel"])) {
2186 ilUtil::sendSuccess($lng->txt("tbl_template_deleted"));
2187 }
2188 }
2189
2190 $create_id = "template_create_overlay_" . $this->getId();
2191 $delete_id = "template_delete_overlay_" . $this->getId();
2192 $list_id = "template_stg_" . $this->getId();
2193
2194 include_once("./Services/Table/classes/class.ilTableTemplatesStorage.php");
2195 $storage = new ilTableTemplatesStorage();
2196 $templates = $storage->getNames($this->getContext(), $ilUser->getId());
2197
2198 include_once("./Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php");
2199
2200 // form to delete template
2201 if (sizeof($templates)) {
2202 $overlay = new ilOverlayGUI($delete_id);
2203 $overlay->setTrigger($list_id . "_delete");
2204 $overlay->setAnchor("ilAdvSelListAnchorElement_" . $list_id);
2205 $overlay->setAutoHide(false);
2206 $overlay->add();
2207
2208 $lng->loadLanguageModule("form");
2209 $this->tpl->setCurrentBlock("template_editor_delete_item");
2210 $this->tpl->setVariable("TEMPLATE_DELETE_OPTION_VALUE", "");
2211 $this->tpl->setVariable("TEMPLATE_DELETE_OPTION", "- " . $lng->txt("form_please_select") . " -");
2212 $this->tpl->parseCurrentBlock();
2213 foreach ($templates as $name) {
2214 $this->tpl->setVariable("TEMPLATE_DELETE_OPTION_VALUE", $name);
2215 $this->tpl->setVariable("TEMPLATE_DELETE_OPTION", $name);
2216 $this->tpl->parseCurrentBlock();
2217 }
2218
2219 $this->tpl->setCurrentBlock("template_editor_delete");
2220 $this->tpl->setVariable("TEMPLATE_DELETE_ID", $delete_id);
2221 $this->tpl->setVariable("TXT_TEMPLATE_DELETE", $lng->txt("tbl_template_delete"));
2222 $this->tpl->setVariable("TXT_TEMPLATE_DELETE_SUBMIT", $lng->txt("delete"));
2223 $this->tpl->setVariable("TEMPLATE_DELETE_CMD", $this->parent_cmd);
2224 $this->tpl->parseCurrentBlock();
2225 }
2226
2227
2228 // form to save new template
2229 $overlay = new ilOverlayGUI($create_id);
2230 $overlay->setTrigger($list_id . "_create");
2231 $overlay->setAnchor("ilAdvSelListAnchorElement_" . $list_id);
2232 $overlay->setAutoHide(false);
2233 $overlay->add();
2234
2235 $this->tpl->setCurrentBlock("template_editor");
2236 $this->tpl->setVariable("TEMPLATE_CREATE_ID", $create_id);
2237 $this->tpl->setVariable("TXT_TEMPLATE_CREATE", $lng->txt("tbl_template_create"));
2238 $this->tpl->setVariable("TXT_TEMPLATE_CREATE_SUBMIT", $lng->txt("save"));
2239 $this->tpl->setVariable("TEMPLATE_CREATE_CMD", $this->parent_cmd);
2240 $this->tpl->parseCurrentBlock();
2241
2242 // load saved template
2243 include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
2244 $alist = new ilAdvancedSelectionListGUI();
2245 $alist->setId($list_id);
2246 $alist->addItem($lng->txt("tbl_template_create"), "create", "#");
2247 if (sizeof($templates)) {
2248 $alist->addItem($lng->txt("tbl_template_delete"), "delete", "#");
2249 foreach ($templates as $name) {
2250 $ilCtrl->setParameter($this->parent_obj, $this->prefix . "_tpl", urlencode($name));
2251 $alist->addItem($name, $name, $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd));
2252 $ilCtrl->setParameter($this->parent_obj, $this->prefix . "_tpl", "");
2253 }
2254 }
2255 $alist->setListTitle($lng->txt("tbl_templates"));
2257 $this->tpl->setVariable("TEMPLATE_SELECTOR", "&nbsp;" . $alist->getHTML());
2258 }
2259
2260 if ($footer) {
2261 $this->tpl->setCurrentBlock("tbl_footer");
2262 $this->tpl->setVariable("COLUMN_COUNT", $this->getColumnCount());
2263 if ($this->getDisplayAsBlock()) {
2264 $this->tpl->setVariable("BLK_CLASS", "Block");
2265 }
2266 $this->tpl->parseCurrentBlock();
2267
2268 // top navigation, if number info or linkbar given
2269 if ($numinfo != "" || $linkbar != "" || $column_selector != "" ||
2270 count($this->filters) > 0 || count($this->optional_filters) > 0) {
2271 if (is_object($ilUser) && (count($this->filters) || count($this->optional_filters))) {
2272 $this->tpl->setCurrentBlock("filter_activation");
2273 $this->tpl->setVariable("TXT_ACTIVATE_FILTER", $lng->txt("show_filter"));
2274 $this->tpl->setVariable("FILA_ID", $this->getId());
2275 if ($this->getId() != "") {
2276 $this->tpl->setVariable("SAVE_URLA", "./ilias.php?baseClass=ilTablePropertiesStorage&table_id=" .
2277 $this->getId() . "&cmd=showFilter&user_id=" . $ilUser->getId());
2278 }
2279 $this->tpl->parseCurrentBlock();
2280
2281
2282 if (!$this->getDisableFilterHiding()) {
2283 $this->tpl->setCurrentBlock("filter_deactivation");
2284 $this->tpl->setVariable("TXT_HIDE", $lng->txt("hide_filter"));
2285 if ($this->getId() != "") {
2286 $this->tpl->setVariable("SAVE_URL", "./ilias.php?baseClass=ilTablePropertiesStorage&table_id=" .
2287 $this->getId() . "&cmd=hideFilter&user_id=" . $ilUser->getId());
2288 $this->tpl->setVariable("FILD_ID", $this->getId());
2289 }
2290 $this->tpl->parseCurrentBlock();
2291 }
2292 }
2293
2294 if ($numinfo != "" && $this->getEnableNumInfo()) {
2295 $this->tpl->setCurrentBlock("top_numinfo");
2296 $this->tpl->setVariable("NUMINFO", $numinfo);
2297 $this->tpl->parseCurrentBlock();
2298 }
2299 if ($linkbar != "" && !$this->getDisplayAsBlock()) {
2300 $linkbar = $this->getLinkbar("2");
2301 $this->tpl->setCurrentBlock("top_linkbar");
2302 $this->tpl->setVariable("LINKBAR", $linkbar);
2303 $this->tpl->parseCurrentBlock();
2304 }
2305
2306 // column selector
2307 $this->tpl->setVariable("COLUMN_SELECTOR", $column_selector);
2308
2309 // row selector
2310 if ($this->getShowRowsSelector() &&
2311 is_object($ilUser) &&
2312 $this->getId() &&
2313 !$this->rows_selector_off) { // JF, 2014-10-27
2314 include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
2315 $alist = new ilAdvancedSelectionListGUI();
2317 $alist->setId("sellst_rows_" . $this->getId());
2318 $hpp = ($ilUser->getPref("hits_per_page") != 9999)
2319 ? $ilUser->getPref("hits_per_page")
2320 : $lng->txt("no_limit");
2321
2322 $options = array(0 => $lng->txt("default") . " (" . $hpp . ")",5 => 5, 10 => 10, 15 => 15, 20 => 20,
2323 30 => 30, 40 => 40, 50 => 50,
2324 100 => 100, 200 => 200, 400 => 400, 800 => 800);
2325 foreach ($options as $k => $v) {
2326 $ilCtrl->setParameter($this->parent_obj, $this->prefix . "_trows", $k);
2327 $alist->addItem($v, $k, $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd));
2328 $ilCtrl->setParameter($this->parent_obj, $this->prefix . "_trows", "");
2329 }
2330 $alist->setListTitle($this->getRowSelectorLabel() ? $this->getRowSelectorLabel() : $lng->txt("rows"));
2331 $this->tpl->setVariable("ROW_SELECTOR", $alist->getHTML());
2332 }
2333
2334 // export
2335 if (sizeof($this->export_formats) && $this->dataExists()) {
2336 include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
2337 $alist = new ilAdvancedSelectionListGUI();
2339 $alist->setId("sellst_xpt");
2340 foreach ($this->export_formats as $format => $caption_lng_id) {
2341 $ilCtrl->setParameter($this->parent_obj, $this->prefix . "_xpt", $format);
2342 $url = $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd);
2343 $ilCtrl->setParameter($this->parent_obj, $this->prefix . "_xpt", "");
2344 $alist->addItem($lng->txt($caption_lng_id), $format, $url);
2345 }
2346 $alist->setListTitle($lng->txt("export"));
2347 $this->tpl->setVariable("EXPORT_SELECTOR", "&nbsp;" . $alist->getHTML());
2348 }
2349
2350 $this->tpl->setCurrentBlock("top_navigation");
2351 $this->tpl->setVariable("COLUMN_COUNT", $this->getColumnCount());
2352 if ($this->getDisplayAsBlock()) {
2353 $this->tpl->setVariable("BLK_CLASS", "Block");
2354 }
2355 $this->tpl->parseCurrentBlock();
2356 }
2357 }
2358 }
2359
2367 public function getLinkbar($a_num)
2368 {
2369 global $DIC;
2370
2371 $ilUser = $DIC->user();
2372
2374 $lng = $this->lng;
2375
2376 $hash = "";
2377 if (is_object($ilUser) && $ilUser->getPref("screen_reader_optimization")) {
2378 $hash = "#" . $this->getTopAnchor();
2379 }
2380
2381 $link = $ilCtrl->getLinkTargetByClass(get_class($this->parent_obj), $this->parent_cmd) .
2382 "&" . $this->getNavParameter() . "=" .
2383 $this->getOrderField() . ":" . $this->getOrderDirection() . ":";
2384
2385 $LinkBar = "";
2386 $layout_prev = $lng->txt("previous");
2387 $layout_next = $lng->txt("next");
2388
2389 // if more entries then entries per page -> show link bar
2390 if ($this->max_count > $this->getLimit() || $this->custom_prev_next) {
2391 $sep = "<span>&nbsp;&nbsp;|&nbsp;&nbsp;</span>";
2392
2393 // calculate number of pages
2394 $pages = intval($this->max_count / $this->getLimit());
2395
2396 // add a page if a rest remains
2397 if (($this->max_count % $this->getLimit())) {
2398 $pages++;
2399 }
2400
2401 // links to other pages
2402 $offset_arr = array();
2403 for ($i = 1 ;$i <= $pages ; $i++) {
2404 $newoffset = $this->getLimit() * ($i-1);
2405
2406 $nav_value = $this->getOrderField() . ":" . $this->getOrderDirection() . ":" . $newoffset;
2407 $offset_arr[$nav_value] = $i;
2408 }
2409
2410 $sep = "<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>";
2411
2412 // previous link
2413 if ($this->custom_prev_next && $this->custom_prev != "") {
2414 if ($LinkBar != "") {
2415 $LinkBar .= $sep;
2416 }
2417 $LinkBar .= "<a href=\"" . $this->custom_prev . $hash . "\">" . $layout_prev . "</a>";
2418 } elseif ($this->getOffset() >= 1 && !$this->custom_prev_next) {
2419 if ($LinkBar != "") {
2420 $LinkBar .= $sep;
2421 }
2422 $prevoffset = $this->getOffset() - $this->getLimit();
2423 $LinkBar .= "<a href=\"" . $link . $prevoffset . $hash . "\">" . $layout_prev . "</a>";
2424 } else {
2425 if ($LinkBar != "") {
2426 $LinkBar .= $sep;
2427 }
2428 $LinkBar .= '<span class="ilTableFootLight">' . $layout_prev . "</span>";
2429 }
2430
2431 // current value
2432 if ($a_num == "1") {
2433 $LinkBar .= '<input type="hidden" name="' . $this->getNavParameter() .
2434 '" value="' . $this->getOrderField() . ":" . $this->getOrderDirection() . ":" . $this->getOffset() . '" />';
2435 }
2436
2437 $sep = "<span>&nbsp;&nbsp;|&nbsp;&nbsp;</span>";
2438
2439 // show next link (if not last page)
2440 if ($this->custom_prev_next && $this->custom_next != "") {
2441 if ($LinkBar != "") {
2442 $LinkBar .= $sep;
2443 }
2444 $LinkBar .= "<a href=\"" . $this->custom_next . $hash . "\">" . $layout_next . "</a>";
2445 } elseif (!(($this->getOffset() / $this->getLimit())==($pages-1)) && ($pages!=1) &&
2446 !$this->custom_prev_next) {
2447 if ($LinkBar != "") {
2448 $LinkBar .= $sep;
2449 }
2450 $newoffset = $this->getOffset() + $this->getLimit();
2451 $LinkBar .= "<a href=\"" . $link . $newoffset . $hash . "\">" . $layout_next . "</a>";
2452 } else {
2453 if ($LinkBar != "") {
2454 $LinkBar .= $sep;
2455 }
2456 $LinkBar .= '<span class="ilTableFootLight">' . $layout_next . "</span>";
2457 }
2458
2459 $sep = "<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>";
2460
2461 if (count($offset_arr) && !$this->getDisplayAsBlock() && !$this->custom_prev_next) {
2462 if ($LinkBar != "") {
2463 $LinkBar .= $sep;
2464 }
2465 $LinkBar .= "" .
2466 '<label for="tab_page_sel_' . $a_num . '">' . $lng->txt("page") . '</label> ' .
2468 $this->nav_value,
2469 $this->getNavParameter() . $a_num,
2470 $offset_arr,
2471 false,
2472 true,
2473 0,
2474 "small",
2475 array("id" => "tab_page_sel_" . $a_num,
2476 "onchange" => "ilTablePageSelection(this, 'cmd[" . $this->parent_cmd . "]')")
2477 );
2478 //' <input class="submit" type="submit" name="cmd['.$this->parent_cmd.']" value="'.
2479 //$lng->txt("ok").'" />';
2480 }
2481
2482 return $LinkBar;
2483 } else {
2484 return false;
2485 }
2486 }
2487
2488 public function fillHiddenRow()
2489 {
2490 $hidden_row = false;
2491 if (count($this->hidden_inputs)) {
2492 foreach ($this->hidden_inputs as $hidden_input) {
2493 $this->tpl->setCurrentBlock("tbl_hidden_field");
2494 $this->tpl->setVariable("FIELD_NAME", $hidden_input["name"]);
2495 $this->tpl->setVariable("FIELD_VALUE", $hidden_input["value"]);
2496 $this->tpl->parseCurrentBlock();
2497 }
2498
2499 $this->tpl->setCurrentBlock("tbl_hidden_row");
2500 $this->tpl->parseCurrentBlock();
2501 }
2502 }
2503
2507 public function fillActionRow()
2508 {
2509 $lng = $this->lng;
2510
2511 // action row
2512 $action_row = false;
2513 $arrow = false;
2514
2515 // add selection buttons
2516 if (count($this->sel_buttons) > 0) {
2517 foreach ($this->sel_buttons as $button) {
2518 $this->tpl->setCurrentBlock("sel_button");
2519 $this->tpl->setVariable(
2520 "SBUTTON_SELECT",
2522 $button["selected"],
2523 $button["sel_var"],
2524 $button["options"],
2525 false,
2526 true
2527 )
2528 );
2529 $this->tpl->setVariable("SBTN_NAME", $button["cmd"]);
2530 $this->tpl->setVariable("SBTN_VALUE", $button["text"]);
2531 $this->tpl->parseCurrentBlock();
2532
2533 if ($this->getTopCommands()) {
2534 $this->tpl->setCurrentBlock("sel_top_button");
2535 $this->tpl->setVariable(
2536 "SBUTTON_SELECT",
2538 $button["selected"],
2539 $button["sel_var"],
2540 $button["options"],
2541 false,
2542 true
2543 )
2544 );
2545 $this->tpl->setVariable("SBTN_NAME", $button["cmd"]);
2546 $this->tpl->setVariable("SBTN_VALUE", $button["text"]);
2547 $this->tpl->parseCurrentBlock();
2548 }
2549 }
2550 $buttons = true;
2551 $action_row = true;
2552 }
2553 $this->sel_buttons[] = array("options" => $a_options, "cmd" => $a_cmd, "text" => $a_text);
2554
2555 // add buttons
2556 if (count($this->buttons) > 0) {
2557 foreach ($this->buttons as $button) {
2558 if (!is_array($button)) {
2559 if ($button instanceof ilButtonBase) {
2560 $this->tpl->setVariable('BUTTON_OBJ', $button->render());
2561
2562 // this will remove id - should be unique
2563 $button = clone $button;
2564
2565 $this->tpl->setVariable('BUTTON_TOP_OBJ', $button->render());
2566 }
2567 continue;
2568 }
2569
2570 if (strlen($button['onclick'])) {
2571 $this->tpl->setCurrentBlock('cmdonclick');
2572 $this->tpl->setVariable('CMD_ONCLICK', $button['onclick']);
2573 $this->tpl->parseCurrentBlock();
2574 }
2575 $this->tpl->setCurrentBlock("plain_button");
2576 if ($button["id"] != "") {
2577 $this->tpl->setVariable("PBID", ' id="' . $button["id"] . '" ');
2578 }
2579 if ($button["class"] != "") {
2580 $this->tpl->setVariable("PBBT_CLASS", ' ' . $button["class"]);
2581 }
2582 $this->tpl->setVariable("PBTN_NAME", $button["cmd"]);
2583 $this->tpl->setVariable("PBTN_VALUE", $button["text"]);
2584 $this->tpl->parseCurrentBlock();
2585
2586 if ($this->getTopCommands()) {
2587 if (strlen($button['onclick'])) {
2588 $this->tpl->setCurrentBlock('top_cmdonclick');
2589 $this->tpl->setVariable('CMD_ONCLICK', $button['onclick']);
2590 $this->tpl->parseCurrentBlock();
2591 }
2592 $this->tpl->setCurrentBlock("plain_top_button");
2593 $this->tpl->setVariable("PBTN_NAME", $button["cmd"]);
2594 $this->tpl->setVariable("PBTN_VALUE", $button["text"]);
2595 if ($button["class"] != "") {
2596 $this->tpl->setVariable("PBBT_CLASS", ' ' . $button["class"]);
2597 }
2598 $this->tpl->parseCurrentBlock();
2599 }
2600 }
2601
2602 $buttons = true;
2603 $action_row = true;
2604 }
2605
2606 // multi selection
2607 if (count($this->mi_sel_buttons)) {
2608 foreach ($this->mi_sel_buttons as $button) {
2609 $this->tpl->setCurrentBlock("mi_sel_button");
2610 $this->tpl->setVariable(
2611 "MI_BUTTON_SELECT",
2613 $button["selected"],
2614 $button["sel_var"],
2615 $button["options"],
2616 false,
2617 true
2618 )
2619 );
2620 $this->tpl->setVariable("MI_BTN_NAME", $button["cmd"]);
2621 $this->tpl->setVariable("MI_BTN_VALUE", $button["text"]);
2622 $this->tpl->parseCurrentBlock();
2623
2624 if ($this->getTopCommands()) {
2625 $this->tpl->setCurrentBlock("mi_top_sel_button");
2626 $this->tpl->setVariable(
2627 "MI_BUTTON_SELECT",
2629 $button["selected"],
2630 $button["sel_var"] . "_2",
2631 $button["options"],
2632 false,
2633 true
2634 )
2635 );
2636 $this->tpl->setVariable("MI_BTN_NAME", $button["cmd"]);
2637 $this->tpl->setVariable("MI_BTN_VALUE", $button["text"]);
2638 $this->tpl->parseCurrentBlock();
2639 }
2640 }
2641 $arrow = true;
2642 $action_row = true;
2643 }
2644
2645
2646 if (count($this->multi) > 1 && $this->dataExists()) {
2647 if ($this->enable_command_for_all && $this->max_count <= self::getAllCommandLimit()) {
2648 $this->tpl->setCurrentBlock("tbl_cmd_select_all");
2649 $this->tpl->setVariable("TXT_SELECT_CMD_ALL", $lng->txt("all_objects"));
2650 $this->tpl->parseCurrentBlock();
2651 }
2652
2653 $this->tpl->setCurrentBlock("tbl_cmd_select");
2654 $sel = array();
2655 foreach ($this->multi as $mc) {
2656 $sel[$mc["cmd"]] = $mc["text"];
2657 }
2658 $this->tpl->setVariable(
2659 "SELECT_CMDS",
2660 ilUtil::formSelect("", "selected_cmd", $sel, false, true)
2661 );
2662 $this->tpl->setVariable("TXT_EXECUTE", $lng->txt("execute"));
2663 $this->tpl->parseCurrentBlock();
2664 $arrow = true;
2665 $action_row = true;
2666
2667 if ($this->getTopCommands()) {
2668 if ($this->enable_command_for_all && $this->max_count <= self::getAllCommandLimit()) {
2669 $this->tpl->setCurrentBlock("tbl_top_cmd_select_all");
2670 $this->tpl->setVariable("TXT_SELECT_CMD_ALL", $lng->txt("all_objects"));
2671 $this->tpl->parseCurrentBlock();
2672 }
2673
2674 $this->tpl->setCurrentBlock("tbl_top_cmd_select");
2675 $sel = array();
2676 foreach ($this->multi as $mc) {
2677 $sel[$mc["cmd"]] = $mc["text"];
2678 }
2679 $this->tpl->setVariable(
2680 "SELECT_CMDS",
2681 ilUtil::formSelect("", "selected_cmd2", $sel, false, true)
2682 );
2683 $this->tpl->setVariable("TXT_EXECUTE", $lng->txt("execute"));
2684 $this->tpl->parseCurrentBlock();
2685 }
2686 } elseif (count($this->multi) == 1 && $this->dataExists()) {
2687 $this->tpl->setCurrentBlock("tbl_single_cmd");
2688 $sel = array();
2689 foreach ($this->multi as $mc) {
2690 $cmd = $mc['cmd'];
2691 $txt = $mc['text'];
2692 }
2693 $this->tpl->setVariable("TXT_SINGLE_CMD", $txt);
2694 $this->tpl->setVariable("SINGLE_CMD", $cmd);
2695 $this->tpl->parseCurrentBlock();
2696 $arrow = true;
2697 $action_row = true;
2698
2699 if ($this->getTopCommands()) {
2700 $this->tpl->setCurrentBlock("tbl_top_single_cmd");
2701 $sel = array();
2702 foreach ($this->multi as $mc) {
2703 $cmd = $mc['cmd'];
2704 $txt = $mc['text'];
2705 }
2706 $this->tpl->setVariable("TXT_SINGLE_CMD", $txt);
2707 $this->tpl->setVariable("SINGLE_CMD", $cmd);
2708 $this->tpl->parseCurrentBlock();
2709 }
2710 }
2711
2712 if ($arrow) {
2713 $this->tpl->setCurrentBlock("tbl_action_img_arrow");
2714 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.svg"));
2715 $this->tpl->setVariable("ALT_ARROW", $lng->txt("action"));
2716 $this->tpl->parseCurrentBlock();
2717
2718 if ($this->getTopCommands()) {
2719 $this->tpl->setCurrentBlock("tbl_top_action_img_arrow");
2720 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_upright.svg"));
2721 $this->tpl->setVariable("ALT_ARROW", $lng->txt("action"));
2722 $this->tpl->parseCurrentBlock();
2723 }
2724 }
2725
2726 if ($action_row) {
2727 $this->tpl->setCurrentBlock("tbl_action_row");
2728 $this->tpl->parseCurrentBlock();
2729 if ($this->getTopCommands()) {
2730 $this->tpl->setCurrentBlock("tbl_top_action_row");
2731 $this->tpl->parseCurrentBlock();
2732 }
2733 }
2734 }
2735
2741 public function setHeaderHTML($html)
2742 {
2743 $this->headerHTML = $html;
2744 }
2745
2752 public function storeProperty($type, $value)
2753 {
2754 global $DIC;
2755
2756 $ilUser = null;
2757 if (isset($DIC["ilUser"])) {
2758 $ilUser = $DIC["ilUser"];
2759 }
2760
2761 if (is_object($ilUser) && $this->getId() != "") {
2762 include_once("./Services/Table/classes/class.ilTablePropertiesStorage.php");
2763 $tab_prop = new ilTablePropertiesStorage();
2764
2765 $tab_prop->storeProperty($this->getId(), $ilUser->getId(), $type, $value);
2766 }
2767 }
2768
2775 public function loadProperty($type)
2776 {
2777 global $DIC;
2778
2779 $ilUser = null;
2780 if (isset($DIC["ilUser"])) {
2781 $ilUser = $DIC["ilUser"];
2782 }
2783
2784 if (is_object($ilUser) && $this->getId() != "") {
2785 include_once("./Services/Table/classes/class.ilTablePropertiesStorage.php");
2786 $tab_prop = new ilTablePropertiesStorage();
2787
2788 return $tab_prop->getProperty($this->getId(), $ilUser->getId(), $type);
2789 }
2790 return null;
2791 }
2792
2798 public function getCurrentState()
2799 {
2800 $this->determineOffsetAndOrder();
2801 $this->determineLimit();
2802 $this->determineSelectedColumns();
2803 $this->determineSelectedFilters();
2804
2805 // "filter" show/hide is not saved
2806
2807 $result = array();
2808 $result["order"] = $this->getOrderField();
2809 $result["direction"] = $this->getOrderDirection();
2810 $result["offset"] = $this->getOffset();
2811 $result["rows"] = $this->getLimit();
2812 $result["selfilters"] = $this->getSelectedFilters();
2813
2814 // #9514 - $this->getSelectedColumns() will omit deselected, leading to
2815 // confusion on restoring template
2816 $result["selfields"] = $this->selected_column;
2817
2818 // gather filter values
2819 if ($this->filters) {
2820 foreach ($this->filters as $item) {
2821 $result["filter_values"][$item->getFieldId()] = $this->getFilterValue($item);
2822 }
2823 }
2824 if ($this->optional_filters && $result["selfilters"]) {
2825 foreach ($this->optional_filters as $item) {
2826 if (in_array($item->getFieldId(), $result["selfilters"])) {
2827 $result["filter_values"][$item->getFieldId()] = $this->getFilterValue($item);
2828 }
2829 }
2830 }
2831
2832 return $result;
2833 }
2834
2841 protected function getFilterValue(ilFormPropertyGUI $a_item)
2842 {
2843 if (method_exists($a_item, "getChecked")) {
2844 return $a_item->getChecked();
2845 } elseif (method_exists($a_item, "getValue")) {
2846 return $a_item->getValue();
2847 } elseif (method_exists($a_item, "getDate")) {
2848 return $a_item->getDate()->get(IL_CAL_DATE);
2849 }
2850 }
2851
2858 protected function SetFilterValue(ilFormPropertyGUI $a_item, $a_value)
2859 {
2860 if (method_exists($a_item, "setChecked")) {
2861 $a_item->setChecked($a_value);
2862 } elseif (method_exists($a_item, "setValue")) {
2863 $a_item->setValue($a_value);
2864 } elseif (method_exists($a_item, "setDate")) {
2865 $a_item->setDate(new ilDate($a_value, IL_CAL_DATE));
2866 }
2867 $a_item->writeToSession();
2868 }
2869
2875 public function setContext($id)
2876 {
2877 if (trim($id)) {
2878 $this->context = $id;
2879 }
2880 }
2881
2887 public function getContext()
2888 {
2889 return $this->context;
2890 }
2891
2897 public function setShowRowsSelector($a_value)
2898 {
2899 $this->show_rows_selector = (bool) $a_value;
2900 }
2901
2907 public function getShowRowsSelector()
2908 {
2910 }
2911
2917 public function setShowTemplates($a_value)
2918 {
2919 $this->show_templates = (bool) $a_value;
2920 }
2921
2927 public function getShowTemplates()
2928 {
2929 return $this->show_templates;
2930 }
2931
2938 public function restoreTemplate($a_name)
2939 {
2940 global $DIC;
2941
2942 $ilUser = $DIC->user();
2943
2944 $a_name = ilUtil::stripSlashes($a_name);
2945
2946 if (trim($a_name) && $this->getContext() != "" && is_object($ilUser) && $ilUser->getId() != ANONYMOUS_USER_ID) {
2947 include_once("./Services/Table/classes/class.ilTableTemplatesStorage.php");
2948 $storage = new ilTableTemplatesStorage();
2949
2950 $data = $storage->load($this->getContext(), $ilUser->getId(), $a_name);
2951 if (is_array($data)) {
2952 foreach ($data as $property => $value) {
2953 $this->storeProperty($property, $value);
2954 }
2955 }
2956
2957 $data["filter_values"] = unserialize($data["filter_values"]);
2958 if ($data["filter_values"]) {
2959 $this->restore_filter_values = $data["filter_values"];
2960 }
2961
2962 $this->restore_filter = true;
2963
2964 return true;
2965 }
2966 return false;
2967 }
2968
2975 public function saveTemplate($a_name)
2976 {
2977 global $DIC;
2978
2979 $ilUser = $DIC->user();
2980
2981 $a_name = ilUtil::prepareFormOutput($a_name, true);
2982
2983 if (trim($a_name) && $this->getContext() != "" && is_object($ilUser) && $ilUser->getId() != ANONYMOUS_USER_ID) {
2984 include_once("./Services/Table/classes/class.ilTableTemplatesStorage.php");
2985 $storage = new ilTableTemplatesStorage();
2986
2987 $state = $this->getCurrentState();
2988 $state["filter_values"] = serialize($state["filter_values"]);
2989 $state["selfields"] = serialize($state["selfields"]);
2990 $state["selfilters"] = serialize($state["selfilters"]);
2991
2992 $storage->store($this->getContext(), $ilUser->getId(), $a_name, $state);
2993 return true;
2994 }
2995 return false;
2996 }
2997
3004 public function deleteTemplate($a_name)
3005 {
3006 global $DIC;
3007
3008 $ilUser = $DIC->user();
3009
3010 $a_name = ilUtil::prepareFormOutput($a_name, true);
3011
3012 if (trim($a_name) && $this->getContext() != "" && is_object($ilUser) && $ilUser->getId() != ANONYMOUS_USER_ID) {
3013 include_once("./Services/Table/classes/class.ilTableTemplatesStorage.php");
3014 $storage = new ilTableTemplatesStorage();
3015 $storage->delete($this->getContext(), $ilUser->getId(), $a_name);
3016 return true;
3017 }
3018 return false;
3019 }
3020
3024 public function getLimit()
3025 {
3026 if ($this->getExportMode() || $this->getPrintMode()) {
3027 return 9999;
3028 }
3029 return parent::getLimit();
3030 }
3031
3035 public function getOffset()
3036 {
3037 if ($this->getExportMode() || $this->getPrintMode()) {
3038 return 0;
3039 }
3040 return parent::getOffset();
3041 }
3042
3048 public function setExportFormats(array $formats)
3049 {
3050 $this->export_formats = array();
3051
3052 // #11339
3053 $valid = array(self::EXPORT_EXCEL => "tbl_export_excel",
3054 self::EXPORT_CSV => "tbl_export_csv");
3055
3056 foreach ($formats as $format) {
3057 if (array_key_exists($format, $valid)) {
3058 $this->export_formats[$format] = $valid[$format];
3059 }
3060 }
3061 }
3062
3067 public function setPrintMode($a_value = false)
3068 {
3069 $this->print_mode = (bool) $a_value;
3070 }
3071
3076 public function getPrintMode()
3077 {
3078 return $this->print_mode;
3079 }
3080
3086 public function getExportMode()
3087 {
3088 return $this->export_mode;
3089 }
3090
3096 public function exportData($format, $send = false)
3097 {
3098 if ($this->dataExists()) {
3099 // #9640: sort
3100 if (!$this->getExternalSorting() && $this->enabled["sort"]) {
3101 $this->determineOffsetAndOrder(true);
3102
3103 $this->row_data = ilUtil::sortArray(
3104 $this->row_data,
3105 $this->getOrderField(),
3106 $this->getOrderDirection(),
3107 $this->numericOrdering($this->getOrderField())
3108 );
3109 }
3110
3111 $filename = "export";
3112
3113 switch ($format) {
3114 case self::EXPORT_EXCEL:
3115 include_once "./Services/Excel/classes/class.ilExcel.php";
3116 $excel = new ilExcel();
3117 $excel->addSheet($this->title
3118 ? $this->title
3119 : $this->lng->txt("export"));
3120 $row = 1;
3121
3122 ob_start();
3123 $this->fillMetaExcel($excel, $row); // row must be increment in fillMetaExcel()! (optional method)
3124
3125 // #14813
3126 $pre = $row;
3127 $this->fillHeaderExcel($excel, $row); // row should NOT be incremented in fillHeaderExcel()! (required method)
3128 if ($pre == $row) {
3129 $row++;
3130 }
3131
3132 foreach ($this->row_data as $set) {
3133 $this->fillRowExcel($excel, $row, $set);
3134 $row++; // #14760
3135 }
3136 ob_end_clean();
3137
3138 if ($send) {
3139 $excel->sendToClient($filename);
3140 } else {
3141 $excel->writeToFile($filename);
3142 }
3143 break;
3144
3145 case self::EXPORT_CSV:
3146 include_once "./Services/Utilities/classes/class.ilCSVWriter.php";
3147 $csv = new ilCSVWriter();
3148 $csv->setSeparator(";");
3149
3150 ob_start();
3151 $this->fillMetaCSV($csv);
3152 $this->fillHeaderCSV($csv);
3153 foreach ($this->row_data as $set) {
3154 $this->fillRowCSV($csv, $set);
3155 }
3156 ob_end_clean();
3157
3158 if ($send) {
3159 $filename .= ".csv";
3160 header("Content-type: text/comma-separated-values");
3161 header("Content-Disposition: attachment; filename=\"" . $filename . "\"");
3162 header("Expires: 0");
3163 header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
3164 header("Pragma: public");
3165 echo $csv->getCSVString();
3166 } else {
3167 file_put_contents($filename, $csv->getCSVString());
3168 }
3169 break;
3170 }
3171
3172 if ($send) {
3173 exit();
3174 }
3175 }
3176 }
3177
3185 protected function fillMetaExcel(ilExcel $a_excel, &$a_row)
3186 {
3187 }
3188
3196 protected function fillHeaderExcel(ilExcel $a_excel, &$a_row)
3197 {
3198 $col = 0;
3199 foreach ($this->column as $column) {
3200 $title = strip_tags($column["text"]);
3201 if ($title) {
3202 $a_excel->setCell($a_row, $col++, $title);
3203 }
3204 }
3205 $a_excel->setBold("A" . $a_row . ":" . $a_excel->getColumnCoord($col-1) . $a_row);
3206 }
3207
3216 protected function fillRowExcel(ilExcel $a_excel, &$a_row, $a_set)
3217 {
3218 $col = 0;
3219 foreach ($a_set as $value) {
3220 if (is_array($value)) {
3221 $value = implode(', ', $value);
3222 }
3223 $a_excel->setCell($a_row, $col++, $value);
3224 }
3225 }
3226
3233 protected function fillMetaCSV($a_csv)
3234 {
3235 }
3236
3243 protected function fillHeaderCSV($a_csv)
3244 {
3245 foreach ($this->column as $column) {
3246 $title = strip_tags($column["text"]);
3247 if ($title) {
3248 $a_csv->addColumn($title);
3249 }
3250 }
3251 $a_csv->addRow();
3252 }
3253
3261 protected function fillRowCSV($a_csv, $a_set)
3262 {
3263 foreach ($a_set as $key => $value) {
3264 if (is_array($value)) {
3265 $value = implode(', ', $value);
3266 }
3267 $a_csv->addColumn(strip_tags($value));
3268 }
3269 $a_csv->addRow();
3270 }
3271
3277 public function setEnableAllCommand($a_value)
3278 {
3279 $this->enable_command_for_all = (bool) $a_value;
3280 }
3281
3287 public static function getAllCommandLimit()
3288 {
3289 global $DIC;
3290
3291 $ilClientIniFile = $DIC["ilClientIniFile"];
3292
3293 $limit = $ilClientIniFile->readVariable("system", "TABLE_ACTION_ALL_LIMIT");
3294 if (!$limit) {
3296 }
3297
3298 return $limit;
3299 }
3300
3305 {
3306 $this->row_selector_label = $row_selector_label;
3307 return $this;
3308 }
3309
3313 public function getRowSelectorLabel()
3314 {
3316 }
3317
3323 public function setPreventDoubleSubmission($a_val)
3324 {
3325 $this->prevent_double_submission = $a_val;
3326 }
3327
3334 {
3336 }
3337
3338 public function setLimit($a_limit = 0, $a_default_limit = 0)
3339 {
3340 parent::setLimit($a_limit, $a_default_limit);
3341
3342 // #17077 - if limit is set "manually" to 9999, force rows selector off
3343 if ($a_limit == 9999 &&
3344 $this->limit_determined) {
3345 $this->rows_selector_off = true;
3346 }
3347 }
3348}
$column
Definition: 39dropdown.php:62
$result
if(!isset( $_REQUEST[ 'ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
if(!array_key_exists('stateid', $_REQUEST)) $state
Handle linkback() response from LinkedIn.
Definition: linkback.php:10
$_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.
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.
setSelectAllCheckbox($a_select_all_checkbox)
Set the name of the checkbox that should be toggled with a select all button.
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.
const FILTER_NUMBER_RANGE
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 sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static img($a_src, $a_alt="", $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
if($format !==null) $name
Definition: metadata.php:146
$format
Definition: metadata.php:141
$end
Definition: saml1-acs.php:18
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
Definition: bootstrap.php:27
$type
$url
$old
global $DIC
Definition: saml.php:7
$ilUser
Definition: imgupload.php:18
$rows
Definition: xhr_table.php:10