45 protected string $id =
"";
47 public static string $owl_path =
"./libs/bower/bower_components/owl.carousel/dist";
58 $this->main_tpl =
$DIC->ui()->mainTemplate();
60 $this->
user = $DIC->user();
64 public function setId(
string $a_val): void
80 $this->orientation = $a_orientation;
91 $this->containerclass = $a_containerclass;
101 $this->icontainerclass = $a_containerclass;
111 $this->headerclass = $a_headerclass;
121 $this->active_headerclass = $a_h_class;
131 $this->contentclass = $a_contentclass;
141 $this->contentwidth = $a_contentwidth;
151 $this->contentheight = $a_contentheight;
164 $this->behaviour = $a_val;
174 $this->use_session_storage = $a_val;
184 $this->allow_multi_opened = $a_val;
197 $this->show_all_element = $a_val;
210 $this->hide_all_element = $a_val;
235 foreach (self::getLocalJavascriptFiles() as
$f) {
236 $tpl->addJavaScript(
$f,
true, 3);
249 foreach (self::getLocalCssFiles() as
$f) {
257 "./Services/Accordion/js/accordion.js",
258 self::$owl_path . self::$owl_js_path
265 "./Services/Accordion/css/accordion.css",
266 self::$owl_path . self::$owl_css_path
273 bool $a_force_open =
false
275 $this->items[] = array(
"header" => $a_header,
276 "content" => $a_content,
"force_open" => $a_force_open);
288 public function getHTML(
bool $async =
false): string
292 self::$accordion_cnt++;
298 $width = (
int) $this->getContentWidth();
299 $height = (
int) $this->getContentHeight();
309 $this->addJavascript();
312 $tpl =
new ilTemplate(
"tpl.accordion.html",
true,
true,
"Services/Accordion");
313 foreach ($this->getItems() as $item) {
314 $tpl->setCurrentBlock(
"item");
315 $tpl->setVariable(
"HEADER", $item[
"header"]);
316 $tpl->setVariable(
"CONTENT", $item[
"content"]);
317 $tpl->setVariable(
"HEADER_CLASS", $this->getHeaderClass()
318 ? $this->getHeaderClass() :
"il_" . $or_short .
"AccordionHead");
319 $tpl->setVariable(
"CONTENT_CLASS", $this->getContentClass()
320 ? $this->getContentClass() :
"il_" . $or_short .
"AccordionContent");
322 if ($this->getBehaviour() != self::FORCE_ALL_OPEN) {
323 $tpl->setVariable(
"HIDE_CONTENT_CLASS",
"ilAccHideContent");
326 $tpl->setVariable(
"OR_SHORT", $or_short);
328 $tpl->setVariable(
"INNER_CONTAINER_CLASS", $this->getInnerContainerClass()
329 ? $this->getInnerContainerClass() :
"il_" . $or_short .
"AccordionInnerContainer");
333 $tpl->setVariable(
"HEIGHT",
"height:" . $height .
"px;");
336 $tpl->setVariable(
"HHEIGHT",
"height:" . $height .
"px;");
338 $tpl->parseCurrentBlock();
341 $tpl->setVariable(
"CONTAINER_CLASS", $this->getContainerClass()
342 ? $this->getContainerClass() :
"il_" . $or_short .
"AccordionContainer");
344 $options[
"orientation"] = $this->getOrientation();
345 $options[
"int_id"] = $this->
getId();
347 if ($this->getUseSessionStorage() && $this->
getId() !=
"") {
350 $ctab = $stor->getProperty(
355 $ctab_arr = explode(
";", $ctab);
357 foreach ($this->force_open as $fo) {
358 if (!in_array($fo, $ctab_arr)) {
362 $ctab = implode(
";", $ctab_arr);
368 $options[
"initial_opened"] = $ctab;
369 $options[
"save_url"] =
"./ilias.php?baseClass=ilaccordionpropertiesstoragegui&cmd=setOpenedTab" .
370 "&accordion_id=" . $this->
getId() .
"&user_id=" .
$ilUser->getId();
373 $options[
"behaviour"] = $this->getBehaviour();
375 $options[
"toggle_class"] =
'il_HAccordionToggleDef';
376 $options[
"toggle_act_class"] =
'il_HAccordionToggleActiveDef';
377 $options[
"content_class"] =
'il_HAccordionContentDef';
379 $options[
"toggle_class"] =
'il_VAccordionToggleDef';
380 $options[
"toggle_act_class"] =
'il_VAccordionToggleActiveDef';
381 $options[
"content_class"] =
'il_VAccordionContentDef';
386 $options[
"width"] = $width;
388 $options[
"width"] =
null;
391 $tpl->setVariable(
"CWIDTH",
'style="width:' . $width .
'px;"');
394 if ($this->head_class_set) {
395 $options[
"active_head_class"] = $this->getActiveHeaderClass();
398 $options[
"active_head_class"] =
"il_HAccordionHeadActive";
400 $options[
"active_head_class"] =
"il_VAccordionHeadActive";
404 $options[
"height"] =
null;
405 $options[
"id"] =
'accordion_' . $this->
getId() .
'_' . self::$accordion_cnt;
406 $options[
"multi"] = (bool) $this->getAllowMultiOpened();
407 $options[
"show_all_element"] = $this->getShowAllElement();
408 $options[
"hide_all_element"] = $this->getHideAllElement();
410 $tpl->setVariable(
"ACC_ID", $options[
"id"]);
413 $code = $this->getOnloadCode($options);
415 $this->main_tpl->addOnLoadCode($code);
417 $html .=
"<script>$code</script>";
424 return 'il.Accordion.add(' . json_encode($options, JSON_THROW_ON_ERROR) .
');';
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setContentClass(string $a_contentclass)
setContentWidth(?int $a_contentwidth)
setShowAllElement(string $a_val)
setContentHeight(?int $a_contentheight)
setContainerClass(string $a_containerclass)
setActiveHeaderClass(string $a_h_class)
getOnloadCode(array $options)
setUseSessionStorage(bool $a_val)
setOrientation(string $a_orientation)
string $active_headerclass
static string $owl_css_path
addItem(string $a_header, string $a_content, bool $a_force_open=false)
getHTML(bool $async=false)
static addJavaScript(ilGlobalTemplate $main_tpl=null)
Add javascript files that are necessary to run accordion.
setInnerContainerClass(string $a_containerclass)
static string $owl_js_path
static int $accordion_cnt
bool $use_session_storage
setAllowMultiOpened(bool $a_val)
setHideAllElement(string $a_val)
setBehaviour(string $a_val)
Set behaviour "ForceAllOpen" | "FirstOpen" | "AllClosed".
static addCss()
Add required css.
setHeaderClass(string $a_headerclass)
static getLocalJavascriptFiles()
static getLocalCssFiles()
ilGlobalTemplateInterface $main_tpl
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
special template class to simplify handling of ITX/PEAR
special template class to simplify handling of ITX/PEAR
static initConnection(?ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Connection module.
static initjQueryUI(ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery-UI JS-File to the global template (see included_components....
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl