ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
4 require_once("Services/Table/classes/class.ilTableGUI.php");
5 
15 class ilTable2GUI extends ilTableGUI
16 {
17  protected $close_command = "";
18  private $unique_id;
19  private $headerHTML;
20  protected $top_anchor = "il_table_top";
21  protected $filters = array();
22  protected $optional_filters = array();
23  protected $filter_cmd = 'applyFilter';
24  protected $reset_cmd = 'resetFilter';
25  protected $filter_cols = 5;
26  protected $ext_sort = false;
27  protected $ext_seg = false;
28  protected $context = "";
29 
30  protected $mi_sel_buttons = null;
31  protected $disable_filter_hiding = false;
32  protected $selected_filter = false;
33  protected $top_commands = true;
34  protected $selectable_columns = array();
35  protected $selected_column = array();
36  protected $show_templates = false;
37  protected $show_rows_selector = true; // JF, 2014-10-27
38  protected $rows_selector_off = false;
39 
40  protected $nav_determined= false;
41  protected $limit_determined = false;
42  protected $filters_determined = false;
43  protected $columns_determined = false;
44  protected $open_form_tag = true;
45  protected $close_form_tag = true;
46 
47  protected $export_formats;
48  protected $export_mode;
49  protected $print_mode;
50 
52  protected $restore_filter; // [bool]
53  protected $restore_filter_values; // [bool]
54 
58  protected $default_filter_visibility = false;
59 
60  protected $sortable_fields = array();
64  protected $prevent_double_submission = true;
65 
70 
71  const FILTER_TEXT = 1;
72  const FILTER_SELECT = 2;
73  const FILTER_DATE = 3;
74  const FILTER_LANGUAGE = 4;
76  const FILTER_DATE_RANGE = 6;
79 
80  const EXPORT_EXCEL = 1;
81  const EXPORT_CSV = 2;
82 
83  const ACTION_ALL_LIMIT = 1000;
84 
89  public function __construct($a_parent_obj, $a_parent_cmd = "", $a_template_context = "")
90  {
91  global $lng;
92 
93  parent::__construct(0, false);
94  $this->unique_id = md5(uniqid());
95  $this->parent_obj = $a_parent_obj;
96  $this->parent_cmd = $a_parent_cmd;
97  $this->buttons = array();
98  $this->header_commands = array();
99  $this->multi = array();
100  $this->hidden_inputs = array();
101  $this->formname = "table_" . $this->unique_id;
102  $this->tpl = new ilTemplate("tpl.table2.html", true, true, "Services/Table");
103 
104  $lng->loadLanguageModule('tbl');
105 
106  if(!$a_template_context)
107  {
108  $a_template_context = $this->getId();
109  }
110  $this->setContext($a_template_context);
111 
112  // activate export mode
113  if(isset($_GET[$this->prefix."_xpt"]))
114  {
115  $this->export_mode = (int)$_GET[$this->prefix."_xpt"];
116  }
117 
118  // template handling
119  if(isset($_GET[$this->prefix."_tpl"]))
120  {
121  $this->restoreTemplate($_GET[$this->prefix."_tpl"]);
122  }
123 
124  $this->determineLimit();
125  $this->setIsDataTable(true);
126  $this->setEnableNumInfo(true);
127  $this->determineSelectedColumns();
128  }
129 
135  function setOpenFormTag($a_val)
136  {
137  $this->open_form_tag = $a_val;
138  }
139 
145  function getOpenFormTag()
146  {
147  return $this->open_form_tag;
148  }
149 
155  function setCloseFormTag($a_val)
156  {
157  $this->close_form_tag = $a_val;
158  }
159 
165  function getCloseFormTag()
166  {
167  return $this->close_form_tag;
168  }
169 
173  function determineLimit()
174  {
175  global $ilUser;
176 
177  if ($this->limit_determined)
178  {
179  return;
180  }
181 
182  $limit = 0;
183  if (isset($_GET[$this->prefix."_trows"]))
184  {
185  $this->storeProperty("rows", $_GET[$this->prefix."_trows"]);
186  $limit = $_GET[$this->prefix."_trows"];
187  $this->resetOffset();
188  }
189 
190  if ($limit == 0)
191  {
192  $rows = $this->loadProperty("rows");
193  if ($rows > 0)
194  {
195  $limit = $rows;
196  }
197  else
198  {
199  if (is_object($ilUser))
200  {
201  $limit = $ilUser->getPref("hits_per_page");
202  }
203  else
204  {
205  $limit = 40;
206  }
207  }
208  }
209 
210  $this->setLimit($limit);
211  $this->limit_determined = true;
212  }
213 
220  {
221  return array();
222  }
223 
228  {
229  if ($this->columns_determined)
230  {
231  return;
232  }
233 
234  $old_sel = $this->loadProperty("selfields");
235 
236  $stored = false;
237  if ($old_sel != "")
238  {
239  $sel_fields =
240  @unserialize($old_sel);
241  $stored = true;
242  }
243  if(!is_array($sel_fields))
244  {
245  $stored = false;
246  $sel_fields = array();
247  }
248 
249  $this->selected_columns = array();
250  $set = false;
251  foreach ($this->getSelectableColumns() as $k => $c)
252  {
253  $this->selected_column[$k] = false;
254 
255  $new_column = ($sel_fields[$k] === NULL);
256 
257  if ($_POST["tblfsh".$this->getId()])
258  {
259  $set = true;
260  if (is_array($_POST["tblfs".$this->getId()]) && in_array($k, $_POST["tblfs".$this->getId()]))
261  {
262  $this->selected_column[$k] = true;
263  }
264  }
265  else if ($stored && !$new_column) // take stored values
266  {
267  $this->selected_column[$k] = $sel_fields[$k];
268  }
269  else // take default values
270  {
271  if ($new_column)
272  {
273  $set = true;
274  }
275  if ($c["default"])
276  {
277  $this->selected_column[$k] = true;
278  }
279  }
280  }
281 
282  if ($old_sel != serialize($this->selected_column) && $set)
283  {
284  $this->storeProperty("selfields", serialize($this->selected_column));
285  }
286 
287  $this->columns_determined = true;
288  }
289 
296  function isColumnSelected($a_col)
297  {
298  return $this->selected_column[$a_col];
299  }
300 
308  {
309  $scol = array();
310  foreach ($this->selected_column as $k => $v)
311  {
312  if ($v)
313  {
314  $scol[$k] = $k;
315  }
316  }
317  return $scol;
318  }
319 
323  function executeCommand()
324  {
325  global $ilCtrl;
326 
327  $next_class = $ilCtrl->getNextClass($this);
328  $cmd = $ilCtrl->getCmd();
329 
330  switch($next_class)
331  {
332  case 'ilformpropertydispatchgui':
333  include_once './Services/Form/classes/class.ilFormPropertyDispatchGUI.php';
334  $form_prop_dispatch = new ilFormPropertyDispatchGUI();
335  $this->initFilter();
336  $item = $this->getFilterItemByPostVar($_GET["postvar"]);
337  $form_prop_dispatch->setItem($item);
338  return $ilCtrl->forwardCommand($form_prop_dispatch);
339  break;
340 
341  }
342  return false;
343  }
344 
348  function resetOffset($a_in_determination = false)
349  {
350  if (!$this->nav_determined && !$a_in_determination)
351  {
352  $this->determineOffsetAndOrder();
353  }
354  $this->nav_value = $this->getOrderField().":".$this->getOrderDirection().":0";
355  $_GET[$this->getNavParameter()] =
356  $_POST[$this->getNavParameter()."1"] =
357  $this->nav_value;
358 //echo $this->nav_value;
359  $this->setOffset(0);
360  }
361 
366  function initFilter()
367  {
368  }
369 
375  public function getParentObject()
376  {
377  return $this->parent_obj;
378  }
379 
385  public function getParentCmd()
386  {
387  return $this->parent_cmd;
388  }
389 
395  function setTopAnchor($a_val)
396  {
397  $this->top_anchor = $a_val;
398  }
399 
405  function getTopAnchor()
406  {
407  return $this->top_anchor;
408  }
409 
415  function setNoEntriesText($a_text)
416  {
417  $this->noentriestext = $a_text;
418  }
419 
425  function getNoEntriesText()
426  {
427  return $this->noentriestext;
428  }
429 
435  function setIsDataTable($a_val)
436  {
437  $this->datatable = $a_val;
438  }
439 
445  function getIsDataTable()
446  {
447  return $this->datatable;
448  }
449 
455  function setEnableTitle($a_enabletitle)
456  {
457  $this->enabled["title"] = $a_enabletitle;
458  }
459 
465  function getEnableTitle()
466  {
467  return $this->enabled["title"];
468  }
469 
475  function setEnableHeader($a_enableheader)
476  {
477  $this->enabled["header"] = $a_enableheader;
478  }
479 
485  function getEnableHeader()
486  {
487  return $this->enabled["header"];
488  }
489 
495  function setEnableNumInfo($a_val)
496  {
497  $this->num_info = $a_val;
498  }
499 
505  function getEnableNumInfo()
506  {
507  return $this->num_info;
508  }
509 
513  final public function setTitle($a_title, $a_icon = 0, $a_icon_alt = 0)
514  {
515  parent::setTitle($a_title, $a_icon, $a_icon_alt);
516  }
517 
523  function setDescription($a_val)
524  {
525  $this->description = $a_val;
526  }
527 
533  function getDescription()
534  {
535  return $this->description;
536  }
537 
543  function setOrderField($a_order_field)
544  {
545  $this->order_field = $a_order_field;
546  }
547 
548  function getOrderField()
549  {
550  return $this->order_field;
551  }
552 
553  final public function setData($a_data)
554  {
555  // check column names against given data (to ensure proper sorting)
556  if(DEVMODE &&
557  $this->enabled["header"] && $this->enabled["sort"] &&
558  $this->columns_determined && is_array($this->column) &&
559  is_array($a_data) && sizeof($a_data) && !$this->getExternalSorting())
560  {
561  $check = $a_data;
562  $check = array_keys(array_shift($check));
563  foreach($this->column as $col)
564  {
565  if($col["sort_field"] && !in_array($col["sort_field"], $check))
566  {
567  $invalid[] = $col["sort_field"];
568  }
569  }
570 
571  // this triggers an error, if some columns are not set for some rows
572  // which may just be a representation of "null" values, e.g.
573  // ilAdvancedMDValues:queryForRecords works that way.
574 /* if(sizeof($invalid))
575  {
576  trigger_error("The following columns are defined as sortable but".
577  " cannot be found in the given data: ".implode(", ", $invalid).
578  ". Sorting will not work properly.", E_USER_WARNING);
579  }*/
580  }
581 
582  $this->row_data = $a_data;
583  }
584 
585  final public function getData()
586  {
587  return $this->row_data;
588  }
589 
590  final public function dataExists()
591  {
592  if (is_array($this->row_data))
593  {
594  if (count($this->row_data) > 0)
595  {
596  return true;
597  }
598  }
599  return false;
600  }
601 
602  final public function setPrefix($a_prefix)
603  {
604  $this->prefix = $a_prefix;
605  }
606 
607  final public function getPrefix()
608  {
609  return $this->prefix;
610  }
611 
616  final function addFilterItem($a_input_item, $a_optional = false)
617  {
618  $a_input_item->setParent($this);
619  if (!$a_optional)
620  {
621  $this->filters[] = $a_input_item;
622  }
623  else
624  {
625  $this->optional_filters[] = $a_input_item;
626  }
627 
628  // restore filter values (from stored view)
629  if($this->restore_filter)
630  {
631  if(array_key_exists($a_input_item->getFieldId(), $this->restore_filter_values))
632  {
633  $this->setFilterValue($a_input_item, $this->restore_filter_values[$a_input_item->getFieldId()]);
634  }
635  else
636  {
637  $this->setFilterValue($a_input_item, null); // #14949
638  }
639  }
640  }
641 
651  function addFilterItemByMetaType($id, $type = self::FILTER_TEXT, $a_optional = false, $caption = NULL)
652  {
653  global $lng;
654 
655  if(!$caption)
656  {
657  $caption = $lng->txt($id);
658  }
659 
660  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
661 
662  switch($type)
663  {
664  case self::FILTER_SELECT:
665  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
666  $item = new ilSelectInputGUI($caption, $id);
667  break;
668 
669  case self::FILTER_DATE:
670  include_once("./Services/Form/classes/class.ilDateTimeInputGUI.php");
671  $item = new ilDateTimeInputGUI($caption, $id);
672  break;
673 
674  case self::FILTER_TEXT:
675  include_once("./Services/Form/classes/class.ilTextInputGUI.php");
676  $item = new ilTextInputGUI($caption, $id);
677  $item->setMaxLength(64);
678  $item->setSize(20);
679  // $item->setSubmitFormOnEnter(true);
680  break;
681 
682  case self::FILTER_LANGUAGE:
683  $lng->loadLanguageModule("meta");
684  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
685  $item = new ilSelectInputGUI($caption, $id);
686  $options = array("" => $lng->txt("trac_all"));
687  foreach ($lng->getInstalledLanguages() as $lang_key)
688  {
689  $options[$lang_key] = $lng->txt("meta_l_".$lang_key);
690  }
691  $item->setOptions($options);
692  break;
693 
694  case self::FILTER_NUMBER_RANGE:
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 
707  case self::FILTER_DATE_RANGE:
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 
718  case self::FILTER_DATETIME_RANGE:
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 
731  case self::FILTER_DURATION_RANGE:
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 function getFilterItems($a_optionals = false)
762  {
763  if (!$a_optionals)
764  {
765  return $this->filters;
766  }
768  }
769 
770  final function getFilterItemByPostVar($a_post_var)
771  {
772  foreach ($this->getFilterItems() as $item)
773  {
774  if ($item->getPostVar() == $a_post_var)
775  {
776  return $item;
777  }
778  }
779  foreach ($this->getFilterItems(true) as $item)
780  {
781  if ($item->getPostVar() == $a_post_var)
782  {
783  return $item;
784  }
785  }
786  return false;
787  }
788 
794  function setFilterCols($a_val)
795  {
796  $this->filter_cols = $a_val;
797  }
798 
804  function getFilterCols()
805  {
806  return $this->filter_cols;
807  }
808 
814  function setDisableFilterHiding($a_val = true)
815  {
816  $this->disable_filter_hiding = $a_val;
817  }
818 
825  {
827  }
828 
835  function isFilterSelected($a_col)
836  {
837  return $this->selected_filter[$a_col];
838  }
839 
847  {
848  $sfil = array();
849  foreach ($this->selected_filter as $k => $v)
850  {
851  if ($v)
852  {
853  $sfil[$k] = $k;
854  }
855  }
856  return $sfil;
857  }
858 
866  {
867  if ($this->filters_determined)
868  {
869  return;
870  }
871 
872  $old_sel = $this->loadProperty("selfilters");
873  $stored = false;
874  if ($old_sel != "")
875  {
876  $sel_filters =
877  @unserialize($old_sel);
878  $stored = true;
879  }
880  if(!is_array($sel_filters))
881  {
882  $stored = false;
883  $sel_filters = array();
884  }
885 
886  $this->selected_filter = array();
887  $set = false;
888  foreach ($this->getFilterItems(true) as $item)
889  {
890  $k = $item->getPostVar();
891 
892  $this->selected_filter[$k] = false;
893 
894  if ($_POST["tblfsf".$this->getId()])
895  {
896  $set = true;
897  if (is_array($_POST["tblff".$this->getId()]) && in_array($k, $_POST["tblff".$this->getId()]))
898  {
899  $this->selected_filter[$k] = true;
900  }
901  else
902  {
903  $item->setValue(NULL);
904  $item->writeToSession();
905  }
906  }
907  else if ($stored) // take stored values
908  {
909  $this->selected_filter[$k] = $sel_filters[$k];
910  }
911  }
912 
913  if ($old_sel != serialize($this->selected_filter) && $set)
914  {
915  $this->storeProperty("selfilters", serialize($this->selected_filter));
916  }
917 
918  $this->filters_determined = true;
919  }
920 
924  function setCustomPreviousNext($a_prev_link, $a_next_link)
925  {
926  $this->custom_prev_next = true;
927  $this->custom_prev = $a_prev_link;
928  $this->custom_next = $a_next_link;
929  }
930 
937  final public function setFormAction($a_form_action, $a_multipart = false)
938  {
939  $this->form_action = $a_form_action;
940  $this->form_multipart = (bool)$a_multipart;
941  }
942 
948  final public function getFormAction()
949  {
950  return $this->form_action;
951  }
952 
958  function setFormName($a_formname = "")
959  {
960  $this->formname = $a_formname;
961  }
962 
968  function getFormName()
969  {
970  return $this->formname;
971  }
972 
978  function setId($a_val)
979  {
980  $this->id = $a_val;
981  if ($this->getPrefix() == "")
982  {
983  $this->setPrefix($a_val);
984  }
985  }
986 
992  function getId()
993  {
994  return $this->id;
995  }
996 
1002  function setDisplayAsBlock($a_val)
1003  {
1004  $this->display_as_block = $a_val;
1005  }
1006 
1013  {
1014  return $this->display_as_block;
1015  }
1016 
1023  {
1025  }
1026 
1032  function setSelectAllCheckbox($a_select_all_checkbox)
1033  {
1034  $this->select_all_checkbox = $a_select_all_checkbox;
1035  }
1036 
1042  function setExternalSorting($a_val)
1043  {
1044  $this->ext_sort = $a_val;
1045  }
1046 
1053  {
1054  return $this->ext_sort;
1055  }
1056 
1063  function setFilterCommand($a_val, $a_caption = null)
1064  {
1065  $this->filter_cmd = $a_val;
1066  $this->filter_cmd_txt = $a_caption;
1067  }
1068 
1074  function getFilterCommand()
1075  {
1076  return $this->filter_cmd;
1077  }
1078 
1085  function setResetCommand($a_val, $a_caption = null)
1086  {
1087  $this->reset_cmd = $a_val;
1088  $this->reset_cmd_txt = $a_caption;
1089  }
1090 
1096  function getResetCommand()
1097  {
1098  return $this->reset_cmd;
1099  }
1100 
1106  function setExternalSegmentation($a_val)
1107  {
1108  $this->ext_seg = $a_val;
1109  }
1110 
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  function setDefaultOrderField($a_defaultorderfield)
1139  {
1140  $this->defaultorderfield = $a_defaultorderfield;
1141  }
1142 
1149  {
1150  return $this->defaultorderfield;
1151  }
1152 
1158  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 
1186  public function getDefaultFilterVisibility()
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  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 
1219  {
1220  $this->buttons[] = $a_button;
1221  }
1222 
1233  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  function setCloseCommand($a_link)
1263  {
1264  $this->close_command = $a_link;
1265  }
1266 
1273  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  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  function setTopCommands($a_val)
1307  {
1308  $this->top_commands = $a_val;
1309  }
1310 
1316  function getTopCommands()
1317  {
1318  return $this->top_commands;
1319  }
1320 
1328  final public function addColumn($a_text, $a_sort_field = "", $a_width = "",
1329  $a_is_checkbox_action_column = false, $a_class = "", $a_tooltip = "", $a_tooltip_with_html = false)
1330  {
1331  $this->column[] = array(
1332  "text" => $a_text,
1333  "sort_field" => $a_sort_field,
1334  "width" => $a_width,
1335  "is_checkbox_action_column" => $a_is_checkbox_action_column,
1336  "class" => $a_class,
1337  "tooltip" => $a_tooltip,
1338  "tooltip_html" => (bool)$a_tooltip_with_html
1339  );
1340  if ($a_sort_field != "")
1341  {
1342  $this->sortable_fields[] = $a_sort_field;
1343  }
1344  $this->column_count = count($this->column);
1345  }
1346 
1347 
1348  final public function getNavParameter()
1349  {
1350  return $this->prefix."_table_nav";
1351  }
1352 
1353  function setOrderLink($sort_field, $order_dir)
1354  {
1355  global $ilCtrl, $ilUser;
1356 
1357  $hash = "";
1358  if (is_object($ilUser) && $ilUser->getPref("screen_reader_optimization"))
1359  {
1360  $hash = "#".$this->getTopAnchor();
1361  }
1362 
1363  $old = $_GET[$this->getNavParameter()];
1364 
1365  // set order link
1366  $ilCtrl->setParameter($this->parent_obj,
1367  $this->getNavParameter(),
1368  $sort_field.":".$order_dir.":".$this->offset);
1369  $this->tpl->setVariable("TBL_ORDER_LINK",
1370  $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd).$hash);
1371 
1372  // set old value of nav variable
1373  $ilCtrl->setParameter($this->parent_obj,
1374  $this->getNavParameter(), $old);
1375  }
1376 
1377  function fillHeader()
1378  {
1379  global $lng;
1380 
1381  $allcolumnswithwidth = true;
1382  foreach ((array) $this->column as $idx => $column)
1383  {
1384  if (!strlen($column["width"]))
1385  {
1386  $allcolumnswithwidth = false;
1387  }
1388  else if($column["width"] == "1")
1389  {
1390  // IE does not like 1 but seems to work with 1%
1391  $this->column[$idx]["width"] = "1%";
1392  }
1393  }
1394  if ($allcolumnswithwidth)
1395  {
1396  foreach ((array) $this->column as $column)
1397  {
1398  $this->tpl->setCurrentBlock("tbl_colgroup_column");
1399  $this->tpl->setVariable("COLGROUP_COLUMN_WIDTH", $column["width"]);
1400  $this->tpl->parseCurrentBlock();
1401  }
1402  }
1403  $ccnt = 0;
1404  foreach ((array) $this->column as $column)
1405  {
1406  $ccnt++;
1407  //tooltip
1408  if ($column["tooltip"] != "")
1409  {
1410  include_once("./Services/UIComponent/Tooltip/classes/class.ilTooltipGUI.php");
1411  ilTooltipGUI::addTooltip("thc_".$this->getId()."_".$ccnt, $column["tooltip"],
1412  "", "bottom center", "top center", !$column["tooltip_html"]);
1413  }
1414  if (!$this->enabled["sort"] || $column["sort_field"] == "" || $column["is_checkbox_action_column"])
1415  {
1416  $this->tpl->setCurrentBlock("tbl_header_no_link");
1417  if ($column["width"] != "")
1418  {
1419  $this->tpl->setVariable("TBL_COLUMN_WIDTH_NO_LINK"," width=\"".$column["width"]."\"");
1420  }
1421  if ($column["class"] != "")
1422  {
1423  $this->tpl->setVariable("TBL_COLUMN_CLASS_NO_LINK"," class=\"".$column["class"]."\"");
1424  }
1425  if (!$column["is_checkbox_action_column"])
1426  {
1427  $this->tpl->setVariable("TBL_HEADER_CELL_NO_LINK",
1428  $column["text"]);
1429  }
1430  else
1431  {
1432  $this->tpl->setVariable("TBL_HEADER_CELL_NO_LINK",
1433  ilUtil::img(ilUtil::getImagePath("spacer.png"), $lng->txt("action")));
1434  }
1435  $this->tpl->setVariable("HEAD_CELL_NL_ID", "thc_".$this->getId()."_".$ccnt);
1436  if ($column["class"] != "")
1437  {
1438  $this->tpl->setVariable("TBL_HEADER_CLASS"," " . $column["class"]);
1439  }
1440  $this->tpl->parseCurrentBlock();
1441  $this->tpl->touchBlock("tbl_header_th");
1442  continue;
1443  }
1444  if (($column["sort_field"] == $this->order_field) && ($this->order_direction != ""))
1445  {
1446  $this->tpl->setCurrentBlock("tbl_order_image");
1447  if ($this->order_direction == "asc")
1448  {
1449  $this->tpl->setVariable("ORDER_CLASS", "glyphicon glyphicon-arrow-up");
1450  }
1451  else
1452  {
1453  $this->tpl->setVariable("ORDER_CLASS", "glyphicon glyphicon-arrow-down");
1454  }
1455  $this->tpl->setVariable("IMG_ORDER_ALT", $this->lng->txt("change_sort_direction"));
1456  $this->tpl->parseCurrentBlock();
1457  }
1458 
1459  $this->tpl->setCurrentBlock("tbl_header_cell");
1460  $this->tpl->setVariable("TBL_HEADER_CELL", $column["text"]);
1461  $this->tpl->setVariable("HEAD_CELL_ID", "thc_".$this->getId()."_".$ccnt);
1462 
1463  // only set width if a value is given for that column
1464  if ($column["width"] != "")
1465  {
1466  $this->tpl->setVariable("TBL_COLUMN_WIDTH"," width=\"".$column["width"]."\"");
1467  }
1468  if ($column["class"] != "")
1469  {
1470  $this->tpl->setVariable("TBL_COLUMN_CLASS"," class=\"".$column["class"]."\"");
1471  }
1472 
1473  $lng_sort_column = $this->lng->txt("sort_by_this_column");
1474  $this->tpl->setVariable("TBL_ORDER_ALT",$lng_sort_column);
1475 
1476  $order_dir = "asc";
1477 
1478  if ($column["sort_field"] == $this->order_field)
1479  {
1480  $order_dir = $this->sort_order;
1481 
1482  $lng_change_sort = $this->lng->txt("change_sort_direction");
1483  $this->tpl->setVariable("TBL_ORDER_ALT",$lng_change_sort);
1484  }
1485 
1486  if ($column["class"] != "")
1487  {
1488  $this->tpl->setVariable("TBL_HEADER_CLASS"," " . $column["class"]);
1489  }
1490  $this->setOrderLink($column["sort_field"], $order_dir);
1491  $this->tpl->parseCurrentBlock();
1492  $this->tpl->touchBlock("tbl_header_th");
1493  }
1494 
1495  $this->tpl->setCurrentBlock("tbl_header");
1496  $this->tpl->parseCurrentBlock();
1497  }
1498 
1502  protected function prepareOutput()
1503  {
1504  }
1505 
1506 
1510  function determineOffsetAndOrder($a_omit_offset = false)
1511  {
1512  global $ilUser;
1513 
1514  if ($this->nav_determined)
1515  {
1516  return true;
1517  }
1518 
1519  if ($_POST[$this->getNavParameter()."1"] != "")
1520  {
1521  if ($_POST[$this->getNavParameter()."1"] != $_POST[$this->getNavParameter()])
1522  {
1523  $this->nav_value = $_POST[$this->getNavParameter()."1"];
1524  }
1525  else if ($_POST[$this->getNavParameter()."2"] != $_POST[$this->getNavParameter()])
1526  {
1527  $this->nav_value = $_POST[$this->getNavParameter()."2"];
1528  }
1529  }
1530  elseif($_GET[$this->getNavParameter()])
1531  {
1532  $this->nav_value = $_GET[$this->getNavParameter()];
1533  }
1534  elseif($_SESSION[$this->getNavParameter()] != "")
1535  {
1536  $this->nav_value = $_SESSION[$this->getNavParameter()];
1537  }
1538 
1539  if ($this->nav_value == "" && $this->getId() != "" && $ilUser->getId() != ANONYMOUS_USER_ID)
1540  {
1541  $order = $this->loadProperty("order");
1542  if (in_array($order, $this->sortable_fields))
1543  {
1544  $direction = $this->loadProperty("direction");
1545  }
1546  else
1547  {
1548  $direction = $this->getDefaultOrderDirection();
1549  }
1550  // get order and direction from db
1551  $this->nav_value =
1552  $order.":".
1553  $direction.":".
1554  $this->loadProperty("offset");
1555  }
1556  $nav = explode(":", $this->nav_value);
1557 
1558  // $nav[0] is order by
1559  $this->setOrderField(($nav[0] != "") ? $nav[0] : $this->getDefaultOrderField());
1560  $this->setOrderDirection(($nav[1] != "") ? $nav[1] : $this->getDefaultOrderDirection());
1561 
1562  if (!$a_omit_offset)
1563  {
1564  // #8904: offset must be discarded when no limit is given
1565  if(!$this->getExternalSegmentation() && $this->limit_determined && $this->limit == 9999)
1566  {
1567  $this->resetOffset(true);
1568  }
1569  else if (!$this->getExternalSegmentation() && $nav[2] >= $this->max_count)
1570  {
1571  $this->resetOffset(true);
1572  }
1573  else
1574  {
1575  $this->setOffset($nav[2]);
1576  }
1577  }
1578 
1579  if (!$a_omit_offset)
1580  {
1581  $this->nav_determined = true;
1582  }
1583  }
1584 
1586  {
1587  if ($this->getOrderField() != "")
1588  {
1589  $this->storeProperty("order", $this->getOrderField());
1590  }
1591  if ($this->getOrderDirection() != "")
1592  {
1593  $this->storeProperty("direction", $this->getOrderDirection());
1594  }
1595 //echo "-".$this->getOffset()."-";
1596  if ($this->getOffset() !== "")
1597  {
1598  $this->storeProperty("offset", $this->getOffset());
1599  }
1600  }
1601 
1602 
1606  public function getHTML()
1607  {
1608  global $lng, $ilCtrl, $ilUser;
1609 
1610  if($this->getExportMode())
1611  {
1612  $this->exportData($this->getExportMode(), true);
1613  }
1614 
1615  $this->prepareOutput();
1616 
1617  if (is_object($ilCtrl) && $this->getId() == "")
1618  {
1619  $ilCtrl->saveParameter($this->getParentObject(), $this->getNavParameter());
1620  }
1621 
1622  if(!$this->getPrintMode())
1623  {
1624  // set form action
1625  if ($this->form_action != "" && $this->getOpenFormTag())
1626  {
1627  $hash = "";
1628  if (is_object($ilUser) && $ilUser->getPref("screen_reader_optimization"))
1629  {
1630  $hash = "#".$this->getTopAnchor();
1631  }
1632 
1633  if((bool)$this->form_multipart)
1634  {
1635  $this->tpl->touchBlock("form_multipart_bl");
1636  }
1637 
1638  if($this->getPreventDoubleSubmission())
1639  {
1640  $this->tpl->touchBlock("pdfs");
1641  }
1642 
1643  $this->tpl->setCurrentBlock("tbl_form_header");
1644  $this->tpl->setVariable("FORMACTION", $this->getFormAction().$hash);
1645  $this->tpl->setVariable("FORMNAME", $this->getFormName());
1646  $this->tpl->parseCurrentBlock();
1647  }
1648 
1649  if ($this->form_action != "" && $this->getCloseFormTag())
1650  {
1651  $this->tpl->touchBlock("tbl_form_footer");
1652  }
1653  }
1654 
1655  if(!$this->enabled['content'])
1656  {
1657  return $this->render();
1658  }
1659 
1660  if (!$this->getExternalSegmentation())
1661  {
1662  $this->setMaxCount(count($this->row_data));
1663  }
1664 
1665  $this->determineOffsetAndOrder();
1666 
1667  $this->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
1668 
1669  $data = $this->getData();
1670  if($this->dataExists())
1671  {
1672  // sort
1673  if (!$this->getExternalSorting() && $this->enabled["sort"])
1674  {
1675  $data = ilUtil::sortArray($data, $this->getOrderField(),
1676  $this->getOrderDirection(), $this->numericOrdering($this->getOrderField()));
1677  }
1678 
1679  // slice
1680  if (!$this->getExternalSegmentation())
1681  {
1682  $data = array_slice($data, $this->getOffset(), $this->getLimit());
1683  }
1684  }
1685 
1686  // fill rows
1687  if($this->dataExists())
1688  {
1689  if($this->getPrintMode())
1690  {
1692  }
1693 
1694  $this->tpl->addBlockFile("TBL_CONTENT", "tbl_content", $this->row_template,
1695  $this->row_template_dir);
1696 
1697  foreach($data as $set)
1698  {
1699  $this->tpl->setCurrentBlock("tbl_content");
1700  $this->css_row = ($this->css_row != "tblrow1")
1701  ? "tblrow1"
1702  : "tblrow2";
1703  $this->tpl->setVariable("CSS_ROW", $this->css_row);
1704 
1705  $this->fillRow($set);
1706  $this->tpl->setCurrentBlock("tbl_content");
1707  $this->tpl->parseCurrentBlock();
1708  }
1709  }
1710  else
1711  {
1712  // add standard no items text (please tell me, if it messes something up, alex, 29.8.2008)
1713  $no_items_text = (trim($this->getNoEntriesText()) != '')
1714  ? $this->getNoEntriesText()
1715  : $lng->txt("no_items");
1716 
1717  $this->css_row = ($this->css_row != "tblrow1")
1718  ? "tblrow1"
1719  : "tblrow2";
1720 
1721  $this->tpl->setCurrentBlock("tbl_no_entries");
1722  $this->tpl->setVariable('TBL_NO_ENTRY_CSS_ROW', $this->css_row);
1723  $this->tpl->setVariable('TBL_NO_ENTRY_COLUMN_COUNT', $this->column_count);
1724  $this->tpl->setVariable('TBL_NO_ENTRY_TEXT', trim($no_items_text));
1725  $this->tpl->parseCurrentBlock();
1726  }
1727 
1728 
1729  if(!$this->getPrintMode())
1730  {
1731  $this->fillFooter();
1732 
1733  $this->fillHiddenRow();
1734 
1735  $this->fillActionRow();
1736 
1737  $this->storeNavParameter();
1738  }
1739 
1740  return $this->render();
1741  }
1742 
1748  function numericOrdering($a_field)
1749  {
1750  return false;
1751  }
1752 
1757  function render()
1758  {
1759  global $lng, $ilCtrl;
1760 
1761  $this->tpl->setVariable("CSS_TABLE",$this->getStyle("table"));
1762  $this->tpl->setVariable("DATA_TABLE", (int) $this->getIsDataTable());
1763  if ($this->getId() != "")
1764  {
1765  $this->tpl->setVariable("ID", 'id="'.$this->getId().'"');
1766  }
1767 
1768  // description
1769  if ($this->getDescription() != "")
1770  {
1771  $this->tpl->setCurrentBlock("tbl_header_description");
1772  $this->tpl->setVariable("TBL_DESCRIPTION", $this->getDescription());
1773  $this->tpl->parseCurrentBlock();
1774  }
1775 
1776  if(!$this->getPrintMode())
1777  {
1778  $this->renderFilter();
1779  }
1780 
1781  if ($this->getDisplayAsBlock())
1782  {
1783  $this->tpl->touchBlock("outer_start_1");
1784  $this->tpl->touchBlock("outer_end_1");
1785  }
1786  else
1787  {
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  {
1797  if ($this->enabled["icon"])
1798  {
1799  $this->tpl->setCurrentBlock("tbl_header_title_icon");
1800  $this->tpl->setVariable("TBL_TITLE_IMG",ilUtil::getImagePath($this->icon));
1801  $this->tpl->setVariable("TBL_TITLE_IMG_ALT",$this->icon_alt);
1802  $this->tpl->parseCurrentBlock();
1803  }
1804 
1805  if(!$this->getPrintMode())
1806  {
1807  foreach($this->header_commands as $command)
1808  {
1809  if ($command["img"] != "")
1810  {
1811  $this->tpl->setCurrentBlock("tbl_header_img_link");
1812  if ($command["target"] != "")
1813  {
1814  $this->tpl->setVariable("TARGET_IMG_LINK",
1815  'target="'.$command["target"].'"');
1816  }
1817  $this->tpl->setVariable("ALT_IMG_LINK", $command["text"]);
1818  $this->tpl->setVariable("HREF_IMG_LINK", $command["href"]);
1819  $this->tpl->setVariable("SRC_IMG_LINK",
1820  $command["img"]);
1821  $this->tpl->parseCurrentBlock();
1822  }
1823  else
1824  {
1825  $this->tpl->setCurrentBlock("head_cmd");
1826  $this->tpl->setVariable("TXT_HEAD_CMD", $command["text"]);
1827  $this->tpl->setVariable("HREF_HEAD_CMD", $command["href"]);
1828  $this->tpl->parseCurrentBlock();
1829  }
1830  }
1831  }
1832 
1833  if (isset ($this->headerHTML)) {
1834  $this->tpl->setCurrentBlock("tbl_header_html");
1835  $this->tpl->setVariable ("HEADER_HTML", $this->headerHTML);
1836  $this->tpl->parseCurrentBlock();
1837  }
1838 
1839  // close command
1840  if ($this->close_command != "")
1841  {
1842  $this->tpl->setCurrentBlock("tbl_header_img_link");
1843  $this->tpl->setVariable("ALT_IMG_LINK",$lng->txt("close"));
1844  $this->tpl->setVariable("HREF_IMG_LINK",$this->close_command);
1845  $this->tpl->parseCurrentBlock();
1846  }
1847 
1848  $this->tpl->setCurrentBlock("tbl_header_title");
1849  $this->tpl->setVariable("TBL_TITLE",$this->title);
1850  $this->tpl->setVariable("TOP_ANCHOR",$this->getTopAnchor());
1851  if ($this->getDisplayAsBlock())
1852  {
1853  $this->tpl->setVariable("BLK_CLASS", "Block");
1854  }
1855  $this->tpl->parseCurrentBlock();
1856  }
1857 
1858  // table header
1859  if ($this->enabled["header"])
1860  {
1861  $this->fillHeader();
1862  }
1863 
1864  $this->tpl->touchBlock("tbl_table_end");
1865 
1866  return $this->tpl->get();
1867  }
1868 
1872  private function renderFilter()
1873  {
1874  global $lng, $tpl;
1875 
1876  $filter = $this->getFilterItems();
1877  $opt_filter = $this->getFilterItems(true);
1878 
1879  $tpl->addJavascript("./Services/Table/js/ServiceTable.js");
1880 
1881  if (count($filter) == 0 && count($opt_filter) == 0)
1882  {
1883  return;
1884  }
1885 
1886  include_once("./Services/YUI/classes/class.ilYuiUtil.php");
1888 
1889  $ccnt = 0;
1890 
1891  // render standard filter
1892  if (count($filter) > 0)
1893  {
1894  foreach ($filter as $item)
1895  {
1896  if ($ccnt >= $this->getFilterCols())
1897  {
1898  $this->tpl->setCurrentBlock("filter_row");
1899  $this->tpl->parseCurrentBlock();
1900  $ccnt = 0;
1901  }
1902  $this->tpl->setCurrentBlock("filter_item");
1903  $this->tpl->setVariable("OPTION_NAME",
1904  $item->getTitle());
1905  $this->tpl->setVariable("F_INPUT_ID",
1906  $item->getFieldId());
1907  $this->tpl->setVariable("INPUT_HTML",
1908  $item->getTableFilterHTML());
1909  $this->tpl->parseCurrentBlock();
1910  $ccnt++;
1911  }
1912  }
1913 
1914  // render optional filter
1915  if (count($opt_filter) > 0)
1916  {
1917  $this->determineSelectedFilters();
1918 
1919  foreach ($opt_filter as $item)
1920  {
1921  if($this->isFilterSelected($item->getPostVar()))
1922  {
1923  if ($ccnt >= $this->getFilterCols())
1924  {
1925  $this->tpl->setCurrentBlock("filter_row");
1926  $this->tpl->parseCurrentBlock();
1927  $ccnt = 0;
1928  }
1929  $this->tpl->setCurrentBlock("filter_item");
1930  $this->tpl->setVariable("OPTION_NAME",
1931  $item->getTitle());
1932  $this->tpl->setVariable("F_INPUT_ID",
1933  $item->getFieldId());
1934  $this->tpl->setVariable("INPUT_HTML",
1935  $item->getTableFilterHTML());
1936  $this->tpl->parseCurrentBlock();
1937  $ccnt++;
1938  }
1939  }
1940 
1941  // filter selection
1942  $items = array();
1943  foreach ($opt_filter as $item)
1944  {
1945  $k = $item->getPostVar();
1946  $items[$k] = array("txt" => $item->getTitle(),
1947  "selected" => $this->isFilterSelected($k));
1948  }
1949 
1950  include_once("./Services/UIComponent/CheckboxListOverlay/classes/class.ilCheckboxListOverlayGUI.php");
1951  $cb_over = new ilCheckboxListOverlayGUI("tbl_filters_".$this->getId());
1952  $cb_over->setLinkTitle($lng->txt("optional_filters"));
1953  $cb_over->setItems($items);
1954 
1955  $cb_over->setFormCmd($this->getParentCmd());
1956  $cb_over->setFieldVar("tblff".$this->getId());
1957  $cb_over->setHiddenVar("tblfsf".$this->getId());
1958 
1959  $cb_over->setSelectionHeaderClass("ilTableMenuItem");
1960  $this->tpl->setCurrentBlock("filter_select");
1961 
1962  // apply should be the first submit because of enter/return, inserting hidden submit
1963  $this->tpl->setVariable("HIDDEN_CMD_APPLY", $this->filter_cmd);
1964 
1965  $this->tpl->setVariable("FILTER_SELECTOR", $cb_over->getHTML());
1966  $this->tpl->parseCurrentBlock();
1967  }
1968 
1969  // if any filter
1970  if($ccnt > 0 || count($opt_filter) > 0)
1971  {
1972  $this->tpl->setVariable("TXT_FILTER", $lng->txt("filter"));
1973 
1974  if($ccnt > 0)
1975  {
1976  if ($ccnt < $this->getFilterCols())
1977  {
1978  for($i = $ccnt; $i<=$this->getFilterCols(); $i++)
1979  {
1980  $this->tpl->touchBlock("filter_empty_cell");
1981  }
1982  }
1983  $this->tpl->setCurrentBlock("filter_row");
1984  $this->tpl->parseCurrentBlock();
1985 
1986  $this->tpl->setCurrentBlock("filter_buttons");
1987  $this->tpl->setVariable("CMD_APPLY", $this->filter_cmd);
1988  $this->tpl->setVariable("TXT_APPLY", $this->filter_cmd_txt
1989  ? $this->filter_cmd_txt
1990  : $lng->txt("apply_filter"));
1991  $this->tpl->setVariable("CMD_RESET", $this->reset_cmd);
1992  $this->tpl->setVariable("TXT_RESET", $this->reset_cmd_txt
1993  ? $this->reset_cmd_txt
1994  : $lng->txt("reset_filter"));
1995  }
1996  else if(count($opt_filter) > 0)
1997  {
1998  $this->tpl->setCurrentBlock("optional_filter_hint");
1999  $this->tpl->setVariable('TXT_OPT_HINT', $lng->txt('optional_filter_hint'));
2000  $this->tpl->parseCurrentBlock();
2001  }
2002 
2003  $this->tpl->setCurrentBlock("filter_section");
2004  $this->tpl->setVariable("FIL_ID", $this->getId());
2005  $this->tpl->parseCurrentBlock();
2006 
2007  // (keep) filter hidden?
2008  if(!$this->isFilterVisible())
2009  {
2010  if (!$this->getDisableFilterHiding())
2011  {
2012  $this->tpl->setCurrentBlock("filter_hidden");
2013  $this->tpl->setVariable("FI_ID", $this->getId());
2014  $this->tpl->parseCurrentBlock();
2015  }
2016  }
2017  }
2018  }
2019 
2024  protected function isFilterVisible()
2025  {
2026  $prop = $this->loadProperty('filter');
2027  if($prop === '0' || $prop === '1')
2028  {
2029  return (bool) $prop;
2030  }
2031  return $this->getDefaultFilterVisibility();
2032  }
2033 
2041  protected function isAdvMDFilter(ilAdvancedMDRecordGUI $a_gui, $a_element)
2042  {
2043  foreach($a_gui->getFilterElements(false) as $item)
2044  {
2045  if($item === $a_element)
2046  {
2047  return true;
2048  }
2049  }
2050  return false;
2051  }
2052 
2056  public function writeFilterToSession()
2057  {
2058  $advmd_record_gui = null;
2059  if(method_exists($this, "getAdvMDRecordGUI"))
2060  {
2061  $advmd_record_gui = $this->getAdvMDRecordGUI();
2062  }
2063 
2064  foreach ($this->getFilterItems() as $item)
2065  {
2066  if($advmd_record_gui &&
2067  $this->isAdvMDFilter($advmd_record_gui, $item))
2068  {
2069  continue;
2070  }
2071 
2072  if ($item->checkInput())
2073  {
2074  $item->setValueByArray($_POST);
2075  $item->writeToSession();
2076  }
2077  }
2078  foreach ($this->getFilterItems(true) as $item)
2079  {
2080  if($advmd_record_gui &&
2081  $this->isAdvMDFilter($advmd_record_gui, $item))
2082  {
2083  continue;
2084  }
2085 
2086  if ($item->checkInput())
2087  {
2088  $item->setValueByArray($_POST);
2089  $item->writeToSession();
2090  }
2091  }
2092 
2093  if($advmd_record_gui)
2094  {
2095  $advmd_record_gui->importFilter();
2096  }
2097 
2098  // #13209
2099  unset($_REQUEST["tbltplcrt"]);
2100  unset($_REQUEST["tbltpldel"]);
2101  }
2102 
2106  public function resetFilter()
2107  {
2108  global $lng;
2109 
2110  $filter = $this->getFilterItems();
2111  $opt_filter = $this->getFilterItems(true);
2112 
2113  foreach ($filter as $item)
2114  {
2115  if ($item->checkInput())
2116  {
2117  $item->setValueByArray($_POST);
2118  $item->clearFromSession();
2119  }
2120  }
2121  foreach ($opt_filter as $item)
2122  {
2123  if ($item->checkInput())
2124  {
2125  $item->setValueByArray($_POST);
2126  $item->clearFromSession();
2127  }
2128  }
2129 
2130  // #13209
2131  unset($_REQUEST["tbltplcrt"]);
2132  unset($_REQUEST["tbltpldel"]);
2133  }
2134 
2141  protected function fillRow($a_set)
2142  {
2143  foreach ($a_set as $key => $value)
2144  {
2145  $this->tpl->setVariable("VAL_".strtoupper($key), $value);
2146  }
2147  }
2148 
2152  function fillFooter()
2153  {
2154  global $lng, $ilCtrl, $ilUser;
2155 
2156  $footer = false;
2157 
2158  // select all checkbox
2159  if ((strlen($this->getFormName())) && (strlen($this->getSelectAllCheckbox())) && $this->dataExists())
2160  {
2161  $this->tpl->setCurrentBlock("select_all_checkbox");
2162  $this->tpl->setVariable("SELECT_ALL_TXT_SELECT_ALL", $lng->txt("select_all"));
2163  $this->tpl->setVariable("SELECT_ALL_CHECKBOX_NAME", $this->getSelectAllCheckbox());
2164  $this->tpl->setVariable("SELECT_ALL_FORM_NAME", $this->getFormName());
2165  $this->tpl->setVariable("CHECKBOXNAME", "chb_select_all_" . $this->unique_id);
2166  $this->tpl->parseCurrentBlock();
2167  }
2168 
2169  // table footer numinfo
2170  if ($this->enabled["numinfo"] && $this->enabled["footer"])
2171  {
2172  $start = $this->offset + 1; // compute num info
2173  if (!$this->dataExists())
2174  {
2175  $start = 0;
2176  }
2177  $end = $this->offset + $this->limit;
2178 
2179  if ($end > $this->max_count or $this->limit == 0)
2180  {
2181  $end = $this->max_count;
2182  }
2183 
2184  if ($this->max_count > 0)
2185  {
2186  if ($this->lang_support)
2187  {
2188  $numinfo = "(".$start." - ".$end." ".strtolower($this->lng->txt("of"))." ".$this->max_count.")";
2189  }
2190  else
2191  {
2192  $numinfo = "(".$start." - ".$end." of ".$this->max_count.")";
2193  }
2194  }
2195  if ($this->max_count > 0)
2196  {
2197  if ($this->getEnableNumInfo())
2198  {
2199  $this->tpl->setCurrentBlock("tbl_footer_numinfo");
2200  $this->tpl->setVariable("NUMINFO", $numinfo);
2201  $this->tpl->parseCurrentBlock();
2202  }
2203  }
2204  $footer = true;
2205  }
2206 
2207  // table footer linkbar
2208  if ($this->enabled["linkbar"] && $this->enabled["footer"] && $this->limit != 0
2209  && $this->max_count > 0)
2210  {
2211  $layout = array(
2212  "link" => $this->footer_style,
2213  "prev" => $this->footer_previous,
2214  "next" => $this->footer_next,
2215  );
2216  //if (!$this->getDisplayAsBlock())
2217  //{
2218  $linkbar = $this->getLinkbar("1");
2219  $this->tpl->setCurrentBlock("tbl_footer_linkbar");
2220  $this->tpl->setVariable("LINKBAR", $linkbar);
2221  $this->tpl->parseCurrentBlock();
2222  $linkbar = true;
2223  //}
2224  $footer = true;
2225  }
2226 
2227  // column selector
2228  if (count($this->getSelectableColumns()) > 0)
2229  {
2230  $items = array();
2231  foreach ($this->getSelectableColumns() as $k => $c)
2232  {
2233  $items[$k] = array("txt" => $c["txt"],
2234  "selected" => $this->isColumnSelected($k));
2235  }
2236  include_once("./Services/UIComponent/CheckboxListOverlay/classes/class.ilCheckboxListOverlayGUI.php");
2237  $cb_over = new ilCheckboxListOverlayGUI("tbl_".$this->getId());
2238  $cb_over->setLinkTitle($lng->txt("columns"));
2239  $cb_over->setItems($items);
2240  //$cb_over->setUrl("./ilias.php?baseClass=ilTablePropertiesStorage&table_id=".
2241  // $this->getId()."&cmd=saveSelectedFields&user_id=".$ilUser->getId());
2242  $cb_over->setFormCmd($this->getParentCmd());
2243  $cb_over->setFieldVar("tblfs".$this->getId());
2244  $cb_over->setHiddenVar("tblfsh".$this->getId());
2245  $cb_over->setSelectionHeaderClass("ilTableMenuItem");
2246  $column_selector = $cb_over->getHTML();
2247  $footer = true;
2248  }
2249 
2250  if($this->getShowTemplates() && is_object($ilUser))
2251  {
2252  // template handling
2253  if(isset($_REQUEST["tbltplcrt"]) && $_REQUEST["tbltplcrt"])
2254  {
2255  if($this->saveTemplate($_REQUEST["tbltplcrt"]))
2256  {
2257  ilUtil::sendSuccess($lng->txt("tbl_template_created"));
2258  }
2259  }
2260  else if(isset($_REQUEST["tbltpldel"]) && $_REQUEST["tbltpldel"])
2261  {
2262  if($this->deleteTemplate($_REQUEST["tbltpldel"]))
2263  {
2264  ilUtil::sendSuccess($lng->txt("tbl_template_deleted"));
2265  }
2266  }
2267 
2268  $create_id = "template_create_overlay_".$this->getId();
2269  $delete_id = "template_delete_overlay_".$this->getId();
2270  $list_id = "template_stg_".$this->getId();
2271 
2272  include_once("./Services/Table/classes/class.ilTableTemplatesStorage.php");
2273  $storage = new ilTableTemplatesStorage();
2274  $templates = $storage->getNames($this->getContext(), $ilUser->getId());
2275 
2276  include_once("./Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php");
2277 
2278  // form to delete template
2279  if(sizeof($templates))
2280  {
2281  $overlay = new ilOverlayGUI($delete_id);
2282  $overlay->setTrigger($list_id."_delete");
2283  $overlay->setAnchor("ilAdvSelListAnchorElement_".$list_id);
2284  $overlay->setAutoHide(false);
2285  $overlay->add();
2286 
2287  $lng->loadLanguageModule("form");
2288  $this->tpl->setCurrentBlock("template_editor_delete_item");
2289  $this->tpl->setVariable("TEMPLATE_DELETE_OPTION_VALUE", "");
2290  $this->tpl->setVariable("TEMPLATE_DELETE_OPTION", "- ".$lng->txt("form_please_select")." -");
2291  $this->tpl->parseCurrentBlock();
2292  foreach($templates as $name)
2293  {
2294  $this->tpl->setVariable("TEMPLATE_DELETE_OPTION_VALUE", $name);
2295  $this->tpl->setVariable("TEMPLATE_DELETE_OPTION", $name);
2296  $this->tpl->parseCurrentBlock();
2297  }
2298 
2299  $this->tpl->setCurrentBlock("template_editor_delete");
2300  $this->tpl->setVariable("TEMPLATE_DELETE_ID", $delete_id);
2301  $this->tpl->setVariable("TXT_TEMPLATE_DELETE", $lng->txt("tbl_template_delete"));
2302  $this->tpl->setVariable("TXT_TEMPLATE_DELETE_SUBMIT", $lng->txt("delete"));
2303  $this->tpl->setVariable("TEMPLATE_DELETE_CMD", $this->parent_cmd);
2304  $this->tpl->parseCurrentBlock();
2305  }
2306 
2307 
2308  // form to save new template
2309  $overlay = new ilOverlayGUI($create_id);
2310  $overlay->setTrigger($list_id."_create");
2311  $overlay->setAnchor("ilAdvSelListAnchorElement_".$list_id);
2312  $overlay->setAutoHide(false);
2313  $overlay->add();
2314 
2315  $this->tpl->setCurrentBlock("template_editor");
2316  $this->tpl->setVariable("TEMPLATE_CREATE_ID", $create_id);
2317  $this->tpl->setVariable("TXT_TEMPLATE_CREATE", $lng->txt("tbl_template_create"));
2318  $this->tpl->setVariable("TXT_TEMPLATE_CREATE_SUBMIT", $lng->txt("save"));
2319  $this->tpl->setVariable("TEMPLATE_CREATE_CMD", $this->parent_cmd);
2320  $this->tpl->parseCurrentBlock();
2321 
2322  // load saved template
2323  include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
2324  $alist = new ilAdvancedSelectionListGUI();
2325  $alist->setId($list_id);
2326  $alist->addItem($lng->txt("tbl_template_create"), "create", "#");
2327  if(sizeof($templates))
2328  {
2329  $alist->addItem($lng->txt("tbl_template_delete"), "delete", "#");
2330  foreach($templates as $name)
2331  {
2332  $ilCtrl->setParameter($this->parent_obj, $this->prefix."_tpl", urlencode($name));
2333  $alist->addItem($name, $name, $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd));
2334  $ilCtrl->setParameter($this->parent_obj, $this->prefix."_tpl", "");
2335  }
2336  }
2337  $alist->setListTitle($lng->txt("tbl_templates"));
2339  $this->tpl->setVariable("TEMPLATE_SELECTOR", "&nbsp;".$alist->getHTML());
2340  }
2341 
2342  if ($footer)
2343  {
2344  $this->tpl->setCurrentBlock("tbl_footer");
2345  $this->tpl->setVariable("COLUMN_COUNT", $this->getColumnCount());
2346  if ($this->getDisplayAsBlock())
2347  {
2348  $this->tpl->setVariable("BLK_CLASS", "Block");
2349  }
2350  $this->tpl->parseCurrentBlock();
2351 
2352  // top navigation, if number info or linkbar given
2353  if ($numinfo != "" || $linkbar != "" || $column_selector != "" ||
2354  count($this->filters) > 0 || count($this->optional_filters) > 0)
2355  {
2356  if (is_object($ilUser) && (count($this->filters) || count($this->optional_filters)))
2357  {
2358  $this->tpl->setCurrentBlock("filter_activation");
2359  $this->tpl->setVariable("TXT_ACTIVATE_FILTER", $lng->txt("show_filter"));
2360  $this->tpl->setVariable("FILA_ID", $this->getId());
2361  if ($this->getId() != "")
2362  {
2363  $this->tpl->setVariable("SAVE_URLA", "./ilias.php?baseClass=ilTablePropertiesStorage&table_id=".
2364  $this->getId()."&cmd=showFilter&user_id=".$ilUser->getId());
2365  }
2366  $this->tpl->parseCurrentBlock();
2367 
2368 
2369  if (!$this->getDisableFilterHiding())
2370  {
2371  $this->tpl->setCurrentBlock("filter_deactivation");
2372  $this->tpl->setVariable("TXT_HIDE", $lng->txt("hide_filter"));
2373  if ($this->getId() != "")
2374  {
2375  $this->tpl->setVariable("SAVE_URL", "./ilias.php?baseClass=ilTablePropertiesStorage&table_id=".
2376  $this->getId()."&cmd=hideFilter&user_id=".$ilUser->getId());
2377  $this->tpl->setVariable("FILD_ID", $this->getId());
2378  }
2379  $this->tpl->parseCurrentBlock();
2380  }
2381 
2382  }
2383 
2384  if ($numinfo != "" && $this->getEnableNumInfo())
2385  {
2386  $this->tpl->setCurrentBlock("top_numinfo");
2387  $this->tpl->setVariable("NUMINFO", $numinfo);
2388  $this->tpl->parseCurrentBlock();
2389  }
2390  if ($linkbar != "" && !$this->getDisplayAsBlock())
2391  {
2392  $linkbar = $this->getLinkbar("2");
2393  $this->tpl->setCurrentBlock("top_linkbar");
2394  $this->tpl->setVariable("LINKBAR", $linkbar);
2395  $this->tpl->parseCurrentBlock();
2396  }
2397 
2398  // column selector
2399  $this->tpl->setVariable("COLUMN_SELECTOR", $column_selector);
2400 
2401  // row selector
2402  if ($this->getShowRowsSelector() &&
2403  is_object($ilUser) &&
2404  $this->getId() &&
2405  !$this->rows_selector_off) // JF, 2014-10-27
2406  {
2407  include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
2408  $alist = new ilAdvancedSelectionListGUI();
2410  $alist->setId("sellst_rows_".$this->getId());
2411  $hpp = ($ilUser->getPref("hits_per_page") != 9999)
2412  ? $ilUser->getPref("hits_per_page")
2413  : $lng->txt("no_limit");
2414 
2415  $options = array(0 => $lng->txt("default")." (".$hpp.")",5 => 5, 10 => 10, 15 => 15, 20 => 20,
2416  30 => 30, 40 => 40, 50 => 50,
2417  100 => 100, 200 => 200, 400 => 400, 800 => 800);
2418  foreach ($options as $k => $v)
2419  {
2420  $ilCtrl->setParameter($this->parent_obj, $this->prefix."_trows", $k);
2421  $alist->addItem($v, $k, $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd));
2422  $ilCtrl->setParameter($this->parent_obj, $this->prefix."_trows", "");
2423  }
2424  $alist->setListTitle($this->getRowSelectorLabel() ? $this->getRowSelectorLabel() : $lng->txt("rows"));
2425  $this->tpl->setVariable("ROW_SELECTOR", $alist->getHTML());
2426  }
2427 
2428  // export
2429  if(sizeof($this->export_formats) && $this->dataExists())
2430  {
2431  include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
2432  $alist = new ilAdvancedSelectionListGUI();
2434  $alist->setId("sellst_xpt");
2435  foreach($this->export_formats as $format => $caption_lng_id)
2436  {
2437  $ilCtrl->setParameter($this->parent_obj, $this->prefix."_xpt", $format);
2438  $url = $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd);
2439  $ilCtrl->setParameter($this->parent_obj, $this->prefix."_xpt", "");
2440  $alist->addItem($lng->txt($caption_lng_id), $format, $url);
2441  }
2442  $alist->setListTitle($lng->txt("export"));
2443  $this->tpl->setVariable("EXPORT_SELECTOR", "&nbsp;".$alist->getHTML());
2444  }
2445 
2446  $this->tpl->setCurrentBlock("top_navigation");
2447  $this->tpl->setVariable("COLUMN_COUNT", $this->getColumnCount());
2448  if ($this->getDisplayAsBlock())
2449  {
2450  $this->tpl->setVariable("BLK_CLASS", "Block");
2451  }
2452  $this->tpl->parseCurrentBlock();
2453  }
2454  }
2455  }
2456 
2464  function getLinkbar($a_num)
2465  {
2466  global $ilCtrl, $lng, $ilUser;
2467 
2468  $hash = "";
2469  if (is_object($ilUser) && $ilUser->getPref("screen_reader_optimization"))
2470  {
2471  $hash = "#".$this->getTopAnchor();
2472  }
2473 
2474  $link = $ilCtrl->getLinkTargetByClass(get_class($this->parent_obj), $this->parent_cmd).
2475  "&".$this->getNavParameter()."=".
2476  $this->getOrderField().":".$this->getOrderDirection().":";
2477 
2478  $LinkBar = "";
2479  $layout_prev = $lng->txt("previous");
2480  $layout_next = $lng->txt("next");
2481 
2482  // if more entries then entries per page -> show link bar
2483  if ($this->max_count > $this->getLimit() || $this->custom_prev_next)
2484  {
2485  $sep = "<span>&nbsp;&nbsp;|&nbsp;&nbsp;</span>";
2486 
2487  // calculate number of pages
2488  $pages = intval($this->max_count / $this->getLimit());
2489 
2490  // add a page if a rest remains
2491  if (($this->max_count % $this->getLimit()))
2492  $pages++;
2493 
2494  // links to other pages
2495  $offset_arr = array();
2496  for ($i = 1 ;$i <= $pages ; $i++)
2497  {
2498  $newoffset = $this->getLimit() * ($i-1);
2499 
2500  $nav_value = $this->getOrderField().":".$this->getOrderDirection().":".$newoffset;
2501  $offset_arr[$nav_value] = $i;
2502  }
2503 
2504  $sep = "<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>";
2505 
2506  // previous link
2507  if ($this->custom_prev_next && $this->custom_prev != "")
2508  {
2509  if ($LinkBar != "")
2510  $LinkBar .= $sep;
2511  $LinkBar .= "<a href=\"".$this->custom_prev.$hash."\">".$layout_prev."</a>";
2512  }
2513  else if ($this->getOffset() >= 1 && !$this->custom_prev_next)
2514  {
2515  if ($LinkBar != "")
2516  $LinkBar .= $sep;
2517  $prevoffset = $this->getOffset() - $this->getLimit();
2518  $LinkBar .= "<a href=\"".$link.$prevoffset.$hash."\">".$layout_prev."</a>";
2519  }
2520  else
2521  {
2522  if ($LinkBar != "")
2523  $LinkBar .= $sep;
2524  $LinkBar .= '<span class="ilTableFootLight">'.$layout_prev."</span>";
2525  }
2526 
2527  // current value
2528  if ($a_num == "1")
2529  {
2530  $LinkBar .= '<input type="hidden" name="'.$this->getNavParameter().
2531  '" value="'.$this->getOrderField().":".$this->getOrderDirection().":".$this->getOffset().'" />';
2532  }
2533 
2534  $sep = "<span>&nbsp;&nbsp;|&nbsp;&nbsp;</span>";
2535 
2536  // show next link (if not last page)
2537  if ($this->custom_prev_next && $this->custom_next != "")
2538  {
2539  if ($LinkBar != "")
2540  $LinkBar .= $sep;
2541  $LinkBar .= "<a href=\"".$this->custom_next.$hash."\">".$layout_next."</a>";
2542  }
2543  else if (! ( ($this->getOffset() / $this->getLimit())==($pages-1) ) && ($pages!=1) &&
2544  !$this->custom_prev_next)
2545  {
2546  if ($LinkBar != "")
2547  $LinkBar .= $sep;
2548  $newoffset = $this->getOffset() + $this->getLimit();
2549  $LinkBar .= "<a href=\"".$link.$newoffset.$hash."\">".$layout_next."</a>";
2550  }
2551  else
2552  {
2553  if ($LinkBar != "")
2554  $LinkBar .= $sep;
2555  $LinkBar .= '<span class="ilTableFootLight">'.$layout_next."</span>";
2556  }
2557 
2558  $sep = "<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>";
2559 
2560  if (count($offset_arr) && !$this->getDisplayAsBlock() && !$this->custom_prev_next)
2561  {
2562  if ($LinkBar != "")
2563  $LinkBar .= $sep;
2564  $LinkBar .= "".
2565  '<label for="tab_page_sel_'.$a_num.'">'.$lng->txt("page").'</label> '.
2566  ilUtil::formSelect($this->nav_value,
2567  $this->getNavParameter().$a_num, $offset_arr, false, true, 0, "small",
2568  array("id" => "tab_page_sel_".$a_num,
2569  "onchange" => "ilTablePageSelection(this, 'cmd[".$this->parent_cmd."]')"));
2570  //' <input class="submit" type="submit" name="cmd['.$this->parent_cmd.']" value="'.
2571  //$lng->txt("ok").'" />';
2572  }
2573 
2574  return $LinkBar;
2575  }
2576  else
2577  {
2578  return false;
2579  }
2580  }
2581 
2582  function fillHiddenRow()
2583  {
2584  $hidden_row = false;
2585  if(count($this->hidden_inputs))
2586  {
2587  foreach ($this->hidden_inputs as $hidden_input)
2588  {
2589  $this->tpl->setCurrentBlock("tbl_hidden_field");
2590  $this->tpl->setVariable("FIELD_NAME", $hidden_input["name"]);
2591  $this->tpl->setVariable("FIELD_VALUE", $hidden_input["value"]);
2592  $this->tpl->parseCurrentBlock();
2593  }
2594 
2595  $this->tpl->setCurrentBlock("tbl_hidden_row");
2596  $this->tpl->parseCurrentBlock();
2597  }
2598  }
2599 
2603  function fillActionRow()
2604  {
2605  global $lng;
2606 
2607  // action row
2608  $action_row = false;
2609  $arrow = false;
2610 
2611  // add selection buttons
2612  if (count($this->sel_buttons) > 0)
2613  {
2614  foreach ($this->sel_buttons as $button)
2615  {
2616  $this->tpl->setCurrentBlock("sel_button");
2617  $this->tpl->setVariable("SBUTTON_SELECT",
2618  ilUtil::formSelect($button["selected"], $button["sel_var"],
2619  $button["options"], false, true));
2620  $this->tpl->setVariable("SBTN_NAME", $button["cmd"]);
2621  $this->tpl->setVariable("SBTN_VALUE", $button["text"]);
2622  $this->tpl->parseCurrentBlock();
2623 
2624  if ($this->getTopCommands())
2625  {
2626  $this->tpl->setCurrentBlock("sel_top_button");
2627  $this->tpl->setVariable("SBUTTON_SELECT",
2628  ilUtil::formSelect($button["selected"], $button["sel_var"],
2629  $button["options"], false, true));
2630  $this->tpl->setVariable("SBTN_NAME", $button["cmd"]);
2631  $this->tpl->setVariable("SBTN_VALUE", $button["text"]);
2632  $this->tpl->parseCurrentBlock();
2633  }
2634  }
2635  $buttons = true;
2636  $action_row = true;
2637  }
2638  $this->sel_buttons[] = array("options" => $a_options, "cmd" => $a_cmd, "text" => $a_text);
2639 
2640  // add buttons
2641  if (count($this->buttons) > 0)
2642  {
2643  foreach ($this->buttons as $button)
2644  {
2645  if(!is_array($button))
2646  {
2647  if($button instanceof ilButtonBase)
2648  {
2649  $this->tpl->setVariable('BUTTON_OBJ', $button->render());
2650 
2651  // this will remove id - should be unique
2652  $button = clone $button;
2653 
2654  $this->tpl->setVariable('BUTTON_TOP_OBJ', $button->render());
2655  }
2656  continue;
2657  }
2658 
2659  if (strlen($button['onclick']))
2660  {
2661  $this->tpl->setCurrentBlock('cmdonclick');
2662  $this->tpl->setVariable('CMD_ONCLICK', $button['onclick']);
2663  $this->tpl->parseCurrentBlock();
2664  }
2665  $this->tpl->setCurrentBlock("plain_button");
2666  if ($button["id"] != "")
2667  {
2668  $this->tpl->setVariable("PBID", ' id="'.$button["id"].'" ');
2669  }
2670  if ($button["class"] != "")
2671  {
2672  $this->tpl->setVariable("PBBT_CLASS", ' '.$button["class"]);
2673  }
2674  $this->tpl->setVariable("PBTN_NAME", $button["cmd"]);
2675  $this->tpl->setVariable("PBTN_VALUE", $button["text"]);
2676  $this->tpl->parseCurrentBlock();
2677 
2678  if ($this->getTopCommands())
2679  {
2680  if (strlen($button['onclick']))
2681  {
2682  $this->tpl->setCurrentBlock('top_cmdonclick');
2683  $this->tpl->setVariable('CMD_ONCLICK', $button['onclick']);
2684  $this->tpl->parseCurrentBlock();
2685  }
2686  $this->tpl->setCurrentBlock("plain_top_button");
2687  $this->tpl->setVariable("PBTN_NAME", $button["cmd"]);
2688  $this->tpl->setVariable("PBTN_VALUE", $button["text"]);
2689  if ($button["class"] != "")
2690  {
2691  $this->tpl->setVariable("PBBT_CLASS", ' '.$button["class"]);
2692  }
2693  $this->tpl->parseCurrentBlock();
2694  }
2695  }
2696 
2697  $buttons = true;
2698  $action_row = true;
2699  }
2700 
2701  // multi selection
2702  if(count($this->mi_sel_buttons))
2703  {
2704  foreach ($this->mi_sel_buttons as $button)
2705  {
2706  $this->tpl->setCurrentBlock("mi_sel_button");
2707  $this->tpl->setVariable("MI_BUTTON_SELECT",
2708  ilUtil::formSelect($button["selected"], $button["sel_var"],
2709  $button["options"], false, true));
2710  $this->tpl->setVariable("MI_BTN_NAME", $button["cmd"]);
2711  $this->tpl->setVariable("MI_BTN_VALUE", $button["text"]);
2712  $this->tpl->parseCurrentBlock();
2713 
2714  if ($this->getTopCommands())
2715  {
2716  $this->tpl->setCurrentBlock("mi_top_sel_button");
2717  $this->tpl->setVariable("MI_BUTTON_SELECT",
2718  ilUtil::formSelect($button["selected"], $button["sel_var"]."_2",
2719  $button["options"], false, true));
2720  $this->tpl->setVariable("MI_BTN_NAME", $button["cmd"]);
2721  $this->tpl->setVariable("MI_BTN_VALUE", $button["text"]);
2722  $this->tpl->parseCurrentBlock();
2723  }
2724 
2725  }
2726  $arrow = true;
2727  $action_row = true;
2728  }
2729 
2730 
2731  if (count($this->multi) > 1 && $this->dataExists())
2732  {
2733  if($this->enable_command_for_all && $this->max_count <= self::getAllCommandLimit())
2734  {
2735  $this->tpl->setCurrentBlock("tbl_cmd_select_all");
2736  $this->tpl->setVariable("TXT_SELECT_CMD_ALL", $lng->txt("all_objects"));
2737  $this->tpl->parseCurrentBlock();
2738  }
2739 
2740  $this->tpl->setCurrentBlock("tbl_cmd_select");
2741  $sel = array();
2742  foreach ($this->multi as $mc)
2743  {
2744  $sel[$mc["cmd"]] = $mc["text"];
2745  }
2746  $this->tpl->setVariable("SELECT_CMDS",
2747  ilUtil::formSelect("", "selected_cmd", $sel, false, true));
2748  $this->tpl->setVariable("TXT_EXECUTE", $lng->txt("execute"));
2749  $this->tpl->parseCurrentBlock();
2750  $arrow = true;
2751  $action_row = true;
2752 
2753  if ($this->getTopCommands())
2754  {
2755  if($this->enable_command_for_all && $this->max_count <= self::getAllCommandLimit())
2756  {
2757  $this->tpl->setCurrentBlock("tbl_top_cmd_select_all");
2758  $this->tpl->setVariable("TXT_SELECT_CMD_ALL", $lng->txt("all_objects"));
2759  $this->tpl->parseCurrentBlock();
2760  }
2761 
2762  $this->tpl->setCurrentBlock("tbl_top_cmd_select");
2763  $sel = array();
2764  foreach ($this->multi as $mc)
2765  {
2766  $sel[$mc["cmd"]] = $mc["text"];
2767  }
2768  $this->tpl->setVariable("SELECT_CMDS",
2769  ilUtil::formSelect("", "selected_cmd2", $sel, false, true));
2770  $this->tpl->setVariable("TXT_EXECUTE", $lng->txt("execute"));
2771  $this->tpl->parseCurrentBlock();
2772  }
2773  }
2774  elseif(count($this->multi) == 1 && $this->dataExists())
2775  {
2776  $this->tpl->setCurrentBlock("tbl_single_cmd");
2777  $sel = array();
2778  foreach ($this->multi as $mc)
2779  {
2780  $cmd = $mc['cmd'];
2781  $txt = $mc['text'];
2782  }
2783  $this->tpl->setVariable("TXT_SINGLE_CMD",$txt);
2784  $this->tpl->setVariable("SINGLE_CMD",$cmd);
2785  $this->tpl->parseCurrentBlock();
2786  $arrow = true;
2787  $action_row = true;
2788 
2789  if ($this->getTopCommands())
2790  {
2791  $this->tpl->setCurrentBlock("tbl_top_single_cmd");
2792  $sel = array();
2793  foreach ($this->multi as $mc)
2794  {
2795  $cmd = $mc['cmd'];
2796  $txt = $mc['text'];
2797  }
2798  $this->tpl->setVariable("TXT_SINGLE_CMD",$txt);
2799  $this->tpl->setVariable("SINGLE_CMD",$cmd);
2800  $this->tpl->parseCurrentBlock();
2801  }
2802  }
2803 
2804  if ($arrow)
2805  {
2806  $this->tpl->setCurrentBlock("tbl_action_img_arrow");
2807  $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.svg"));
2808  $this->tpl->setVariable("ALT_ARROW", $lng->txt("action"));
2809  $this->tpl->parseCurrentBlock();
2810 
2811  if ($this->getTopCommands())
2812  {
2813  $this->tpl->setCurrentBlock("tbl_top_action_img_arrow");
2814  $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_upright.svg"));
2815  $this->tpl->setVariable("ALT_ARROW", $lng->txt("action"));
2816  $this->tpl->parseCurrentBlock();
2817  }
2818  }
2819 
2820  if ($action_row)
2821  {
2822  $this->tpl->setCurrentBlock("tbl_action_row");
2823  $this->tpl->parseCurrentBlock();
2824  if ($this->getTopCommands())
2825  {
2826  $this->tpl->setCurrentBlock("tbl_top_action_row");
2827  $this->tpl->parseCurrentBlock();
2828  }
2829  }
2830  }
2831 
2837  public function setHeaderHTML($html)
2838  {
2839  $this->headerHTML = $html;
2840  }
2841 
2848  function storeProperty($type, $value)
2849  {
2850  global $ilUser;
2851 
2852  if(is_object($ilUser) && $this->getId() != "")
2853  {
2854  include_once("./Services/Table/classes/class.ilTablePropertiesStorage.php");
2855  $tab_prop = new ilTablePropertiesStorage();
2856 
2857  $tab_prop->storeProperty($this->getId(), $ilUser->getId(), $type, $value);
2858  }
2859  }
2860 
2867  function loadProperty($type)
2868  {
2869  global $ilUser;
2870 
2871  if(is_object($ilUser) && $this->getId() != "")
2872  {
2873  include_once("./Services/Table/classes/class.ilTablePropertiesStorage.php");
2874  $tab_prop = new ilTablePropertiesStorage();
2875 
2876  return $tab_prop->getProperty($this->getId(), $ilUser->getId(), $type);
2877  }
2878  return null;
2879  }
2880 
2886  public function getCurrentState()
2887  {
2888  $this->determineOffsetAndOrder();
2889  $this->determineLimit();
2890  $this->determineSelectedColumns();
2891  $this->determineSelectedFilters();
2892 
2893  // "filter" show/hide is not saved
2894 
2895  $result = array();
2896  $result["order"] = $this->getOrderField();
2897  $result["direction"] = $this->getOrderDirection();
2898  $result["offset"] = $this->getOffset();
2899  $result["rows"] = $this->getLimit();
2900  $result["selfilters"] = $this->getSelectedFilters();
2901 
2902  // #9514 - $this->getSelectedColumns() will omit deselected, leading to
2903  // confusion on restoring template
2904  $result["selfields"] = $this->selected_column;
2905 
2906  // gather filter values
2907  if($this->filters)
2908  {
2909  foreach($this->filters as $item)
2910  {
2911  $result["filter_values"][$item->getFieldId()] = $this->getFilterValue($item);
2912  }
2913  }
2914  if($this->optional_filters && $result["selfilters"])
2915  {
2916  foreach($this->optional_filters as $item)
2917  {
2918  if(in_array($item->getFieldId(), $result["selfilters"]))
2919  {
2920  $result["filter_values"][$item->getFieldId()] = $this->getFilterValue($item);
2921  }
2922  }
2923  }
2924 
2925  return $result;
2926  }
2927 
2934  protected function getFilterValue(ilFormPropertyGUI $a_item)
2935  {
2936  if(method_exists($a_item, "getChecked"))
2937  {
2938  return $a_item->getChecked();
2939  }
2940  else if(method_exists($a_item, "getValue"))
2941  {
2942  return $a_item->getValue();
2943  }
2944  else if(method_exists($a_item, "getDate"))
2945  {
2946  return $a_item->getDate()->get(IL_CAL_DATE);
2947  }
2948  }
2949 
2956  protected function SetFilterValue(ilFormPropertyGUI $a_item, $a_value)
2957  {
2958  if(method_exists($a_item, "setChecked"))
2959  {
2960  $a_item->setChecked($a_value);
2961  }
2962  else if(method_exists($a_item, "setValue"))
2963  {
2964  $a_item->setValue($a_value);
2965  }
2966  else if(method_exists($a_item, "setDate"))
2967  {
2968  $a_item->setDate(new ilDate($a_value, IL_CAL_DATE));
2969  }
2970  $a_item->writeToSession();
2971  }
2972 
2978  public function setContext($id)
2979  {
2980  if(trim($id))
2981  {
2982  $this->context = $id;
2983  }
2984  }
2985 
2991  public function getContext()
2992  {
2993  return $this->context;
2994  }
2995 
3001  public function setShowRowsSelector($a_value)
3002  {
3003  $this->show_rows_selector = (bool)$a_value;
3004  }
3005 
3011  public function getShowRowsSelector()
3012  {
3014  }
3015 
3021  public function setShowTemplates($a_value)
3022  {
3023  $this->show_templates = (bool)$a_value;
3024  }
3025 
3031  public function getShowTemplates()
3032  {
3033  return $this->show_templates;
3034  }
3035 
3042  public function restoreTemplate($a_name)
3043  {
3044  global $ilUser;
3045 
3046  $a_name = ilUtil::stripSlashes($a_name);
3047 
3048  if(trim($a_name) && $this->getContext() != "" && is_object($ilUser) && $ilUser->getId() != ANONYMOUS_USER_ID)
3049  {
3050  include_once("./Services/Table/classes/class.ilTableTemplatesStorage.php");
3051  $storage = new ilTableTemplatesStorage();
3052 
3053  $data = $storage->load($this->getContext(), $ilUser->getId(), $a_name);
3054  if(is_array($data))
3055  {
3056  foreach($data as $property => $value)
3057  {
3058  $this->storeProperty($property, $value);
3059  }
3060  }
3061 
3062  $data["filter_values"] = unserialize($data["filter_values"]);
3063  if($data["filter_values"])
3064  {
3065  $this->restore_filter_values = $data["filter_values"];
3066  }
3067 
3068  $this->restore_filter = true;
3069 
3070  return true;
3071  }
3072  return false;
3073  }
3074 
3081  public function saveTemplate($a_name)
3082  {
3083  global $ilUser;
3084 
3085  $a_name = ilUtil::prepareFormOutput($a_name, true);
3086 
3087  if(trim($a_name) && $this->getContext() != "" && is_object($ilUser) && $ilUser->getId() != ANONYMOUS_USER_ID)
3088  {
3089  include_once("./Services/Table/classes/class.ilTableTemplatesStorage.php");
3090  $storage = new ilTableTemplatesStorage();
3091 
3092  $state = $this->getCurrentState();
3093  $state["filter_values"] = serialize($state["filter_values"]);
3094  $state["selfields"] = serialize($state["selfields"]);
3095  $state["selfilters"] = serialize($state["selfilters"]);
3096 
3097  $storage->store($this->getContext(), $ilUser->getId(), $a_name, $state);
3098  return true;
3099  }
3100  return false;
3101  }
3102 
3109  public function deleteTemplate($a_name)
3110  {
3111  global $ilUser;
3112 
3113  $a_name = ilUtil::prepareFormOutput($a_name, true);
3114 
3115  if(trim($a_name) && $this->getContext() != "" && is_object($ilUser) && $ilUser->getId() != ANONYMOUS_USER_ID)
3116  {
3117  include_once("./Services/Table/classes/class.ilTableTemplatesStorage.php");
3118  $storage = new ilTableTemplatesStorage();
3119  $storage->delete($this->getContext(), $ilUser->getId(), $a_name);
3120  return true;
3121  }
3122  return false;
3123  }
3124 
3128  function getLimit()
3129  {
3130  if($this->getExportMode() || $this->getPrintMode())
3131  {
3132  return 9999;
3133  }
3134  return parent::getLimit();
3135  }
3136 
3140  function getOffset()
3141  {
3142  if($this->getExportMode() || $this->getPrintMode())
3143  {
3144  return 0;
3145  }
3146  return parent::getOffset();
3147  }
3148 
3154  public function setExportFormats(array $formats)
3155  {
3156  $this->export_formats = array();
3157 
3158  // #11339
3159  $valid = array(self::EXPORT_EXCEL => "tbl_export_excel",
3160  self::EXPORT_CSV => "tbl_export_csv");
3161 
3162  foreach($formats as $format)
3163  {
3164  if(array_key_exists($format, $valid))
3165  {
3166  $this->export_formats[$format] = $valid[$format];
3167  }
3168  }
3169  }
3170 
3175  public function setPrintMode($a_value = false)
3176  {
3177  $this->print_mode = (bool)$a_value;
3178  }
3179 
3184  public function getPrintMode()
3185  {
3186  return $this->print_mode;
3187  }
3188 
3194  public function getExportMode()
3195  {
3196  return $this->export_mode;
3197  }
3198 
3204  public function exportData($format, $send = false)
3205  {
3206  if($this->dataExists())
3207  {
3208  // #9640: sort
3209  if (!$this->getExternalSorting() && $this->enabled["sort"])
3210  {
3211  $this->determineOffsetAndOrder(true);
3212 
3213  $this->row_data = ilUtil::sortArray($this->row_data, $this->getOrderField(),
3214  $this->getOrderDirection(), $this->numericOrdering($this->getOrderField()));
3215  }
3216 
3217  $filename = "export";
3218 
3219  switch($format)
3220  {
3221  case self::EXPORT_EXCEL:
3222  include_once "./Services/Excel/classes/class.ilExcel.php";
3223  $excel = new ilExcel();
3224  $excel->addSheet($this->title
3225  ? $this->title
3226  : $this->lng->txt("export"));
3227  $row = 1;
3228 
3229  ob_start();
3230  $this->fillMetaExcel($excel, $row); // row must be increment in fillMetaExcel()! (optional method)
3231 
3232  // #14813
3233  $pre = $row;
3234  $this->fillHeaderExcel($excel, $row); // row should NOT be incremented in fillHeaderExcel()! (required method)
3235  if($pre == $row)
3236  {
3237  $row++;
3238  }
3239 
3240  foreach($this->row_data as $set)
3241  {
3242  $this->fillRowExcel($excel, $row, $set);
3243  $row++; // #14760
3244  }
3245  ob_end_clean();
3246 
3247  if($send)
3248  {
3249  $excel->sendToClient($filename);
3250  }
3251  else
3252  {
3253  $excel->writeToFile($filename);
3254  }
3255  break;
3256 
3257  case self::EXPORT_CSV:
3258  include_once "./Services/Utilities/classes/class.ilCSVWriter.php";
3259  $csv = new ilCSVWriter();
3260  $csv->setSeparator(";");
3261 
3262  ob_start();
3263  $this->fillMetaCSV($csv);
3264  $this->fillHeaderCSV($csv);
3265  foreach($this->row_data as $set)
3266  {
3267  $this->fillRowCSV($csv, $set);
3268  }
3269  ob_end_clean();
3270 
3271  if($send)
3272  {
3273  $filename .= ".csv";
3274  header("Content-type: text/comma-separated-values");
3275  header("Content-Disposition: attachment; filename=\"".$filename."\"");
3276  header("Expires: 0");
3277  header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
3278  header("Pragma: public");
3279  echo $csv->getCSVString();
3280 
3281  }
3282  else
3283  {
3284  file_put_contents($filename, $csv->getCSVString());
3285  }
3286  break;
3287  }
3288 
3289  if($send)
3290  {
3291  exit();
3292  }
3293  }
3294  }
3295 
3303  protected function fillMetaExcel(ilExcel $a_excel, &$a_row)
3304  {
3305 
3306  }
3307 
3315  protected function fillHeaderExcel(ilExcel $a_excel, &$a_row)
3316  {
3317  $col = 0;
3318  foreach ($this->column as $column)
3319  {
3320  $title = strip_tags($column["text"]);
3321  if($title)
3322  {
3323  $a_excel->setCell($a_row, $col++, $title);
3324  }
3325  }
3326  $a_excel->setBold("A".$a_row.":".$a_excel->getColumnCoord($col-1).$a_row);
3327  }
3328 
3337  protected function fillRowExcel(ilExcel $a_excel, &$a_row, $a_set)
3338  {
3339  $col = 0;
3340  foreach ($a_set as $value)
3341  {
3342  if(is_array($value))
3343  {
3344  $value = implode(', ', $value);
3345  }
3346  $a_excel->setCell($a_row, $col++, $value);
3347  }
3348  }
3349 
3356  protected function fillMetaCSV($a_csv)
3357  {
3358 
3359  }
3360 
3367  protected function fillHeaderCSV($a_csv)
3368  {
3369  foreach ($this->column as $column)
3370  {
3371  $title = strip_tags($column["text"]);
3372  if($title)
3373  {
3374  $a_csv->addColumn($title);
3375  }
3376  }
3377  $a_csv->addRow();
3378  }
3379 
3387  protected function fillRowCSV($a_csv, $a_set)
3388  {
3389  foreach ($a_set as $key => $value)
3390  {
3391  if(is_array($value))
3392  {
3393  $value = implode(', ', $value);
3394  }
3395  $a_csv->addColumn(strip_tags($value));
3396  }
3397  $a_csv->addRow();
3398  }
3399 
3405  public function setEnableAllCommand($a_value)
3406  {
3407  $this->enable_command_for_all = (bool)$a_value;
3408  }
3409 
3415  public static function getAllCommandLimit()
3416  {
3417  global $ilClientIniFile;
3418 
3419  $limit = $ilClientIniFile->readVariable("system", "TABLE_ACTION_ALL_LIMIT");
3420  if(!$limit)
3421  {
3422  $limit = self::ACTION_ALL_LIMIT;
3423  }
3424 
3425  return $limit;
3426  }
3427 
3432  {
3433  $this->row_selector_label = $row_selector_label;
3434  return $this;
3435  }
3436 
3440  public function getRowSelectorLabel()
3441  {
3443  }
3444 
3450  public function setPreventDoubleSubmission($a_val)
3451  {
3452  $this->prevent_double_submission = $a_val;
3453  }
3454 
3460  public function getPreventDoubleSubmission()
3461  {
3463  }
3464 
3465  function setLimit($a_limit = 0, $a_default_limit = 0)
3466  {
3467  parent::setLimit($a_limit, $a_default_limit);
3468 
3469  // #17077 - if limit is set "manually" to 9999, force rows selector off
3470  if($a_limit == 9999 &&
3471  $this->limit_determined)
3472  {
3473  $this->rows_selector_off = true;
3474  }
3475  }
3476 }
3477 
3478 ?>
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
setRowSelectorLabel($row_selector_label)
initFilter()
Init filter.
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
This class represents a duration (typical hh:mm:ss) property in a property form.
setDescription($a_val)
Set description.
getExternalSorting()
Get external sorting.
fillHeaderExcel(ilExcel $a_excel, &$a_row)
Excel Version of Fill Header.
prepareOutput()
Anything that must be done before HTML is generated.
getContext()
Get context.
setExternalSorting($a_val)
Set external sorting.
__construct($a_parent_obj, $a_parent_cmd="", $a_template_context="")
Constructor.
getDefaultOrderField()
Get Default order field.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
setExportFormats(array $formats)
Set available export formats.
addHiddenInput($a_name, $a_value)
Add Hidden Input field.
getTopAnchor()
Get top anchor.
getTopCommands()
Get top commands (display command buttons on top of table, too)
addCommandButtonInstance(ilButtonBase $a_button)
Add Command button instance.
Helper class to generate CSV files.
$_SESSION["AccountId"]
This class represents a selection list property in a property form.
$result
addFilterItemByMetaType($id, $type=self::FILTER_TEXT, $a_optional=false, $caption=NULL)
Add filter by standard type.
getColumnCount()
Returns the column count based on the number of the header row columns public.
setDisplayAsBlock($a_val)
Set display as block.
getSelectAllCheckbox()
Get the name of the checkbox that should be toggled with a select all button.
getFilterCommand()
Get filter command.
getSelectableColumns()
Get selectable columns.
setOffset($a_offset)
set dataset offset public
setPrintMode($a_value=false)
Toogle print mode.
renderFilter()
Render Filter section.
fillRowExcel(ilExcel $a_excel, &$a_row, $a_set)
Excel Version of Fill Row.
$_GET["client_id"]
setShowTemplates($a_value)
Toggle templates.
storeProperty($type, $value)
Store table property.
getIsDataTable()
Get is data table.
setEnableNumInfo($a_val)
Set enable num info.
getFilterValue(ilFormPropertyGUI $a_item)
Get current filter value.
setFilterCols($a_val)
Set filter columns.
static initConnection()
Init YUI Connection module.
$valid
setExternalSegmentation($a_val)
Set external segmentation.
determineSelectedColumns()
Determine selected columns.
exportData($format, $send=false)
Export and optionally send current table data.
$cmd
Definition: sahs_server.php:35
resetOffset($a_in_determination=false)
Reset offset.
getFilterItemByPostVar($a_post_var)
addFilterItem($a_input_item, $a_optional=false)
Add filter item.
static setUseRelativeDates($a_status)
set use relative dates
setIsDataTable($a_val)
Set is data table.
getFormName()
Get Form name.
Saves (mostly asynchronously) user properties of tables (e.g.
$url
Definition: shib_logout.php:72
setFooter($a_style, $a_previous=0, $a_next=0)
set order direction public
determineLimit()
Determine the limit.
Class ilTableGUI.
getOpenFormTag()
Get open form tag.
setDefaultFilterVisiblity($a_status)
Set default filter visiblity.
deleteTemplate($a_name)
Delete template.
getParentCmd()
Get parent command.
getOrderDirection()
Get order direction.
getLinkbar($a_num)
Get previous/next linkbar.
setNoEntriesText($a_text)
Set text for an empty table.
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
fillFooter()
Fill footer row.
getParentObject()
Get parent object.
const FILTER_NUMBER_RANGE
setId($a_val)
Set id.
getDescription()
Get description.
saveTemplate($a_name)
Save current state as template.
getDisplayAsBlock()
Get display as block.
addHeaderCommand($a_href, $a_text, $a_target="", $a_img="")
Add Header Command (Link) (Image needed for now)
Saves (mostly asynchronously) user properties of tables (e.g.
This class represents a date/time property in a property form.
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
fillActionRow()
Fill Action Row.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
getShowRowsSelector()
Get rows-per-page selector state.
getHTML()
Get HTML.
getDefaultOrderDirection()
Get Default order direction.
setOrderLink($sort_field, $order_dir)
getFilterElements($a_only_non_empty=true)
Get SQL conditions for current filter value(s)
getShowTemplates()
Get template state.
setOrderDirection($a_order_direction)
set order direction public
setOrderField($a_order_field)
set order column
setTopCommands($a_val)
Set top commands (display command buttons on top of table, too)
const FILTER_DATETIME_RANGE
Class ilTable2GUI.
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.
$column
Definition: 39dropdown.php:62
isFilterVisible()
Check if filter is visible: manually shown (session, db) or default value set.
Class for single dates.
setResetCommand($a_val, $a_caption=null)
Set reset filter command.
getColumnCoord($a_col)
Get column "name" from number.
if(!is_array($argv)) $options
setBold($a_coords)
Set cell(s) to bold.
fillMetaCSV($a_csv)
Add meta information to csv export.
getDisableFilterHiding()
Get disable filter hiding.
restoreTemplate($a_name)
Restore state from template.
getOffset()
Get offset.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
This class represents a number property in a property form.
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.
setDisableFilterHiding($a_val=true)
Set disable filter hiding.
const FILTER_DURATION_RANGE
special template class to simplify handling of ITX/PEAR
numericOrdering($a_field)
Should this field be sorted numeric?
getExternalSegmentation()
Get external segmentation.
addMultiCommand($a_cmd, $a_text)
Add Command button.
static getAllCommandLimit()
Get maximum number of entries to enable actions for all.
This is a utility class for the yui overlays.
setCustomPreviousNext($a_prev_link, $a_next_link)
Set custom previous/next links.
This class represents a text property in a property form.
setHeaderHTML($html)
set header html
setPrefix($a_prefix)
$ilUser
Definition: imgupload.php:18
User interface class for a checkbox list overlay.
getSelectedColumns()
Get selected columns.
getFormAction()
Get Form action parameter.
Add a drawing to the header
Definition: 04printing.php:69
isAdvMDFilter(ilAdvancedMDRecordGUI $a_gui, $a_element)
Check if filter element is based on adv md.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
getPreventDoubleSubmission()
Get prevent double submission.
getEnableHeader()
Get Enable Header.
$old
$txt
Definition: error.php:12
SetFilterValue(ilFormPropertyGUI $a_item, $a_value)
Set current filter value.
setEnableAllCommand($a_value)
Enable actions for all entries in current result.
addSelectionButton($a_sel_var, $a_options, $a_cmd, $a_text, $a_default_selection='')
Add Selection List + Command button.
getEnableTitle()
Get Enable Title.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
Create styles array
The data for the language used.
getNoEntriesText()
Get text for an empty table.
writeFilterToSession()
Write filter values to session.
executeCommand()
Execute command.
isColumnSelected($a_col)
Is given column selected?
isFilterSelected($a_col)
Is given filter selected?
render()
render table public
addMultiItemSelectionButton($a_sel_var, $a_options, $a_cmd, $a_text, $a_default_selection='')
Add Selection List + Command button for selected items.
getResetCommand()
Get reset filter command.
setCell($a_row, $a_col, $a_value)
Set cell value.
setContext($id)
Set context.
determineOffsetAndOrder($a_omit_offset=false)
Determine offset and order.
User interface class for advanced drop-down selection lists.
determineSelectedFilters()
Determine selected filters.
This class represents a number property in a property form.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
const IL_CAL_DATE
getEnableNumInfo()
Get enable num info.
getSelectedFilters()
Get selected filters.
static img($a_src, $a_alt="", $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
getFilterCols()
Get filter columns.
This class represents a property in a property form.
setFormName($a_formname="")
Set Form name.
global $lng
Definition: privfeed.php:17
setShowRowsSelector($a_value)
Toggle rows-per-page selector.
getPrintMode()
Get print mode.
getCurrentState()
get current settings for order, limit, columns and filter
setOpenFormTag($a_val)
Set open form tag.
setEnableHeader($a_enableheader)
Set Enable Header.
loadProperty($type)
Load table property.
fillRow($a_set)
Standard Version of Fill Row.
setCloseCommand($a_link)
Add command for closing table.
getLimit()
Get limit.
fillHeaderCSV($a_csv)
CSV Version of Fill Header.
Set thin black border outline around column
setSelectAllCheckbox($a_select_all_checkbox)
Set the name of the checkbox that should be toggled with a select all button.
setMaxCount($a_max_count)
set max.
getCloseFormTag()
Get close form tag.
getId()
Get element id.
fillMetaExcel(ilExcel $a_excel, &$a_row)
Add meta information to excel export.
getExportMode()
Was export activated?
getFilterItems($a_optionals=false)
Get filter items.
setEnableTitle($a_enabletitle)
Set Enable Title.
getDefaultFilterVisibility()
Get default filter visibility.
getStyle($a_element)
writeToSession()
Write to session.
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.
$_POST["username"]
$html
Definition: example_001.php:87
resetFilter()
Reset filter.
setPreventDoubleSubmission($a_val)
Set prevent double submission.
setTopAnchor($a_val)
Set top anchor.
setCloseFormTag($a_val)
Set close form tag.
setLimit($a_limit=0, $a_default_limit=0)
fillRowCSV($a_csv, $a_set)
CSV Version of Fill Row.
setFilterCommand($a_val, $a_caption=null)
Set filter command.