4 require_once(
"Services/Table/classes/class.ilTableGUI.php");
65 public function __construct($a_parent_obj, $a_parent_cmd =
"", $a_template_context =
"")
70 $this->unique_id = md5(uniqid());
71 $this->parent_obj = $a_parent_obj;
72 $this->parent_cmd = $a_parent_cmd;
73 $this->buttons = array();
74 $this->header_commands = array();
75 $this->multi = array();
76 $this->hidden_inputs = array();
78 $this->tpl =
new ilTemplate(
"tpl.table2.html",
true,
true,
"Services/Table");
80 $lng->loadLanguageModule(
'tbl');
82 if(!$a_template_context)
84 $a_template_context = $this->
getId();
89 if(isset(
$_GET[$this->prefix.
"_xpt"]))
91 $this->export_mode = (int)
$_GET[$this->prefix.
"_xpt"];
95 if(isset(
$_GET[$this->prefix.
"_tpl"]))
113 $this->open_form_tag = $a_val;
133 $this->close_form_tag = $a_val;
153 if ($this->limit_determined)
159 if (isset(
$_GET[$this->prefix.
"_trows"]))
175 if (is_object($ilUser))
177 $limit = $ilUser->getPref(
"hits_per_page");
187 $this->limit_determined =
true;
205 if ($this->columns_determined)
216 @unserialize($old_sel);
219 if(!is_array($sel_fields))
222 $sel_fields = array();
225 $this->selected_columns = array();
229 $this->selected_column[$k] =
false;
236 $this->selected_column[$k] =
true;
241 $this->selected_column[$k] = $sel_fields[$k];
247 $this->selected_column[$k] =
true;
252 if ($old_sel != serialize($this->selected_column) && $set)
254 $this->
storeProperty(
"selfields", serialize($this->selected_column));
257 $this->columns_determined =
true;
268 return $this->selected_column[$a_col];
280 foreach ($this->selected_column as $k => $v)
297 $next_class = $ilCtrl->getNextClass($this);
298 $cmd = $ilCtrl->getCmd();
302 case 'ilformpropertydispatchgui':
303 include_once
'./Services/Form/classes/class.ilFormPropertyDispatchGUI.php';
307 $form_prop_dispatch->setItem($item);
308 return $ilCtrl->forwardCommand($form_prop_dispatch);
320 if (!$this->nav_determined && !$a_in_determination)
347 return $this->parent_obj;
357 return $this->parent_cmd;
367 $this->top_anchor = $a_val;
387 $this->noentriestext = $a_text;
397 return $this->noentriestext;
407 $this->datatable = $a_val;
417 return $this->datatable;
427 $this->enabled[
"title"] = $a_enabletitle;
437 return $this->enabled[
"title"];
447 $this->enabled[
"header"] = $a_enableheader;
457 return $this->enabled[
"header"];
467 $this->num_info = $a_val;
477 return $this->num_info;
483 final public function setTitle($a_title, $a_icon = 0, $a_icon_alt = 0)
495 $this->description = $a_val;
505 return $this->description;
515 $this->order_field = $a_order_field;
520 return $this->order_field;
527 $this->enabled[
"header"] && $this->enabled[
"sort"] &&
528 $this->columns_determined && is_array($this->column) &&
529 is_array($a_data) &&
sizeof($a_data))
532 $check = array_keys(array_shift($check));
533 foreach($this->column as $col)
535 if($col[
"sort_field"] && !in_array($col[
"sort_field"], $check))
537 $invalid[] = $col[
"sort_field"];
542 trigger_error(
"The following columns are defined as sortable but".
543 " cannot be found in the given data: ".implode(
", ", $invalid).
544 ". Sorting will not work properly.", E_USER_WARNING);
548 $this->row_data = $a_data;
553 return $this->row_data;
558 if (is_array($this->row_data))
560 if (count($this->row_data) > 0)
570 $this->prefix = $a_prefix;
584 $a_input_item->setParent($this);
587 $this->filters[] = $a_input_item;
591 $this->optional_filters[] = $a_input_item;
595 if($this->restore_filter_values &&
596 array_key_exists($a_input_item->getFieldId(), $this->restore_filter_values))
598 $this->setFilterValue($a_input_item, $this->restore_filter_values[$a_input_item->getFieldId()]);
617 $caption = $lng->txt($id);
620 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
624 case self::FILTER_SELECT:
625 include_once(
"./Services/Form/classes/class.ilSelectInputGUI.php");
629 case self::FILTER_DATE:
630 include_once(
"./Services/Form/classes/class.ilDateTimeInputGUI.php");
635 case self::FILTER_TEXT:
636 include_once(
"./Services/Form/classes/class.ilTextInputGUI.php");
638 $item->setMaxLength(64);
643 case self::FILTER_LANGUAGE:
644 include_once(
"./Services/Form/classes/class.ilSelectInputGUI.php");
646 $options = array(
"" => $lng->txt(
"trac_all"));
647 foreach ($lng->getInstalledLanguages() as $lang_key)
649 $options[$lang_key] = $lng->txt(
"lang_".$lang_key);
651 $item->setOptions($options);
654 case self::FILTER_NUMBER_RANGE:
655 include_once(
"./Services/Form/classes/class.ilCombinationInputGUI.php");
656 include_once(
"./Services/Form/classes/class.ilNumberInputGUI.php");
659 $item->addCombinationItem(
"from", $combi_item, $lng->txt(
"from"));
661 $item->addCombinationItem(
"to", $combi_item, $lng->txt(
"to"));
663 $item->setMaxLength(7);
667 case self::FILTER_DATE_RANGE:
668 include_once(
"./Services/Form/classes/class.ilCombinationInputGUI.php");
669 include_once(
"./Services/Form/classes/class.ilDateTimeInputGUI.php");
672 $item->addCombinationItem(
"from", $combi_item, $lng->txt(
"from"));
674 $item->addCombinationItem(
"to", $combi_item, $lng->txt(
"to"));
679 case self::FILTER_DURATION_RANGE:
680 $lng->loadLanguageModule(
"form");
681 include_once(
"./Services/Form/classes/class.ilCombinationInputGUI.php");
682 include_once(
"./Services/Form/classes/class.ilDurationInputGUI.php");
685 $combi_item->setShowMonths(
false);
686 $combi_item->setShowDays(
true);
687 $item->addCombinationItem(
"from", $combi_item, $lng->txt(
"from"));
689 $combi_item->setShowMonths(
false);
690 $combi_item->setShowDays(
true);
691 $item->addCombinationItem(
"to", $combi_item, $lng->txt(
"to"));
700 $item->readFromSession();
720 if ($item->getPostVar() == $a_post_var)
727 if ($item->getPostVar() == $a_post_var)
742 $this->filter_cols = $a_val;
762 $this->disable_filter_hiding = $a_val;
783 return $this->selected_filter[$a_col];
795 foreach ($this->selected_filter as $k => $v)
813 if ($this->filters_determined)
823 @unserialize($old_sel);
826 if(!is_array($sel_filters))
829 $sel_filters = array();
832 $this->selected_filter = array();
836 $k = $item->getPostVar();
838 $this->selected_filter[$k] =
false;
845 $this->selected_filter[$k] =
true;
849 $item->setValue(NULL);
850 $item->writeToSession();
855 $this->selected_filter[$k] = $sel_filters[$k];
859 if ($old_sel != serialize($this->selected_filter) && $set)
861 $this->
storeProperty(
"selfilters", serialize($this->selected_filter));
864 $this->filters_determined =
true;
872 $this->custom_prev_next =
true;
873 $this->custom_prev = $a_prev_link;
874 $this->custom_next = $a_next_link;
884 $this->form_action = $a_form_action;
894 return $this->form_action;
904 $this->formname = $a_formname;
914 return $this->formname;
948 $this->display_as_block = $a_val;
958 return $this->display_as_block;
978 $this->select_all_checkbox = $a_select_all_checkbox;
988 $this->ext_sort = $a_val;
1008 $this->filter_cmd = $a_val;
1028 $this->reset_cmd = $a_val;
1048 $this->ext_seg = $a_val;
1069 $this->row_template = $a_template;
1070 $this->row_template_dir = $a_template_dir;
1080 $this->defaultorderfield = $a_defaultorderfield;
1090 return $this->defaultorderfield;
1100 $this->defaultorderdirection = $a_defaultorderdirection;
1110 return $this->defaultorderdirection;
1120 $this->buttons = array();
1131 $this->buttons[] = array(
"cmd" => $a_cmd,
"text" => $a_text,
'onclick' => $a_onclick,
1145 echo
"ilTabl2GUI->addSelectionButton() has been deprecated with 4.2. Please try to move the drop-down to ilToolbarGUI.";
1160 $this->mi_sel_buttons[] = array(
"sel_var" => $a_sel_var,
"options" => $a_options,
"selected" => $a_default_selection,
"cmd" => $a_cmd,
"text" => $a_text);
1173 $this->close_command = $a_link;
1184 $this->multi[] = array(
"cmd" => $a_cmd,
"text" => $a_text);
1195 $this->hidden_inputs[] = array(
"name" => $a_name,
"value" => $a_value);
1206 $this->header_commands[] = array(
"href" => $a_href,
"text" => $a_text,
1207 "target" => $a_target,
"img" => $a_img);
1217 $this->top_commands = $a_val;
1237 final public function addColumn($a_text, $a_sort_field =
"", $a_width =
"",
1238 $a_is_checkbox_action_column =
false, $a_class =
"", $a_tooltip =
"")
1240 $this->column[] = array(
1242 "sort_field" => $a_sort_field,
1243 "width" => $a_width,
1244 "is_checkbox_action_column" => $a_is_checkbox_action_column,
1245 "class" => $a_class,
1246 "tooltip" => $a_tooltip
1248 $this->column_count = count($this->column);
1254 return $this->prefix.
"_table_nav";
1262 if (is_object($ilUser) && $ilUser->getPref(
"screen_reader_optimization"))
1264 $hash =
"#".$this->getTopAnchor();
1270 $ilCtrl->setParameter($this->parent_obj,
1272 $sort_field.
":".$order_dir.
":".$this->offset);
1273 $this->tpl->setVariable(
"TBL_ORDER_LINK",
1274 $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd).$hash);
1277 $ilCtrl->setParameter($this->parent_obj,
1285 $allcolumnswithwidth =
true;
1286 foreach ((array) $this->column as $idx => $column)
1288 if (!strlen($column[
"width"]))
1290 $allcolumnswithwidth =
false;
1292 else if($column[
"width"] ==
"1")
1295 $this->column[$idx][
"width"] =
"1%";
1298 if ($allcolumnswithwidth)
1300 foreach ((array) $this->column as $column)
1302 $this->tpl->setCurrentBlock(
"tbl_colgroup_column");
1303 $this->tpl->setVariable(
"COLGROUP_COLUMN_WIDTH", $column[
"width"]);
1304 $this->tpl->parseCurrentBlock();
1308 foreach ((array) $this->column as $column)
1313 if ($column[
"tooltip"] !=
"")
1315 include_once(
"./Services/UIComponent/Tooltip/classes/class.ilTooltipGUI.php");
1318 if (!$this->enabled[
"sort"] || $column[
"sort_field"] ==
"" || $column[
"is_checkbox_action_column"])
1320 $this->tpl->setCurrentBlock(
"tbl_header_no_link");
1321 if ($column[
"width"] !=
"")
1323 $this->tpl->setVariable(
"TBL_COLUMN_WIDTH_NO_LINK",
" width=\"".$column[
"width"].
"\"");
1325 if (!$column[
"is_checkbox_action_column"])
1327 $this->tpl->setVariable(
"TBL_HEADER_CELL_NO_LINK",
1332 $this->tpl->setVariable(
"TBL_HEADER_CELL_NO_LINK",
1335 $this->tpl->setVariable(
"HEAD_CELL_NL_ID",
"thc_".$this->
getId().
"_".$ccnt);
1337 if ($column[
"class"] !=
"")
1339 $this->tpl->setVariable(
"TBL_HEADER_CLASS",
" " . $column[
"class"]);
1341 $this->tpl->parseCurrentBlock();
1342 $this->tpl->touchBlock(
"tbl_header_th");
1345 if (($column[
"sort_field"] == $this->order_field) && ($this->order_direction !=
""))
1347 $this->tpl->setCurrentBlock(
"tbl_order_image");
1348 $this->tpl->setVariable(
"IMG_ORDER_DIR",
ilUtil::getImagePath($this->order_direction.
"_order.gif"));
1349 $this->tpl->setVariable(
"IMG_ORDER_ALT", $this->lng->txt(
"change_sort_direction"));
1350 $this->tpl->parseCurrentBlock();
1353 $this->tpl->setCurrentBlock(
"tbl_header_cell");
1354 $this->tpl->setVariable(
"TBL_HEADER_CELL", $column[
"text"]);
1355 $this->tpl->setVariable(
"HEAD_CELL_ID",
"thc_".$this->
getId().
"_".$ccnt);
1358 if ($column[
"width"] !=
"")
1360 $this->tpl->setVariable(
"TBL_COLUMN_WIDTH",
" width=\"".$column[
"width"].
"\"");
1363 $lng_sort_column = $this->lng->txt(
"sort_by_this_column");
1364 $this->tpl->setVariable(
"TBL_ORDER_ALT",$lng_sort_column);
1368 if ($column[
"sort_field"] == $this->order_field)
1370 $order_dir = $this->sort_order;
1372 $lng_change_sort = $this->lng->txt(
"change_sort_direction");
1373 $this->tpl->setVariable(
"TBL_ORDER_ALT",$lng_change_sort);
1376 if ($column[
"class"] !=
"")
1378 $this->tpl->setVariable(
"TBL_HEADER_CLASS",
" " . $column[
"class"]);
1380 $this->
setOrderLink($column[
"sort_field"], $order_dir);
1381 $this->tpl->parseCurrentBlock();
1382 $this->tpl->touchBlock(
"tbl_header_th");
1385 $this->tpl->setCurrentBlock(
"tbl_header");
1386 $this->tpl->parseCurrentBlock();
1404 if ($this->nav_determined)
1429 if ($this->nav_value ==
"" && $this->
getId() !=
"" && $ilUser->getId() != ANONYMOUS_USER_ID)
1437 $nav = explode(
":", $this->nav_value);
1443 if (!$a_omit_offset)
1460 if (!$a_omit_offset)
1462 $this->nav_determined =
true;
1498 if (is_object($ilCtrl) && $this->
getId() ==
"")
1503 if(!$this->enabled[
'content'])
1515 $this->
setFooter(
"tblfooter",$this->lng->txt(
"previous"),$this->lng->txt(
"next"));
1542 $this->tpl->addBlockFile(
"TBL_CONTENT",
"tbl_content", $this->row_template,
1543 $this->row_template_dir);
1545 foreach($data as $set)
1547 $this->tpl->setCurrentBlock(
"tbl_content");
1548 $this->css_row = ($this->css_row !=
"tblrow1")
1551 $this->tpl->setVariable(
"CSS_ROW", $this->css_row);
1554 $this->tpl->setCurrentBlock(
"tbl_content");
1555 $this->tpl->parseCurrentBlock();
1563 : $lng->txt(
"no_items");
1565 $this->css_row = ($this->css_row !=
"tblrow1")
1569 $this->tpl->setCurrentBlock(
"tbl_no_entries");
1570 $this->tpl->setVariable(
'TBL_NO_ENTRY_CSS_ROW', $this->css_row);
1571 $this->tpl->setVariable(
'TBL_NO_ENTRY_COLUMN_COUNT', $this->column_count);
1572 $this->tpl->setVariable(
'TBL_NO_ENTRY_TEXT', trim($no_items_text));
1573 $this->tpl->parseCurrentBlock();
1583 if (is_object($ilUser) && $ilUser->getPref(
"screen_reader_optimization"))
1585 $hash =
"#".$this->getTopAnchor();
1588 $this->tpl->setCurrentBlock(
"tbl_form_header");
1589 $this->tpl->setVariable(
"FORMACTION", $this->
getFormAction().$hash);
1590 $this->tpl->setVariable(
"FORMNAME", $this->
getFormName());
1591 $this->tpl->parseCurrentBlock();
1596 $this->tpl->touchBlock(
"tbl_form_footer");
1629 $this->tpl->setVariable(
"CSS_TABLE",$this->
getStyle(
"table"));
1630 $this->tpl->setVariable(
"DATA_TABLE", (
int) $this->
getIsDataTable());
1631 if ($this->
getId() !=
"")
1633 $this->tpl->setVariable(
"ID",
'id="'.$this->
getId().
'"');
1639 $this->tpl->setCurrentBlock(
"tbl_header_description");
1640 $this->tpl->setVariable(
"TBL_DESCRIPTION", $this->
getDescription());
1641 $this->tpl->parseCurrentBlock();
1651 $this->tpl->touchBlock(
"outer_start_1");
1652 $this->tpl->touchBlock(
"outer_end_1");
1656 $this->tpl->touchBlock(
"outer_start_2");
1657 $this->tpl->touchBlock(
"outer_end_2");
1661 if ($this->enabled[
"title"] && ($this->title !=
""
1662 || $this->icon !=
"" || count($this->header_commands) > 0 ||
1663 $this->headerHTML !=
"" || $this->close_command !=
""))
1665 if ($this->enabled[
"icon"])
1667 $this->tpl->setCurrentBlock(
"tbl_header_title_icon");
1669 $this->tpl->setVariable(
"TBL_TITLE_IMG_ALT",$this->icon_alt);
1670 $this->tpl->parseCurrentBlock();
1675 foreach($this->header_commands as
$command)
1677 if ($command[
"img"] !=
"")
1679 $this->tpl->setCurrentBlock(
"tbl_header_img_link");
1680 if ($command[
"target"] !=
"")
1682 $this->tpl->setVariable(
"TARGET_IMG_LINK",
1683 'target="'.$command[
"target"].
'"');
1685 $this->tpl->setVariable(
"ALT_IMG_LINK", $command[
"text"]);
1686 $this->tpl->setVariable(
"HREF_IMG_LINK", $command[
"href"]);
1687 $this->tpl->setVariable(
"SRC_IMG_LINK",
1689 $this->tpl->parseCurrentBlock();
1693 $this->tpl->setCurrentBlock(
"head_cmd");
1694 $this->tpl->setVariable(
"TXT_HEAD_CMD", $command[
"text"]);
1695 $this->tpl->setVariable(
"HREF_HEAD_CMD", $command[
"href"]);
1696 $this->tpl->parseCurrentBlock();
1701 if (isset ($this->headerHTML)) {
1702 $this->tpl->setCurrentBlock(
"tbl_header_html");
1703 $this->tpl->setVariable (
"HEADER_HTML", $this->headerHTML);
1704 $this->tpl->parseCurrentBlock();
1708 if ($this->close_command !=
"")
1710 $this->tpl->setCurrentBlock(
"tbl_header_img_link");
1711 $this->tpl->setVariable(
"ALT_IMG_LINK",$lng->txt(
"close"));
1712 $this->tpl->setVariable(
"HREF_IMG_LINK",$this->close_command);
1714 $this->tpl->parseCurrentBlock();
1717 $this->tpl->setCurrentBlock(
"tbl_header_title");
1718 $this->tpl->setVariable(
"TBL_TITLE",$this->title);
1719 $this->tpl->setVariable(
"TOP_ANCHOR",$this->
getTopAnchor());
1722 $this->tpl->setVariable(
"BLK_CLASS",
"Block");
1724 $this->tpl->parseCurrentBlock();
1728 if ($this->enabled[
"header"])
1733 $this->tpl->touchBlock(
"tbl_table_end");
1735 return $this->tpl->get();
1748 $tpl->addJavascript(
"./Services/Table/js/ServiceTable.js");
1750 if (count($filter) == 0 && count($opt_filter) == 0)
1755 include_once(
"./Services/YUI/classes/class.ilYuiUtil.php");
1761 if (count($filter) > 0)
1763 foreach ($filter as $item)
1767 $this->tpl->setCurrentBlock(
"filter_row");
1768 $this->tpl->parseCurrentBlock();
1771 $this->tpl->setCurrentBlock(
"filter_item");
1772 $this->tpl->setVariable(
"OPTION_NAME",
1774 $this->tpl->setVariable(
"F_INPUT_ID",
1775 $item->getFieldId());
1776 $this->tpl->setVariable(
"INPUT_HTML",
1777 $item->getTableFilterHTML());
1778 $this->tpl->parseCurrentBlock();
1784 if (count($opt_filter) > 0)
1788 foreach ($opt_filter as $item)
1794 $this->tpl->setCurrentBlock(
"filter_row");
1795 $this->tpl->parseCurrentBlock();
1798 $this->tpl->setCurrentBlock(
"filter_item");
1799 $this->tpl->setVariable(
"OPTION_NAME",
1801 $this->tpl->setVariable(
"F_INPUT_ID",
1802 $item->getFieldId());
1803 $this->tpl->setVariable(
"INPUT_HTML",
1804 $item->getTableFilterHTML());
1805 $this->tpl->parseCurrentBlock();
1812 foreach ($opt_filter as $item)
1814 $k = $item->getPostVar();
1815 $items[$k] = array(
"txt" => $item->getTitle(),
1819 include_once(
"./Services/UIComponent/CheckboxListOverlay/classes/class.ilCheckboxListOverlayGUI.php");
1821 $cb_over->setLinkTitle($lng->txt(
"optional_filters"));
1822 $cb_over->setItems($items);
1825 $cb_over->setFieldVar(
"tblff".$this->
getId());
1826 $cb_over->setHiddenVar(
"tblfsf".$this->
getId());
1828 $cb_over->setSelectionHeaderClass(
"ilTableMenuItem");
1829 $this->tpl->setCurrentBlock(
"filter_select");
1832 $this->tpl->setVariable(
"HIDDEN_CMD_APPLY", $this->filter_cmd);
1834 $this->tpl->setVariable(
"FILTER_SELECTOR", $cb_over->getHTML());
1835 $this->tpl->parseCurrentBlock();
1839 if($ccnt > 0 || count($opt_filter) > 0)
1841 $this->tpl->setVariable(
"TXT_FILTER", $lng->txt(
"filter"));
1849 $this->tpl->touchBlock(
"filter_empty_cell");
1852 $this->tpl->setCurrentBlock(
"filter_row");
1853 $this->tpl->parseCurrentBlock();
1855 $this->tpl->setCurrentBlock(
"filter_buttons");
1856 $this->tpl->setVariable(
"CMD_APPLY", $this->filter_cmd);
1857 $this->tpl->setVariable(
"TXT_APPLY", $lng->txt(
"apply_filter"));
1858 $this->tpl->setVariable(
"CMD_RESET", $this->reset_cmd);
1859 $this->tpl->setVariable(
"TXT_RESET", $lng->txt(
"reset_filter"));
1861 else if(count($opt_filter) > 0)
1863 $this->tpl->setCurrentBlock(
"optional_filter_hint");
1864 $this->tpl->setVariable(
'TXT_OPT_HINT', $lng->txt(
'optional_filter_hint'));
1865 $this->tpl->parseCurrentBlock();
1868 $this->tpl->setCurrentBlock(
"filter_section");
1869 $this->tpl->setVariable(
"FIL_ID", $this->
getId());
1870 $this->tpl->parseCurrentBlock();
1877 $this->tpl->setCurrentBlock(
"filter_hidden");
1878 $this->tpl->setVariable(
"FI_ID", $this->
getId());
1879 $this->tpl->parseCurrentBlock();
1895 foreach ($filter as $item)
1897 if ($item->checkInput())
1899 $item->setValueByArray(
$_POST);
1900 $item->writeToSession();
1903 foreach ($opt_filter as $item)
1905 if ($item->checkInput())
1907 $item->setValueByArray(
$_POST);
1908 $item->writeToSession();
1923 foreach ($filter as $item)
1925 if ($item->checkInput())
1927 $item->setValueByArray(
$_POST);
1928 $item->clearFromSession();
1931 foreach ($opt_filter as $item)
1933 if ($item->checkInput())
1935 $item->setValueByArray(
$_POST);
1936 $item->clearFromSession();
1949 foreach ($a_set as $key => $value)
1951 $this->tpl->setVariable(
"VAL_".strtoupper($key), $value);
1967 $this->tpl->setCurrentBlock(
"select_all_checkbox");
1968 $this->tpl->setVariable(
"SELECT_ALL_TXT_SELECT_ALL", $lng->txt(
"select_all"));
1970 $this->tpl->setVariable(
"SELECT_ALL_FORM_NAME", $this->
getFormName());
1971 $this->tpl->setVariable(
"CHECKBOXNAME",
"chb_select_all_" . $this->unique_id);
1972 $this->tpl->parseCurrentBlock();
1976 if ($this->enabled[
"numinfo"] && $this->enabled[
"footer"])
1978 $start = $this->offset + 1;
1985 if ($end > $this->max_count or $this->limit == 0)
1990 if ($this->max_count > 0)
1992 if ($this->lang_support)
1994 $numinfo =
"(".$start.
" - ".$end.
" ".strtolower($this->lng->txt(
"of")).
" ".$this->max_count.
")";
1998 $numinfo =
"(".$start.
" - ".$end.
" of ".$this->max_count.
")";
2001 if ($this->max_count > 0)
2005 $this->tpl->setCurrentBlock(
"tbl_footer_numinfo");
2006 $this->tpl->setVariable(
"NUMINFO", $numinfo);
2007 $this->tpl->parseCurrentBlock();
2014 if ($this->enabled[
"linkbar"] && $this->enabled[
"footer"] && $this->limit != 0
2015 && $this->max_count > 0)
2018 "link" => $this->footer_style,
2019 "prev" => $this->footer_previous,
2020 "next" => $this->footer_next,
2025 $this->tpl->setCurrentBlock(
"tbl_footer_linkbar");
2026 $this->tpl->setVariable(
"LINKBAR", $linkbar);
2027 $this->tpl->parseCurrentBlock();
2039 $items[$k] = array(
"txt" => $c[
"txt"],
2042 include_once(
"./Services/UIComponent/CheckboxListOverlay/classes/class.ilCheckboxListOverlayGUI.php");
2044 $cb_over->setLinkTitle($lng->txt(
"columns"));
2045 $cb_over->setItems($items);
2049 $cb_over->setFieldVar(
"tblfs".$this->
getId());
2050 $cb_over->setHiddenVar(
"tblfsh".$this->
getId());
2051 $cb_over->setSelectionHeaderClass(
"ilTableMenuItem");
2052 $column_selector = $cb_over->getHTML();
2074 $create_id =
"template_create_overlay_".$this->getId();
2075 $delete_id =
"template_delete_overlay_".$this->getId();
2076 $list_id =
"template_stg_".$this->getId();
2078 include_once(
"./Services/Table/classes/class.ilTableTemplatesStorage.php");
2080 $templates = $storage->getNames($this->
getContext(), $ilUser->getId());
2082 include_once(
"./Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php");
2085 if(
sizeof($templates))
2088 $overlay->setTrigger($list_id.
"_delete");
2089 $overlay->setAnchor(
"ilAdvSelListAnchorElement_".$list_id);
2090 $overlay->setAutoHide(
false);
2093 $this->tpl->setCurrentBlock(
"template_editor_delete_item");
2094 $this->tpl->setVariable(
"TEMPLATE_DELETE_OPTION",
"");
2095 $this->tpl->parseCurrentBlock();
2096 foreach($templates as $name)
2098 $this->tpl->setVariable(
"TEMPLATE_DELETE_OPTION", $name);
2099 $this->tpl->parseCurrentBlock();
2102 $this->tpl->setCurrentBlock(
"template_editor_delete");
2103 $this->tpl->setVariable(
"TEMPLATE_DELETE_ID", $delete_id);
2104 $this->tpl->setVariable(
"TXT_TEMPLATE_DELETE", $lng->txt(
"tbl_template_delete"));
2105 $this->tpl->setVariable(
"TXT_TEMPLATE_DELETE_SUBMIT", $lng->txt(
"delete"));
2106 $this->tpl->setVariable(
"TEMPLATE_DELETE_CMD", $this->parent_cmd);
2107 $this->tpl->parseCurrentBlock();
2113 $overlay->setTrigger($list_id.
"_create");
2114 $overlay->setAnchor(
"ilAdvSelListAnchorElement_".$list_id);
2115 $overlay->setAutoHide(
false);
2118 $this->tpl->setCurrentBlock(
"template_editor");
2119 $this->tpl->setVariable(
"TEMPLATE_CREATE_ID", $create_id);
2120 $this->tpl->setVariable(
"TXT_TEMPLATE_CREATE", $lng->txt(
"tbl_template_create"));
2121 $this->tpl->setVariable(
"TXT_TEMPLATE_CREATE_SUBMIT", $lng->txt(
"save"));
2122 $this->tpl->setVariable(
"TEMPLATE_CREATE_CMD", $this->parent_cmd);
2123 $this->tpl->parseCurrentBlock();
2126 include_once(
"./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
2128 $alist->setId($list_id);
2129 $alist->addItem($lng->txt(
"tbl_template_create"),
"create",
"#");
2130 if(
sizeof($templates))
2132 $alist->addItem($lng->txt(
"tbl_template_delete"),
"delete",
"#");
2133 foreach($templates as $name)
2135 $ilCtrl->setParameter($this->parent_obj, $this->prefix.
"_tpl", urlencode($name));
2136 $alist->addItem($name, $name, $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd));
2137 $ilCtrl->setParameter($this->parent_obj, $this->prefix.
"_tpl",
"");
2140 $alist->setListTitle($lng->txt(
"tbl_templates"));
2141 $this->tpl->setVariable(
"TEMPLATE_SELECTOR",
" ".$alist->getHTML());
2146 $this->tpl->setCurrentBlock(
"tbl_footer");
2147 $this->tpl->setVariable(
"COLUMN_COUNT", $this->
getColumnCount());
2150 $this->tpl->setVariable(
"BLK_CLASS",
"Block");
2152 $this->tpl->parseCurrentBlock();
2155 if ($numinfo !=
"" || $linkbar !=
"" || $column_selector !=
"" ||
2156 count($this->filters) > 0 || count($this->optional_filters) > 0)
2158 if (is_object($ilUser) && (count($this->filters) || count($this->optional_filters)))
2160 $this->tpl->setCurrentBlock(
"filter_activation");
2161 $this->tpl->setVariable(
"TXT_ACTIVATE_FILTER", $lng->txt(
"show_filter"));
2162 $this->tpl->setVariable(
"FILA_ID", $this->
getId());
2163 if ($this->
getId() !=
"")
2165 $this->tpl->setVariable(
"SAVE_URLA",
"./ilias.php?baseClass=ilTablePropertiesStorage&table_id=".
2166 $this->
getId().
"&cmd=showFilter&user_id=".$ilUser->getId());
2168 $this->tpl->parseCurrentBlock();
2173 $this->tpl->setCurrentBlock(
"filter_deactivation");
2174 $this->tpl->setVariable(
"TXT_HIDE", $lng->txt(
"hide_filter"));
2175 if ($this->
getId() !=
"")
2177 $this->tpl->setVariable(
"SAVE_URL",
"./ilias.php?baseClass=ilTablePropertiesStorage&table_id=".
2178 $this->
getId().
"&cmd=hideFilter&user_id=".$ilUser->getId());
2179 $this->tpl->setVariable(
"FILD_ID", $this->
getId());
2181 $this->tpl->parseCurrentBlock();
2188 $this->tpl->setCurrentBlock(
"top_numinfo");
2189 $this->tpl->setVariable(
"NUMINFO", $numinfo);
2190 $this->tpl->parseCurrentBlock();
2195 $this->tpl->setCurrentBlock(
"top_linkbar");
2196 $this->tpl->setVariable(
"LINKBAR", $linkbar);
2197 $this->tpl->parseCurrentBlock();
2201 $this->tpl->setVariable(
"COLUMN_SELECTOR", $column_selector);
2206 include_once(
"./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
2208 $alist->setId(
"sellst_rows");
2209 $hpp = ($ilUser->getPref(
"hits_per_page") != 9999)
2210 ? $ilUser->getPref(
"hits_per_page")
2211 : $lng->txt(
"unlimited");
2213 $options = array(0 => $lng->txt(
"default").
" (".$hpp.
")",5 => 5, 10 => 10, 15 => 15, 20 => 20,
2214 30 => 30, 40 => 40, 50 => 50,
2215 100 => 100, 200 => 200, 400 => 400, 800 => 800);
2216 foreach ($options as $k => $v)
2218 $ilCtrl->setParameter($this->parent_obj, $this->prefix.
"_trows", $k);
2219 $alist->addItem($v, $k, $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd));
2220 $ilCtrl->setParameter($this->parent_obj, $this->prefix.
"_trows",
"");
2222 $alist->setListTitle($lng->txt(
"rows"));
2223 $this->tpl->setVariable(
"ROW_SELECTOR", $alist->getHTML());
2227 if(
sizeof($this->export_formats) && $this->
dataExists())
2229 $map = array(self::EXPORT_EXCEL =>
"tbl_export_excel",
2230 self::EXPORT_CSV =>
"tbl_export_csv");
2231 include_once(
"./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
2233 $alist->setId(
"sellst_xpt");
2234 foreach($this->export_formats as $format)
2236 $ilCtrl->setParameter($this->parent_obj, $this->prefix.
"_xpt", $format);
2237 $url = $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd);
2238 $ilCtrl->setParameter($this->parent_obj, $this->prefix.
"_xpt",
"");
2239 $alist->addItem($lng->txt($map[$format]), $format, $url);
2241 $alist->setListTitle($lng->txt(
"export"));
2242 $this->tpl->setVariable(
"EXPORT_SELECTOR",
" ".$alist->getHTML());
2245 $this->tpl->setCurrentBlock(
"top_navigation");
2246 $this->tpl->setVariable(
"COLUMN_COUNT", $this->
getColumnCount());
2249 $this->tpl->setVariable(
"BLK_CLASS",
"Block");
2251 $this->tpl->parseCurrentBlock();
2268 if (is_object($ilUser) && $ilUser->getPref(
"screen_reader_optimization"))
2270 $hash =
"#".$this->getTopAnchor();
2273 $link = $ilCtrl->getLinkTargetByClass(get_class($this->parent_obj), $this->parent_cmd).
2274 "&".$this->getNavParameter().
"=".
2278 $layout_prev = $lng->txt(
"previous");
2279 $layout_next = $lng->txt(
"next");
2282 if ($this->max_count > $this->
getLimit() || $this->custom_prev_next)
2284 $sep =
"<span> | </span>";
2287 $pages = intval($this->max_count / $this->
getLimit());
2290 if (($this->max_count % $this->
getLimit()))
2294 $offset_arr = array();
2295 for ($i = 1 ;$i <= $pages ; $i++)
2297 $newoffset = $this->
getLimit() * ($i-1);
2300 $offset_arr[$nav_value] = $i;
2303 $sep =
"<span> </span>";
2306 if ($this->custom_prev_next && $this->custom_prev !=
"")
2310 $LinkBar .=
"<a href=\"".$this->custom_prev.$hash.
"\">".$layout_prev.
"</a>";
2312 else if ($this->
getOffset() >= 1 && !$this->custom_prev_next)
2317 $LinkBar .=
"<a href=\"".$link.$prevoffset.$hash.
"\">".$layout_prev.
"</a>";
2323 $LinkBar .=
'<span class="ilTableFootLight">'.$layout_prev.
"</span>";
2329 $LinkBar .=
'<input type="hidden" name="'.$this->getNavParameter().
2333 $sep =
"<span> | </span>";
2336 if ($this->custom_prev_next && $this->custom_next !=
"")
2340 $LinkBar .=
"<a href=\"".$this->custom_next.$hash.
"\">".$layout_next.
"</a>";
2342 else if (! ( ($this->
getOffset() / $this->
getLimit())==($pages-1) ) && ($pages!=1) &&
2343 !$this->custom_prev_next)
2348 $LinkBar .=
"<a href=\"".$link.$newoffset.$hash.
"\">".$layout_next.
"</a>";
2354 $LinkBar .=
'<span class="ilTableFootLight">'.$layout_next.
"</span>";
2357 $sep =
"<span> </span>";
2359 if (count($offset_arr) && !$this->
getDisplayAsBlock() && !$this->custom_prev_next)
2364 '<label for="tab_page_sel_'.$a_num.
'">'.$lng->txt(
"page").
'</label> '.
2366 $this->
getNavParameter().$a_num, $offset_arr,
false,
true, 0,
"small",
2367 array(
"id" =>
"tab_page_sel_".$a_num,
2368 "onchange" =>
"ilTablePageSelection(this, 'cmd[".$this->parent_cmd.
"]')"));
2383 $hidden_row =
false;
2384 if(count($this->hidden_inputs))
2386 foreach ($this->hidden_inputs as $hidden_input)
2388 $this->tpl->setCurrentBlock(
"tbl_hidden_field");
2389 $this->tpl->setVariable(
"FIELD_NAME", $hidden_input[
"name"]);
2390 $this->tpl->setVariable(
"FIELD_VALUE", $hidden_input[
"value"]);
2391 $this->tpl->parseCurrentBlock();
2394 $this->tpl->setCurrentBlock(
"tbl_hidden_row");
2395 $this->tpl->parseCurrentBlock();
2407 $action_row =
false;
2411 if (count($this->sel_buttons) > 0)
2413 foreach ($this->sel_buttons as $button)
2415 $this->tpl->setCurrentBlock(
"sel_button");
2416 $this->tpl->setVariable(
"SBUTTON_SELECT",
2418 $button[
"options"],
false,
true));
2419 $this->tpl->setVariable(
"SBTN_NAME", $button[
"cmd"]);
2420 $this->tpl->setVariable(
"SBTN_VALUE", $button[
"text"]);
2421 $this->tpl->parseCurrentBlock();
2425 $this->tpl->setCurrentBlock(
"sel_top_button");
2426 $this->tpl->setVariable(
"SBUTTON_SELECT",
2428 $button[
"options"],
false,
true));
2429 $this->tpl->setVariable(
"SBTN_NAME", $button[
"cmd"]);
2430 $this->tpl->setVariable(
"SBTN_VALUE", $button[
"text"]);
2431 $this->tpl->parseCurrentBlock();
2437 $this->sel_buttons[] = array(
"options" => $a_options,
"cmd" => $a_cmd,
"text" => $a_text);
2440 if (count($this->buttons) > 0)
2442 foreach ($this->buttons as $button)
2444 if (strlen($button[
'onclick']))
2446 $this->tpl->setCurrentBlock(
'cmdonclick');
2447 $this->tpl->setVariable(
'CMD_ONCLICK', $button[
'onclick']);
2448 $this->tpl->parseCurrentBlock();
2450 $this->tpl->setCurrentBlock(
"plain_button");
2451 if ($button[
"id"] !=
"")
2453 $this->tpl->setVariable(
"PBID",
' id="'.$button[
"id"].
'" ');
2455 $this->tpl->setVariable(
"PBTN_NAME", $button[
"cmd"]);
2456 $this->tpl->setVariable(
"PBTN_VALUE", $button[
"text"]);
2457 $this->tpl->parseCurrentBlock();
2461 if (strlen($button[
'onclick']))
2463 $this->tpl->setCurrentBlock(
'top_cmdonclick');
2464 $this->tpl->setVariable(
'CMD_ONCLICK', $button[
'onclick']);
2465 $this->tpl->parseCurrentBlock();
2467 $this->tpl->setCurrentBlock(
"plain_top_button");
2468 $this->tpl->setVariable(
"PBTN_NAME", $button[
"cmd"]);
2469 $this->tpl->setVariable(
"PBTN_VALUE", $button[
"text"]);
2470 $this->tpl->parseCurrentBlock();
2479 if(count($this->mi_sel_buttons))
2481 foreach ($this->mi_sel_buttons as $button)
2483 $this->tpl->setCurrentBlock(
"mi_sel_button");
2484 $this->tpl->setVariable(
"MI_BUTTON_SELECT",
2486 $button[
"options"],
false,
true));
2487 $this->tpl->setVariable(
"MI_BTN_NAME", $button[
"cmd"]);
2488 $this->tpl->setVariable(
"MI_BTN_VALUE", $button[
"text"]);
2489 $this->tpl->parseCurrentBlock();
2493 $this->tpl->setCurrentBlock(
"mi_top_sel_button");
2494 $this->tpl->setVariable(
"MI_BUTTON_SELECT",
2496 $button[
"options"],
false,
true));
2497 $this->tpl->setVariable(
"MI_BTN_NAME", $button[
"cmd"]);
2498 $this->tpl->setVariable(
"MI_BTN_VALUE", $button[
"text"]);
2499 $this->tpl->parseCurrentBlock();
2508 if (count($this->multi) > 1 && $this->
dataExists())
2510 $this->tpl->setCurrentBlock(
"tbl_cmd_select");
2512 foreach ($this->multi as $mc)
2514 $sel[$mc[
"cmd"]] = $mc[
"text"];
2516 $this->tpl->setVariable(
"SELECT_CMDS",
2518 $this->tpl->setVariable(
"TXT_EXECUTE", $lng->txt(
"execute"));
2519 $this->tpl->parseCurrentBlock();
2525 $this->tpl->setCurrentBlock(
"tbl_top_cmd_select");
2527 foreach ($this->multi as $mc)
2529 $sel[$mc[
"cmd"]] = $mc[
"text"];
2531 $this->tpl->setVariable(
"SELECT_CMDS",
2533 $this->tpl->setVariable(
"TXT_EXECUTE", $lng->txt(
"execute"));
2534 $this->tpl->parseCurrentBlock();
2537 elseif(count($this->multi) == 1 && $this->
dataExists())
2539 $this->tpl->setCurrentBlock(
"tbl_single_cmd");
2541 foreach ($this->multi as $mc)
2546 $this->tpl->setVariable(
"TXT_SINGLE_CMD",$txt);
2547 $this->tpl->setVariable(
"SINGLE_CMD",
$cmd);
2548 $this->tpl->parseCurrentBlock();
2554 $this->tpl->setCurrentBlock(
"tbl_top_single_cmd");
2556 foreach ($this->multi as $mc)
2561 $this->tpl->setVariable(
"TXT_SINGLE_CMD",$txt);
2562 $this->tpl->setVariable(
"SINGLE_CMD",
$cmd);
2563 $this->tpl->parseCurrentBlock();
2569 $this->tpl->setCurrentBlock(
"tbl_action_img_arrow");
2571 $this->tpl->setVariable(
"ALT_ARROW", $lng->txt(
"action"));
2572 $this->tpl->parseCurrentBlock();
2576 $this->tpl->setCurrentBlock(
"tbl_top_action_img_arrow");
2578 $this->tpl->setVariable(
"ALT_ARROW", $lng->txt(
"action"));
2579 $this->tpl->parseCurrentBlock();
2585 $this->tpl->setCurrentBlock(
"tbl_action_row");
2586 $this->tpl->parseCurrentBlock();
2589 $this->tpl->setCurrentBlock(
"tbl_top_action_row");
2590 $this->tpl->parseCurrentBlock();
2602 $this->headerHTML = $html;
2615 if(is_object($ilUser) && $this->
getId() !=
"" && $ilUser->getId() != ANONYMOUS_USER_ID)
2617 include_once(
"./Services/Table/classes/class.ilTablePropertiesStorage.php");
2620 $tab_prop->storeProperty($this->
getId(), $ilUser->getId(), $type, $value);
2634 if(is_object($ilUser) && $this->
getId() !=
"" && $ilUser->getId() != ANONYMOUS_USER_ID)
2636 include_once(
"./Services/Table/classes/class.ilTablePropertiesStorage.php");
2639 return $tab_prop->getProperty($this->
getId(), $ilUser->getId(), $type);
2668 foreach($this->filters as $item)
2673 if($this->optional_filters &&
$result[
"selfilters"])
2675 foreach($this->optional_filters as $item)
2677 if(in_array($item->getFieldId(),
$result[
"selfilters"]))
2695 if(method_exists($a_item,
"getChecked"))
2697 return $a_item->getChecked();
2699 else if(method_exists($a_item,
"getValue"))
2701 return $a_item->getValue();
2703 else if(method_exists($a_item,
"getDate"))
2717 if(method_exists($a_item,
"setChecked"))
2719 $a_item->setChecked($a_value);
2721 else if(method_exists($a_item,
"setValue"))
2723 $a_item->setValue($a_value);
2725 else if(method_exists($a_item,
"setDate"))
2741 $this->context = $id;
2762 $this->show_rows_selector = (bool)$a_value;
2782 $this->show_templates = (bool)$a_value;
2807 if(trim($a_name) && $this->
getContext() !=
"" && is_object($ilUser) && $ilUser->getId() != ANONYMOUS_USER_ID)
2809 include_once(
"./Services/Table/classes/class.ilTableTemplatesStorage.php");
2812 $data = $storage->load($this->
getContext(), $ilUser->getId(), $a_name);
2815 foreach(
$data as $property => $value)
2821 $data[
"filter_values"] = unserialize(
$data[
"filter_values"]);
2822 if(
$data[
"filter_values"])
2824 $this->restore_filter_values =
$data[
"filter_values"];
2844 if(trim($a_name) && $this->
getContext() !=
"" && is_object($ilUser) && $ilUser->getId() != ANONYMOUS_USER_ID)
2846 include_once(
"./Services/Table/classes/class.ilTableTemplatesStorage.php");
2850 $state[
"filter_values"] = serialize($state[
"filter_values"]);
2851 $state[
"selfields"] = serialize($state[
"selfields"]);
2852 $state[
"selfilters"] = serialize($state[
"selfilters"]);
2854 $storage->store($this->
getContext(), $ilUser->getId(), $a_name, $state);
2872 if(trim($a_name) && $this->
getContext() !=
"" && is_object($ilUser) && $ilUser->getId() != ANONYMOUS_USER_ID)
2874 include_once(
"./Services/Table/classes/class.ilTableTemplatesStorage.php");
2876 $storage->delete($this->
getContext(), $ilUser->getId(), $a_name);
2913 $this->export_formats = array();
2914 $valid = array(self::EXPORT_EXCEL, self::EXPORT_CSV);
2915 foreach($formats as $format)
2917 if(in_array($format,
$valid))
2919 $this->export_formats[] = $format;
2930 $this->print_mode = (bool)$a_value;
2965 case self::EXPORT_EXCEL:
2966 include_once
"./Services/Excel/classes/class.ilExcelUtils.php";
2967 include_once
"./Services/Excel/classes/class.ilExcelWriterAdapter.php";
2969 $workbook = $adapter->getWorkbook();
2970 $worksheet = $workbook->addWorksheet();
2976 foreach($this->row_data as $set)
2986 case self::EXPORT_CSV:
2987 include_once
"./Services/Utilities/classes/class.ilCSVWriter.php";
2989 $csv->setSeparator(
";");
2994 foreach($this->row_data as $set)
3003 header(
"Content-type: text/comma-separated-values");
3004 header(
"Content-Disposition: attachment; filename=\"".
$filename.
"\"");
3005 header(
"Expires: 0");
3006 header(
"Cache-Control: must-revalidate, post-check=0,pre-check=0");
3007 header(
"Pragma: public");
3008 echo $csv->getCSVString();
3013 file_put_contents(
$filename, $csv->getCSVString());
3047 foreach ($this->column as $column)
3049 $title = strip_tags($column[
"text"]);
3052 $worksheet->write($a_row, $col,
$title);
3070 foreach ($a_set as $key => $value)
3072 if(is_array($value))
3074 $value = implode(
', ', $value);
3076 $a_worksheet->write($a_row, $col, strip_tags($value));
3100 foreach ($this->column as $column)
3102 $title = strip_tags($column[
"text"]);
3105 $a_csv->addColumn(
$title);
3120 foreach ($a_set as $key => $value)
3122 if(is_array($value))
3124 $value = implode(
', ', $value);
3126 $a_csv->addColumn(strip_tags($value));