ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
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"
 

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 51 of file class.ilAccordionGUI.php.

52 {
53 global $DIC;
54
55 $this->main_tpl = $DIC->ui()->mainTemplate();
56
57 $this->user = $DIC->user();
59 }
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 236 of file class.ilAccordionGUI.php.

236 : void
237 {
238 global $DIC;
239
240 $tpl = $DIC["tpl"];
241
242 foreach (self::getLocalCssFiles() as $f) {
243 $tpl->addCss($f);
244 }
245 }

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 267 of file class.ilAccordionGUI.php.

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

References $items.

◆ addJavaScript()

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

Add javascript files that are necessary to run accordion.

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

218 : void
219 {
220 global $DIC;
221
222 if ($main_tpl != null) {
223 $tpl = $main_tpl;
224 } else {
225 $tpl = $DIC["tpl"];
226 }
227
228 foreach (self::getLocalJavascriptFiles() as $f) {
229 $tpl->addJavaScript($f, true, 3);
230 }
231 }
ilGlobalTemplateInterface $main_tpl

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

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

+ Here is the caller graph for this function:

◆ getActiveHeaderClass()

ilAccordionGUI::getActiveHeaderClass ( )

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

121 : string
122 {
124 }

References $active_headerclass.

◆ getAllowMultiOpened()

ilAccordionGUI::getAllowMultiOpened ( )

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

184 : bool
185 {
187 }

References $allow_multi_opened.

◆ getBehaviour()

ilAccordionGUI::getBehaviour ( )

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

164 : string
165 {
166 return $this->behaviour;
167 }

References $behaviour.

◆ getContainerClass()

ilAccordionGUI::getContainerClass ( )

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

91 : string
92 {
94 }

References $containerclass.

◆ getContentClass()

ilAccordionGUI::getContentClass ( )

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

131 : string
132 {
133 return $this->contentclass;
134 }

References $contentclass.

◆ getContentHeight()

ilAccordionGUI::getContentHeight ( )

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

151 : ?int
152 {
154 }

References $contentheight.

◆ getContentWidth()

ilAccordionGUI::getContentWidth ( )

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

141 : ?int
142 {
143 return $this->contentwidth;
144 }

References $contentwidth.

◆ getHeaderClass()

ilAccordionGUI::getHeaderClass ( )

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

111 : string
112 {
113 return $this->headerclass;
114 }

References $headerclass.

◆ getHideAllElement()

ilAccordionGUI::getHideAllElement ( )

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

210 : string
211 {
213 }

References $hide_all_element.

◆ getHTML()

ilAccordionGUI::getHTML ( bool  $async = false)

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

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

+ Here is the call graph for this function:

◆ getId()

ilAccordionGUI::getId ( )

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

66 : string
67 {
68 return $this->id;
69 }

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 101 of file class.ilAccordionGUI.php.

101 : string
102 {
104 }

References $icontainerclass.

◆ getItems()

ilAccordionGUI::getItems ( )

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

280 : array
281 {
282 return $this->items;
283 }

◆ getLocalCssFiles()

static ilAccordionGUI::getLocalCssFiles ( )
static

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

260 : array
261 {
262 return array(
263 "./components/ILIAS/Accordion/css/accordion.css"
264 );
265 }

Referenced by ilPCTabs\getCssFiles().

+ Here is the caller graph for this function:

◆ getLocalJavascriptFiles()

static ilAccordionGUI::getLocalJavascriptFiles ( )
static

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

247 : array
248 {
249 $debug = false;
250 if ($debug) {
251 return array(
252 "../components/ILIAS/Accordion/resources/accordion.js"
253 );
254 }
255 return array(
256 "assets/js/accordion.js"
257 );
258 }

Referenced by ilPCTabs\getJavascriptFiles().

+ Here is the caller graph for this function:

◆ getOnloadCode()

ilAccordionGUI::getOnloadCode ( array  $options)
protected

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

419 : string
420 {
421 return 'il.Accordion.add(' . json_encode($options, JSON_THROW_ON_ERROR) . ');';
422 }

References ILIAS\UI\Implementation\Component\Input\Field\$options.

◆ getOrientation()

ilAccordionGUI::getOrientation ( )

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

81 : string
82 {
83 return $this->orientation;
84 }

References $orientation.

◆ getShowAllElement()

ilAccordionGUI::getShowAllElement ( )

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

197 : string
198 {
200 }

References $show_all_element.

◆ getUseSessionStorage()

ilAccordionGUI::getUseSessionStorage ( )

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

174 : bool
175 {
177 }

References $use_session_storage.

◆ setActiveHeaderClass()

ilAccordionGUI::setActiveHeaderClass ( string  $a_h_class)

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

116 : void
117 {
118 $this->active_headerclass = $a_h_class;
119 }

◆ setAllowMultiOpened()

ilAccordionGUI::setAllowMultiOpened ( bool  $a_val)

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

179 : void
180 {
181 $this->allow_multi_opened = $a_val;
182 }

◆ setBehaviour()

ilAccordionGUI::setBehaviour ( string  $a_val)

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

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

159 : void
160 {
161 $this->behaviour = $a_val;
162 }

◆ setContainerClass()

ilAccordionGUI::setContainerClass ( string  $a_containerclass)

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

86 : void
87 {
88 $this->containerclass = $a_containerclass;
89 }

◆ setContentClass()

ilAccordionGUI::setContentClass ( string  $a_contentclass)

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

126 : void
127 {
128 $this->contentclass = $a_contentclass;
129 }

◆ setContentHeight()

ilAccordionGUI::setContentHeight ( ?int  $a_contentheight)

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

146 : void
147 {
148 $this->contentheight = $a_contentheight;
149 }

◆ setContentWidth()

ilAccordionGUI::setContentWidth ( ?int  $a_contentwidth)

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

136 : void
137 {
138 $this->contentwidth = $a_contentwidth;
139 }

◆ setHeaderClass()

ilAccordionGUI::setHeaderClass ( string  $a_headerclass)

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

106 : void
107 {
108 $this->headerclass = $a_headerclass;
109 }

◆ setHideAllElement()

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

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

205 : void
206 {
207 $this->hide_all_element = $a_val;
208 }

◆ setId()

ilAccordionGUI::setId ( string  $a_val)

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

61 : void
62 {
63 $this->id = $a_val;
64 }

◆ setInnerContainerClass()

ilAccordionGUI::setInnerContainerClass ( string  $a_containerclass)

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

96 : void
97 {
98 $this->icontainerclass = $a_containerclass;
99 }

◆ setOrientation()

ilAccordionGUI::setOrientation ( string  $a_orientation)

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

71 : void
72 {
73 if (in_array(
74 $a_orientation,
76 )) {
77 $this->orientation = $a_orientation;
78 }
79 }

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 192 of file class.ilAccordionGUI.php.

192 : void
193 {
194 $this->show_all_element = $a_val;
195 }

◆ setUseSessionStorage()

ilAccordionGUI::setUseSessionStorage ( bool  $a_val)

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

169 : void
170 {
171 $this->use_session_storage = $a_val;
172 }

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 48 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 49 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 47 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().

◆ $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: