ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 = "./node_modules/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: shib_login.php:26

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 }

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

Referenced by 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 276 of file class.ilAccordionGUI.php.

280 : void {
281 $this->items[] = array("header" => $a_header,
282 "content" => $a_content, "force_open" => $a_force_open);
283
284 if ($a_force_open) {
285 $this->force_open[] = sizeof($this->items);
286 }
287 }

References $items.

◆ 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, ilYuiUtil\initConnection(), and iljQueryUtil\initjQueryUI().

Referenced by ilLMPresentationGUI\addResourceFiles(), ilLMPresentationGUI\glossary(), 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 294 of file class.ilAccordionGUI.php.

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

References 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.

Referenced by ILIAS\UI\Implementation\Component\Table\AbstractTable\getStorageId().

+ Here is the caller graph for this function:

◆ getInnerContainerClass()

ilAccordionGUI::getInnerContainerClass ( )

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

104 : string
105 {
107 }

References $icontainerclass.

◆ getItems()

ilAccordionGUI::getItems ( )

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

289 : array
290 {
291 return $this->items;
292 }

◆ getLocalCssFiles()

static ilAccordionGUI::getLocalCssFiles ( )
static

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

268 : array
269 {
270 return array(
271 "./components/ILIAS/Accordion/css/accordion.css",
272 self::$owl_path . self::$owl_css_path
273 );
274 }

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 $debug = false;
257 if ($debug) {
258 return array(
259 "../components/ILIAS/Accordion/resources/accordion.js"
260 );
261 }
262 return array(
263 "assets/js/accordion.js",
264 "assets/js" . self::$owl_js_path
265 );
266 }

Referenced by ilPCTabs\getJavascriptFiles().

+ Here is the caller graph for this function:

◆ getOnloadCode()

ilAccordionGUI::getOnloadCode ( array  $options)
protected

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

428 : string
429 {
430 return 'il.Accordion.add(' . json_encode($options, JSON_THROW_ON_ERROR) . ');';
431 }

◆ 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 = "./node_modules/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: