ILIAS  release_8 Revision v8.24
ilAccordionGUI Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilAccordionGUI:

Public Member Functions

 __construct ()
 
 setId (string $a_val)
 
 getId ()
 
 setOrientation (string $a_orientation)
 
 getOrientation ()
 
 setContainerClass (string $a_containerclass)
 
 getContainerClass ()
 
 setInnerContainerClass (string $a_containerclass)
 
 getInnerContainerClass ()
 
 setHeaderClass (string $a_headerclass)
 
 getHeaderClass ()
 
 setActiveHeaderClass (string $a_h_class)
 
 getActiveHeaderClass ()
 
 setContentClass (string $a_contentclass)
 
 getContentClass ()
 
 setContentWidth (?int $a_contentwidth)
 
 getContentWidth ()
 
 setContentHeight (?int $a_contentheight)
 
 getContentHeight ()
 
 setBehaviour (string $a_val)
 Set behaviour "ForceAllOpen" | "FirstOpen" | "AllClosed". More...
 
 getBehaviour ()
 
 setUseSessionStorage (bool $a_val)
 
 getUseSessionStorage ()
 
 setAllowMultiOpened (bool $a_val)
 
 getAllowMultiOpened ()
 
 setShowAllElement (string $a_val)
 
 getShowAllElement ()
 
 setHideAllElement (string $a_val)
 
 getHideAllElement ()
 
 addItem (string $a_header, string $a_content, bool $a_force_open=false)
 
 getItems ()
 
 getHTML (bool $async=false)
 

Static Public Member Functions

static addJavaScript (ilGlobalTemplate $main_tpl=null)
 Add javascript files that are necessary to run accordion. More...
 
static addCss ()
 Add required css. More...
 
static getLocalJavascriptFiles ()
 
static getLocalCssFiles ()
 

Data Fields

const VERTICAL = "vertical"
 
const HORIZONTAL = "horizontal"
 
const FORCE_ALL_OPEN = "ForceAllOpen"
 
const FIRST_OPEN = "FirstOpen"
 
const ALL_CLOSED = "AllClosed"
 

Static Public Attributes

static string $owl_path = "./libs/bower/bower_components/owl.carousel/dist"
 
static string $owl_js_path = "/owl.carousel.js"
 
static string $owl_css_path = "/assets/owl.carousel.css"
 

Protected Member Functions

 getOnloadCode (array $options)
 

Protected Attributes

string $orientation
 
ilObjUser $user
 
array $items = array()
 
array $force_open = array()
 
bool $use_session_storage = false
 
bool $allow_multi_opened = false
 
string $show_all_element = ""
 
string $hide_all_element = ""
 
int $contentwidth = null
 
int $contentheight = null
 
string $headerclass = ""
 
string $contentclass = ""
 
string $icontainerclass = ""
 
string $containerclass = ""
 
string $id = ""
 
bool $head_class_set = false
 
ilGlobalTemplateInterface $main_tpl
 
string $active_headerclass = ""
 
string $behaviour = self::FIRST_OPEN
 

Static Protected Attributes

static int $accordion_cnt = 0
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Accordion user interface class

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 23 of file class.ilAccordionGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilAccordionGUI::__construct ( )

Definition at line 54 of file class.ilAccordionGUI.php.

55 {
56 global $DIC;
57
58 $this->main_tpl = $DIC->ui()->mainTemplate();
59
60 $this->user = $DIC->user();
62 }
setOrientation(string $a_orientation)
global $DIC
Definition: feed.php:28

References $DIC, setOrientation(), ILIAS\Repository\user(), and VERTICAL.

+ Here is the call graph for this function:

Member Function Documentation

◆ addCss()

static ilAccordionGUI::addCss ( )
static

Add required css.

Definition at line 243 of file class.ilAccordionGUI.php.

243 : void
244 {
245 global $DIC;
246
247 $tpl = $DIC["tpl"];
248
249 foreach (self::getLocalCssFiles() as $f) {
250 $tpl->addCss($f);
251 }
252 }
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41

References $DIC, Vendor\Package\$f, and $tpl.

Referenced by ilPCIIMTriggerEditorGUI\__construct(), ilTableTemplatesTableGUI\__construct(), ilLMPresentationGUI\addResourceFiles(), ilLMPresentationGUI\glossary(), and ilPageObjectGUI\showPage().

+ Here is the caller graph for this function:

◆ addItem()

ilAccordionGUI::addItem ( string  $a_header,
string  $a_content,
bool  $a_force_open = false 
)

Definition at line 270 of file class.ilAccordionGUI.php.

274 : void {
275 $this->items[] = array("header" => $a_header,
276 "content" => $a_content, "force_open" => $a_force_open);
277
278 if ($a_force_open) {
279 $this->force_open[] = sizeof($this->items);
280 }
281 }

References $items.

Referenced by ilObjFileGUI\addUIFormToAccordion().

+ Here is the caller graph for this function:

◆ addJavaScript()

static ilAccordionGUI::addJavaScript ( ilGlobalTemplate  $main_tpl = null)
static

Add javascript files that are necessary to run accordion.

Definition at line 221 of file class.ilAccordionGUI.php.

221 : void
222 {
223 global $DIC;
224
225 if ($main_tpl != null) {
226 $tpl = $main_tpl;
227 } else {
228 $tpl = $DIC["tpl"];
229 }
230
232
234
235 foreach (self::getLocalJavascriptFiles() as $f) {
236 $tpl->addJavaScript($f, true, 3);
237 }
238 }
ilGlobalTemplateInterface $main_tpl
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....

References $DIC, Vendor\Package\$f, $main_tpl, $tpl, ilYuiUtil\initConnection(), and iljQueryUtil\initjQueryUI().

Referenced by ilPCIIMTriggerEditorGUI\__construct(), ilLMPresentationGUI\addResourceFiles(), ilLMPresentationGUI\glossary(), ilObjStudyProgrammeTreeGUI\initAsyncUIElements(), and ilPageObjectGUI\showPage().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getActiveHeaderClass()

ilAccordionGUI::getActiveHeaderClass ( )

Definition at line 124 of file class.ilAccordionGUI.php.

124 : string
125 {
127 }

References $active_headerclass.

◆ getAllowMultiOpened()

ilAccordionGUI::getAllowMultiOpened ( )

Definition at line 187 of file class.ilAccordionGUI.php.

187 : bool
188 {
190 }

References $allow_multi_opened.

◆ getBehaviour()

ilAccordionGUI::getBehaviour ( )

Definition at line 167 of file class.ilAccordionGUI.php.

167 : string
168 {
169 return $this->behaviour;
170 }

References $behaviour.

◆ getContainerClass()

ilAccordionGUI::getContainerClass ( )

Definition at line 94 of file class.ilAccordionGUI.php.

94 : string
95 {
97 }

References $containerclass.

◆ getContentClass()

ilAccordionGUI::getContentClass ( )

Definition at line 134 of file class.ilAccordionGUI.php.

134 : string
135 {
136 return $this->contentclass;
137 }

References $contentclass.

◆ getContentHeight()

ilAccordionGUI::getContentHeight ( )

Definition at line 154 of file class.ilAccordionGUI.php.

154 : ?int
155 {
157 }

References $contentheight.

◆ getContentWidth()

ilAccordionGUI::getContentWidth ( )

Definition at line 144 of file class.ilAccordionGUI.php.

144 : ?int
145 {
146 return $this->contentwidth;
147 }

References $contentwidth.

◆ getHeaderClass()

ilAccordionGUI::getHeaderClass ( )

Definition at line 114 of file class.ilAccordionGUI.php.

114 : string
115 {
116 return $this->headerclass;
117 }

References $headerclass.

