87 "numinfo_header" =>
false,
96 "table" =>
"fullwidth"
110 $this->global_tpl = $a_global_tpl;
111 $this->ilias =& $ilias;
112 $this->header_vars = array();
113 $this->header_params = array();
114 $this->enabled[
"form"] =
true;
115 $this->action_buttons = array();
116 if ($this->global_tpl)
122 $this->tpl =
new ilTemplate(
"tpl.table.html",
true,
true,
"Services/Table");
129 $this->lang_support =
false;
143 $this->tpl =& $a_tpl;
158 if (is_array($a_data))
160 $this->data = $a_data;
176 function setTitle($a_title,$a_icon = 0,$a_icon_alt = 0)
178 $this->title = $a_title;
179 $this->icon = $a_icon;
180 $this->icon_alt = $a_icon_alt;
184 $this->enabled[
"icon"] =
false;
189 if (!$this->icon_alt)
193 $this->enabled[
"icon"] =
true;
203 function setHelp($a_help_page,$a_help_icon,$a_help_icon_alt = 0)
205 $this->help_page = $a_help_page;
206 $this->help_icon = $a_help_icon;
207 $this->help_icon_alt = $a_help_icon_alt;
209 if (!$this->help_icon_alt)
222 $this->header_names = $a_header_names;
223 $this->column_count = count($this->header_names);
244 $this->header_vars = $a_header_vars;
246 if ($a_header_params == 0 or !is_array($a_header_params))
248 $this->link_params =
"";
252 $this->header_params = $a_header_params;
254 foreach ($a_header_params as
$key => $val)
256 $this->link_params .=
$key.
"=".$val.
"&";
268 $this->column_width = $a_column_width;
279 $this->column_width[$a_column_number] = $a_column_width;
291 $this->max_count = $a_max_count;
293 if ($this->max_limit)
305 function setLimit($a_limit = 0, $a_default_limit = 0)
307 $this->limit = ($a_limit) ? $a_limit : $a_default_limit;
309 if ($this->limit == 0)
311 $this->max_limit =
true;
331 $this->prefix = ($a_prefix) ? $a_prefix :
"";
341 $this->offset = ($a_offset) ? $a_offset : 0;
361 if (empty($a_order_column))
363 if (!empty($a_default_column))
365 $this->order_column = array_search($a_default_column,$this->header_vars);
369 $this->order_column = 0;
375 $this->order_column = array_search($a_order_column,$this->header_vars);
378 if ($this->order_column ===
false)
381 $this->order_column = 0;
400 if ($a_order_direction ==
"desc")
402 $this->order_direction =
"desc";
403 $this->sort_order =
"asc";
407 $this->order_direction =
"asc";
408 $this->sort_order =
"desc";
427 function setFooter($a_style,$a_previous = 0,$a_next = 0)
429 $this->footer_style = $a_style;
431 $this->footer_previous = ($a_previous) ? $a_previous :
"<<<";
432 $this->footer_next = ($a_next) ? $a_next :
">>>";
445 if (!in_array($a_module_name,array_keys($this->enabled)))
450 $this->enabled[$a_module_name] =
true;
463 if (!in_array($a_module_name,array_keys($this->enabled)))
468 $this->enabled[$a_module_name] =
false;
474 if($this->enabled[
"sort"])
476 $this->data =
ilUtil::sortArray($this->data,$this->order_column,$this->order_direction);
478 $this->data = array_slice($this->data,$this->offset,$this->limit);
487 if($this->enabled[
'table'])
489 $this->tpl->setVariable(
"CSS_TABLE",$this->
getStyle(
"table"));
493 if ($this->enabled[
"icon"] && $this->enabled[
"title"])
495 $this->tpl->setCurrentBlock(
"tbl_header_title_icon");
497 $this->tpl->setVariable(
"TBL_TITLE_IMG_ALT",$this->icon_alt);
498 $this->tpl->parseCurrentBlock();
501 if ($this->enabled[
"help"] && $this->enabled[
"title"])
503 $this->tpl->setCurrentBlock(
"tbl_header_title_help");
505 $this->tpl->setVariable(
"TBL_HELP_LINK",$this->help_page);
506 $this->tpl->setVariable(
"TBL_HELP_IMG_ALT",$this->help_icon_alt);
507 $this->tpl->parseCurrentBlock();
511 if ($this->enabled[
"hits"] && $this->enabled[
"title"])
513 $this->tpl->setCurrentBlock(
"tbl_header_hits_page");
514 $this->tpl->setVariable(
"LIMIT",
$_SESSION[
"tbl_limit"]);
515 $this->tpl->setVariable(
"HITS_PER_PAGE",$this->lng->txt(
"hits_per_page"));
516 $this->tpl->parseCurrentBlock();
520 if ($this->enabled[
"title"])
522 $this->tpl->setCurrentBlock(
"tbl_header_title");
523 $this->tpl->setVariable(
"COLUMN_COUNT",$this->column_count);
524 $this->tpl->setVariable(
"TBL_TITLE",$this->title);
525 $this->tpl->parseCurrentBlock();
529 if ($this->enabled[
"header"])
539 if ($this->enabled[
"content"] && is_array($this->data))
541 if($this->enabled[
'auto_sort'])
548 foreach ($this->data as $tbl_content_row)
550 foreach ($tbl_content_row as
$key => $tbl_content_cell)
552 if (is_array($tbl_content_cell))
554 $this->tpl->setCurrentBlock(
"tbl_cell_subtitle");
555 $this->tpl->setVariable(
"TBL_CELL_SUBTITLE",$tbl_content_cell[1]);
556 $this->tpl->parseCurrentBlock();
557 $tbl_content_cell =
"<b>".$tbl_content_cell[0].
"</b>";
560 $this->tpl->setCurrentBlock(
"tbl_content_cell");
561 $this->tpl->setVariable(
"TBL_CONTENT_CELL",$tbl_content_cell);
562 $this->tpl->parseCurrentBlock();
565 $this->tpl->setCurrentBlock(
"tbl_content_row");
567 $this->tpl->setVariable(
"ROWCOLOR", $rowcolor);
568 $this->tpl->parseCurrentBlock();
574 if ($this->enabled[
"select_all"])
578 $this->tpl->setVariable(
'SELECT_PREFIX',$this->prefix);
579 $this->tpl->setVariable(
"SELECT_ALL_TXT_SELECT_ALL", $this->lng->txt(
"select_all"));
581 $this->tpl->setVariable(
"SELECT_ALL_FORM_NAME", $this->
getFormName());
582 if (!($this->enabled[
"numinfo"] && $this->enabled[
"footer"]))
590 if ($this->enabled[
"numinfo_header"])
592 $start = $this->offset + 1;
595 if ($end > $this->max_count or $this->limit == 0)
600 if ($this->lang_support)
602 $numinfo =
"(".$this->lng->txt(
"dataset").
" ".
$start.
" - ".$end.
" ".strtolower($this->lng->txt(
"of")).
" ".$this->max_count.
")";
606 $numinfo =
"(Dataset ".$start.
" - ".$end.
" of ".$this->max_count.
")";
608 if ($this->max_count > 0)
611 $this->tpl->setCurrentBlock(
"tbl_header_numinfo");
612 $this->tpl->setVariable(
"NUMINFO_HEADER", $numinfo);
613 $this->tpl->setVariable(
"COLUMN_COUNT_HEADER", $this->
getColumnCount());
614 $this->tpl->parseCurrentBlock();
618 if ($this->enabled[
"numinfo"] && $this->enabled[
"footer"])
620 $start = $this->offset + 1;
623 if ($end > $this->max_count or $this->limit == 0)
628 if ($this->lang_support)
630 $numinfo =
"(".$this->lng->txt(
"dataset").
" ".
$start.
" - ".$end.
" ".strtolower($this->lng->txt(
"of")).
" ".$this->max_count.
")";
634 $numinfo =
"(Dataset ".$start.
" - ".$end.
" of ".$this->max_count.
")";
636 if ($this->max_count > 0)
639 $this->tpl->setCurrentBlock(
"tbl_footer_numinfo");
640 $this->tpl->setVariable(
"NUMINFO", $numinfo);
641 $this->tpl->parseCurrentBlock();
645 if ($this->enabled[
"linkbar"] && $this->enabled[
"footer"] && $this->limit != 0
646 && $this->max_count > 0)
649 $this->prefix.
"sort_by" => $this->header_vars[$this->order_column],
650 $this->prefix.
"sort_order" => $this->order_direction
655 "link" => $this->footer_style,
656 "prev" => $this->footer_previous,
657 "next" => $this->footer_next,
661 ? basename($_SERVER[
"PHP_SELF"])
665 $this->tpl->setCurrentBlock(
"tbl_footer_linkbar");
666 $this->tpl->setVariable(
"LINKBAR", $linkbar);
667 $this->tpl->parseCurrentBlock();
671 if ($this->enabled[
"footer"] && $this->max_count > 0)
673 $this->tpl->setCurrentBlock(
"tbl_footer");
674 $this->tpl->setVariable(
"COLUMN_COUNT",$this->column_count);
675 $this->tpl->parseCurrentBlock();
679 if ($this->enabled[
"action"])
681 foreach ($this->action_buttons as $button)
683 $this->tpl->setCurrentBlock(
"tbl_action_btn");
684 $this->tpl->setVariable(
"BTN_NAME", $button[
"name"]);
685 $this->tpl->setVariable(
"BTN_VALUE", $button[
"value"]);
686 $this->tpl->parseCurrentBlock();
688 $this->tpl->setCurrentBlock(
"tbl_action_row");
690 $this->tpl->setVariable(
"ALT_ARROW", $this->lng->txt(
"arrow_downright.gif"));
691 $this->tpl->setVariable(
"COLUMN_COUNTS", $this->
getColumnCount());
692 $this->tpl->parseCurrentBlock();
695 if ($this->enabled[
"form"])
697 $this->tpl->touchBlock(
"tbl_form_footer");
700 if($this->enabled[
'table'])
702 $this->tpl->touchBlock(
"tbl_table_end");
705 if (!$this->global_tpl)
707 return $this->tpl->get();
713 foreach ($this->header_names as
$key => $tbl_header_cell)
715 if (!$this->enabled[
"sort"])
717 $this->tpl->setCurrentBlock(
"tbl_header_no_link");
718 if ($this->column_width[
$key])
720 $this->tpl->setVariable(
"TBL_COLUMN_WIDTH_NO_LINK",
" width=\"".$this->column_width[$key].
"\"");
722 $this->tpl->setVariable(
"TBL_HEADER_CELL_NO_LINK",$tbl_header_cell);
723 $this->tpl->parseCurrentBlock();
726 if ((
$key == $this->order_column) && ($this->order_direction !=
""))
728 if (strcmp($this->header_vars[
$key],
"") != 0)
730 $this->tpl->setCurrentBlock(
"tbl_order_image");
731 $this->tpl->setVariable(
"IMG_ORDER_DIR",
ilUtil::getImagePath($this->order_direction.
"_order.gif"));
732 $this->tpl->parseCurrentBlock();
736 $this->tpl->setCurrentBlock(
"tbl_header_cell");
737 $this->tpl->setVariable(
"TBL_HEADER_CELL",$tbl_header_cell);
740 if ($this->column_width[
$key])
742 $this->tpl->setVariable(
"TBL_COLUMN_WIDTH",
" width=\"".$this->column_width[$key].
"\"");
745 $lng_sort_column = (
$this->lang_support) ? $this->lng->txt(
"sort_by_this_column") :
"Sort by this column";
746 $this->tpl->setVariable(
"TBL_ORDER_ALT",$lng_sort_column);
750 if ($key == $this->order_column)
752 $order_dir = $this->sort_order;
754 $lng_change_sort = (
$this->lang_support) ? $this->lng->txt(
"change_sort_direction") :
"Change sort direction";
755 $this->tpl->setVariable(
"TBL_ORDER_ALT",$lng_change_sort);
759 $this->tpl->parseCurrentBlock();
762 $this->tpl->setCurrentBlock(
"tbl_header");
763 $this->tpl->parseCurrentBlock();
768 $this->tpl->setVariable(
"TBL_ORDER_LINK",basename($_SERVER[
"PHP_SELF"]).
"?".$this->link_params.$this->prefix.
"sort_by=".$this->header_vars[
$key].
"&".$this->prefix.
"sort_order=".$order_dir.
"&".$this->prefix.
"offset=".$this->offset);
779 $this->styles[$a_element] = $a_style;
789 return $this->styles[$a_element];
799 $this->base = $a_base;
829 $this->form_name = $a_name;
849 $this->select_all_checkbox = $a_select_all_checkbox;
859 $this->action_buttons = array();
871 array_push($this->action_buttons,
874 "value" => $btn_value