/**
  * Fill footer row
  */
 function fillFooter()
 {
     global $lng, $ilCtrl, $ilUser;
     $footer = false;
     // select all checkbox
     if (strlen($this->getFormName()) && strlen($this->getSelectAllCheckbox()) && $this->dataExists()) {
         $this->tpl->setCurrentBlock("select_all_checkbox");
         $this->tpl->setVariable("SELECT_ALL_TXT_SELECT_ALL", $lng->txt("select_all"));
         $this->tpl->setVariable("SELECT_ALL_CHECKBOX_NAME", $this->getSelectAllCheckbox());
         $this->tpl->setVariable("SELECT_ALL_FORM_NAME", $this->getFormName());
         $this->tpl->setVariable("CHECKBOXNAME", "chb_select_all_" . $this->unique_id);
         $this->tpl->parseCurrentBlock();
     }
     // table footer numinfo
     if ($this->enabled["numinfo"] && $this->enabled["footer"]) {
         $start = $this->offset + 1;
         // compute num info
         if (!$this->dataExists()) {
             $start = 0;
         }
         $end = $this->offset + $this->limit;
         if ($end > $this->max_count or $this->limit == 0) {
             $end = $this->max_count;
         }
         if ($this->max_count > 0) {
             if ($this->lang_support) {
                 $numinfo = "(" . $start . " - " . $end . " " . strtolower($this->lng->txt("of")) . " " . $this->max_count . ")";
             } else {
                 $numinfo = "(" . $start . " - " . $end . " of " . $this->max_count . ")";
             }
         }
         if ($this->max_count > 0) {
             if ($this->getEnableNumInfo()) {
                 $this->tpl->setCurrentBlock("tbl_footer_numinfo");
                 $this->tpl->setVariable("NUMINFO", $numinfo);
                 $this->tpl->parseCurrentBlock();
             }
         }
         $footer = true;
     }
     // table footer linkbar
     if ($this->enabled["linkbar"] && $this->enabled["footer"] && $this->limit != 0 && $this->max_count > 0) {
         $layout = array("link" => $this->footer_style, "prev" => $this->footer_previous, "next" => $this->footer_next);
         //if (!$this->getDisplayAsBlock())
         //{
         $linkbar = $this->getLinkbar("1");
         $this->tpl->setCurrentBlock("tbl_footer_linkbar");
         $this->tpl->setVariable("LINKBAR", $linkbar);
         $this->tpl->parseCurrentBlock();
         $linkbar = true;
         //}
         $footer = true;
     }
     // column selector
     if (count($this->getSelectableColumns()) > 0) {
         $items = array();
         foreach ($this->getSelectableColumns() as $k => $c) {
             $items[$k] = array("txt" => $c["txt"], "selected" => $this->isColumnSelected($k));
         }
         include_once "./Services/UIComponent/CheckboxListOverlay/classes/class.ilCheckboxListOverlayGUI.php";
         $cb_over = new ilCheckboxListOverlayGUI("tbl_" . $this->getId());
         $cb_over->setLinkTitle($lng->txt("columns"));
         $cb_over->setItems($items);
         //$cb_over->setUrl("./ilias.php?baseClass=ilTablePropertiesStorage&table_id=".
         //		$this->getId()."&cmd=saveSelectedFields&user_id=".$ilUser->getId());
         $cb_over->setFormCmd($this->getParentCmd());
         $cb_over->setFieldVar("tblfs" . $this->getId());
         $cb_over->setHiddenVar("tblfsh" . $this->getId());
         $cb_over->setSelectionHeaderClass("ilTableMenuItem");
         $column_selector = $cb_over->getHTML();
         $footer = true;
     }
     if ($this->getShowTemplates() && is_object($ilUser)) {
         // template handling
         if (isset($_REQUEST["tbltplcrt"]) && $_REQUEST["tbltplcrt"]) {
             if ($this->saveTemplate($_REQUEST["tbltplcrt"])) {
                 ilUtil::sendSuccess($lng->txt("tbl_template_created"));
             }
         } else {
             if (isset($_REQUEST["tbltpldel"]) && $_REQUEST["tbltpldel"]) {
                 if ($this->deleteTemplate($_REQUEST["tbltpldel"])) {
                     ilUtil::sendSuccess($lng->txt("tbl_template_deleted"));
                 }
             }
         }
         $create_id = "template_create_overlay_" . $this->getId();
         $delete_id = "template_delete_overlay_" . $this->getId();
         $list_id = "template_stg_" . $this->getId();
         include_once "./Services/Table/classes/class.ilTableTemplatesStorage.php";
         $storage = new ilTableTemplatesStorage();
         $templates = $storage->getNames($this->getContext(), $ilUser->getId());
         include_once "./Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php";
         // form to delete template
         if (count($templates)) {
             $overlay = new ilOverlayGUI($delete_id);
             $overlay->setTrigger($list_id . "_delete");
             $overlay->setAnchor("ilAdvSelListAnchorElement_" . $list_id);
             $overlay->setAutoHide(false);
             $overlay->add();
             $lng->loadLanguageModule("form");
             $this->tpl->setCurrentBlock("template_editor_delete_item");
             $this->tpl->setVariable("TEMPLATE_DELETE_OPTION_VALUE", "");
             $this->tpl->setVariable("TEMPLATE_DELETE_OPTION", "- " . $lng->txt("form_please_select") . " -");
             $this->tpl->parseCurrentBlock();
             foreach ($templates as $name) {
                 $this->tpl->setVariable("TEMPLATE_DELETE_OPTION_VALUE", $name);
                 $this->tpl->setVariable("TEMPLATE_DELETE_OPTION", $name);
                 $this->tpl->parseCurrentBlock();
             }
             $this->tpl->setCurrentBlock("template_editor_delete");
             $this->tpl->setVariable("TEMPLATE_DELETE_ID", $delete_id);
             $this->tpl->setVariable("TXT_TEMPLATE_DELETE", $lng->txt("tbl_template_delete"));
             $this->tpl->setVariable("TXT_TEMPLATE_DELETE_SUBMIT", $lng->txt("delete"));
             $this->tpl->setVariable("TEMPLATE_DELETE_CMD", $this->parent_cmd);
             $this->tpl->parseCurrentBlock();
         }
         // form to save new template
         $overlay = new ilOverlayGUI($create_id);
         $overlay->setTrigger($list_id . "_create");
         $overlay->setAnchor("ilAdvSelListAnchorElement_" . $list_id);
         $overlay->setAutoHide(false);
         $overlay->add();
         $this->tpl->setCurrentBlock("template_editor");
         $this->tpl->setVariable("TEMPLATE_CREATE_ID", $create_id);
         $this->tpl->setVariable("TXT_TEMPLATE_CREATE", $lng->txt("tbl_template_create"));
         $this->tpl->setVariable("TXT_TEMPLATE_CREATE_SUBMIT", $lng->txt("save"));
         $this->tpl->setVariable("TEMPLATE_CREATE_CMD", $this->parent_cmd);
         $this->tpl->parseCurrentBlock();
         // load saved template
         include_once "./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php";
         $alist = new ilAdvancedSelectionListGUI();
         $alist->setId($list_id);
         $alist->addItem($lng->txt("tbl_template_create"), "create", "#");
         if (count($templates)) {
             $alist->addItem($lng->txt("tbl_template_delete"), "delete", "#");
             foreach ($templates as $name) {
                 $ilCtrl->setParameter($this->parent_obj, $this->prefix . "_tpl", urlencode($name));
                 $alist->addItem($name, $name, $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd));
                 $ilCtrl->setParameter($this->parent_obj, $this->prefix . "_tpl", "");
             }
         }
         $alist->setListTitle($lng->txt("tbl_templates"));
         $this->tpl->setVariable("TEMPLATE_SELECTOR", " " . $alist->getHTML());
     }
     if ($footer) {
         $this->tpl->setCurrentBlock("tbl_footer");
         $this->tpl->setVariable("COLUMN_COUNT", $this->getColumnCount());
         if ($this->getDisplayAsBlock()) {
             $this->tpl->setVariable("BLK_CLASS", "Block");
         }
         $this->tpl->parseCurrentBlock();
         // top navigation, if number info or linkbar given
         if ($numinfo != "" || $linkbar != "" || $column_selector != "" || count($this->filters) > 0 || count($this->optional_filters) > 0) {
             if (is_object($ilUser) && (count($this->filters) || count($this->optional_filters))) {
                 $this->tpl->setCurrentBlock("filter_activation");
                 $this->tpl->setVariable("TXT_ACTIVATE_FILTER", $lng->txt("show_filter"));
                 $this->tpl->setVariable("FILA_ID", $this->getId());
                 if ($this->getId() != "") {
                     $this->tpl->setVariable("SAVE_URLA", "./ilias.php?baseClass=ilTablePropertiesStorage&table_id=" . $this->getId() . "&cmd=showFilter&user_id=" . $ilUser->getId());
                 }
                 $this->tpl->parseCurrentBlock();
                 if (!$this->getDisableFilterHiding()) {
                     $this->tpl->setCurrentBlock("filter_deactivation");
                     $this->tpl->setVariable("TXT_HIDE", $lng->txt("hide_filter"));
                     if ($this->getId() != "") {
                         $this->tpl->setVariable("SAVE_URL", "./ilias.php?baseClass=ilTablePropertiesStorage&table_id=" . $this->getId() . "&cmd=hideFilter&user_id=" . $ilUser->getId());
                         $this->tpl->setVariable("FILD_ID", $this->getId());
                     }
                     $this->tpl->parseCurrentBlock();
                 }
             }
             if ($numinfo != "" && $this->getEnableNumInfo()) {
                 $this->tpl->setCurrentBlock("top_numinfo");
                 $this->tpl->setVariable("NUMINFO", $numinfo);
                 $this->tpl->parseCurrentBlock();
             }
             if ($linkbar != "" && !$this->getDisplayAsBlock()) {
                 $linkbar = $this->getLinkbar("2");
                 $this->tpl->setCurrentBlock("top_linkbar");
                 $this->tpl->setVariable("LINKBAR", $linkbar);
                 $this->tpl->parseCurrentBlock();
             }
             // column selector
             $this->tpl->setVariable("COLUMN_SELECTOR", $column_selector);
             // row selector
             if ($this->getShowRowsSelector() && is_object($ilUser)) {
                 include_once "./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php";
                 $alist = new ilAdvancedSelectionListGUI();
                 $alist->setId("sellst_rows_" . $this->getId());
                 $hpp = $ilUser->getPref("hits_per_page") != 9999 ? $ilUser->getPref("hits_per_page") : $lng->txt("unlimited");
                 $options = array(0 => $lng->txt("default") . " (" . $hpp . ")", 5 => 5, 10 => 10, 15 => 15, 20 => 20, 30 => 30, 40 => 40, 50 => 50, 100 => 100, 200 => 200, 400 => 400, 800 => 800);
                 foreach ($options as $k => $v) {
                     $ilCtrl->setParameter($this->parent_obj, $this->prefix . "_trows", $k);
                     $alist->addItem($v, $k, $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd));
                     $ilCtrl->setParameter($this->parent_obj, $this->prefix . "_trows", "");
                 }
                 $alist->setListTitle($this->getRowSelectorLabel() ? $this->getRowSelectorLabel() : $lng->txt("rows"));
                 $this->tpl->setVariable("ROW_SELECTOR", $alist->getHTML());
             }
             // export
             if (count($this->export_formats) && $this->dataExists()) {
                 include_once "./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php";
                 $alist = new ilAdvancedSelectionListGUI();
                 $alist->setId("sellst_xpt");
                 foreach ($this->export_formats as $format => $caption_lng_id) {
                     $ilCtrl->setParameter($this->parent_obj, $this->prefix . "_xpt", $format);
                     $url = $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd);
                     $ilCtrl->setParameter($this->parent_obj, $this->prefix . "_xpt", "");
                     $caption = $lng->txt($caption_lng_id);
                     //this part is necessary, because the labels for xls- and csv-Export are fetched from the ilias-lang-files, while the label for pdf-export is fetched from the lang-file of the plugin. If the ilias-lang-file does not contain a translation for the caption_lng_id, it will set it into '-'es. In that case the caption comes from the plugin and we just use the string that is there.
                     if (strpos($caption, '-') === 0 && strpos($caption, '-', strlen($caption) - 1) === strlen($caption) - 1) {
                         $alist->addItem($caption_lng_id, $format, $url);
                     } else {
                         $alist->addItem($lng->txt($caption_lng_id), $format, $url);
                     }
                 }
                 $alist->setListTitle($lng->txt("export"));
                 $this->tpl->setVariable("EXPORT_SELECTOR", " " . $alist->getHTML());
             }
             $this->tpl->setCurrentBlock("top_navigation");
             $this->tpl->setVariable("COLUMN_COUNT", $this->getColumnCount());
             if ($this->getDisplayAsBlock()) {
                 $this->tpl->setVariable("BLK_CLASS", "Block");
             }
             $this->tpl->parseCurrentBlock();
         }
     }
 }
