/**
  * Get toolbar html
  */
 function getHTML()
 {
     global $lng;
     $tpl = new ilTemplate("tpl.toolbar.html", true, true, "Services/UIComponent/Toolbar");
     if (count($this->items) > 0) {
         foreach ($this->items as $item) {
             switch ($item["type"]) {
                 case "button":
                     $tpl->setCurrentBlock("button");
                     $tpl->setVariable("BTN_TXT", $item["txt"]);
                     $tpl->setVariable("BTN_LINK", $item["cmd"]);
                     if ($item["target"] != "") {
                         $tpl->setVariable("BTN_TARGET", 'target="' . $item["target"] . '"');
                     }
                     if ($item["id"] != "") {
                         $tpl->setVariable("BID", 'id="' . $item["id"] . '"');
                     }
                     if ($item["acc_key"] != "") {
                         include_once "./Services/Accessibility/classes/class.ilAccessKeyGUI.php";
                         $tpl->setVariable("BTN_ACC_KEY", ilAccessKeyGUI::getAttribute($item["acc_key"]));
                     }
                     if ($item['add_attrs']) {
                         $tpl->setVariable('BTN_ADD_ARG', $item['add_attrs']);
                     }
                     $tpl->parseCurrentBlock();
                     $tpl->touchBlock("item");
                     break;
                 case "fbutton":
                     $tpl->setCurrentBlock("form_button");
                     $tpl->setVariable("SUB_TXT", $item["txt"]);
                     $tpl->setVariable("SUB_CMD", $item["cmd"]);
                     $tpl->parseCurrentBlock();
                     $tpl->touchBlock("item");
                     break;
                 case "input":
                     if ($item["label"]) {
                         $tpl->setCurrentBlock("input_label");
                         $tpl->setVariable("TXT_INPUT", $item["input"]->getTitle());
                         $tpl->parseCurrentBlock();
                     }
                     $tpl->setCurrentBlock("input");
                     $tpl->setVariable("INPUT_HTML", $item["input"]->getToolbarHTML());
                     $tpl->parseCurrentBlock();
                     $tpl->touchBlock("item");
                     break;
                 case "separator":
                     $tpl->touchBlock("separator");
                     $tpl->touchBlock("item");
                     break;
                 case "text":
                     $tpl->setCurrentBlock("text");
                     $tpl->setVariable("VAL_TEXT", $item["text"]);
                     $tpl->touchBlock("item");
                     break;
                 case "spacer":
                     $tpl->touchBlock("spacer");
                     if (!$item["width"]) {
                         $item["width"] = 2;
                     }
                     $tpl->setVariable("SPACER_WIDTH", $item["width"]);
                     $tpl->touchBlock("item");
                     break;
                 case "link":
                     if ($item["disabled"] == false) {
                         $tpl->setCurrentBlock("link");
                         $tpl->setVariable("LINK_TXT", $item["txt"]);
                         $tpl->setVariable("LINK_URL", $item["cmd"]);
                         $tpl->parseCurrentBlock();
                         $tpl->touchBlock("item");
                         break;
                     } else {
                         $tpl->setCurrentBlock("link_disabled");
                         $tpl->setVariable("LINK_DISABLED_TXT", $item["txt"]);
                         //$tpl->setVariable("LINK_URL", $item["cmd"]);
                         $tpl->parseCurrentBlock();
                         $tpl->touchBlock("item");
                         break;
                     }
             }
         }
         $tpl->setVariable("TXT_FUNCTIONS", $lng->txt("functions"));
         if ($this->lead_img["img"] != "") {
             $tpl->setCurrentBlock("lead_image");
             $tpl->setVariable("IMG_SRC", $this->lead_img["img"]);
             $tpl->setVariable("IMG_ALT", $this->lead_img["alt"]);
             $tpl->parseCurrentBlock();
         }
         // form?
         if ($this->getFormAction() != "") {
             if ($this->getOpenFormTag()) {
                 $tpl->setCurrentBlock("form_open");
                 $tpl->setVariable("FORMACTION", $this->getFormAction());
                 if ($this->multipart) {
                     $tpl->setVariable("ENC_TYPE", 'enctype="multipart/form-data"');
                 }
                 if ($this->form_target != "") {
                     $tpl->setVariable("TARGET", ' target="' . $this->form_target . '" ');
                 }
                 if ($this->form_name != "") {
                     $tpl->setVariable("FORMNAME", 'name="' . $this->getFormName() . '"');
                 }
                 $tpl->parseCurrentBlock();
             }
             if ($this->getCloseFormTag()) {
                 $tpl->touchBlock("form_close");
             }
         }
         // id
         if ($this->getId() != "") {
             $tpl->setVariable("ID", ' id="' . $this->getId() . '" ');
         }
         // hidden style
         if ($this->getHidden()) {
             $tpl->setVariable("STYLE", ' style="display:none;" ');
         }
         return $tpl->get();
     }
     return "";
 }
 /**
  * inserts sequential learning module navigation
  * at template variable LMNAVIGATION_CONTENT
  */
 function ilLMNavigation()
 {
     global $ilUser;
     include_once "./Modules/LearningModule/classes/class.ilLMPage.php";
     include_once "./Services/Accessibility/classes/class.ilAccessKeyGUI.php";
     $page_id = $this->getCurrentPageId();
     if (empty($page_id)) {
         return;
     }
     // process navigation for free page
     if (!$this->lm_tree->isInTree($page_id)) {
         if ($this->offlineMode() || $_GET["back_pg"] == "") {
             return;
         }
         $limpos = strpos($_GET["back_pg"], ":");
         if ($limpos > 0) {
             $back_pg = substr($_GET["back_pg"], 0, $limpos);
         } else {
             $back_pg = $_GET["back_pg"];
         }
         if (!$this->lm->cleanFrames()) {
             $back_href = $this->getLink($this->lm->getRefId(), "layout", $back_pg, $_GET["frame"], "", "reduce");
             $back_target = "";
         } else {
             $back_href = $this->getLink($this->lm->getRefId(), "layout", $back_pg, "", "", "reduce");
             $back_target = 'target="' . ilFrameTargetInfo::_getFrame("MainContent") . '" ';
         }
         $back_img = ilUtil::getImagePath("nav_arr2_L.png", false, "output", $this->offlineMode());
         $this->tpl->setCurrentBlock("ilLMNavigation_Prev");
         $this->tpl->setVariable("IMG_PREV", $back_img);
         $this->tpl->setVariable("HREF_PREV", $back_href);
         $this->tpl->setVariable("FRAME_PREV", $back_target);
         $this->tpl->setVariable("TXT_PREV", $this->lng->txt("back"));
         $this->tpl->setVariable("ALT_PREV", $this->lng->txt("back"));
         $this->tpl->setVariable("PREV_ACC_KEY", ilAccessKeyGUI::getAttribute(ilAccessKey::PREVIOUS));
         $this->tpl->setVariable("SPACER_PREV", $this->offlineMode() ? "images/spacer.png" : ilUtil::getImagePath("spacer.png"));
         $this->tpl->parseCurrentBlock();
         $this->tpl->setCurrentBlock("ilLMNavigation_Prev2");
         $this->tpl->setVariable("IMG_PREV2", $back_img);
         $this->tpl->setVariable("HREF_PREV2", $back_href);
         $this->tpl->setVariable("FRAME_PREV2", $back_target);
         $this->tpl->setVariable("TXT_PREV2", $this->lng->txt("back"));
         $this->tpl->setVariable("ALT_PREV2", $this->lng->txt("back"));
         $this->tpl->setVariable("SPACER_PREV2", $this->offlineMode() ? "images/spacer.png" : ilUtil::getImagePath("spacer.png"));
         $this->tpl->parseCurrentBlock();
         return;
     }
     // determine successor page_id
     $found = false;
     // empty chapter
     if ($this->chapter_has_no_active_page && ilLMObject::_lookupType($_GET["obj_id"]) == "st") {
         $c_id = $_GET["obj_id"];
     } else {
         if ($this->deactivated_page) {
             $c_id = $_GET["obj_id"];
         } else {
             $c_id = $page_id;
         }
     }
     while (!$found) {
         $succ_node = $this->lm_tree->fetchSuccessorNode($c_id, "pg");
         $c_id = $succ_node["obj_id"];
         $active = ilLMPage::_lookupActive($c_id, $this->lm->getType(), $this->lm_set->get("time_scheduled_page_activation"));
         if ($succ_node["obj_id"] > 0 && ($ilUser->getId() == ANONYMOUS_USER_ID || $this->needs_to_be_purchased) && ($this->lm->getPublicAccessMode() == "selected" && !ilLMObject::_isPagePublic($succ_node["obj_id"]))) {
             $found = false;
         } else {
             if ($succ_node["obj_id"] > 0 && !$active) {
                 // look, whether activation data should be shown
                 $act_data = ilLMPage::_lookupActivationData((int) $succ_node["obj_id"], $this->lm->getType());
                 if ($act_data["show_activation_info"] && ilUtil::now() < $act_data["activation_start"]) {
                     $found = true;
                 } else {
                     $found = false;
                 }
             } else {
                 $found = true;
             }
         }
     }
     $succ_str = $succ_node !== false ? " -> " . $succ_node["obj_id"] . "_" . $succ_node["type"] : "";
     // determine predecessor page id
     $found = false;
     if ($this->deactivated_page) {
         $c_id = $_GET["obj_id"];
     } else {
         $c_id = $page_id;
     }
     while (!$found) {
         $pre_node = $this->lm_tree->fetchPredecessorNode($c_id, "pg");
         $c_id = $pre_node["obj_id"];
         $active = ilLMPage::_lookupActive($c_id, $this->lm->getType(), $this->lm_set->get("time_scheduled_page_activation"));
         if ($pre_node["obj_id"] > 0 && ($ilUser->getId() == ANONYMOUS_USER_ID || $this->needs_to_be_purchased) && ($this->lm->getPublicAccessMode() == "selected" && !ilLMObject::_isPagePublic($pre_node["obj_id"]))) {
             $found = false;
         } else {
             if ($pre_node["obj_id"] > 0 && !$active) {
                 // look, whether activation data should be shown
                 $act_data = ilLMPage::_lookupActivationData((int) $pre_node["obj_id"], $this->lm->getType());
                 if ($act_data["show_activation_info"] && ilUtil::now() < $act_data["activation_start"]) {
                     $found = true;
                 } else {
                     $found = false;
                 }
             } else {
                 $found = true;
             }
         }
     }
     $pre_str = $pre_node !== false ? $pre_node["obj_id"] . "_" . $pre_node["type"] . " -> " : "";
     // determine target frame
     $framestr = !empty($_GET["frame"]) ? "frame=" . $_GET["frame"] . "&" : "";
     // Determine whether the view of a learning resource should
     // be shown in the frameset of ilias, or in a separate window.
     $showViewInFrameset = true;
     if ($pre_node != "") {
         // get presentation title
         $prev_title = ilLMPageObject::_getPresentationTitle($pre_node["obj_id"], $this->lm->getPageHeader(), $this->lm->isActiveNumbering(), $this->lm_set->get("time_scheduled_page_activation"), false, 0, $this->lang);
         $prev_title = ilUtil::shortenText($prev_title, 50, true);
         $prev_img = ilUtil::getImagePath("nav_arr_L.png", false, "output", $this->offlineMode());
         if (!$this->lm->cleanFrames()) {
             $prev_href = $this->getLink($this->lm->getRefId(), "layout", $pre_node["obj_id"], $_GET["frame"]);
             $prev_target = "";
         } else {
             if ($showViewInFrameset && !$this->offlineMode()) {
                 $prev_href = $this->getLink($this->lm->getRefId(), "layout", $pre_node["obj_id"]);
                 $prev_target = 'target="' . ilFrameTargetInfo::_getFrame("MainContent") . '" ';
             } else {
                 $prev_href = $this->getLink($this->lm->getRefId(), "layout", $pre_node["obj_id"]);
                 $prev_target = 'target="_top" ';
             }
         }
         if (($ilUser->getId() == ANONYMOUS_USER_ID || $this->needs_to_be_purchased) && ($this->lm->getPublicAccessMode() == 'selected' && !ilLMObject::_isPagePublic($pre_node["obj_id"]))) {
             $output = $this->lng->txt("msg_page_not_public");
         }
         $this->tpl->setCurrentBlock("ilLMNavigation_Prev");
         $this->tpl->setVariable("IMG_PREV", $prev_img);
         $this->tpl->setVariable("HREF_PREV", $prev_href);
         $this->tpl->setVariable("FRAME_PREV", $prev_target);
         $this->tpl->setVariable("TXT_PREV", $prev_title);
         $this->tpl->setVariable("ALT_PREV", $this->lng->txt("previous"));
         $this->tpl->setVariable("SPACER_PREV", $this->offlineMode() ? "images/spacer.png" : ilUtil::getImagePath("spacer.png"));
         $this->tpl->setVariable("PREV_ACC_KEY", ilAccessKeyGUI::getAttribute(ilAccessKey::PREVIOUS));
         $this->tpl->parseCurrentBlock();
         $this->tpl->setCurrentBlock("ilLMNavigation_Prev2");
         $this->tpl->setVariable("IMG_PREV2", $prev_img);
         $this->tpl->setVariable("HREF_PREV2", $prev_href);
         $this->tpl->setVariable("FRAME_PREV2", $prev_target);
         $this->tpl->setVariable("TXT_PREV2", $prev_title);
         $this->tpl->setVariable("ALT_PREV2", $this->lng->txt("previous"));
         $this->tpl->setVariable("SPACER_PREV2", $this->offlineMode() ? "images/spacer.png" : ilUtil::getImagePath("spacer.png"));
         $this->tpl->parseCurrentBlock();
     }
     if ($succ_node != "") {
         // get presentation title
         $succ_title = ilLMPageObject::_getPresentationTitle($succ_node["obj_id"], $this->lm->getPageHeader(), $this->lm->isActiveNumbering(), $this->lm_set->get("time_scheduled_page_activation"), false, 0, $this->lang);
         $succ_title = ilUtil::shortenText($succ_title, 50, true);
         $succ_img = ilUtil::getImagePath("nav_arr_R.png", false, "output", $this->offlineMode());
         if (!$this->lm->cleanFrames()) {
             $succ_href = $this->getLink($this->lm->getRefId(), "layout", $succ_node["obj_id"], $_GET["frame"]);
             $succ_target = "";
         } else {
             if ($showViewInFrameset && !$this->offlineMode()) {
                 $succ_href = $this->getLink($this->lm->getRefId(), "layout", $succ_node["obj_id"]);
                 $succ_target = ' target="' . ilFrameTargetInfo::_getFrame("MainContent") . '" ';
             } else {
                 $succ_href = $this->getLink($this->lm->getRefId(), "layout", $succ_node["obj_id"]);
                 $succ_target = ' target="_top" ';
             }
         }
         if (($ilUser->getId() == ANONYMOUS_USER_ID || $this->needs_to_be_purchased) && ($this->lm->getPublicAccessMode() == 'selected' && !ilLMObject::_isPagePublic($pre_node["obj_id"]))) {
             $output = $this->lng->txt("msg_page_not_public");
         }
         $this->tpl->setCurrentBlock("ilLMNavigation_Next");
         $this->tpl->setVariable("IMG_SUCC", $succ_img);
         $this->tpl->setVariable("HREF_SUCC", $succ_href);
         $this->tpl->setVariable("FRAME_SUCC", $succ_target);
         $this->tpl->setVariable("TXT_SUCC", $succ_title);
         $this->tpl->setVariable("ALT_SUCC", $this->lng->txt("next"));
         $this->tpl->setVariable("SPACER_SUCC", $this->offlineMode() ? "images/spacer.png" : ilUtil::getImagePath("spacer.png"));
         $this->tpl->setVariable("NEXT_ACC_KEY", ilAccessKeyGUI::getAttribute(ilAccessKey::NEXT));
         $this->tpl->parseCurrentBlock();
         $this->tpl->setCurrentBlock("ilLMNavigation_Next2");
         $this->tpl->setVariable("IMG_SUCC2", $succ_img);
         $this->tpl->setVariable("HREF_SUCC2", $succ_href);
         $this->tpl->setVariable("FRAME_SUCC2", $succ_target);
         $this->tpl->setVariable("TXT_SUCC2", $succ_title);
         $this->tpl->setVariable("ALT_SUCC2", $this->lng->txt("next"));
         $this->tpl->setVariable("SPACER_SUCC2", $this->offlineMode() ? "images/spacer.png" : ilUtil::getImagePath("spacer.png"));
         $this->tpl->parseCurrentBlock();
         // check if successor page is not restricted
         if (!$this->offlineMode()) {
             if ($this->lm->getRestrictForwardNavigation()) {
                 if ($this->getTracker()->hasPredIncorrectAnswers($succ_node["obj_id"])) {
                     $this->tpl->addOnLoadCode("\$('.ilc_page_rnav_RightNavigation').addClass('ilNoDisplay');");
                 }
             }
         }
     }
 }
 /**
  * Get selection list HTML
  */
 public function getHTML($a_only_cmd_list_asynch = false)
 {
     $items = $this->getItems();
     // do not show list, if no item is in list
     if (count($items) == 0 && !$this->getAsynch()) {
         return "";
     }
     include_once "./Services/YUI/classes/class.ilYuiUtil.php";
     ilYuiUtil::initOverlay();
     $GLOBALS["tpl"]->addJavascript("./Services/UIComponent/Overlay/js/ilOverlay.js");
     $GLOBALS["tpl"]->addJavascript("./Services/UIComponent/AdvancedSelectionList/js/AdvancedSelectionList.js");
     $tpl = new ilTemplate("tpl.adv_selection_list.html", true, true, "Services/UIComponent/AdvancedSelectionList", "DEFAULT", false, true);
     reset($items);
     $cnt = 0;
     if ($this->getAsynch()) {
         $tpl->setCurrentBlock("asynch_request");
         $tpl->setVariable("IMG_LOADER", ilUtil::getImagePath("loader.gif"));
         $tpl->parseCurrentBlock();
     } else {
         foreach ($items as $item) {
             if (isset($item["ref_id"])) {
                 $sel_arr[$item["ref_id"]] = isset($item["title"]) ? $item["title"] : "";
             }
             $this->css_row = $this->css_row != "tblrow1_mo" ? "tblrow1_mo" : "tblrow2_mo";
             if ($this->getUseImages()) {
                 if ($item["img"]) {
                     $tpl->setCurrentBlock("image");
                     $tpl->setVariable("IMG_ITEM", $item["img"]);
                     $tpl->setVariable("ALT_ITEM", $item["alt"]);
                     $tpl->parseCurrentBlock();
                 } else {
                     $tpl->touchBlock("no_image");
                 }
             }
             if ($this->getOnClickMode() == ilAdvancedSelectionListGUI::ON_ITEM_CLICK_HREF || $this->getItemLinkClass() != "") {
                 if ($item["frame"]) {
                     $tpl->setCurrentBlock("frame");
                     $tpl->setVariable("TARGET_ITEM", $item["frame"]);
                     $tpl->parseCurrentBlock();
                 }
                 if ($this->getItemLinkClass() != "") {
                     $tpl->setCurrentBlock("item_link_class");
                     $tpl->setVariable("ITEM_LINK_CLASS", $this->getItemLinkClass());
                     $tpl->parseCurrentBlock();
                 }
                 $tpl->setCurrentBlock("href_s");
                 $tpl->setVariable("HREF_ITEM", 'href="' . $item["link"] . '"');
                 $tpl->setVariable("ID_ITEM", $this->getId() . "_" . $item["value"]);
                 $tpl->parseCurrentBlock();
                 $tpl->touchBlock("href_e");
             }
             $tpl->setCurrentBlock("item");
             if ($this->getOnClickMode() == ilAdvancedSelectionListGUI::ON_ITEM_CLICK_HREF) {
                 if ($item["prevent_background_click"]) {
                     $tpl->setVariable("ONCLICK_ITEM", '');
                 } else {
                     if ($item["onclick"] == "") {
                         $tpl->setVariable("ONCLICK_ITEM", 'onclick="' . "return il.AdvancedSelectionList.openTarget('" . $item["link"] . "','" . $item["frame"] . "');" . '"');
                     } else {
                         $tpl->setVariable("ONCLICK_ITEM", 'onclick="' . "return " . $item["onclick"] . ";" . '"');
                     }
                 }
             } else {
                 if ($this->getOnClickMode() == ilAdvancedSelectionListGUI::ON_ITEM_CLICK_FORM_SUBMIT) {
                     $tpl->setVariable("ONCLICK_ITEM", 'onclick="return il.AdvancedSelectionList.submitForm(\'' . $this->getId() . '\'' . ", '" . $this->form_mode["select_name"] . "','" . $item["value"] . "'," . "'" . $this->on_click_form_id . "','" . $this->form_mode["button_cmd"] . "');\"");
                 } else {
                     if ($this->getOnClickMode() == ilAdvancedSelectionListGUI::ON_ITEM_CLICK_FORM_SELECT) {
                         $tpl->setVariable("ONCLICK_ITEM", 'onclick="return il.AdvancedSelectionList.selectForm(\'' . $this->getId() . '\'' . ", '" . $this->form_mode["select_name"] . "','" . $item["value"] . "'," . "'" . $item["title"] . "');\"");
                     } else {
                         if ($this->getOnClickMode() == ilAdvancedSelectionListGUI::ON_ITEM_CLICK_NOP) {
                             $tpl->setVariable("ONCLICK_ITEM", 'onclick="il.AdvancedSelectionList.clickNop(\'' . $this->getId() . '\'' . ", '" . $this->form_mode["select_name"] . "','" . $item["value"] . "'," . "'" . $item["title"] . "');\"");
                         }
                     }
                 }
             }
             $tpl->setVariable("CSS_ROW", $this->css_row);
             if ($item["html"] == "") {
                 $tpl->setVariable("TXT_ITEM", $item["title"]);
             } else {
                 $tpl->setVariable("TXT_ITEM", $item["html"]);
             }
             $tpl->setVariable("ID_ITEM_TR", $this->getId() . "_" . $item["value"] . "_tr");
             if ($item["ttip"] != "") {
                 include_once "./Services/UIComponent/Tooltip/classes/class.ilTooltipGUI.php";
                 ilTooltipGUI::addTooltip($this->getId() . "_" . $item["value"] . "_tr", $item["ttip"], "", $item["tt_my"], $item["tt_at"], $item["tt_use_htmlspecialchars"]);
             }
             $tpl->parseCurrentBlock();
             // add item to js object
             $tpl->setCurrentBlock("js_item");
             $tpl->setVariable("IT_ID", $this->getId());
             $tpl->setVariable("IT_HID_NAME", $this->form_mode["select_name"]);
             $tpl->setVariable("IT_HID_VAL", $item["value"]);
             $tpl->setVariable("IT_TITLE", str_replace("'", "\\'", $item["title"]));
             $tpl->parseCurrentBlock();
         }
     }
     $tpl->setCurrentBlock("cmd_table");
     $tpl->parseCurrentBlock();
     if ($a_only_cmd_list_asynch) {
         return $tpl->get("cmd_table");
     }
     if ($this->getHeaderIcon() != ilAdvancedSelectionListGUI::NO_ICON) {
         $tpl->setCurrentBlock("top_img");
         switch ($this->getHeaderIcon()) {
             case ilAdvancedSelectionListGUI::DOWN_ARROW_LIGHT:
                 $tpl->setVariable("IMG_DOWN", ilUtil::getImagePath(ilAdvancedSelectionListGUI::DOWN_ARROW_LIGHT));
                 break;
             case ilAdvancedSelectionListGUI::DOWN_ARROW_DARK:
                 $tpl->setVariable("IMG_DOWN", ilUtil::getImagePath(ilAdvancedSelectionListGUI::DOWN_ARROW_DARK));
                 break;
             case ilAdvancedSelectionListGUI::DOWN_ARROW_TOPBAR:
                 $tpl->setVariable("IMG_DOWN", ilUtil::getImagePath(ilAdvancedSelectionListGUI::DOWN_ARROW_TOPBAR));
                 break;
             default:
                 $tpl->setVariable("IMG_DOWN", $this->getHeaderIcon());
                 break;
         }
         // do not repeat title (accessibility) -> empty alt
         //$tpl->setVariable("ALT_SEL_TOP", $this->getListTitle());
         $tpl->setVariable("ALT_SEL_TOP", "");
         $tpl->parseCurrentBlock();
     }
     // output hidden input, if click mode is form submission
     if ($this->getOnClickMode() == ilAdvancedSelectionListGUI::ON_ITEM_CLICK_FORM_SUBMIT) {
         $tpl->setCurrentBlock("hidden_input");
         $tpl->setVariable("HID", $this->getId());
         $tpl->parseCurrentBlock();
     }
     // output hidden input and initialize
     if ($this->getOnClickMode() == ilAdvancedSelectionListGUI::ON_ITEM_CLICK_FORM_SELECT) {
         $tpl->setCurrentBlock("hidden_input");
         $tpl->setVariable("HID", $this->getId());
         $tpl->parseCurrentBlock();
         // init hidden input with selected value
         $tpl->setCurrentBlock("init_hidden_input");
         $tpl->setVariable("H2ID", $this->getId());
         $tpl->setVariable("HID_NAME", $this->form_mode["select_name"]);
         $tpl->setVariable("HID_VALUE", $this->getSelectedValue());
         $tpl->parseCurrentBlock();
     }
     // js section
     $tpl->setCurrentBlock("js_section");
     if ($this->getAccessKey() > 0) {
         include_once "./Services/Accessibility/classes/class.ilAccessKeyGUI.php";
         $tpl->setVariable("ACCKEY", ilAccessKeyGUI::getAttribute($this->getAccessKey()));
     }
     $cfg["trigger_event"] = $this->getTriggerEvent();
     $cfg["auto_hide"] = $this->getAutoHide();
     if ($this->getSelectCallback() != "") {
         $cfg["select_callback"] = $this->getSelectCallback();
     }
     $cfg["anchor_id"] = "ilAdvSelListAnchorElement_" . $this->getId();
     $cfg["asynch"] = $this->getAsynch() ? true : false;
     $cfg["asynch_url"] = $this->getAsynchUrl();
     $toggle = $this->getAdditionalToggleElement();
     if (is_array($toggle)) {
         $cfg["toggle_el"] = $toggle["el"];
         $cfg["toggle_class_on"] = $toggle["class_on"];
     }
     //echo "<br>".htmlentities($this->getAsynchUrl());
     include_once "./Services/JSON/classes/class.ilJsonUtil.php";
     $tpl->setVariable("TXT_SEL_TOP", $this->getListTitle());
     $tpl->setVariable("ID", $this->getId());
     $tpl->setVariable("CFG", ilJsonUtil::encode($cfg));
     //echo htmlentities(ilJsonUtil::encode($cfg));
     $tpl->setVariable("CLASS_SEL_TOP", $this->getSelectionHeaderClass());
     if ($this->getSelectionHeaderSpanClass() != "") {
         $tpl->setVariable("CLASS_SEL_TOP_SPAN", $this->getSelectionHeaderSpanClass());
     }
     // set the async url to an extra template variable
     // (needed for a mobile skin)
     $tpl->setVariable("ASYNC_URL", $this->getAsynchUrl());
     $tpl->parseCurrentBlock();
     // no js sections
     if (false) {
         switch ($this->mode) {
             // links mode
             case ilAdvancedSelectionListGUI::MODE_LINKS:
                 reset($items);
                 $cnt = 0;
                 foreach ($items as $item) {
                     $tpl->setCurrentBlock("no_js_link");
                     $tpl->setVariable("LINKS_CLASS", $this->links_mode["link_class"]);
                     $tpl->setVariable("LINKS_HREF", $item["link"]);
                     $tpl->setVariable("LINKS_TXT", $item["title"]);
                     $tpl->parseCurrentBlock();
                     $tpl->setCurrentBlock("no_js_section");
                     $tpl->parseCurrentBlock();
                 }
                 break;
             case ilAdvancedSelectionListGUI::MODE_FORM_SELECT:
                 reset($items);
                 $cnt = 0;
                 foreach ($items as $item) {
                     $tpl->setCurrentBlock("no_js_form_option");
                     $tpl->setVariable("FRM_OPTION_TXT", $item["title"]);
                     $tpl->setVariable("FRM_OPTION_VAL", $item["value"]);
                     if ($this->getSelectedValue() == $item["value"]) {
                         $tpl->setVariable("SELECTED", ' selected="selected" ');
                     }
                     $tpl->parseCurrentBlock();
                 }
                 if ($this->form_mode["include_form_tag"]) {
                     $tpl->setCurrentBlock("no_js_form_begin");
                     $tpl->setVariable("FRM_ID", $this->form_mode["form_id"]);
                     $tpl->setVariable("FRM_CLASS", $this->form_mode["form_class"]);
                     $tpl->setVariable("FRM_ACTION", $this->form_mode["form_action"]);
                     $tpl->setVariable("FRM_TARGET", $this->form_mode["form_target"]);
                     $tpl->parseCurrentBlock();
                     $tpl->touchBlock("no_js_form_end");
                 }
                 if ($this->form_mode["button_text"]) {
                     $tpl->setCurrentBlock("no_js_form_button");
                     $tpl->setVariable("FRM_BT_TXT", $this->form_mode["button_text"]);
                     $tpl->setVariable("FRM_BT_CLASS", $this->form_mode["button_class"]);
                     if ($this->form_mode["button_cmd"] != "") {
                         $tpl->setVariable("FRM_BT_CMD", 'name="cmd[' . $this->form_mode["button_cmd"] . ']"');
                     }
                     $tpl->parseCurrentBlock();
                 }
                 $tpl->setVariable("FRM_SELECT_NAME", $this->form_mode["select_name"]);
                 $tpl->setVariable("FRM_SELECT_CLASS", $this->form_mode["select_class"]);
                 if ($this->getAccessKey() > 0) {
                     include_once "./Services/Accessibility/classes/class.ilAccessKeyGUI.php";
                     $tpl->setVariable("ACCKEYNJS", ilAccessKeyGUI::getAttribute($this->getAccessKey()));
                 }
                 $tpl->setCurrentBlock("no_js_section");
                 $tpl->parseCurrentBlock();
                 break;
         }
     }
     return $tpl->get();
 }
示例#4
0
 /**
  * Fill side icons (upper icon, tree icon, webfolder icon)
  */
 function fillSideIcons()
 {
     global $lng, $ilSetting;
     if ($this->upper_icon == "" && $this->tree_flat_link == "" && $this->mount_webfolder == "") {
         return;
     }
     // upper icon
     // deprecated
     if ($this->upper_icon != "") {
         /*if ($this->upper_icon_frame != "")
         			{
         				$this->setCurrentBlock("target_top");
         				$this->setVariable("TARGET_TOP", $this->upper_icon_frame);
         				$this->parseCurrentBlock();
         			}
         	
         			$this->setCurrentBlock("alt_top");
         			$this->setVariable("ALT_TOP", $lng->txt("up"));
         			$this->parseCurrentBlock();
         	
         			$this->setCurrentBlock("top");
         			$this->setVariable("LINK_TOP", $this->upper_icon);
         			$this->parseCurrentBlock();*/
     }
     // tree/flat icon
     if ($this->tree_flat_link != "") {
         if ($this->left_nav_content != "") {
             $this->touchBlock("tree_lns");
         }
         $this->setCurrentBlock("tree_mode");
         $this->setVariable("LINK_MODE", $this->tree_flat_link);
         if ($ilSetting->get("tree_frame") == "right") {
             if ($this->tree_flat_mode == "tree") {
                 $this->setVariable("IMG_TREE", ilUtil::getImagePath("icon_sidebar_on.svg"));
                 $this->setVariable("RIGHT", "Right");
             } else {
                 $this->setVariable("IMG_TREE", ilUtil::getImagePath("icon_sidebar_on.svg"));
                 $this->setVariable("RIGHT", "Right");
             }
         } else {
             if ($this->tree_flat_mode == "tree") {
                 $this->setVariable("IMG_TREE", ilUtil::getImagePath("icon_sidebar_on.svg"));
             } else {
                 $this->setVariable("IMG_TREE", ilUtil::getImagePath("icon_sidebar_on.svg"));
             }
         }
         $this->setVariable("ALT_TREE", $lng->txt($this->tree_flat_mode . "view"));
         $this->setVariable("TARGET_TREE", ilFrameTargetInfo::_getFrame("MainContent"));
         include_once "./Services/Accessibility/classes/class.ilAccessKeyGUI.php";
         $this->setVariable("TREE_ACC_KEY", ilAccessKeyGUI::getAttribute($this->tree_flat_mode == "tree" ? ilAccessKey::TREE_ON : ilAccessKey::TREE_OFF));
         $this->parseCurrentBlock();
     }
     // mount webfolder
     if ($this->mount_webfolder != "") {
         require_once 'Services/WebDAV/classes/class.ilDAVServer.php';
         $davServer = new ilDAVServer();
         $a_ref_id = $this->mount_webfolder;
         $a_link = $davServer->getMountURI($a_ref_id);
         $a_folder = $davServer->getFolderURI($a_ref_id);
         $this->setCurrentBlock("mount_webfolder");
         $this->setVariable("LINK_MOUNT_WEBFOLDER", $a_link);
         $this->setVariable("FOLDER_MOUNT_WEBFOLDER", $a_folder);
         $this->setVariable("IMG_MOUNT_WEBFOLDER", ilUtil::getImagePath("ic_mount_webfolder.png"));
         $this->setVariable("ALT_MOUNT_WEBFOLDER", $lng->txt("mount_webfolder"));
         $this->setVariable("TARGET_MOUNT_WEBFOLDER", '_blank');
         $this->parseCurrentBlock();
     }
     $this->setCurrentBlock("tree_icons");
     $this->parseCurrentBlock();
 }
 /**
  * Get selection list HTML
  */
 public function getHTML($a_only_cmd_list_asynch = false)
 {
     $items = $this->getItems();
     // do not show list, if no item is in list
     if (count($items) == 0 && !$this->getAsynch() && $this->getGroupedList() == null) {
         return "";
     }
     /* bootstrap made this obsolete ?!
     		include_once("./Services/YUI/classes/class.ilYuiUtil.php");
     		ilYuiUtil::initOverlay();
     		$GLOBALS["tpl"]->addJavascript("./Services/UIComponent/Overlay/js/ilOverlay.js");					
     		*/
     $GLOBALS["tpl"]->addJavascript("./Services/UIComponent/AdvancedSelectionList/js/AdvancedSelectionList.js");
     $tpl = new ilTemplate("tpl.adv_selection_list.html", true, true, "Services/UIComponent/AdvancedSelectionList", "DEFAULT", false, true);
     reset($items);
     $cnt = 0;
     if ($this->getAsynch()) {
         $tpl->setCurrentBlock("asynch_request");
         $tpl->setVariable("IMG_LOADER", ilUtil::getImagePath("loader.svg"));
         $tpl->parseCurrentBlock();
     } else {
         if ($this->getGroupedList() != null) {
             $tpl->setVariable("GROUPED_LIST_HTML", $this->getGroupedList()->getHTML());
         } else {
             foreach ($items as $item) {
                 if (isset($item["ref_id"])) {
                     $sel_arr[$item["ref_id"]] = isset($item["title"]) ? $item["title"] : "";
                 }
                 $this->css_row = $this->css_row != "tblrow1_mo" ? "tblrow1_mo" : "tblrow2_mo";
                 if ($this->getUseImages()) {
                     if ($item["img"]) {
                         $tpl->setCurrentBlock("image");
                         $tpl->setVariable("IMG_ITEM", $item["img"]);
                         $tpl->setVariable("ALT_ITEM", $item["alt"]);
                         $tpl->parseCurrentBlock();
                     } else {
                         $tpl->touchBlock("no_image");
                     }
                 }
                 if ($this->getOnClickMode() == ilAdvancedSelectionListGUI::ON_ITEM_CLICK_HREF || $this->getItemLinkClass() != "") {
                     if ($item["frame"]) {
                         $tpl->setCurrentBlock("frame");
                         $tpl->setVariable("TARGET_ITEM", $item["frame"]);
                         $tpl->parseCurrentBlock();
                     }
                     if ($this->getItemLinkClass() != "") {
                         $tpl->setCurrentBlock("item_link_class");
                         $tpl->setVariable("ITEM_LINK_CLASS", $this->getItemLinkClass());
                         $tpl->parseCurrentBlock();
                     }
                     $tpl->setCurrentBlock("href_s");
                     $tpl->setVariable("HREF_ITEM", 'href="' . $item["link"] . '"');
                     $tpl->setVariable("ID_ITEM", $this->getId() . "_" . $item["value"]);
                     $tpl->parseCurrentBlock();
                     $tpl->touchBlock("href_e");
                 }
                 $tpl->setCurrentBlock("item");
                 if ($this->getOnClickMode() == ilAdvancedSelectionListGUI::ON_ITEM_CLICK_HREF) {
                     if ($item["prevent_background_click"]) {
                         $tpl->setVariable("ONCLICK_ITEM", '');
                     } else {
                         if ($item["onclick"] == "") {
                             $tpl->setVariable("ONCLICK_ITEM", 'onclick="' . "return il.AdvancedSelectionList.openTarget('" . $item["link"] . "','" . $item["frame"] . "');" . '"');
                         } else {
                             $tpl->setVariable("ONCLICK_ITEM", 'onclick="' . "return " . $item["onclick"] . ";" . '"');
                         }
                     }
                 } else {
                     if ($this->getOnClickMode() == ilAdvancedSelectionListGUI::ON_ITEM_CLICK_FORM_SUBMIT) {
                         $tpl->setVariable("ONCLICK_ITEM", 'onclick="return il.AdvancedSelectionList.submitForm(\'' . $this->getId() . '\'' . ", '" . $this->form_mode["select_name"] . "','" . $item["value"] . "'," . "'" . $this->on_click_form_id . "','" . $this->form_mode["button_cmd"] . "');\"");
                     } else {
                         if ($this->getOnClickMode() == ilAdvancedSelectionListGUI::ON_ITEM_CLICK_FORM_SELECT) {
                             $tpl->setVariable("ONCLICK_ITEM", 'onclick="return il.AdvancedSelectionList.selectForm(\'' . $this->getId() . '\'' . ", '" . $this->form_mode["select_name"] . "','" . $item["value"] . "'," . "'" . $item["title"] . "');\"");
                         } else {
                             if ($this->getOnClickMode() == ilAdvancedSelectionListGUI::ON_ITEM_CLICK_NOP) {
                                 $tpl->setVariable("ONCLICK_ITEM", 'onclick="il.AdvancedSelectionList.clickNop(\'' . $this->getId() . '\'' . ", '" . $this->form_mode["select_name"] . "','" . $item["value"] . "'," . "'" . $item["title"] . "');\"");
                             }
                         }
                     }
                 }
                 $tpl->setVariable("CSS_ROW", $this->css_row);
                 if ($item["html"] == "") {
                     $tpl->setVariable("TXT_ITEM", $item["title"]);
                 } else {
                     $tpl->setVariable("TXT_ITEM", $item["html"]);
                 }
                 $tpl->setVariable("ID_ITEM_TR", $this->getId() . "_" . $item["value"] . "_tr");
                 if ($item["ttip"] != "") {
                     include_once "./Services/UIComponent/Tooltip/classes/class.ilTooltipGUI.php";
                     ilTooltipGUI::addTooltip($this->getId() . "_" . $item["value"] . "_tr", $item["ttip"], "", $item["tt_my"], $item["tt_at"], $item["tt_use_htmlspecialchars"]);
                 }
                 $tpl->parseCurrentBlock();
                 // add item to js object
                 $tpl->setCurrentBlock("js_item");
                 $tpl->setVariable("IT_ID", $this->getId());
                 $tpl->setVariable("IT_HID_NAME", $this->form_mode["select_name"]);
                 $tpl->setVariable("IT_HID_VAL", $item["value"]);
                 $tpl->setVariable("IT_TITLE", str_replace("'", "\\'", $item["title"]));
                 $tpl->parseCurrentBlock();
             }
             // output hidden input, if click mode is form submission
             if ($this->getOnClickMode() == ilAdvancedSelectionListGUI::ON_ITEM_CLICK_FORM_SUBMIT) {
                 $tpl->setCurrentBlock("hidden_input");
                 $tpl->setVariable("HID", $this->getId());
                 $tpl->parseCurrentBlock();
             }
             // output hidden input and initialize
             if ($this->getOnClickMode() == ilAdvancedSelectionListGUI::ON_ITEM_CLICK_FORM_SELECT) {
                 $tpl->setCurrentBlock("hidden_input");
                 $tpl->setVariable("HID", $this->getId());
                 $tpl->parseCurrentBlock();
                 // init hidden input with selected value
                 $tpl->setCurrentBlock("init_hidden_input");
                 $tpl->setVariable("H2ID", $this->getId());
                 $tpl->setVariable("HID_NAME", $this->form_mode["select_name"]);
                 $tpl->setVariable("HID_VALUE", $this->getSelectedValue());
                 $tpl->parseCurrentBlock();
             }
         }
     }
     if ($a_only_cmd_list_asynch) {
         $tpl->touchBlock("cmd_table");
         return $tpl->get("cmd_table");
     }
     if ($this->getGroupedList() == null) {
         $tpl->setCurrentBlock("dd_content");
         if ($this->getPullRight()) {
             $tpl->setVariable("UL_CLASS", "dropdown-menu pull-right");
         } else {
             $tpl->setVariable("UL_CLASS", "dropdown-menu");
         }
         $tpl->setVariable("TABLE_ID", $this->getId());
         $tpl->parseCurrentBlock();
     }
     if ($this->getHeaderIcon() != ilAdvancedSelectionListGUI::NO_ICON) {
         $tpl->setCurrentBlock("top_img");
         switch ($this->getHeaderIcon()) {
             case ilAdvancedSelectionListGUI::ICON_CONFIG:
                 $tpl->setVariable("IMG_SPAN_STYLE", ilAdvancedSelectionListGUI::ICON_CONFIG);
                 break;
             case ilAdvancedSelectionListGUI::DOWN_ARROW_DARK:
             default:
                 $tpl->setVariable("IMG_SPAN_STYLE", ilAdvancedSelectionListGUI::ICON_ARROW);
                 break;
         }
         $tpl->parseCurrentBlock();
     }
     if ($this->getAsynch()) {
         $tpl->setCurrentBlock("asynch_bl");
         $tpl->setVariable("ASYNCH_URL", $this->getAsynchUrl());
         $tpl->setVariable("ASYNCH_ID", $this->getId());
         $tpl->setVariable("ASYNCH_TRIGGER_ID", $this->getId());
         $tpl->parseCurrentBlock();
     }
     // js section
     $tpl->setCurrentBlock("js_section");
     if ($this->getAccessKey() > 0) {
         include_once "./Services/Accessibility/classes/class.ilAccessKeyGUI.php";
         $tpl->setVariable("ACCKEY", ilAccessKeyGUI::getAttribute($this->getAccessKey()));
     }
     $cfg["trigger_event"] = $this->getTriggerEvent();
     $cfg["auto_hide"] = $this->getAutoHide();
     if ($this->getSelectCallback() != "") {
         $cfg["select_callback"] = $this->getSelectCallback();
     }
     $cfg["anchor_id"] = "ilAdvSelListAnchorElement_" . $this->getId();
     $cfg["asynch"] = $this->getAsynch() ? true : false;
     $cfg["asynch_url"] = $this->getAsynchUrl();
     $toggle = $this->getAdditionalToggleElement();
     if (is_array($toggle)) {
         $cfg["toggle_el"] = $toggle["el"];
         $cfg["toggle_class_on"] = $toggle["class_on"];
     }
     //echo "<br>".htmlentities($this->getAsynchUrl());
     include_once "./Services/JSON/classes/class.ilJsonUtil.php";
     $tpl->setVariable("CFG", ilJsonUtil::encode($cfg));
     //echo htmlentities(ilJsonUtil::encode($cfg));
     $tpl->setVariable("TXT_SEL_TOP", $this->getListTitle());
     $tpl->setVariable("ID", $this->getId());
     //$tpl->setVariable("CLASS_SEL_TOP", $this->getSelectionHeaderClass());
     switch ($this->getStyle()) {
         case self::STYLE_DEFAULT:
             $tpl->setVariable("BTN_CLASS", "btn btn-sm btn-default");
             $tpl->setVariable("TAG", "button");
             break;
         case self::STYLE_EMPH:
             $tpl->setVariable("BTN_CLASS", "btn btn-sm btn-primary");
             $tpl->setVariable("TAG", "button");
             break;
         case self::STYLE_LINK_BUTTON:
             $tpl->setVariable("BTN_CLASS", "btn btn-sm btn-link");
             $tpl->setVariable("TAG", "button");
             break;
         case self::STYLE_LINK:
             $tpl->setVariable("BTN_CLASS", "");
             $tpl->setVariable("TAG", "a");
             break;
     }
     if ($this->getSelectionHeaderSpanClass() != "") {
         $tpl->setVariable("CLASS_SEL_TOP_SPAN", $this->getSelectionHeaderSpanClass());
     }
     // set the async url to an extra template variable
     // (needed for a mobile skin)
     // $tpl->setVariable("ASYNC_URL", $this->getAsynchUrl());
     $tpl->parseCurrentBlock();
     return $tpl->get();
 }