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 :
">>>";
442 if (!in_array($a_module_name,array_keys($this->enabled)))
447 $this->enabled[$a_module_name] =
true;
457 if (!in_array($a_module_name,array_keys($this->enabled)))
462 $this->enabled[$a_module_name] =
false;
468 if($this->enabled[
"sort"])
470 $this->data =
ilUtil::sortArray($this->data,$this->order_column,$this->order_direction);
472 $this->data = array_slice($this->data,$this->offset,$this->limit);
481 if($this->enabled[
'table'])
483 $this->tpl->setVariable(
"CSS_TABLE",$this->
getStyle(
"table"));
487 if ($this->enabled[
"icon"] && $this->enabled[
"title"])
489 $this->tpl->setCurrentBlock(
"tbl_header_title_icon");
491 $this->tpl->setVariable(
"TBL_TITLE_IMG_ALT",$this->icon_alt);
492 $this->tpl->parseCurrentBlock();
495 if ($this->enabled[
"help"] && $this->enabled[
"title"])
497 $this->tpl->setCurrentBlock(
"tbl_header_title_help");
499 $this->tpl->setVariable(
"TBL_HELP_LINK",$this->help_page);
500 $this->tpl->setVariable(
"TBL_HELP_IMG_ALT",$this->help_icon_alt);
501 $this->tpl->parseCurrentBlock();
505 if ($this->enabled[
"hits"] && $this->enabled[
"title"])
507 $this->tpl->setCurrentBlock(
"tbl_header_hits_page");
508 $this->tpl->setVariable(
"LIMIT",
$_SESSION[
"tbl_limit"]);
509 $this->tpl->setVariable(
"HITS_PER_PAGE",$this->lng->txt(
"hits_per_page"));
510 $this->tpl->parseCurrentBlock();
514 if ($this->enabled[
"title"])
516 $this->tpl->setCurrentBlock(
"tbl_header_title");
517 $this->tpl->setVariable(
"COLUMN_COUNT",$this->column_count);
518 $this->tpl->setVariable(
"TBL_TITLE",$this->title);
519 $this->tpl->parseCurrentBlock();
523 if ($this->enabled[
"header"])
533 if ($this->enabled[
"content"] && is_array($this->data))
535 if($this->enabled[
'auto_sort'])
542 foreach ($this->data as $tbl_content_row)
544 foreach ($tbl_content_row as $key => $tbl_content_cell)
546 if (is_array($tbl_content_cell))
548 $this->tpl->setCurrentBlock(
"tbl_cell_subtitle");
549 $this->tpl->setVariable(
"TBL_CELL_SUBTITLE",$tbl_content_cell[1]);
550 $this->tpl->parseCurrentBlock();
551 $tbl_content_cell =
"<b>".$tbl_content_cell[0].
"</b>";
554 $this->tpl->setCurrentBlock(
"tbl_content_cell");
555 $this->tpl->setVariable(
"TBL_CONTENT_CELL",$tbl_content_cell);
556 $this->tpl->parseCurrentBlock();
559 $this->tpl->setCurrentBlock(
"tbl_content_row");
561 $this->tpl->setVariable(
"ROWCOLOR", $rowcolor);
562 $this->tpl->parseCurrentBlock();
568 if ($this->enabled[
"select_all"])
572 $this->tpl->setVariable(
'SELECT_PREFIX',$this->prefix);
573 $this->tpl->setVariable(
"SELECT_ALL_TXT_SELECT_ALL", $this->lng->txt(
"select_all"));
575 $this->tpl->setVariable(
"SELECT_ALL_FORM_NAME", $this->
getFormName());
576 if (!($this->enabled[
"numinfo"] && $this->enabled[
"footer"]))
584 if ($this->enabled[
"numinfo_header"])
586 $start = $this->offset + 1;
589 if ($end > $this->max_count or $this->limit == 0)
594 if ($this->lang_support)
596 $numinfo =
"(".$this->lng->txt(
"dataset").
" ".$start.
" - ".$end.
" ".strtolower($this->lng->txt(
"of")).
" ".$this->max_count.
")";
600 $numinfo =
"(Dataset ".$start.
" - ".$end.
" of ".$this->max_count.
")";
602 if ($this->max_count > 0)
605 $this->tpl->setCurrentBlock(
"tbl_header_numinfo");
606 $this->tpl->setVariable(
"NUMINFO_HEADER", $numinfo);
607 $this->tpl->setVariable(
"COLUMN_COUNT_HEADER", $this->
getColumnCount());
608 $this->tpl->parseCurrentBlock();
612 if ($this->enabled[
"numinfo"] && $this->enabled[
"footer"])
614 $start = $this->offset + 1;
617 if ($end > $this->max_count or $this->limit == 0)
622 if ($this->lang_support)
624 $numinfo =
"(".$this->lng->txt(
"dataset").
" ".$start.
" - ".$end.
" ".strtolower($this->lng->txt(
"of")).
" ".$this->max_count.
")";
628 $numinfo =
"(Dataset ".$start.
" - ".$end.
" of ".$this->max_count.
")";
630 if ($this->max_count > 0)
633 $this->tpl->setCurrentBlock(
"tbl_footer_numinfo");
634 $this->tpl->setVariable(
"NUMINFO", $numinfo);
635 $this->tpl->parseCurrentBlock();
639 if ($this->enabled[
"linkbar"] && $this->enabled[
"footer"] && $this->limit != 0
640 && $this->max_count > 0)
643 $this->prefix.
"sort_by" => $this->header_vars[$this->order_column],
644 $this->prefix.
"sort_order" => $this->order_direction
646 $params = array_merge($this->header_params,$params);
649 "link" => $this->footer_style,
650 "prev" => $this->footer_previous,
651 "next" => $this->footer_next,
655 ? basename($_SERVER[
"PHP_SELF"])
658 $linkbar =
ilUtil::Linkbar(
$base,$this->max_count,$this->limit,$this->offset,$params,$layout, $this->prefix);
659 $this->tpl->setCurrentBlock(
"tbl_footer_linkbar");
660 $this->tpl->setVariable(
"LINKBAR", $linkbar);
661 $this->tpl->parseCurrentBlock();
665 if ($this->enabled[
"footer"] && $this->max_count > 0)
667 $this->tpl->setCurrentBlock(
"tbl_footer");
668 $this->tpl->setVariable(
"COLUMN_COUNT",$this->column_count);
669 $this->tpl->parseCurrentBlock();
673 if ($this->enabled[
"action"])
675 foreach ($this->action_buttons as $button)
677 $this->tpl->setCurrentBlock(
"tbl_action_btn");
678 $this->tpl->setVariable(
"BTN_NAME", $button[
"name"]);
679 $this->tpl->setVariable(
"BTN_VALUE", $button[
"value"]);
680 $this->tpl->parseCurrentBlock();
682 $this->tpl->setCurrentBlock(
"tbl_action_row");
684 $this->tpl->setVariable(
"ALT_ARROW", $this->lng->txt(
"arrow_downright.gif"));
685 $this->tpl->setVariable(
"COLUMN_COUNTS", $this->
getColumnCount());
686 $this->tpl->parseCurrentBlock();
689 if ($this->enabled[
"form"])
691 $this->tpl->touchBlock(
"tbl_form_footer");
694 if($this->enabled[
'table'])
696 $this->tpl->touchBlock(
"tbl_table_end");
699 if (!$this->global_tpl)
701 return $this->tpl->get();
707 foreach ($this->header_names as $key => $tbl_header_cell)
709 if (!$this->enabled[
"sort"])
711 $this->tpl->setCurrentBlock(
"tbl_header_no_link");
712 if ($this->column_width[$key])
714 $this->tpl->setVariable(
"TBL_COLUMN_WIDTH_NO_LINK",
" width=\"".$this->column_width[$key].
"\"");
716 $this->tpl->setVariable(
"TBL_HEADER_CELL_NO_LINK",$tbl_header_cell);
717 $this->tpl->parseCurrentBlock();
720 if (($key == $this->order_column) && ($this->order_direction !=
""))
722 if (strcmp($this->header_vars[$key],
"") != 0)
724 $this->tpl->setCurrentBlock(
"tbl_order_image");
725 $this->tpl->setVariable(
"IMG_ORDER_DIR",
ilUtil::getImagePath($this->order_direction.
"_order.gif"));
726 $this->tpl->parseCurrentBlock();
730 $this->tpl->setCurrentBlock(
"tbl_header_cell");
731 $this->tpl->setVariable(
"TBL_HEADER_CELL",$tbl_header_cell);
734 if ($this->column_width[$key])
736 $this->tpl->setVariable(
"TBL_COLUMN_WIDTH",
" width=\"".$this->column_width[$key].
"\"");
739 $lng_sort_column = (
$this->lang_support) ? $this->lng->txt(
"sort_by_this_column") :
"Sort by this column";
740 $this->tpl->setVariable(
"TBL_ORDER_ALT",$lng_sort_column);
744 if ($key == $this->order_column)
746 $order_dir = $this->sort_order;
748 $lng_change_sort = (
$this->lang_support) ? $this->lng->txt(
"change_sort_direction") :
"Change sort direction";
749 $this->tpl->setVariable(
"TBL_ORDER_ALT",$lng_change_sort);
753 $this->tpl->parseCurrentBlock();
756 $this->tpl->setCurrentBlock(
"tbl_header");
757 $this->tpl->parseCurrentBlock();
762 $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);
773 $this->styles[$a_element] = $a_style;
783 return $this->styles[$a_element];
793 $this->base = $a_base;
823 $this->form_name = $a_name;
843 $this->select_all_checkbox = $a_select_all_checkbox;
853 $this->action_buttons = array();
865 array_push($this->action_buttons,
868 "value" => $btn_value