◆ getHideAllElement()

ilAccordionGUI::getHideAllElement ( )

Definition at line 213 of file class.ilAccordionGUI.php.

213 : string
214 {
216 }

References $hide_all_element.

◆ getHTML()

ilAccordionGUI::getHTML ( bool  $async = false)

Definition at line 288 of file class.ilAccordionGUI.php.

288 : string
289 {
291
292 self::$accordion_cnt++;
293
294 $or_short = ($this->getOrientation() == ilAccordionGUI::HORIZONTAL)
295 ? "H"
296 : "V";
297
298 $width = (int) $this->getContentWidth();
299 $height = (int) $this->getContentHeight();
301 if ($width == 0) {
302 $width = 200;
303 }
304 if ($height == 0) {
305 $height = 100;
306 }
307 }
308
309 $this->addJavascript();
310 $this->addCss();
311
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");
321
322 if ($this->getBehaviour() != self::FORCE_ALL_OPEN) {
323 $tpl->setVariable("HIDE_CONTENT_CLASS", "ilAccHideContent");
324 }
325
326 $tpl->setVariable("OR_SHORT", $or_short);
327
328 $tpl->setVariable("INNER_CONTAINER_CLASS", $this->getInnerContainerClass()
329 ? $this->getInnerContainerClass() : "il_" . $or_short . "AccordionInnerContainer");
330
331
332 if ($height > 0) {
333 $tpl->setVariable("HEIGHT", "height:" . $height . "px;");
334 }
335 if ($height > 0 && $this->getOrientation() == ilAccordionGUI::HORIZONTAL) {
336 $tpl->setVariable("HHEIGHT", "height:" . $height . "px;");
337 }
338 $tpl->parseCurrentBlock();
339 }
340
341 $tpl->setVariable("CONTAINER_CLASS", $this->getContainerClass()
342 ? $this->getContainerClass() : "il_" . $or_short . "AccordionContainer");
343
344 $options["orientation"] = $this->getOrientation();
345 $options["int_id"] = $this->getId();
346
347 if ($this->getUseSessionStorage() && $this->getId() != "") {
349
350 $ctab = $stor->getProperty(
351 $this->getId(),
352 $ilUser->getId(),
353 "opened"
354 );
355 $ctab_arr = explode(";", $ctab);
356
357 foreach ($this->force_open as $fo) {
358 if (!in_array($fo, $ctab_arr)) {
359 $ctab_arr[] = $fo;
360 }
361 }
362 $ctab = implode(";", $ctab_arr);
363
364 if ($ctab == "0") {
365 $ctab = "";
366 }
367
368 $options["initial_opened"] = $ctab;
369 $options["save_url"] = "./ilias.php?baseClass=ilaccordionpropertiesstoragegui&cmd=setOpenedTab" .
370 "&accordion_id=" . $this->getId() . "&user_id=" . $ilUser->getId();
371 }
372
373 $options["behaviour"] = $this->getBehaviour();
375 $options["toggle_class"] = 'il_HAccordionToggleDef';
376 $options["toggle_act_class"] = 'il_HAccordionToggleActiveDef';
377 $options["content_class"] = 'il_HAccordionContentDef';
378 } else {
379 $options["toggle_class"] = 'il_VAccordionToggleDef';
380 $options["toggle_act_class"] = 'il_VAccordionToggleActiveDef';
381 $options["content_class"] = 'il_VAccordionContentDef';
382 }
383
384
385 if ($width > 0) {
386 $options["width"] = $width;
387 } else {
388 $options["width"] = null;
389 }
390 if ($width > 0 && $this->getOrientation() == ilAccordionGUI::VERTICAL) {
391 $tpl->setVariable("CWIDTH", 'style="width:' . $width . 'px;"');
392 }
393
394 if ($this->head_class_set) {
395 $options["active_head_class"] = $this->getActiveHeaderClass();
396 } else {
398 $options["active_head_class"] = "il_HAccordionHeadActive";
399 } else {
400 $options["active_head_class"] = "il_VAccordionHeadActive";
401 }
402 }
403
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();
409
410 $tpl->setVariable("ACC_ID", $options["id"]);
411
412 $html = $tpl->get();
413 $code = $this->getOnloadCode($options);
414 if (!$async) {
415 $this->main_tpl->addOnLoadCode($code);
416 } else {
417 $html .= "<script>$code</script>";
418 }
419 return $html;
420 }
getOnloadCode(array $options)
static addCss()
Add required css.
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
$ilUser
Definition: imgupload.php:34

