78                            "numinfo_header" => 
false,
 
   87                            "table" => 
"fullwidth" 
   97    public function __construct($a_data = 0, $a_global_tpl = 
true)
 
  104        $this->global_tpl = $a_global_tpl;
 
  105        $this->header_vars = array();
 
  106        $this->header_params = array();
 
  107        $this->enabled[
"form"] = 
true;
 
  108        $this->action_buttons = array();
 
  109        if ($this->global_tpl) {
 
  112            $this->tpl = 
new ilTemplate(
"tpl.table.html", 
true, 
true, 
"Services/Table");
 
  118            $this->lang_support = 
false;
 
  147        if (is_array($a_data)) {
 
  148            $this->data = $a_data;
 
  164    public function setTitle($a_title, $a_icon = 0, $a_icon_alt = 0)
 
  166        $this->title = $a_title;
 
  167        $this->icon = $a_icon;
 
  168        $this->icon_alt = $a_icon_alt;
 
  171            $this->enabled[
"icon"] = 
false;
 
  176        if (!$this->icon_alt) {
 
  179        $this->enabled[
"icon"] = 
true;
 
  189    public function setHelp($a_help_page, $a_help_icon, $a_help_icon_alt = 0)
 
  191        $this->help_page = $a_help_page;
 
  192        $this->help_icon = $a_help_icon;
 
  193        $this->help_icon_alt = $a_help_icon_alt;
 
  195        if (!$this->help_icon_alt) {
 
  207        $this->header_names = $a_header_names;
 
  208        $this->column_count = count($this->header_names);
 
  229        $this->header_vars = $a_header_vars;
 
  231        if ($a_header_params == 0 or !is_array($a_header_params)) {
 
  232            $this->link_params = 
"";
 
  234            $this->header_params = $a_header_params;    
 
  236            foreach ($a_header_params as $key => $val) {
 
  237                $this->link_params .= $key . 
"=" . $val . 
"&";
 
  249        $this->column_width = $a_column_width;
 
  260        $this->column_width[$a_column_number] = $a_column_width;
 
  272        $this->max_count = $a_max_count;
 
  274        if ($this->max_limit) {
 
  285    public function setLimit($a_limit = 0, $a_default_limit = 0)
 
  287        $this->limit = ($a_limit) ? $a_limit : $a_default_limit;
 
  289        if ($this->limit == 0) {
 
  290            $this->max_limit = 
true;
 
  310        $this->prefix = ($a_prefix) ? $a_prefix : 
"";
 
  320        $this->offset = ($a_offset) ? $a_offset : 0;
 
  340        if (empty($a_order_column)) {
 
  341            if (!empty($a_default_column)) {
 
  342                $this->order_column = array_search($a_default_column, $this->header_vars);
 
  344                $this->order_column = 0;
 
  348            $this->order_column = array_search($a_order_column, $this->header_vars);
 
  351        if ($this->order_column === 
false) {
 
  353            $this->order_column = 0;
 
  372        if (strtolower($a_order_direction) == 
"desc") {
 
  373            $this->order_direction = 
"desc";
 
  374            $this->sort_order = 
"asc";
 
  376            $this->order_direction = 
"asc"; 
 
  377            $this->sort_order = 
"desc";
 
  396    public function setFooter($a_style, $a_previous = 0, $a_next = 0)
 
  398        $this->footer_style = $a_style;
 
  400        $this->footer_previous = ($a_previous) ? $a_previous : 
"<<<";
 
  401        $this->footer_next = ($a_next) ? $a_next : 
">>>";
 
  414        if (!in_array($a_module_name, array_keys($this->enabled))) {
 
  418        $this->enabled[$a_module_name] = 
true;
 
  431        if (!in_array($a_module_name, array_keys($this->enabled))) {
 
  435        $this->enabled[$a_module_name] = 
false;
 
  441        if ($this->enabled[
"sort"]) {
 
  442            $this->data = 
ilUtil::sortArray($this->data, $this->order_column, $this->order_direction);
 
  444        $this->data = array_slice($this->data, $this->offset, $this->limit);
 
  453        if ($this->enabled[
'table']) {
 
  454            $this->tpl->setVariable(
"CSS_TABLE", 
"table table-striped" );
 
  458        if ($this->enabled[
"icon"] && $this->enabled[
"title"]) {
 
  459            $this->tpl->setCurrentBlock(
"tbl_header_title_icon");
 
  461            $this->tpl->setVariable(
"TBL_TITLE_IMG_ALT", $this->icon_alt);
 
  462            $this->tpl->parseCurrentBlock();
 
  465        if ($this->enabled[
"help"] && $this->enabled[
"title"]) {
 
  466            $this->tpl->setCurrentBlock(
"tbl_header_title_help");
 
  468            $this->tpl->setVariable(
"TBL_HELP_LINK", $this->help_page);
 
  469            $this->tpl->setVariable(
"TBL_HELP_IMG_ALT", $this->help_icon_alt);
 
  470            $this->tpl->parseCurrentBlock();
 
  474        if ($this->enabled[
"hits"] && $this->enabled[
"title"]) {
 
  475            $this->tpl->setCurrentBlock(
"tbl_header_hits_page");
 
  476            $this->tpl->setVariable(
"LIMIT", 
$_SESSION[
"tbl_limit"]);
 
  477            $this->tpl->setVariable(
"HITS_PER_PAGE", $this->lng->txt(
"hits_per_page"));
 
  478            $this->tpl->parseCurrentBlock();
 
  482        if ($this->enabled[
"title"]) {
 
  483            $this->tpl->setCurrentBlock(
"tbl_header_title");
 
  484            $this->tpl->setVariable(
"COLUMN_COUNT", $this->column_count);
 
  485            $this->tpl->setVariable(
"TBL_TITLE", $this->title);
 
  486            $this->tpl->parseCurrentBlock();
 
  490        if ($this->enabled[
"header"]) {
 
  499        if ($this->enabled[
"content"] && is_array($this->data)) {
 
  500            if ($this->enabled[
'auto_sort']) {
 
  506            foreach ($this->data as $tbl_content_row) {
 
  507                foreach ($tbl_content_row as $key => $tbl_content_cell) {
 
  508                    if (is_array($tbl_content_cell)) {
 
  509                        $this->tpl->setCurrentBlock(
"tbl_cell_subtitle");
 
  510                        $this->tpl->setVariable(
"TBL_CELL_SUBTITLE", $tbl_content_cell[1]);
 
  511                        $this->tpl->parseCurrentBlock();
 
  512                        $tbl_content_cell = 
"<b>" . $tbl_content_cell[0] . 
"</b>";
 
  515                    $this->tpl->setCurrentBlock(
"tbl_content_cell");
 
  516                    $this->tpl->setVariable(
"TBL_CONTENT_CELL", $tbl_content_cell);
 
  517                    $this->tpl->parseCurrentBlock();
 
  520                $this->tpl->setCurrentBlock(
"tbl_content_row");
 
  522                $this->tpl->setVariable(
"ROWCOLOR", $rowcolor);
 
  523                $this->tpl->parseCurrentBlock();
 
  529        if ($this->enabled[
"select_all"]) {
 
  531                $this->tpl->setVariable(
'SELECT_PREFIX', $this->prefix);
 
  532                $this->tpl->setVariable(
"SELECT_ALL_TXT_SELECT_ALL", $this->lng->txt(
"select_all"));
 
  534                $this->tpl->setVariable(
"SELECT_ALL_FORM_NAME", $this->
getFormName());
 
  535                if (!($this->enabled[
"numinfo"] && $this->enabled[
"footer"])) {
 
  542        if ($this->enabled[
"numinfo_header"]) {
 
  543            $start = $this->offset + 1;                         
 
  546            if ($end > $this->max_count or $this->limit == 0) {
 
  550            if ($this->lang_support) {
 
  551                $numinfo = 
"(" . $this->lng->txt(
"dataset") . 
" " . $start . 
" - " . $end . 
" " . strtolower($this->lng->txt(
"of")) . 
" " . $this->max_count . 
")";
 
  553                $numinfo = 
"(Dataset " . $start . 
" - " . $end . 
" of " . $this->max_count . 
")";
 
  555            if ($this->max_count > 0) {
 
  557                $this->tpl->setCurrentBlock(
"tbl_header_numinfo");
 
  558                $this->tpl->setVariable(
"NUMINFO_HEADER", $numinfo);
 
  559                $this->tpl->setVariable(
"COLUMN_COUNT_HEADER", $this->
getColumnCount());
 
  560                $this->tpl->parseCurrentBlock();
 
  564        if ($this->enabled[
"numinfo"] && $this->enabled[
"footer"]) {
 
  565            $start = $this->offset + 1;                         
 
  568            if ($end > $this->max_count or $this->limit == 0) {
 
  572            if ($this->lang_support) {
 
  573                $numinfo = 
"(" . $this->lng->txt(
"dataset") . 
" " . $start . 
" - " . $end . 
" " . strtolower($this->lng->txt(
"of")) . 
" " . $this->max_count . 
")";
 
  575                $numinfo = 
"(Dataset " . $start . 
" - " . $end . 
" of " . $this->max_count . 
")";
 
  577            if ($this->max_count > 0) {
 
  579                $this->tpl->setCurrentBlock(
"tbl_footer_numinfo");
 
  580                $this->tpl->setVariable(
"NUMINFO", $numinfo);
 
  581                $this->tpl->parseCurrentBlock();
 
  585        if ($this->enabled[
"linkbar"] && $this->enabled[
"footer"] && $this->limit != 0
 
  586             && $this->max_count > 0) {
 
  588                            $this->prefix . 
"sort_by" => $this->header_vars[$this->order_column],
 
  589                            $this->prefix . 
"sort_order" => $this->order_direction
 
  591            $params = array_merge($this->header_params, $params);
 
  594                            "link" => $this->footer_style,
 
  595                            "prev" => $this->footer_previous,
 
  596                            "next" => $this->footer_next,
 
  603            $linkbar = 
ilUtil::Linkbar(
$base, $this->max_count, $this->limit, $this->offset, $params, $layout, $this->prefix);
 
  604            $this->tpl->setCurrentBlock(
"tbl_footer_linkbar");
 
  605            $this->tpl->setVariable(
"LINKBAR", $linkbar);
 
  606            $this->tpl->parseCurrentBlock();
 
  610        if ($this->enabled[
"footer"] && $this->max_count > 0) {
 
  611            $this->tpl->setCurrentBlock(
"tbl_footer");
 
  612            $this->tpl->setVariable(
"COLUMN_COUNT", $this->column_count);
 
  613            $this->tpl->parseCurrentBlock();
 
  617        if ($this->enabled[
"action"] && is_array($this->action_buttons)) {
 
  618            foreach ($this->action_buttons as $button) {
 
  619                $this->tpl->setCurrentBlock(
"tbl_action_btn");
 
  620                $this->tpl->setVariable(
"BTN_NAME", $button[
"name"]);
 
  621                $this->tpl->setVariable(
"BTN_VALUE", $button[
"value"]);
 
  622                $this->tpl->parseCurrentBlock();
 
  624            $this->tpl->setCurrentBlock(
"tbl_action_row");
 
  626            $this->tpl->setVariable(
"ALT_ARROW", $this->lng->txt(
"arrow_downright.svg"));
 
  628            $this->tpl->parseCurrentBlock();
 
  631        if ($this->enabled[
"form"]) {
 
  632            $this->tpl->touchBlock(
"tbl_form_footer");
 
  635        if ($this->enabled[
'table']) {
 
  636            $this->tpl->touchBlock(
"tbl_table_end");
 
  639        if (!$this->global_tpl) {
 
  640            return $this->tpl->get();
 
  646        foreach ($this->header_names as $key => $tbl_header_cell) {
 
  647            if (!$this->enabled[
"sort"]) {
 
  648                $this->tpl->setCurrentBlock(
"tbl_header_no_link");
 
  649                if ($this->column_width[$key]) {
 
  650                    $this->tpl->setVariable(
"TBL_COLUMN_WIDTH_NO_LINK", 
" width=\"" . $this->column_width[$key] . 
"\"");
 
  652                $this->tpl->setVariable(
"TBL_HEADER_CELL_NO_LINK", $tbl_header_cell);
 
  653                $this->tpl->parseCurrentBlock();
 
  656            if (($key == $this->order_column) && ($this->order_direction != 
"")) {
 
  657                if (strcmp($this->header_vars[$key], 
"") != 0) {
 
  658                    $this->tpl->setCurrentBlock(
"tbl_order_image");
 
  659                    $this->tpl->parseCurrentBlock();
 
  663            $this->tpl->setCurrentBlock(
"tbl_header_cell");
 
  664            $this->tpl->setVariable(
"TBL_HEADER_CELL", $tbl_header_cell);
 
  667            if ($this->column_width[$key]) {
 
  668                $this->tpl->setVariable(
"TBL_COLUMN_WIDTH", 
" width=\"" . $this->column_width[$key] . 
"\"");
 
  671            $lng_sort_column = (
$this->lang_support) ? $this->lng->txt(
"sort_by_this_column") : 
"Sort by this column";
 
  672            $this->tpl->setVariable(
"TBL_ORDER_ALT", $lng_sort_column);
 
  676            if ($key == $this->order_column) {
 
  677                $order_dir = $this->sort_order;
 
  679                $lng_change_sort = (
$this->lang_support) ? $this->lng->txt(
"change_sort_direction") : 
"Change sort direction";
 
  680                $this->tpl->setVariable(
"TBL_ORDER_ALT", $lng_change_sort);
 
  684            $this->tpl->parseCurrentBlock();
 
  687        $this->tpl->setCurrentBlock(
"tbl_header");
 
  688        $this->tpl->parseCurrentBlock();
 
  693        $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);
 
  704        $this->styles[$a_element] = $a_style;
 
  714        return $this->styles[$a_element];
 
  724        $this->
base = $a_base;
 
  754        $this->form_name = $a_name;
 
  774        $this->select_all_checkbox = $a_select_all_checkbox;
 
  784        $this->action_buttons = array();
 
  797            $this->action_buttons,
 
  800                "value" => $btn_value
 
An exception for terminatinating execution or to throw for unit testing.
getBase()
Get Base script name (deprecated, only use this for workarounds).
getOrderDirection()
Get order direction.
setOrderLink($key, $order_dir)
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
set table title @access public
setMaxCount($a_max_count)
set max.
setHeaderVars($a_header_vars, $a_header_params=0)
set table header vars @access public
setBase($a_base)
Set Base script name (deprecated, only use this for workarounds).
setHeaderNames($a_header_names)
set table header names @access public
setTemplate($a_tpl)
set template @access public
setOrderColumn($a_order_column=0, $a_default_column=0)
set order column @access public
disable($a_module_name)
diesables particular modules of table
setSelectAllCheckbox($a_select_all_checkbox)
setStyle($a_element, $a_style)
setPrefix($a_prefix)
set prefix for sort and offset fields (if you have two or more tables on a page that you want to sort...
__construct($a_data=0, $a_global_tpl=true)
Constructor.
setOrderDirection($a_order_direction)
set order direction @access public
setLimit($a_limit=0, $a_default_limit=0)
set max.
setFormName($a_name="cmd")
setColumnWidth($a_column_width)
set table column widths @access public
enable($a_module_name)
enables particular modules of table
getColumnCount()
Returns the column count based on the number of the header row columns @access public.
addActionButton($btn_name, $btn_value)
setData($a_data)
set table data @access public
getOrderColumn()
Get order column.
render()
render table @access public
setFooter($a_style, $a_previous=0, $a_next=0)
set order direction @access public
setOffset($a_offset)
set dataset offset @access public
setHelp($a_help_page, $a_help_icon, $a_help_icon_alt=0)
set table help page @access public
setOneColumnWidth($a_column_width, $a_column_number)
set one table column width @access public
special template class to simplify handling of ITX/PEAR
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static Linkbar($AScript, $AHits, $ALimit, $AOffset, $AParams=array(), $ALayout=array(), $prefix='')
Linkbar Diese Funktion erzeugt einen typischen Navigationsbalken mit "Previous"- und "Next"-Links und...
static switchColor($a_num, $a_css1, $a_css2)
switches style sheets for each even $a_num (used for changing colors of different result rows)
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)