4 require_once(
"Services/Table/classes/class.ilTableGUI.php");
63 public function __construct($a_parent_obj, $a_parent_cmd =
"", $a_template_context =
"")
68 $this->unique_id = md5(uniqid());
69 $this->parent_obj = $a_parent_obj;
70 $this->parent_cmd = $a_parent_cmd;
71 $this->buttons = array();
72 $this->header_commands = array();
73 $this->multi = array();
74 $this->hidden_inputs = array();
76 $this->tpl =
new ilTemplate(
"tpl.table2.html",
true,
true,
"Services/Table");
78 $lng->loadLanguageModule(
'tbl');
80 if(!$a_template_context)
82 $a_template_context = $this->
getId();
87 if(isset(
$_GET[$this->prefix.
"_xpt"]))
89 $this->export_mode = (int)
$_GET[$this->prefix.
"_xpt"];
93 if(isset(
$_GET[$this->prefix.
"_tpl"]))
111 if ($this->limit_determined)
117 if (isset(
$_GET[$this->prefix.
"_trows"]))
133 if (is_object($ilUser))
135 $limit = $ilUser->getPref(
"hits_per_page");
145 $this->limit_determined =
true;
163 if ($this->columns_determined)
174 @unserialize($old_sel);
177 if(!is_array($sel_fields))
180 $sel_fields = array();
183 $this->selected_columns = array();
187 $this->selected_column[$k] =
false;
194 $this->selected_column[$k] =
true;
199 $this->selected_column[$k] = $sel_fields[$k];
205 $this->selected_column[$k] =
true;
210 if ($old_sel != serialize($this->selected_column) && $set)
212 $this->
storeProperty(
"selfields", serialize($this->selected_column));
215 $this->columns_determined =
true;
226 return $this->selected_column[$a_col];
238 foreach ($this->selected_column as $k => $v)
255 $next_class = $ilCtrl->getNextClass($this);
256 $cmd = $ilCtrl->getCmd();
260 case 'ilformpropertydispatchgui':
261 include_once
'./Services/Form/classes/class.ilFormPropertyDispatchGUI.php';
265 $form_prop_dispatch->setItem($item);
266 return $ilCtrl->forwardCommand($form_prop_dispatch);
278 if (!$this->nav_determined && !$a_in_determination)
305 return $this->parent_obj;
315 return $this->parent_cmd;
325 $this->top_anchor = $a_val;
345 $this->noentriestext = $a_text;
355 return $this->noentriestext;
365 $this->datatable = $a_val;
375 return $this->datatable;
385 $this->enabled[
"title"] = $a_enabletitle;
395 return $this->enabled[
"title"];
405 $this->enabled[
"header"] = $a_enableheader;
415 return $this->enabled[
"header"];
425 $this->num_info = $a_val;
435 return $this->num_info;
441 final public function setTitle($a_title, $a_icon = 0, $a_icon_alt = 0)
453 $this->description = $a_val;
463 return $this->description;
473 $this->order_field = $a_order_field;
478 return $this->order_field;
483 $this->row_data = $a_data;
488 return $this->row_data;
493 if (is_array($this->row_data))
495 if (count($this->row_data) > 0)
505 $this->prefix = $a_prefix;
519 $a_input_item->setParent($this);
522 $this->filters[] = $a_input_item;
526 $this->optional_filters[] = $a_input_item;
530 if($this->restore_filter_values &&
531 array_key_exists($a_input_item->getFieldId(), $this->restore_filter_values))
533 $this->setFilterValue($a_input_item, $this->restore_filter_values[$a_input_item->getFieldId()]);
552 $caption = $lng->txt($id);
555 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
559 case self::FILTER_SELECT:
560 include_once(
"./Services/Form/classes/class.ilSelectInputGUI.php");
564 case self::FILTER_DATE:
565 include_once(
"./Services/Form/classes/class.ilDateTimeInputGUI.php");
570 case self::FILTER_TEXT:
571 include_once(
"./Services/Form/classes/class.ilTextInputGUI.php");
573 $item->setMaxLength(64);
578 case self::FILTER_LANGUAGE:
579 include_once(
"./Services/Form/classes/class.ilSelectInputGUI.php");
581 $options = array(
"" => $lng->txt(
"trac_all"));
582 foreach ($lng->getInstalledLanguages() as $lang_key)
584 $options[$lang_key] = $lng->txt(
"lang_".$lang_key);
586 $item->setOptions($options);
589 case self::FILTER_NUMBER_RANGE:
590 include_once(
"./Services/Form/classes/class.ilCombinationInputGUI.php");
591 include_once(
"./Services/Form/classes/class.ilNumberInputGUI.php");
594 $item->addCombinationItem(
"from", $combi_item, $lng->txt(
"from"));
596 $item->addCombinationItem(
"to", $combi_item, $lng->txt(
"to"));
598 $item->setMaxLength(7);
602 case self::FILTER_DATE_RANGE:
603 include_once(
"./Services/Form/classes/class.ilCombinationInputGUI.php");
604 include_once(
"./Services/Form/classes/class.ilDateTimeInputGUI.php");
607 $item->addCombinationItem(
"from", $combi_item, $lng->txt(
"from"));
609 $item->addCombinationItem(
"to", $combi_item, $lng->txt(
"to"));
614 case self::FILTER_DURATION_RANGE:
615 $lng->loadLanguageModule(
"form");
616 include_once(
"./Services/Form/classes/class.ilCombinationInputGUI.php");
617 include_once(
"./Services/Form/classes/class.ilDurationInputGUI.php");
620 $combi_item->setShowMonths(
false);
621 $combi_item->setShowDays(
true);
622 $item->addCombinationItem(
"from", $combi_item, $lng->txt(
"from"));
624 $combi_item->setShowMonths(
false);
625 $combi_item->setShowDays(
true);
626 $item->addCombinationItem(
"to", $combi_item, $lng->txt(
"to"));
635 $item->readFromSession();
655 if ($item->getPostVar() == $a_post_var)
662 if ($item->getPostVar() == $a_post_var)
677 $this->filter_cols = $a_val;
697 $this->disable_filter_hiding = $a_val;
718 return $this->selected_filter[$a_col];
730 foreach ($this->selected_filter as $k => $v)
748 if ($this->filters_determined)
758 @unserialize($old_sel);
761 if(!is_array($sel_filters))
764 $sel_filters = array();
767 $this->selected_filter = array();
771 $k = $item->getPostVar();
773 $this->selected_filter[$k] =
false;
780 $this->selected_filter[$k] =
true;
784 $item->setValue(NULL);
785 $item->writeToSession();
790 $this->selected_filter[$k] = $sel_filters[$k];
794 if ($old_sel != serialize($this->selected_filter) && $set)
796 $this->
storeProperty(
"selfilters", serialize($this->selected_filter));
799 $this->filters_determined =
true;
807 $this->custom_prev_next =
true;
808 $this->custom_prev = $a_prev_link;
809 $this->custom_next = $a_next_link;
819 $this->form_action = $a_form_action;
829 return $this->form_action;
839 $this->formname = $a_formname;
849 return $this->formname;
883 $this->display_as_block = $a_val;
893 return $this->display_as_block;
913 $this->select_all_checkbox = $a_select_all_checkbox;
923 $this->ext_sort = $a_val;
943 $this->filter_cmd = $a_val;
963 $this->reset_cmd = $a_val;
983 $this->ext_seg = $a_val;
1004 $this->row_template = $a_template;
1005 $this->row_template_dir = $a_template_dir;
1015 $this->defaultorderfield = $a_defaultorderfield;
1025 return $this->defaultorderfield;
1035 $this->defaultorderdirection = $a_defaultorderdirection;
1045 return $this->defaultorderdirection;
1055 $this->buttons = array();
1066 $this->buttons[] = array(
"cmd" => $a_cmd,
"text" => $a_text,
'onclick' => $a_onclick);
1079 $this->sel_buttons[] = array(
"sel_var" => $a_sel_var,
"options" => $a_options,
"selected" => $a_default_selection,
"cmd" => $a_cmd,
"text" => $a_text);
1093 $this->mi_sel_buttons[] = array(
"sel_var" => $a_sel_var,
"options" => $a_options,
"selected" => $a_default_selection,
"cmd" => $a_cmd,
"text" => $a_text);
1106 $this->close_command = $a_link;
1117 $this->multi[] = array(
"cmd" => $a_cmd,
"text" => $a_text);
1128 $this->hidden_inputs[] = array(
"name" => $a_name,
"value" => $a_value);
1139 $this->header_commands[] = array(
"href" => $a_href,
"text" => $a_text,
1140 "target" => $a_target,
"img" => $a_img);
1150 $this->top_commands = $a_val;
1170 final public function addColumn($a_text, $a_sort_field =
"", $a_width =
"",
1171 $a_is_checkbox_action_column =
false, $a_class =
"", $a_tooltip =
"")
1173 $this->column[] = array(
1175 "sort_field" => $a_sort_field,
1176 "width" => $a_width,
1177 "is_checkbox_action_column" => $a_is_checkbox_action_column,
1178 "class" => $a_class,
1179 "tooltip" => $a_tooltip
1181 $this->column_count = count($this->column);
1187 return $this->prefix.
"_table_nav";
1195 if (is_object($ilUser) && $ilUser->getPref(
"screen_reader_optimization"))
1197 $hash =
"#".$this->getTopAnchor();
1203 $ilCtrl->setParameter($this->parent_obj,
1205 $sort_field.
":".$order_dir.
":".$this->offset);
1206 $this->tpl->setVariable(
"TBL_ORDER_LINK",
1207 $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd).$hash);
1210 $ilCtrl->setParameter($this->parent_obj,
1218 $allcolumnswithwidth =
true;
1219 foreach ((array) $this->column as $column)
1221 if (!strlen($column[
"width"])) $allcolumnswithwidth =
false;
1223 if ($allcolumnswithwidth)
1225 foreach ((array) $this->column as $column)
1227 $this->tpl->setCurrentBlock(
"tbl_colgroup_column");
1228 $this->tpl->setVariable(
"COLGROUP_COLUMN_WIDTH", $column[
"width"]);
1229 $this->tpl->parseCurrentBlock();
1233 foreach ((array) $this->column as $column)
1238 if ($column[
"tooltip"] !=
"")
1240 include_once(
"./Services/UIComponent/Tooltip/classes/class.ilTooltipGUI.php");
1243 if (!$this->enabled[
"sort"] || $column[
"sort_field"] ==
"" || $column[
"is_checkbox_action_column"])
1245 $this->tpl->setCurrentBlock(
"tbl_header_no_link");
1246 if ($column[
"width"] !=
"")
1248 $this->tpl->setVariable(
"TBL_COLUMN_WIDTH_NO_LINK",
" width=\"".$column[
"width"].
"\"");
1250 if (!$column[
"is_checkbox_action_column"])
1252 $this->tpl->setVariable(
"TBL_HEADER_CELL_NO_LINK",
1257 $this->tpl->setVariable(
"TBL_HEADER_CELL_NO_LINK",
1260 $this->tpl->setVariable(
"HEAD_CELL_NL_ID",
"thc_".$this->
getId().
"_".$ccnt);
1262 if ($column[
"class"] !=
"")
1264 $this->tpl->setVariable(
"TBL_HEADER_CLASS",
" " . $column[
"class"]);
1266 $this->tpl->parseCurrentBlock();
1267 $this->tpl->touchBlock(
"tbl_header_th");
1270 if (($column[
"sort_field"] == $this->order_field) && ($this->order_direction !=
""))
1272 $this->tpl->setCurrentBlock(
"tbl_order_image");
1273 $this->tpl->setVariable(
"IMG_ORDER_DIR",
ilUtil::getImagePath($this->order_direction.
"_order.gif"));
1274 $this->tpl->setVariable(
"IMG_ORDER_ALT", $this->lng->txt(
"change_sort_direction"));
1275 $this->tpl->parseCurrentBlock();
1278 $this->tpl->setCurrentBlock(
"tbl_header_cell");
1279 $this->tpl->setVariable(
"TBL_HEADER_CELL", $column[
"text"]);
1280 $this->tpl->setVariable(
"HEAD_CELL_ID",
"thc_".$this->
getId().
"_".$ccnt);
1283 if ($column[
"width"] !=
"")
1285 $this->tpl->setVariable(
"TBL_COLUMN_WIDTH",
" width=\"".$column[
"width"].
"\"");
1288 $lng_sort_column = $this->lng->txt(
"sort_by_this_column");
1289 $this->tpl->setVariable(
"TBL_ORDER_ALT",$lng_sort_column);
1293 if ($column[
"sort_field"] == $this->order_field)
1295 $order_dir = $this->sort_order;
1297 $lng_change_sort = $this->lng->txt(
"change_sort_direction");
1298 $this->tpl->setVariable(
"TBL_ORDER_ALT",$lng_change_sort);
1301 if ($column[
"class"] !=
"")
1303 $this->tpl->setVariable(
"TBL_HEADER_CLASS",
" " . $column[
"class"]);
1305 $this->
setOrderLink($column[
"sort_field"], $order_dir);
1306 $this->tpl->parseCurrentBlock();
1307 $this->tpl->touchBlock(
"tbl_header_th");
1310 $this->tpl->setCurrentBlock(
"tbl_header");
1311 $this->tpl->parseCurrentBlock();
1329 if ($this->nav_determined)
1354 if ($this->nav_value ==
"" && $this->
getId() !=
"" && $ilUser->getId() != ANONYMOUS_USER_ID)
1362 $nav = explode(
":", $this->nav_value);
1368 if (!$a_omit_offset)
1380 if (!$a_omit_offset)
1382 $this->nav_determined =
true;
1418 if (is_object($ilCtrl) && $this->
getId() ==
"")
1423 if(!$this->enabled[
'content'])
1435 $this->
setFooter(
"tblfooter",$this->lng->txt(
"previous"),$this->lng->txt(
"next"));
1462 $this->tpl->addBlockFile(
"TBL_CONTENT",
"tbl_content", $this->row_template,
1463 $this->row_template_dir);
1465 foreach($data as $set)
1467 $this->tpl->setCurrentBlock(
"tbl_content");
1468 $this->css_row = ($this->css_row !=
"tblrow1")
1471 $this->tpl->setVariable(
"CSS_ROW", $this->css_row);
1474 $this->tpl->setCurrentBlock(
"tbl_content");
1475 $this->tpl->parseCurrentBlock();
1483 : $lng->txt(
"no_items");
1485 $this->css_row = ($this->css_row !=
"tblrow1")
1489 $this->tpl->setCurrentBlock(
"tbl_no_entries");
1490 $this->tpl->setVariable(
'TBL_NO_ENTRY_CSS_ROW', $this->css_row);
1491 $this->tpl->setVariable(
'TBL_NO_ENTRY_COLUMN_COUNT', $this->column_count);
1492 $this->tpl->setVariable(
'TBL_NO_ENTRY_TEXT', trim($no_items_text));
1493 $this->tpl->parseCurrentBlock();
1500 if ($this->form_action !=
"")
1503 if (is_object($ilUser) && $ilUser->getPref(
"screen_reader_optimization"))
1505 $hash =
"#".$this->getTopAnchor();
1508 $this->tpl->setCurrentBlock(
"tbl_form_header");
1509 $this->tpl->setVariable(
"FORMACTION", $this->
getFormAction().$hash);
1510 $this->tpl->setVariable(
"FORMNAME", $this->
getFormName());
1511 $this->tpl->parseCurrentBlock();
1512 $this->tpl->touchBlock(
"tbl_form_footer");
1545 $this->tpl->setVariable(
"CSS_TABLE",$this->
getStyle(
"table"));
1546 $this->tpl->setVariable(
"DATA_TABLE", (
int) $this->
getIsDataTable());
1547 if ($this->
getId() !=
"")
1549 $this->tpl->setVariable(
"ID",
'id="'.$this->
getId().
'"');
1555 $this->tpl->setCurrentBlock(
"tbl_header_description");
1556 $this->tpl->setVariable(
"TBL_DESCRIPTION", $this->
getDescription());
1557 $this->tpl->parseCurrentBlock();
1567 $this->tpl->touchBlock(
"outer_start_1");
1568 $this->tpl->touchBlock(
"outer_end_1");
1572 $this->tpl->touchBlock(
"outer_start_2");
1573 $this->tpl->touchBlock(
"outer_end_2");
1577 if ($this->enabled[
"title"] && ($this->title !=
""
1578 || $this->icon !=
"" || count($this->header_commands) > 0 ||
1579 $this->headerHTML !=
"" || $this->close_command !=
""))
1581 if ($this->enabled[
"icon"])
1583 $this->tpl->setCurrentBlock(
"tbl_header_title_icon");
1585 $this->tpl->setVariable(
"TBL_TITLE_IMG_ALT",$this->icon_alt);
1586 $this->tpl->parseCurrentBlock();
1591 foreach($this->header_commands as
$command)
1593 if ($command[
"img"] !=
"")
1595 $this->tpl->setCurrentBlock(
"tbl_header_img_link");
1596 if ($command[
"target"] !=
"")
1598 $this->tpl->setVariable(
"TARGET_IMG_LINK",
1599 'target="'.$command[
"target"].
'"');
1601 $this->tpl->setVariable(
"ALT_IMG_LINK", $command[
"text"]);
1602 $this->tpl->setVariable(
"HREF_IMG_LINK", $command[
"href"]);
1603 $this->tpl->setVariable(
"SRC_IMG_LINK",
1605 $this->tpl->parseCurrentBlock();
1609 $this->tpl->setCurrentBlock(
"head_cmd");
1610 $this->tpl->setVariable(
"TXT_HEAD_CMD", $command[
"text"]);
1611 $this->tpl->setVariable(
"HREF_HEAD_CMD", $command[
"href"]);
1612 $this->tpl->parseCurrentBlock();
1617 if (isset ($this->headerHTML)) {
1618 $this->tpl->setCurrentBlock(
"tbl_header_html");
1619 $this->tpl->setVariable (
"HEADER_HTML", $this->headerHTML);
1620 $this->tpl->parseCurrentBlock();
1624 if ($this->close_command !=
"")
1626 $this->tpl->setCurrentBlock(
"tbl_header_img_link");
1627 $this->tpl->setVariable(
"ALT_IMG_LINK",$lng->txt(
"close"));
1628 $this->tpl->setVariable(
"HREF_IMG_LINK",$this->close_command);
1630 $this->tpl->parseCurrentBlock();
1633 $this->tpl->setCurrentBlock(
"tbl_header_title");
1634 $this->tpl->setVariable(
"TBL_TITLE",$this->title);
1635 $this->tpl->setVariable(
"TOP_ANCHOR",$this->
getTopAnchor());
1638 $this->tpl->setVariable(
"BLK_CLASS",
"Block");
1640 $this->tpl->parseCurrentBlock();
1644 if ($this->enabled[
"header"])
1649 $this->tpl->touchBlock(
"tbl_table_end");
1651 return $this->tpl->get();
1664 $tpl->addJavascript(
"./Services/Table/js/ServiceTable.js");
1666 if (count($filter) == 0 && count($opt_filter) == 0)
1671 include_once(
"./Services/YUI/classes/class.ilYuiUtil.php");
1677 if (count($filter) > 0)
1679 foreach ($filter as $item)
1683 $this->tpl->setCurrentBlock(
"filter_row");
1684 $this->tpl->parseCurrentBlock();
1687 $this->tpl->setCurrentBlock(
"filter_item");
1688 $this->tpl->setVariable(
"OPTION_NAME",
1690 $this->tpl->setVariable(
"F_INPUT_ID",
1691 $item->getFieldId());
1692 $this->tpl->setVariable(
"INPUT_HTML",
1693 $item->getTableFilterHTML());
1694 $this->tpl->parseCurrentBlock();
1700 if (count($opt_filter) > 0)
1704 foreach ($opt_filter as $item)
1710 $this->tpl->setCurrentBlock(
"filter_row");
1711 $this->tpl->parseCurrentBlock();
1714 $this->tpl->setCurrentBlock(
"filter_item");
1715 $this->tpl->setVariable(
"OPTION_NAME",
1717 $this->tpl->setVariable(
"F_INPUT_ID",
1718 $item->getFieldId());
1719 $this->tpl->setVariable(
"INPUT_HTML",
1720 $item->getTableFilterHTML());
1721 $this->tpl->parseCurrentBlock();
1728 foreach ($opt_filter as $item)
1730 $k = $item->getPostVar();
1731 $items[$k] = array(
"txt" => $item->getTitle(),
1735 include_once(
"./Services/UIComponent/CheckboxListOverlay/classes/class.ilCheckboxListOverlayGUI.php");
1737 $cb_over->setLinkTitle($lng->txt(
"optional_filters"));
1738 $cb_over->setItems($items);
1741 $cb_over->setFieldVar(
"tblff".$this->
getId());
1742 $cb_over->setHiddenVar(
"tblfsf".$this->
getId());
1744 $cb_over->setSelectionHeaderClass(
"ilTableMenuItem");
1745 $this->tpl->setCurrentBlock(
"filter_select");
1748 $this->tpl->setVariable(
"HIDDEN_CMD_APPLY", $this->filter_cmd);
1750 $this->tpl->setVariable(
"FILTER_SELECTOR", $cb_over->getHTML());
1751 $this->tpl->parseCurrentBlock();
1755 if($ccnt > 0 || count($opt_filter) > 0)
1757 $this->tpl->setVariable(
"TXT_FILTER", $lng->txt(
"filter"));
1765 $this->tpl->touchBlock(
"filter_empty_cell");
1768 $this->tpl->setCurrentBlock(
"filter_row");
1769 $this->tpl->parseCurrentBlock();
1771 $this->tpl->setCurrentBlock(
"filter_buttons");
1772 $this->tpl->setVariable(
"CMD_APPLY", $this->filter_cmd);
1773 $this->tpl->setVariable(
"TXT_APPLY", $lng->txt(
"apply_filter"));
1774 $this->tpl->setVariable(
"CMD_RESET", $this->reset_cmd);
1775 $this->tpl->setVariable(
"TXT_RESET", $lng->txt(
"reset_filter"));
1777 else if(count($opt_filter) > 0)
1779 $this->tpl->setCurrentBlock(
"optional_filter_hint");
1780 $this->tpl->setVariable(
'TXT_OPT_HINT', $lng->txt(
'optional_filter_hint'));
1781 $this->tpl->parseCurrentBlock();
1784 $this->tpl->setCurrentBlock(
"filter_section");
1785 $this->tpl->setVariable(
"FIL_ID", $this->
getId());
1786 $this->tpl->parseCurrentBlock();
1793 $this->tpl->setCurrentBlock(
"filter_hidden");
1794 $this->tpl->setVariable(
"FI_ID", $this->
getId());
1795 $this->tpl->parseCurrentBlock();
1811 foreach ($filter as $item)
1813 if ($item->checkInput())
1815 $item->setValueByArray(
$_POST);
1816 $item->writeToSession();
1819 foreach ($opt_filter as $item)
1821 if ($item->checkInput())
1823 $item->setValueByArray(
$_POST);
1824 $item->writeToSession();
1839 foreach ($filter as $item)
1841 if ($item->checkInput())
1843 $item->setValueByArray(
$_POST);
1844 $item->clearFromSession();
1847 foreach ($opt_filter as $item)
1849 if ($item->checkInput())
1851 $item->setValueByArray(
$_POST);
1852 $item->clearFromSession();
1865 foreach ($a_set as $key => $value)
1867 $this->tpl->setVariable(
"VAL_".strtoupper($key), $value);
1883 $this->tpl->setCurrentBlock(
"select_all_checkbox");
1884 $this->tpl->setVariable(
"SELECT_ALL_TXT_SELECT_ALL", $lng->txt(
"select_all"));
1886 $this->tpl->setVariable(
"SELECT_ALL_FORM_NAME", $this->
getFormName());
1887 $this->tpl->setVariable(
"CHECKBOXNAME",
"chb_select_all_" . $this->unique_id);
1888 $this->tpl->parseCurrentBlock();
1892 if ($this->enabled[
"numinfo"] && $this->enabled[
"footer"])
1894 $start = $this->offset + 1;
1901 if ($end > $this->max_count or $this->limit == 0)
1906 if ($this->max_count > 0)
1908 if ($this->lang_support)
1910 $numinfo =
"(".$start.
" - ".$end.
" ".strtolower($this->lng->txt(
"of")).
" ".$this->max_count.
")";
1914 $numinfo =
"(".$start.
" - ".$end.
" of ".$this->max_count.
")";
1917 if ($this->max_count > 0)
1921 $this->tpl->setCurrentBlock(
"tbl_footer_numinfo");
1922 $this->tpl->setVariable(
"NUMINFO", $numinfo);
1923 $this->tpl->parseCurrentBlock();
1930 if ($this->enabled[
"linkbar"] && $this->enabled[
"footer"] && $this->limit != 0
1931 && $this->max_count > 0)
1934 "link" => $this->footer_style,
1935 "prev" => $this->footer_previous,
1936 "next" => $this->footer_next,
1941 $this->tpl->setCurrentBlock(
"tbl_footer_linkbar");
1942 $this->tpl->setVariable(
"LINKBAR", $linkbar);
1943 $this->tpl->parseCurrentBlock();
1955 $items[$k] = array(
"txt" => $c[
"txt"],
1958 include_once(
"./Services/UIComponent/CheckboxListOverlay/classes/class.ilCheckboxListOverlayGUI.php");
1960 $cb_over->setLinkTitle($lng->txt(
"columns"));
1961 $cb_over->setItems($items);
1965 $cb_over->setFieldVar(
"tblfs".$this->
getId());
1966 $cb_over->setHiddenVar(
"tblfsh".$this->
getId());
1967 $cb_over->setSelectionHeaderClass(
"ilTableMenuItem");
1968 $column_selector = $cb_over->getHTML();
1990 $create_id =
"template_create_overlay_".$this->getId();
1991 $delete_id =
"template_delete_overlay_".$this->getId();
1992 $list_id =
"template_stg_".$this->getId();
1994 include_once(
"./Services/Table/classes/class.ilTableTemplatesStorage.php");
1996 $templates = $storage->getNames($this->
getContext(), $ilUser->getId());
1998 include_once(
"./Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php");
2001 if(
sizeof($templates))
2004 $overlay->setTrigger($list_id.
"_delete");
2005 $overlay->setAnchor(
"ilAdvSelListAnchorElement_".$list_id);
2006 $overlay->setAutoHide(
false);
2009 $this->tpl->setCurrentBlock(
"template_editor_delete_item");
2010 $this->tpl->setVariable(
"TEMPLATE_DELETE_OPTION",
"");
2011 $this->tpl->parseCurrentBlock();
2012 foreach($templates as
$name)
2014 $this->tpl->setVariable(
"TEMPLATE_DELETE_OPTION", $name);
2015 $this->tpl->parseCurrentBlock();
2018 $this->tpl->setCurrentBlock(
"template_editor_delete");
2019 $this->tpl->setVariable(
"TEMPLATE_DELETE_ID", $delete_id);
2020 $this->tpl->setVariable(
"TXT_TEMPLATE_DELETE", $lng->txt(
"tbl_template_delete"));
2021 $this->tpl->setVariable(
"TXT_TEMPLATE_DELETE_SUBMIT", $lng->txt(
"delete"));
2022 $this->tpl->setVariable(
"TEMPLATE_DELETE_CMD", $this->parent_cmd);
2023 $this->tpl->parseCurrentBlock();
2029 $overlay->setTrigger($list_id.
"_create");
2030 $overlay->setAnchor(
"ilAdvSelListAnchorElement_".$list_id);
2031 $overlay->setAutoHide(
false);
2034 $this->tpl->setCurrentBlock(
"template_editor");
2035 $this->tpl->setVariable(
"TEMPLATE_CREATE_ID", $create_id);
2036 $this->tpl->setVariable(
"TXT_TEMPLATE_CREATE", $lng->txt(
"tbl_template_create"));
2037 $this->tpl->setVariable(
"TXT_TEMPLATE_CREATE_SUBMIT", $lng->txt(
"save"));
2038 $this->tpl->setVariable(
"TEMPLATE_CREATE_CMD", $this->parent_cmd);
2039 $this->tpl->parseCurrentBlock();
2042 include_once(
"./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
2044 $alist->setId($list_id);
2045 $alist->addItem($lng->txt(
"tbl_template_create"),
"create",
"#");
2046 if(
sizeof($templates))
2048 $alist->addItem($lng->txt(
"tbl_template_delete"),
"delete",
"#");
2049 foreach($templates as
$name)
2051 $ilCtrl->setParameter($this->parent_obj, $this->prefix.
"_tpl", $name);
2052 $alist->addItem($name, $name, $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd));
2053 $ilCtrl->setParameter($this->parent_obj, $this->prefix.
"_tpl",
"");
2056 $alist->setListTitle($lng->txt(
"tbl_templates"));
2057 $this->tpl->setVariable(
"TEMPLATE_SELECTOR",
" ".$alist->getHTML());
2062 $this->tpl->setCurrentBlock(
"tbl_footer");
2063 $this->tpl->setVariable(
"COLUMN_COUNT", $this->
getColumnCount());
2066 $this->tpl->setVariable(
"BLK_CLASS",
"Block");
2068 $this->tpl->parseCurrentBlock();
2071 if ($numinfo !=
"" || $linkbar !=
"" || $column_selector !=
"" ||
2072 count($this->filters) > 0 || count($this->optional_filters) > 0)
2074 if (is_object($ilUser) && (count($this->filters) || count($this->optional_filters)))
2076 $this->tpl->setCurrentBlock(
"filter_activation");
2077 $this->tpl->setVariable(
"TXT_ACTIVATE_FILTER", $lng->txt(
"show_filter"));
2078 $this->tpl->setVariable(
"FILA_ID", $this->
getId());
2079 if ($this->
getId() !=
"")
2081 $this->tpl->setVariable(
"SAVE_URLA",
"./ilias.php?baseClass=ilTablePropertiesStorage&table_id=".
2082 $this->
getId().
"&cmd=showFilter&user_id=".$ilUser->getId());
2084 $this->tpl->parseCurrentBlock();
2089 $this->tpl->setCurrentBlock(
"filter_deactivation");
2090 $this->tpl->setVariable(
"TXT_HIDE", $lng->txt(
"hide_filter"));
2091 if ($this->
getId() !=
"")
2093 $this->tpl->setVariable(
"SAVE_URL",
"./ilias.php?baseClass=ilTablePropertiesStorage&table_id=".
2094 $this->
getId().
"&cmd=hideFilter&user_id=".$ilUser->getId());
2095 $this->tpl->setVariable(
"FILD_ID", $this->
getId());
2097 $this->tpl->parseCurrentBlock();
2104 $this->tpl->setCurrentBlock(
"top_numinfo");
2105 $this->tpl->setVariable(
"NUMINFO", $numinfo);
2106 $this->tpl->parseCurrentBlock();
2111 $this->tpl->setCurrentBlock(
"top_linkbar");
2112 $this->tpl->setVariable(
"LINKBAR", $linkbar);
2113 $this->tpl->parseCurrentBlock();
2117 $this->tpl->setVariable(
"COLUMN_SELECTOR", $column_selector);
2122 include_once(
"./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
2124 $alist->setId(
"sellst_rows");
2125 $hpp = ($ilUser->getPref(
"hits_per_page") != 9999)
2126 ? $ilUser->getPref(
"hits_per_page")
2127 : $lng->txt(
"unlimited");
2129 $options = array(0 => $lng->txt(
"default").
" (".$hpp.
")",5 => 5, 10 => 10, 15 => 15, 20 => 20,
2130 30 => 30, 40 => 40, 50 => 50,
2131 100 => 100, 200 => 200, 400 => 400, 800 => 800);
2132 foreach ($options as $k => $v)
2134 $ilCtrl->setParameter($this->parent_obj, $this->prefix.
"_trows", $k);
2135 $alist->addItem($v, $k, $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd));
2136 $ilCtrl->setParameter($this->parent_obj, $this->prefix.
"_trows",
"");
2138 $alist->setListTitle($lng->txt(
"rows"));
2139 $this->tpl->setVariable(
"ROW_SELECTOR", $alist->getHTML());
2143 if(
sizeof($this->export_formats))
2145 $map = array(self::EXPORT_EXCEL =>
"tbl_export_excel",
2146 self::EXPORT_CSV =>
"tbl_export_csv");
2147 include_once(
"./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
2149 $alist->setId(
"sellst_xpt");
2150 foreach($this->export_formats as $format)
2152 $ilCtrl->setParameter($this->parent_obj, $this->prefix.
"_xpt", $format);
2153 $url = $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd);
2154 $ilCtrl->setParameter($this->parent_obj, $this->prefix.
"_xpt",
"");
2155 $alist->addItem($lng->txt($map[$format]), $format, $url);
2157 $alist->setListTitle($lng->txt(
"export"));
2158 $this->tpl->setVariable(
"EXPORT_SELECTOR",
" ".$alist->getHTML());
2161 $this->tpl->setCurrentBlock(
"top_navigation");
2162 $this->tpl->setVariable(
"COLUMN_COUNT", $this->
getColumnCount());
2165 $this->tpl->setVariable(
"BLK_CLASS",
"Block");
2167 $this->tpl->parseCurrentBlock();
2184 if (is_object($ilUser) && $ilUser->getPref(
"screen_reader_optimization"))
2186 $hash =
"#".$this->getTopAnchor();
2189 $link = $ilCtrl->getLinkTargetByClass(get_class($this->parent_obj), $this->parent_cmd).
2190 "&".$this->getNavParameter().
"=".
2194 $layout_prev = $lng->txt(
"previous");
2195 $layout_next = $lng->txt(
"next");
2198 if ($this->max_count > $this->
getLimit() || $this->custom_prev_next)
2200 $sep =
"<span> | </span>";
2203 $pages = intval($this->max_count / $this->
getLimit());
2206 if (($this->max_count % $this->
getLimit()))
2210 $offset_arr = array();
2211 for ($i = 1 ;$i <= $pages ; $i++)
2213 $newoffset = $this->
getLimit() * ($i-1);
2216 $offset_arr[$nav_value] = $i;
2219 $sep =
"<span> </span>";
2222 if ($this->custom_prev_next && $this->custom_prev !=
"")
2226 $LinkBar .=
"<a href=\"".$this->custom_prev.$hash.
"\">".$layout_prev.
"</a>";
2228 else if ($this->
getOffset() >= 1 && !$this->custom_prev_next)
2233 $LinkBar .=
"<a href=\"".$link.$prevoffset.$hash.
"\">".$layout_prev.
"</a>";
2239 $LinkBar .=
'<span class="ilTableFootLight">'.$layout_prev.
"</span>";
2245 $LinkBar .=
'<input type="hidden" name="'.$this->getNavParameter().
2249 $sep =
"<span> | </span>";
2252 if ($this->custom_prev_next && $this->custom_next !=
"")
2256 $LinkBar .=
"<a href=\"".$this->custom_next.$hash.
"\">".$layout_next.
"</a>";
2258 else if (! ( ($this->
getOffset() / $this->
getLimit())==($pages-1) ) && ($pages!=1) &&
2259 !$this->custom_prev_next)
2264 $LinkBar .=
"<a href=\"".$link.$newoffset.$hash.
"\">".$layout_next.
"</a>";
2270 $LinkBar .=
'<span class="ilTableFootLight">'.$layout_next.
"</span>";
2273 $sep =
"<span> </span>";
2275 if (count($offset_arr) && !$this->
getDisplayAsBlock() && !$this->custom_prev_next)
2280 '<label for="tab_page_sel_'.$a_num.
'">'.$lng->txt(
"page").
'</label> '.
2282 $this->
getNavParameter().$a_num, $offset_arr,
false,
true, 0,
"small",
2283 array(
"id" =>
"tab_page_sel_".$a_num,
2284 "onchange" =>
"ilTablePageSelection(this, 'cmd[".$this->parent_cmd.
"]')"));
2299 $hidden_row =
false;
2300 if(count($this->hidden_inputs))
2302 foreach ($this->hidden_inputs as $hidden_input)
2304 $this->tpl->setCurrentBlock(
"tbl_hidden_field");
2305 $this->tpl->setVariable(
"FIELD_NAME", $hidden_input[
"name"]);
2306 $this->tpl->setVariable(
"FIELD_VALUE", $hidden_input[
"value"]);
2307 $this->tpl->parseCurrentBlock();
2310 $this->tpl->setCurrentBlock(
"tbl_hidden_row");
2311 $this->tpl->parseCurrentBlock();
2323 $action_row =
false;
2327 if (count($this->sel_buttons) > 0)
2329 foreach ($this->sel_buttons as $button)
2331 $this->tpl->setCurrentBlock(
"sel_button");
2332 $this->tpl->setVariable(
"SBUTTON_SELECT",
2334 $button[
"options"],
false,
true));
2335 $this->tpl->setVariable(
"SBTN_NAME", $button[
"cmd"]);
2336 $this->tpl->setVariable(
"SBTN_VALUE", $button[
"text"]);
2337 $this->tpl->parseCurrentBlock();
2341 $this->tpl->setCurrentBlock(
"sel_top_button");
2342 $this->tpl->setVariable(
"SBUTTON_SELECT",
2344 $button[
"options"],
false,
true));
2345 $this->tpl->setVariable(
"SBTN_NAME", $button[
"cmd"]);
2346 $this->tpl->setVariable(
"SBTN_VALUE", $button[
"text"]);
2347 $this->tpl->parseCurrentBlock();
2353 $this->sel_buttons[] = array(
"options" => $a_options,
"cmd" => $a_cmd,
"text" => $a_text);
2356 if (count($this->buttons) > 0)
2358 foreach ($this->buttons as $button)
2360 if (strlen($button[
'onclick']))
2362 $this->tpl->setCurrentBlock(
'cmdonclick');
2363 $this->tpl->setVariable(
'CMD_ONCLICK', $button[
'onclick']);
2364 $this->tpl->parseCurrentBlock();
2366 $this->tpl->setCurrentBlock(
"plain_button");
2367 $this->tpl->setVariable(
"PBTN_NAME", $button[
"cmd"]);
2368 $this->tpl->setVariable(
"PBTN_VALUE", $button[
"text"]);
2369 $this->tpl->parseCurrentBlock();
2373 if (strlen($button[
'onclick']))
2375 $this->tpl->setCurrentBlock(
'top_cmdonclick');
2376 $this->tpl->setVariable(
'CMD_ONCLICK', $button[
'onclick']);
2377 $this->tpl->parseCurrentBlock();
2379 $this->tpl->setCurrentBlock(
"plain_top_button");
2380 $this->tpl->setVariable(
"PBTN_NAME", $button[
"cmd"]);
2381 $this->tpl->setVariable(
"PBTN_VALUE", $button[
"text"]);
2382 $this->tpl->parseCurrentBlock();
2391 if(count($this->mi_sel_buttons))
2393 foreach ($this->mi_sel_buttons as $button)
2395 $this->tpl->setCurrentBlock(
"mi_sel_button");
2396 $this->tpl->setVariable(
"MI_BUTTON_SELECT",
2398 $button[
"options"],
false,
true));
2399 $this->tpl->setVariable(
"MI_BTN_NAME", $button[
"cmd"]);
2400 $this->tpl->setVariable(
"MI_BTN_VALUE", $button[
"text"]);
2401 $this->tpl->parseCurrentBlock();
2405 $this->tpl->setCurrentBlock(
"mi_top_sel_button");
2406 $this->tpl->setVariable(
"MI_BUTTON_SELECT",
2408 $button[
"options"],
false,
true));
2409 $this->tpl->setVariable(
"MI_BTN_NAME", $button[
"cmd"]);
2410 $this->tpl->setVariable(
"MI_BTN_VALUE", $button[
"text"]);
2411 $this->tpl->parseCurrentBlock();
2420 if (count($this->multi) > 1 && $this->
dataExists())
2422 $this->tpl->setCurrentBlock(
"tbl_cmd_select");
2424 foreach ($this->multi as $mc)
2426 $sel[$mc[
"cmd"]] = $mc[
"text"];
2428 $this->tpl->setVariable(
"SELECT_CMDS",
2430 $this->tpl->setVariable(
"TXT_EXECUTE", $lng->txt(
"execute"));
2431 $this->tpl->parseCurrentBlock();
2437 $this->tpl->setCurrentBlock(
"tbl_top_cmd_select");
2439 foreach ($this->multi as $mc)
2441 $sel[$mc[
"cmd"]] = $mc[
"text"];
2443 $this->tpl->setVariable(
"SELECT_CMDS",
2445 $this->tpl->setVariable(
"TXT_EXECUTE", $lng->txt(
"execute"));
2446 $this->tpl->parseCurrentBlock();
2449 elseif(count($this->multi) == 1 && $this->
dataExists())
2451 $this->tpl->setCurrentBlock(
"tbl_single_cmd");
2453 foreach ($this->multi as $mc)
2458 $this->tpl->setVariable(
"TXT_SINGLE_CMD",$txt);
2459 $this->tpl->setVariable(
"SINGLE_CMD",
$cmd);
2460 $this->tpl->parseCurrentBlock();
2466 $this->tpl->setCurrentBlock(
"tbl_top_single_cmd");
2468 foreach ($this->multi as $mc)
2473 $this->tpl->setVariable(
"TXT_SINGLE_CMD",$txt);
2474 $this->tpl->setVariable(
"SINGLE_CMD",
$cmd);
2475 $this->tpl->parseCurrentBlock();
2481 $this->tpl->setCurrentBlock(
"tbl_action_img_arrow");
2483 $this->tpl->setVariable(
"ALT_ARROW", $lng->txt(
"action"));
2484 $this->tpl->parseCurrentBlock();
2488 $this->tpl->setCurrentBlock(
"tbl_top_action_img_arrow");
2490 $this->tpl->setVariable(
"ALT_ARROW", $lng->txt(
"action"));
2491 $this->tpl->parseCurrentBlock();
2497 $this->tpl->setCurrentBlock(
"tbl_action_row");
2498 $this->tpl->parseCurrentBlock();
2501 $this->tpl->setCurrentBlock(
"tbl_top_action_row");
2502 $this->tpl->parseCurrentBlock();
2514 $this->headerHTML = $html;
2527 if(is_object($ilUser) && $this->
getId() !=
"" && $ilUser->getId() != ANONYMOUS_USER_ID)
2529 include_once(
"./Services/Table/classes/class.ilTablePropertiesStorage.php");
2532 $tab_prop->storeProperty($this->
getId(), $ilUser->getId(),
$type, $value);
2546 if(is_object($ilUser) && $this->
getId() !=
"" && $ilUser->getId() != ANONYMOUS_USER_ID)
2548 include_once(
"./Services/Table/classes/class.ilTablePropertiesStorage.php");
2551 return $tab_prop->getProperty($this->
getId(), $ilUser->getId(),
$type);
2573 $result[
"rows"] = $this->
getLimit();
2580 foreach($this->filters as $item)
2582 $result[
"filter_values"][$item->getFieldId()] = $this->
getFilterValue($item);
2585 if($this->optional_filters && $result[
"selfilters"])
2587 foreach($this->optional_filters as $item)
2589 if(in_array($item->getFieldId(), $result[
"selfilters"]))
2591 $result[
"filter_values"][$item->getFieldId()] = $this->
getFilterValue($item);
2607 if(method_exists($a_item,
"getChecked"))
2609 return $a_item->getChecked();
2611 else if(method_exists($a_item,
"getValue"))
2613 return $a_item->getValue();
2615 else if(method_exists($a_item,
"getDate"))
2629 if(method_exists($a_item,
"setChecked"))
2631 $a_item->setChecked($a_value);
2633 else if(method_exists($a_item,
"setValue"))
2635 $a_item->setValue($a_value);
2637 else if(method_exists($a_item,
"setDate"))
2653 $this->context = $id;
2674 $this->show_rows_selector = (bool)$a_value;
2694 $this->show_templates = (bool)$a_value;
2717 if(trim($a_name) && $this->
getContext() !=
"" && is_object($ilUser) && $ilUser->getId() != ANONYMOUS_USER_ID)
2719 include_once(
"./Services/Table/classes/class.ilTableTemplatesStorage.php");
2722 $data = $storage->load($this->
getContext(), $ilUser->getId(), $a_name);
2725 foreach(
$data as $property => $value)
2731 $data[
"filter_values"] = unserialize(
$data[
"filter_values"]);
2732 if(
$data[
"filter_values"])
2734 $this->restore_filter_values =
$data[
"filter_values"];
2752 if(trim($a_name) && $this->
getContext() !=
"" && is_object($ilUser) && $ilUser->getId() != ANONYMOUS_USER_ID)
2754 include_once(
"./Services/Table/classes/class.ilTableTemplatesStorage.php");
2758 $state[
"filter_values"] = serialize($state[
"filter_values"]);
2759 $state[
"selfields"] = serialize($state[
"selfields"]);
2760 $state[
"selfilters"] = serialize($state[
"selfilters"]);
2762 $storage->store($this->
getContext(), $ilUser->getId(), $a_name, $state);
2778 if(trim($a_name) && $this->
getContext() !=
"" && is_object($ilUser) && $ilUser->getId() != ANONYMOUS_USER_ID)
2780 include_once(
"./Services/Table/classes/class.ilTableTemplatesStorage.php");
2782 $storage->delete($this->
getContext(), $ilUser->getId(), $a_name);
2819 $this->export_formats = array();
2820 $valid = array(self::EXPORT_EXCEL, self::EXPORT_CSV);
2821 foreach($formats as $format)
2823 if(in_array($format,
$valid))
2825 $this->export_formats[] = $format;
2836 $this->print_mode = (bool)$a_value;
2871 case self::EXPORT_EXCEL:
2872 include_once
"./Services/Excel/classes/class.ilExcelUtils.php";
2873 include_once
"./Services/Excel/classes/class.ilExcelWriterAdapter.php";
2875 $workbook = $adapter->getWorkbook();
2876 $worksheet = $workbook->addWorksheet();
2882 foreach($this->row_data as $set)
2892 case self::EXPORT_CSV:
2893 include_once
"./Services/Utilities/classes/class.ilCSVWriter.php";
2895 $csv->setSeparator(
";");
2900 foreach($this->row_data as $set)
2909 header(
"Content-type: text/comma-separated-values");
2910 header(
"Content-Disposition: attachment; filename=\"".
$filename.
"\"");
2911 header(
"Expires: 0");
2912 header(
"Cache-Control: must-revalidate, post-check=0,pre-check=0");
2913 header(
"Pragma: public");
2914 echo $csv->getCSVString();
2919 file_put_contents(
$filename, $csv->getCSVString());
2953 foreach ($this->column as $column)
2956 $worksheet->write($a_row, $col, strip_tags($column[
"text"]));
2972 foreach ($a_set as $key => $value)
2975 if(is_array($value))
2977 $value = implode(
', ', $value);
2979 $a_worksheet->write($a_row, $col, strip_tags($value));
3002 foreach ($this->column as $column)
3004 $a_csv->addColumn(strip_tags($column[
"text"]));
3018 foreach ($a_set as $key => $value)
3020 if(is_array($value))
3022 $value = implode(
', ', $value);
3024 $a_csv->addColumn(strip_tags($value));