References $ilUser, $tpl, ILIAS\Survey\Mode\getId(), HORIZONTAL, ILIAS\Repository\int(), and VERTICAL.

+ Here is the call graph for this function:

◆ getId()

ilAccordionGUI::getId ( )

Definition at line 69 of file class.ilAccordionGUI.php.

69 : string
70 {
71 return $this->id;
72 }

References $id.

◆ getInnerContainerClass()

ilAccordionGUI::getInnerContainerClass ( )

Definition at line 104 of file class.ilAccordionGUI.php.

104 : string
105 {
107 }

References $icontainerclass.

◆ getItems()

ilAccordionGUI::getItems ( )

Definition at line 283 of file class.ilAccordionGUI.php.

283 : array
284 {
285 return $this->items;
286 }

◆ getLocalCssFiles()

static ilAccordionGUI::getLocalCssFiles ( )
static

Definition at line 262 of file class.ilAccordionGUI.php.

262 : array
263 {
264 return array(
265 "./Services/Accordion/css/accordion.css",
266 self::$owl_path . self::$owl_css_path
267 );
268 }

Referenced by ilPCTabs\getCssFiles().

+ Here is the caller graph for this function:

◆ getLocalJavascriptFiles()

static ilAccordionGUI::getLocalJavascriptFiles ( )
static

Definition at line 254 of file class.ilAccordionGUI.php.

254 : array
255 {
256 return array(
257 "./Services/Accordion/js/accordion.js",
258 self::$owl_path . self::$owl_js_path
259 );
260 }

Referenced by ilPCTabs\getJavascriptFiles().

+ Here is the caller graph for this function:

◆ getOnloadCode()

ilAccordionGUI::getOnloadCode ( array  $options)
protected

Definition at line 422 of file class.ilAccordionGUI.php.

422 : string
423 {
424 return 'il.Accordion.add(' . json_encode($options, JSON_THROW_ON_ERROR) . ');';
425 }

◆ getOrientation()

ilAccordionGUI::getOrientation ( )

Definition at line 84 of file class.ilAccordionGUI.php.

84 : string
85 {
86 return $this->orientation;
87 }

References $orientation.

◆ getShowAllElement()

ilAccordionGUI::getShowAllElement ( )

Definition at line 200 of file class.ilAccordionGUI.php.

200 : string
201 {
203 }

References $show_all_element.

◆ getUseSessionStorage()

ilAccordionGUI::getUseSessionStorage ( )

Definition at line 177 of file class.ilAccordionGUI.php.

177 : bool
178 {
180 }

References $use_session_storage.

◆ setActiveHeaderClass()

ilAccordionGUI::setActiveHeaderClass ( string  $a_h_class)

Definition at line 119 of file class.ilAccordionGUI.php.

119 : void
120 {
121 $this->active_headerclass = $a_h_class;
122 }

◆ setAllowMultiOpened()

ilAccordionGUI::setAllowMultiOpened ( bool  $a_val)

Definition at line 182 of file class.ilAccordionGUI.php.

182 : void
183 {
184 $this->allow_multi_opened = $a_val;
185 }

◆ setBehaviour()

ilAccordionGUI::setBehaviour ( string  $a_val)

Set behaviour "ForceAllOpen" | "FirstOpen" | "AllClosed".

Definition at line 162 of file class.ilAccordionGUI.php.

162 : void
163 {
164 $this->behaviour = $a_val;
165 }

◆ setContainerClass()

ilAccordionGUI::setContainerClass ( string  $a_containerclass)

Definition at line 89 of file class.ilAccordionGUI.php.

89 : void
90 {
91 $this->containerclass = $a_containerclass;
92 }

◆ setContentClass()

ilAccordionGUI::setContentClass ( string  $a_contentclass)

Definition at line 129 of file class.ilAccordionGUI.php.

129 : void
130 {
131 $this->contentclass = $a_contentclass;
132 }

◆ setContentHeight()

ilAccordionGUI::setContentHeight ( ?int  $a_contentheight)

Definition at line 149 of file class.ilAccordionGUI.php.

149 : void
150 {
151 $this->contentheight = $a_contentheight;
152 }

◆ setContentWidth()

ilAccordionGUI::setContentWidth ( ?int  $a_contentwidth)

Definition at line 139 of file class.ilAccordionGUI.php.

139 : void
140 {
141 $this->contentwidth = $a_contentwidth;
142 }

◆ setHeaderClass()

ilAccordionGUI::setHeaderClass ( string  $a_headerclass)

Definition at line 109 of file class.ilAccordionGUI.php.

109 : void
110 {
111 $this->headerclass = $a_headerclass;
112 }

◆ setHideAllElement()

ilAccordionGUI::setHideAllElement ( string  $a_val)
Parameters
string$a_valID of hide all html element

Definition at line 208 of file class.ilAccordionGUI.php.

208 : void
209 {
210 $this->hide_all_element = $a_val;
211 }

◆ setId()

ilAccordionGUI::setId ( string  $a_val)

Definition at line 64 of file class.ilAccordionGUI.php.

64 : void
65 {
66 $this->id = $a_val;
67 }

◆ setInnerContainerClass()

ilAccordionGUI::setInnerContainerClass ( string  $a_containerclass)

Definition at line 99 of file class.ilAccordionGUI.php.

99 : void
100 {
101 $this->icontainerclass = $a_containerclass;
102 }

◆ setOrientation()

ilAccordionGUI::setOrientation ( string  $a_orientation)

Definition at line 74 of file class.ilAccordionGUI.php.

74 : void
75 {
76 if (in_array(
77 $a_orientation,
79 )) {
80 $this->orientation = $a_orientation;
81 }
82 }

References HORIZONTAL, and VERTICAL.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setShowAllElement()

ilAccordionGUI::setShowAllElement ( string  $a_val)
Parameters
string$a_valID of show all html element

Definition at line 195 of file class.ilAccordionGUI.php.

195 : void
196 {
197 $this->show_all_element = $a_val;
198 }

◆ setUseSessionStorage()

ilAccordionGUI::setUseSessionStorage ( bool  $a_val)

Definition at line 172 of file class.ilAccordionGUI.php.

172 : void
173 {
174 $this->use_session_storage = $a_val;
175 }

Field Documentation

◆ $accordion_cnt

int ilAccordionGUI::$accordion_cnt = 0
staticprotected

Definition at line 34 of file class.ilAccordionGUI.php.

◆ $active_headerclass

string ilAccordionGUI::$active_headerclass = ""
protected

Definition at line 51 of file class.ilAccordionGUI.php.

Referenced by getActiveHeaderClass().

◆ $allow_multi_opened

bool ilAccordionGUI::$allow_multi_opened = false
protected

Definition at line 36 of file class.ilAccordionGUI.php.

Referenced by getAllowMultiOpened().

◆ $behaviour

string ilAccordionGUI::$behaviour = self::FIRST_OPEN
protected

Definition at line 52 of file class.ilAccordionGUI.php.

Referenced by getBehaviour().

◆ $containerclass

string ilAccordionGUI::$containerclass = ""
protected

Definition at line 44 of file class.ilAccordionGUI.php.