示例#2
0
 /**
  * Render Filter section
  */
 private function renderFilter()
 {
     global $lng, $tpl;
     $filter = $this->getFilterItems();
     $opt_filter = $this->getFilterItems(true);
     $tpl->addJavascript("./Services/Table/js/ServiceTable.js");
     if (count($filter) == 0 && count($opt_filter) == 0) {
         return;
     }
     include_once "./Services/YUI/classes/class.ilYuiUtil.php";
     ilYuiUtil::initConnection();
     $ccnt = 0;
     // render standard filter
     if (count($filter) > 0) {
         foreach ($filter as $item) {
             if ($ccnt >= $this->getFilterCols()) {
                 $this->tpl->setCurrentBlock("filter_row");
                 $this->tpl->parseCurrentBlock();
                 $ccnt = 0;
             }
             $this->tpl->setCurrentBlock("filter_item");
             $this->tpl->setVariable("OPTION_NAME", $item->getTitle());
             $this->tpl->setVariable("F_INPUT_ID", $item->getFieldId());
             $this->tpl->setVariable("INPUT_HTML", $item->getTableFilterHTML());
             $this->tpl->parseCurrentBlock();
             $ccnt++;
         }
     }
     // render optional filter
     if (count($opt_filter) > 0) {
         $this->determineSelectedFilters();
         foreach ($opt_filter as $item) {
             if ($this->isFilterSelected($item->getPostVar())) {
                 if ($ccnt >= $this->getFilterCols()) {
                     $this->tpl->setCurrentBlock("filter_row");
                     $this->tpl->parseCurrentBlock();
                     $ccnt = 0;
                 }
                 $this->tpl->setCurrentBlock("filter_item");
                 $this->tpl->setVariable("OPTION_NAME", $item->getTitle());
                 $this->tpl->setVariable("F_INPUT_ID", $item->getFieldId());
                 $this->tpl->setVariable("INPUT_HTML", $item->getTableFilterHTML());
                 $this->tpl->parseCurrentBlock();
                 $ccnt++;
             }
         }
         // filter selection
         $items = array();
         foreach ($opt_filter as $item) {
             $k = $item->getPostVar();
             $items[$k] = array("txt" => $item->getTitle(), "selected" => $this->isFilterSelected($k));
         }
         include_once "./Services/UIComponent/CheckboxListOverlay/classes/class.ilCheckboxListOverlayGUI.php";
         $cb_over = new ilCheckboxListOverlayGUI("tbl_filters_" . $this->getId());
         $cb_over->setLinkTitle($lng->txt("optional_filters"));
         $cb_over->setItems($items);
         $cb_over->setFormCmd($this->getParentCmd());
         $cb_over->setFieldVar("tblff" . $this->getId());
         $cb_over->setHiddenVar("tblfsf" . $this->getId());
         $this->tpl->setCurrentBlock("filter_select");
         // apply should be the first submit because of enter/return, inserting hidden submit
         $this->tpl->setVariable("HIDDEN_CMD_APPLY", $this->filter_cmd);
         $this->tpl->setVariable("FILTER_SELECTOR", $cb_over->getHTML());
         $this->tpl->parseCurrentBlock();
     }
     // if any filter
     if ($ccnt > 0 || count($opt_filter) > 0) {
         $this->tpl->setVariable("TXT_FILTER", $lng->txt("filter"));
         if ($ccnt > 0) {
             if ($ccnt < $this->getFilterCols()) {
                 for ($i = $ccnt; $i <= $this->getFilterCols(); $i++) {
                     $this->tpl->touchBlock("filter_empty_cell");
                 }
             }
             $this->tpl->setCurrentBlock("filter_row");
             $this->tpl->parseCurrentBlock();
             $this->tpl->setCurrentBlock("filter_buttons");
             $this->tpl->setVariable("CMD_APPLY", $this->filter_cmd);
             $this->tpl->setVariable("TXT_APPLY", $lng->txt("apply_filter"));
             $this->tpl->setVariable("CMD_RESET", $this->reset_cmd);
             $this->tpl->setVariable("TXT_RESET", $lng->txt("reset_filter"));
         } else {
             if (count($opt_filter) > 0) {
                 $this->tpl->setCurrentBlock("optional_filter_hint");
                 $this->tpl->setVariable('TXT_OPT_HINT', $lng->txt('optional_filter_hint'));
                 $this->tpl->parseCurrentBlock();
             }
         }
         $this->tpl->setCurrentBlock("filter_section");
         $this->tpl->setVariable("FIL_ID", $this->getId());
         $this->tpl->parseCurrentBlock();
         // (keep) filter hidden?
         if ($this->loadProperty("filter") != 1) {
             if (!$this->getDisableFilterHiding()) {
                 $this->tpl->setCurrentBlock("filter_hidden");
                 $this->tpl->setVariable("FI_ID", $this->getId());
                 $this->tpl->parseCurrentBlock();
             }
         }
     }
 }