/**
  * Get accordion html
  */
 function getHTML()
 {
     global $ilUser;
     self::$accordion_cnt++;
     $or_short = $this->getOrientation() == ilAccordionGUI::HORIZONTAL ? "H" : "V";
     $width = (int) $this->getContentWidth();
     $height = (int) $this->getContentHeight();
     if ($this->getOrientation() == ilAccordionGUI::HORIZONTAL) {
         if ($width == 0) {
             $width = 200;
         }
         if ($height == 0) {
             $height = 100;
         }
     }
     $this->addJavascript();
     $this->addCss();
     $tpl = new ilTemplate("tpl.accordion.html", true, true, "Services/Accordion");
     foreach ($this->getItems() as $item) {
         $tpl->setCurrentBlock("item");
         $tpl->setVariable("HEADER", $item["header"]);
         $tpl->setVariable("CONTENT", $item["content"]);
         $tpl->setVariable("HEADER_CLASS", $this->getHeaderClass() ? $this->getHeaderClass() : "il_" . $or_short . "AccordionHead");
         $tpl->setVariable("CONTENT_CLASS", $this->getContentClass() ? $this->getContentClass() : "il_" . $or_short . "AccordionContent");
         $tpl->setVariable("OR_SHORT", $or_short);
         $tpl->setVariable("INNER_CONTAINER_CLASS", $this->getInnerContainerClass() ? $this->getInnerContainerClass() : "il_" . $or_short . "AccordionInnerContainer");
         if ($height > 0) {
             $tpl->setVariable("HEIGHT", "height:" . $height . "px;");
         }
         if ($height > 0 && $this->getOrientation() == ilAccordionGUI::HORIZONTAL) {
             $tpl->setVariable("HHEIGHT", "height:" . $height . "px;");
         }
         $tpl->parseCurrentBlock();
     }
     $tpl->setVariable("CNT", self::$accordion_cnt);
     $tpl->setVariable("CONTAINER_CLASS", $this->getContainerClass() ? $this->getContainerClass() : "il_" . $or_short . "AccordionContainer");
     $tpl->setVariable("ORIENTATION", $this->getOrientation());
     $tpl->setVariable("ID", $this->getId());
     if ($this->getBehaviour() == "OneOpenSession" && $this->getId() != "") {
         include_once "./Services/Accordion/classes/class.ilAccordionPropertiesStorage.php";
         $stor = new ilAccordionPropertiesStorage();
         $ctab = $stor->getProperty($this->getId(), $ilUser->getId(), "opened");
         $tpl->setVariable("BEHAVIOUR", $ctab);
         $tpl->setVariable("SAVE_URL", "./ilias.php?baseClass=ilaccordionpropertiesstorage&cmd=setOpenedTab" . "&accordion_id=" . $this->getId() . "&user_id=" . $ilUser->getId());
     } else {
         if ($this->getBehaviour() != "") {
             $tpl->setVariable("BEHAVIOUR", $this->getBehaviour());
         }
     }
     $tpl->setVariable("OR2_SHORT", $or_short);
     if ($width > 0) {
         $tpl->setVariable("WIDTH", $width);
     } else {
         $tpl->setVariable("WIDTH", "null");
     }
     if ($width > 0 && $this->getOrientation() == ilAccordionGUI::VERTICAL) {
         $tpl->setVariable("CWIDTH", 'style="width:' . $width . 'px;"');
     }
     if ($this->head_class_set) {
         $tpl->setVariable("ACTIVE_HEAD_CLASS", $this->getActiveHeaderClass());
     } else {
         if ($this->getOrientation() == ilAccordionGUI::VERTICAL) {
             $tpl->setVariable("ACTIVE_HEAD_CLASS", "il_HAccordionHeadActive");
         } else {
             $tpl->setVariable("ACTIVE_HEAD_CLASS", "il_VAccordionHeadActive");
         }
     }
     return $tpl->get();
 }
Exemplo n.º 2
0
 /**
  * Get accordion html
  */
 function getHTML()
 {
     global $ilUser;
     self::$accordion_cnt++;
     $or_short = $this->getOrientation() == ilAccordionGUI::HORIZONTAL ? "H" : "V";
     $width = (int) $this->getContentWidth();
     $height = (int) $this->getContentHeight();
     if ($this->getOrientation() == ilAccordionGUI::HORIZONTAL) {
         if ($width == 0) {
             $width = 200;
         }
         if ($height == 0) {
             $height = 100;
         }
     }
     $this->addJavascript();
     $this->addCss();
     $tpl = new ilTemplate("tpl.accordion.html", true, true, "Services/Accordion");
     foreach ($this->getItems() as $item) {
         $tpl->setCurrentBlock("item");
         $tpl->setVariable("HEADER", $item["header"]);
         $tpl->setVariable("CONTENT", $item["content"]);
         $tpl->setVariable("HEADER_CLASS", $this->getHeaderClass() ? $this->getHeaderClass() : "il_" . $or_short . "AccordionHead");
         $tpl->setVariable("CONTENT_CLASS", $this->getContentClass() ? $this->getContentClass() : "il_" . $or_short . "AccordionContent");
         if ($this->getBehaviour() != self::FORCE_ALL_OPEN) {
             $tpl->setVariable("HIDE_CONTENT_CLASS", "ilAccHideContent");
         }
         $tpl->setVariable("OR_SHORT", $or_short);
         $tpl->setVariable("INNER_CONTAINER_CLASS", $this->getInnerContainerClass() ? $this->getInnerContainerClass() : "il_" . $or_short . "AccordionInnerContainer");
         if ($height > 0) {
             $tpl->setVariable("HEIGHT", "height:" . $height . "px;");
         }
         if ($height > 0 && $this->getOrientation() == ilAccordionGUI::HORIZONTAL) {
             $tpl->setVariable("HHEIGHT", "height:" . $height . "px;");
         }
         $tpl->parseCurrentBlock();
     }
     $tpl->setVariable("CONTAINER_CLASS", $this->getContainerClass() ? $this->getContainerClass() : "il_" . $or_short . "AccordionContainer");
     $options["orientation"] = $this->getOrientation();
     $options["int_id"] = $this->getId();
     if ($this->getUseSessionStorage() && $this->getId() != "") {
         include_once "./Services/Accordion/classes/class.ilAccordionPropertiesStorage.php";
         $stor = new ilAccordionPropertiesStorage();
         $ctab = $stor->getProperty($this->getId(), $ilUser->getId(), "opened");
         $ctab_arr = explode(";", $ctab);
         foreach ($this->force_open as $fo) {
             if (!in_array($fo, $ctab_arr)) {
                 $ctab_arr[] = $fo;
             }
         }
         $ctab = implode(";", $ctab_arr);
         if ($ctab == "0") {
             $ctab = "";
         }
         $options["initial_opened"] = $ctab;
         $options["save_url"] = "./ilias.php?baseClass=ilaccordionpropertiesstorage&cmd=setOpenedTab" . "&accordion_id=" . $this->getId() . "&user_id=" . $ilUser->getId();
     }
     $options["behaviour"] = $this->getBehaviour();
     if ($this->getOrientation() == ilAccordionGUI::HORIZONTAL) {
         $options["toggle_class"] = 'il_HAccordionToggleDef';
         $options["toggle_act_class"] = 'il_HAccordionToggleActiveDef';
         $options["content_class"] = 'il_HAccordionContentDef';
     } else {
         $options["toggle_class"] = 'il_VAccordionToggleDef';
         $options["toggle_act_class"] = 'il_VAccordionToggleActiveDef';
         $options["content_class"] = 'il_VAccordionContentDef';
     }
     if ($width > 0) {
         $options["width"] = $width;
     } else {
         $options["width"] = null;
     }
     if ($width > 0 && $this->getOrientation() == ilAccordionGUI::VERTICAL) {
         $tpl->setVariable("CWIDTH", 'style="width:' . $width . 'px;"');
     }
     if ($this->head_class_set) {
         $options["active_head_class"] = $this->getActiveHeaderClass();
     } else {
         if ($this->getOrientation() == ilAccordionGUI::VERTICAL) {
             $options["active_head_class"] = "il_HAccordionHeadActive";
         } else {
             $options["active_head_class"] = "il_VAccordionHeadActive";
         }
     }
     $options["height"] = null;
     $options["id"] = 'accordion_' . $this->getId() . '_' . self::$accordion_cnt;
     $options["multi"] = (bool) $this->getAllowMultiOpened();
     $options["show_all_element"] = $this->getShowAllElement();
     $options["hide_all_element"] = $this->getHideAllElement();
     include_once "./Services/JSON/classes/class.ilJsonUtil.php";
     $tpl->setVariable("OPTIONS", $str = ilJsonUtil::encode($options));
     $tpl->setVariable("ACC_ID", $options["id"]);
     //echo "<br><br><br><br><br><br>".$str;
     return $tpl->get();
 }