Referenced by getContainerClass().

◆ $contentclass

string ilAccordionGUI::$contentclass = ""
protected

Definition at line 42 of file class.ilAccordionGUI.php.

Referenced by getContentClass().

◆ $contentheight

int ilAccordionGUI::$contentheight = null
protected

Definition at line 40 of file class.ilAccordionGUI.php.

Referenced by getContentHeight().

◆ $contentwidth

int ilAccordionGUI::$contentwidth = null
protected

Definition at line 39 of file class.ilAccordionGUI.php.

Referenced by getContentWidth().

◆ $force_open

array ilAccordionGUI::$force_open = array()
protected

Definition at line 33 of file class.ilAccordionGUI.php.

◆ $head_class_set

bool ilAccordionGUI::$head_class_set = false
protected

Definition at line 46 of file class.ilAccordionGUI.php.

◆ $headerclass

string ilAccordionGUI::$headerclass = ""
protected

Definition at line 41 of file class.ilAccordionGUI.php.

Referenced by getHeaderClass().

◆ $hide_all_element

string ilAccordionGUI::$hide_all_element = ""
protected

Definition at line 38 of file class.ilAccordionGUI.php.

Referenced by getHideAllElement().

◆ $icontainerclass

string ilAccordionGUI::$icontainerclass = ""
protected

Definition at line 43 of file class.ilAccordionGUI.php.

Referenced by getInnerContainerClass().

◆ $id

string ilAccordionGUI::$id = ""
protected

Definition at line 45 of file class.ilAccordionGUI.php.

Referenced by getId().

◆ $items

array ilAccordionGUI::$items = array()
protected

Definition at line 32 of file class.ilAccordionGUI.php.

Referenced by addItem().

◆ $main_tpl

ilGlobalTemplateInterface ilAccordionGUI::$main_tpl
protected

Definition at line 50 of file class.ilAccordionGUI.php.

Referenced by addJavaScript().

◆ $orientation

string ilAccordionGUI::$orientation
protected

Definition at line 30 of file class.ilAccordionGUI.php.

Referenced by getOrientation().

◆ $owl_css_path

string ilAccordionGUI::$owl_css_path = "/assets/owl.carousel.css"
static

Definition at line 49 of file class.ilAccordionGUI.php.

◆ $owl_js_path

string ilAccordionGUI::$owl_js_path = "/owl.carousel.js"
static

Definition at line 48 of file class.ilAccordionGUI.php.

◆ $owl_path

string ilAccordionGUI::$owl_path = "./libs/bower/bower_components/owl.carousel/dist"
static

Definition at line 47 of file class.ilAccordionGUI.php.

◆ $show_all_element

string ilAccordionGUI::$show_all_element = ""
protected

Definition at line 37 of file class.ilAccordionGUI.php.

Referenced by getShowAllElement().

◆ $use_session_storage

bool ilAccordionGUI::$use_session_storage = false
protected

Definition at line 35 of file class.ilAccordionGUI.php.

Referenced by getUseSessionStorage().

◆ $user

ilObjUser ilAccordionGUI::$user
protected

Definition at line 31 of file class.ilAccordionGUI.php.

◆ ALL_CLOSED

const ilAccordionGUI::ALL_CLOSED = "AllClosed"

◆ FIRST_OPEN

◆ FORCE_ALL_OPEN

const ilAccordionGUI::FORCE_ALL_OPEN = "ForceAllOpen"

◆ HORIZONTAL

const ilAccordionGUI::HORIZONTAL = "horizontal"

Definition at line 26 of file class.ilAccordionGUI.php.

Referenced by getHTML(), and setOrientation().

◆ VERTICAL

const ilAccordionGUI::VERTICAL = "vertical"

Definition at line 25 of file class.ilAccordionGUI.php.

Referenced by __construct(), getHTML(), and setOrientation().


The documentation for this class was generated from the following file: