45 protected string $id =
"";
47 public static string $owl_path =
"./node_modules/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;
225 if ($main_tpl !=
null) {
235 foreach (self::getLocalJavascriptFiles() as
$f) {
236 $tpl->addJavaScript($f,
true, 3);
249 foreach (self::getLocalCssFiles() as
$f) {
259 "../components/ILIAS/Accordion/resources/accordion.js" 263 "assets/js/accordion.js",
264 "assets/js" . self::$owl_js_path
271 "./components/ILIAS/Accordion/css/accordion.css",
272 self::$owl_path . self::$owl_css_path
279 bool $a_force_open =
false 281 $this->items[] = array(
"header" => $a_header,
282 "content" => $a_content,
"force_open" => $a_force_open);
294 public function getHTML(
bool $async =
false): string
298 self::$accordion_cnt++;
315 $this->addJavascript();
318 $tpl =
new ilTemplate(
"tpl.accordion.html",
true,
true,
"components/ILIAS/Accordion");
319 foreach ($this->
getItems() as $item) {
320 $tpl->setCurrentBlock(
"item");
321 $tpl->setVariable(
"HEADER", $item[
"header"]);
322 $tpl->setVariable(
"CONTENT", $item[
"content"]);
329 $tpl->setVariable(
"HIDE_CONTENT_CLASS",
"ilAccHideContent");
332 $tpl->setVariable(
"OR_SHORT", $or_short);
339 $tpl->setVariable(
"HEIGHT",
"height:" . $height .
"px;");
342 $tpl->setVariable(
"HHEIGHT",
"height:" . $height .
"px;");
344 $tpl->parseCurrentBlock();
351 $options[
"int_id"] = $this->
getId();
356 $ctab = $stor->getProperty(
361 $ctab_arr = explode(
";", $ctab);
363 foreach ($this->force_open as $fo) {
364 if (!in_array($fo, $ctab_arr)) {
368 $ctab = implode(
";", $ctab_arr);
374 $options[
"initial_opened"] = $ctab;
375 $options[
"save_url"] =
"./ilias.php?baseClass=ilaccordionpropertiesstoragegui&cmd=setOpenedTab" .
376 "&accordion_id=" . $this->
getId() .
"&user_id=" . $ilUser->getId();
381 $options[
"toggle_class"] =
'il_HAccordionToggleDef';
382 $options[
"toggle_act_class"] =
'il_HAccordionToggleActiveDef';
383 $options[
"content_class"] =
'il_HAccordionContentDef';
385 $options[
"toggle_class"] =
'il_VAccordionToggleDef';
386 $options[
"toggle_act_class"] =
'il_VAccordionToggleActiveDef';
387 $options[
"content_class"] =
'il_VAccordionContentDef';
392 $options[
"width"] = $width;
394 $options[
"width"] =
null;
397 $tpl->setVariable(
"CWIDTH",
'style="width:' . $width .
'px;"');
400 if ($this->head_class_set) {
404 $options[
"active_head_class"] =
"il_HAccordionHeadActive";
406 $options[
"active_head_class"] =
"il_VAccordionHeadActive";
410 $options[
"height"] =
null;
411 $options[
"id"] =
'accordion_' . $this->
getId() .
'_' . self::$accordion_cnt;
416 $tpl->setVariable(
"ACC_ID", $options[
"id"]);
421 $this->main_tpl->addOnLoadCode($code);
423 $html .=
"<script>$code</script>";
430 return 'il.Accordion.add(' . json_encode($options, JSON_THROW_ON_ERROR) .
');';
static getLocalCssFiles()
getHTML(bool $async=false)
static int $accordion_cnt
static initjQueryUI(?ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery-UI JS-File to the global template (see included_components.txt for included components)
addItem(string $a_header, string $a_content, bool $a_force_open=false)
static addJavaScript(?ilGlobalTemplate $main_tpl=null)
Add javascript files that are necessary to run accordion.
setBehaviour(string $a_val)
Set behaviour "ForceAllOpen" | "FirstOpen" | "AllClosed".
special template class to simplify handling of ITX/PEAR
getOnloadCode(array $options)
static string $owl_css_path
setHideAllElement(string $a_val)
setContentClass(string $a_contentclass)
bool $use_session_storage
static getLocalJavascriptFiles()
setOrientation(string $a_orientation)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
setContentHeight(?int $a_contentheight)
setContainerClass(string $a_containerclass)
static addCss()
Add required css.
ilGlobalTemplateInterface $main_tpl
setShowAllElement(string $a_val)
setContentWidth(?int $a_contentwidth)
setAllowMultiOpened(bool $a_val)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
string $active_headerclass
static string $owl_js_path
setInnerContainerClass(string $a_containerclass)
setUseSessionStorage(bool $a_val)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setHeaderClass(string $a_headerclass)
static initConnection(?ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Connection module.
setActiveHeaderClass(string $a_h_class)