ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
ilAccordionGUI Class Reference

Accordion user interface class. More...

+ Collaboration diagram for ilAccordionGUI:

Public Member Functions

 __construct ()
 Constructor. More...
 
 setId ($a_val)
 Set id. More...
 
 getId ()
 Get id. More...
 
 setOrientation ($a_orientation)
 Set Orientation. More...
 
 getOrientation ()
 Get Orientation. More...
 
 setContainerClass ($a_containerclass)
 Set Container CSS Class. More...
 
 getContainerClass ()
 Get Container CSS Class. More...
 
 setInnerContainerClass ($a_containerclass)
 Set inner Container CSS Class. More...
 
 getInnerContainerClass ()
 Get inner Container CSS Class. More...
 
 setHeaderClass ($a_headerclass)
 Set Header CSS Class. More...
 
 getHeaderClass ()
 Get Header CSS Class. More...
 
 setActiveHeaderClass ($a_h_class)
 Set active header class. More...
 
 getActiveHeaderClass ()
 Get active Header CSS Class. More...
 
 setContentClass ($a_contentclass)
 Set Content CSS Class. More...
 
 getContentClass ()
 Get Content CSS Class. More...
 
 setContentWidth ($a_contentwidth)
 Set ContentWidth. More...
 
 getContentWidth ()
 Get ContentWidth. More...
 
 setContentHeight ($a_contentheight)
 Set ContentHeight. More...
 
 getContentHeight ()
 Get ContentHeight. More...
 
 setBehaviour ($a_val)
 Set behaviour "ForceAllOpen" | "FirstOpen" | "AllClosed". More...
 
 getBehaviour ()
 Get behaviour. More...
 
 setUseSessionStorage ($a_val)
 Set use session storage. More...
 
 getUseSessionStorage ()
 Get use session storage. More...
 
 setAllowMultiOpened ($a_val)
 Set allow multi opened. More...
 
 getAllowMultiOpened ()
 Get allow multi opened. More...
 
 setShowAllElement ($a_val)
 Set show all element. More...
 
 getShowAllElement ()
 Get show all element. More...
 
 setHideAllElement ($a_val)
 Set hide all element. More...
 
 getHideAllElement ()
 Get hide all element. More...
 
 addItem ($a_header, $a_content, $a_force_open=false)
 Add item. More...
 
 getItems ()
 Get all items. More...
 
 getHTML ()
 Get accordion html. More...
 

Static Public Member Functions

static addJavaScript ()
 Add javascript files that are necessary to run accordion. More...
 
static addCss ()
 Add required css. More...
 

Data Fields

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

Protected Attributes

 $items = array()
 
 $force_open = array()
 
 $use_session_storage = false
 
 $allow_multi_opened = false
 
 $show_all_element = null
 
 $hide_all_element = null
 

Static Protected Attributes

static $accordion_cnt = 0
 

Detailed Description

Accordion user interface class.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id:$

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

Constructor & Destructor Documentation

◆ __construct()

ilAccordionGUI::__construct ( )

Constructor.

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

References setOrientation(), and VERTICAL.

31  {
33  }
setOrientation($a_orientation)
Set Orientation.
+ Here is the call graph for this function:

Member Function Documentation

◆ addCss()

static ilAccordionGUI::addCss ( )
static

Add required css.

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

References $tpl.

Referenced by ilTableTemplatesTableGUI\__construct(), ilObjStyleSheetGUI\_getTemplatePreview(), getHTML(), ilPCIIMTriggerEditorGUI\getImageMapTableHTML(), ilPCTabsGUI\initForm(), ilLMPresentationGUI\layout(), and ilPageObjectGUI\showPage().

339  {
340  global $tpl;
341 
342  $tpl->addCss("./Services/Accordion/css/accordion.css");
343  }
global $tpl
Definition: ilias.php:8
+ Here is the caller graph for this function:

◆ addItem()

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

Add item.

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

References $items.

349  {
350  $this->items[] = array("header" => $a_header,
351  "content" => $a_content, "force_open" => $a_force_open);
352 
353  if($a_force_open)
354  {
355  $this->force_open[] = sizeof($this->items);
356  }
357  }

◆ addJavaScript()

static ilAccordionGUI::addJavaScript ( )
static

Add javascript files that are necessary to run accordion.

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

References $tpl, ilYuiUtil\initConnection(), and iljQueryUtil\initjQueryUI().

Referenced by ilPCIIMTriggerEditorGUI\getImageMapTableHTML(), ilLMPresentationGUI\layout(), and ilPageObjectGUI\showPage().

323  {
324  global $tpl;
325 
326 
327  include_once("./Services/YUI/classes/class.ilYuiUtil.php");
329 
330  include_once("./Services/jQuery/classes/class.iljQueryUtil.php");
332  $tpl->addJavaScript("./Services/Accordion/js/accordion.js", true, 3);
333  }
static initjQueryUI()
Init jQuery UI (see included_components.txt for included components)
static initConnection()
Init YUI Connection module.
global $tpl
Definition: ilias.php:8
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getActiveHeaderClass()

ilAccordionGUI::getActiveHeaderClass ( )

Get active Header CSS Class.

Returns
string Active header CSS Class

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

Referenced by getHTML().

155  {
156  return $this->active_headerclass;
157  }
+ Here is the caller graph for this function:

◆ getAllowMultiOpened()

ilAccordionGUI::getAllowMultiOpened ( )

Get allow multi opened.

Returns
bool allow multiple accordions being opened

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

References $allow_multi_opened.

Referenced by getHTML().

275  {
277  }
+ Here is the caller graph for this function:

◆ getBehaviour()

ilAccordionGUI::getBehaviour ( )

Get behaviour.

Returns

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

Referenced by getHTML().

235  {
236  return $this->behaviour;
237  }
+ Here is the caller graph for this function:

◆ getContainerClass()

ilAccordionGUI::getContainerClass ( )

Get Container CSS Class.

Returns
string Container CSS Class

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

Referenced by getHTML().

95  {
96  return $this->containerclass;
97  }
+ Here is the caller graph for this function:

◆ getContentClass()

ilAccordionGUI::getContentClass ( )

Get Content CSS Class.

Returns
string Content CSS Class

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

Referenced by getHTML().

175  {
176  return $this->contentclass;
177  }
+ Here is the caller graph for this function:

◆ getContentHeight()

ilAccordionGUI::getContentHeight ( )

Get ContentHeight.

Returns
integer ContentHeight

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

Referenced by getHTML().

215  {
216  return $this->contentheight;
217  }
+ Here is the caller graph for this function:

◆ getContentWidth()

ilAccordionGUI::getContentWidth ( )

Get ContentWidth.

Returns
integer ContentWidth

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

Referenced by getHTML().

195  {
196  return $this->contentwidth;
197  }
+ Here is the caller graph for this function:

◆ getHeaderClass()

ilAccordionGUI::getHeaderClass ( )

Get Header CSS Class.

Returns
string Header CSS Class

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

Referenced by getHTML().

135  {
136  return $this->headerclass;
137  }
+ Here is the caller graph for this function:

◆ getHideAllElement()

ilAccordionGUI::getHideAllElement ( )

Get hide all element.

Returns
string ID of hide all html element

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

References $hide_all_element.

Referenced by getHTML().

315  {
317  }
+ Here is the caller graph for this function:

◆ getHTML()

ilAccordionGUI::getHTML ( )

Get accordion html.

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

References $ilUser, $options, $tpl, addCss(), ilJsonUtil\encode(), getActiveHeaderClass(), getAllowMultiOpened(), getBehaviour(), getContainerClass(), getContentClass(), getContentHeight(), getContentWidth(), getHeaderClass(), getHideAllElement(), getId(), getInnerContainerClass(), getItems(), getOrientation(), getShowAllElement(), getUseSessionStorage(), HORIZONTAL, and VERTICAL.

371  {
372  global $ilUser;
373 
374  self::$accordion_cnt++;
375 
376  $or_short = ($this->getOrientation() == ilAccordionGUI::HORIZONTAL)
377  ? "H"
378  : "V";
379 
380  $width = (int) $this->getContentWidth();
381  $height = (int) $this->getContentHeight();
383  {
384  if ($width == 0)
385  {
386  $width = 200;
387  }
388  if ($height == 0)
389  {
390  $height = 100;
391  }
392  }
393 
394  $this->addJavascript();
395  $this->addCss();
396 
397  $tpl = new ilTemplate("tpl.accordion.html", true, true, "Services/Accordion");
398  foreach ($this->getItems() as $item)
399  {
400  $tpl->setCurrentBlock("item");
401  $tpl->setVariable("HEADER", $item["header"]);
402  $tpl->setVariable("CONTENT", $item["content"]);
403  $tpl->setVariable("HEADER_CLASS", $this->getHeaderClass()
404  ? $this->getHeaderClass() : "il_".$or_short."AccordionHead");
405  $tpl->setVariable("CONTENT_CLASS", $this->getContentClass()
406  ? $this->getContentClass() : "il_".$or_short."AccordionContent");
407 
408  if ($this->getBehaviour() != self::FORCE_ALL_OPEN)
409  {
410  $tpl->setVariable("HIDE_CONTENT_CLASS", "ilAccHideContent");
411  }
412 
413  $tpl->setVariable("OR_SHORT", $or_short);
414 
415  $tpl->setVariable("INNER_CONTAINER_CLASS", $this->getInnerContainerClass()
416  ? $this->getInnerContainerClass() : "il_".$or_short."AccordionInnerContainer");
417 
418 
419  if ($height > 0)
420  {
421  $tpl->setVariable("HEIGHT", "height:".$height."px;");
422  }
423  if ($height > 0 && $this->getOrientation() == ilAccordionGUI::HORIZONTAL)
424  {
425  $tpl->setVariable("HHEIGHT", "height:".$height."px;");
426  }
427  $tpl->parseCurrentBlock();
428  }
429 
430  $tpl->setVariable("CONTAINER_CLASS", $this->getContainerClass()
431  ? $this->getContainerClass() : "il_".$or_short."AccordionContainer");
432 
433  $options["orientation"] = $this->getOrientation();
434  $options["int_id"] = $this->getId();
435 
436  if ($this->getUseSessionStorage() && $this->getId() != "")
437  {
438  include_once("./Services/Accordion/classes/class.ilAccordionPropertiesStorage.php");
439  $stor = new ilAccordionPropertiesStorage();
440 
441  $ctab = $stor->getProperty($this->getId(), $ilUser->getId(),
442  "opened");
443  $ctab_arr = explode(";", $ctab);
444 
445  foreach ($this->force_open as $fo)
446  {
447  if (!in_array($fo, $ctab_arr))
448  {
449  $ctab_arr[] = $fo;
450  }
451  }
452  $ctab = implode(";", $ctab_arr);
453 
454  if ($ctab == "0") {
455  $ctab = "";
456  }
457 
458  $options["initial_opened"] = $ctab;
459  $options["save_url"] = "./ilias.php?baseClass=ilaccordionpropertiesstorage&cmd=setOpenedTab".
460  "&accordion_id=".$this->getId()."&user_id=".$ilUser->getId();
461  }
462 
463  $options["behaviour"] = $this->getBehaviour();
465  {
466  $options["toggle_class"] = 'il_HAccordionToggleDef';
467  $options["toggle_act_class"] = 'il_HAccordionToggleActiveDef';
468  $options["content_class"] = 'il_HAccordionContentDef';
469  }
470  else
471  {
472  $options["toggle_class"] = 'il_VAccordionToggleDef';
473  $options["toggle_act_class"] = 'il_VAccordionToggleActiveDef';
474  $options["content_class"] = 'il_VAccordionContentDef';
475  }
476 
477 
478  if ($width > 0)
479  {
480  $options["width"] = $width;
481  }
482  else
483  {
484  $options["width"] = null;
485  }
486  if ($width > 0 && $this->getOrientation() == ilAccordionGUI::VERTICAL)
487  {
488  $tpl->setVariable("CWIDTH", 'style="width:'.$width.'px;"');
489  }
490 
491  if ($this->head_class_set)
492  {
493  $options["active_head_class"] = $this->getActiveHeaderClass();
494  }
495  else
496  {
498  {
499  $options["active_head_class"] = "il_HAccordionHeadActive";
500  }
501  else
502  {
503  $options["active_head_class"] = "il_VAccordionHeadActive";
504  }
505  }
506 
507  $options["height"] = null;
508  $options["id"] = 'accordion_'.$this->getId().'_'.self::$accordion_cnt;
509  $options["multi"] = (bool) $this->getAllowMultiOpened();
510  $options["show_all_element"] = $this->getShowAllElement();
511  $options["hide_all_element"] = $this->getHideAllElement();
512 
513  include_once("./Services/JSON/classes/class.ilJsonUtil.php");
514  $tpl->setVariable("OPTIONS", $str = ilJsonUtil::encode($options));
515  $tpl->setVariable("ACC_ID", $options["id"]);
516 //echo "<br><br><br><br><br><br>".$str;
517  return $tpl->get();
518  }
getContentWidth()
Get ContentWidth.
getContentHeight()
Get ContentHeight.
getContainerClass()
Get Container CSS Class.
getOrientation()
Get Orientation.
getActiveHeaderClass()
Get active Header CSS Class.
getHeaderClass()
Get Header CSS Class.
getAllowMultiOpened()
Get allow multi opened.
global $tpl
Definition: ilias.php:8
getShowAllElement()
Get show all element.
getHideAllElement()
Get hide all element.
getInnerContainerClass()
Get inner Container CSS Class.
static encode($mixed, $suppress_native=false)
static addCss()
Add required css.
if(!is_array($argv)) $options
special template class to simplify handling of ITX/PEAR
getContentClass()
Get Content CSS Class.
getUseSessionStorage()
Get use session storage.
global $ilUser
Definition: imgupload.php:15
getItems()
Get all items.
Saves (mostly asynchronously) user properties of accordions.
getBehaviour()
Get behaviour.
+ Here is the call graph for this function:

◆ getId()

ilAccordionGUI::getId ( )

Get id.

Returns
string id

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

Referenced by getHTML().

51  {
52  return $this->id;
53  }
+ Here is the caller graph for this function:

◆ getInnerContainerClass()

ilAccordionGUI::getInnerContainerClass ( )

Get inner Container CSS Class.

Returns
string Container CSS Class

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

Referenced by getHTML().

115  {
116  return $this->icontainerclass;
117  }
+ Here is the caller graph for this function:

◆ getItems()

ilAccordionGUI::getItems ( )

Get all items.

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

References $items.

Referenced by getHTML().

363  {
364  return $this->items;
365  }
+ Here is the caller graph for this function:

◆ getOrientation()

ilAccordionGUI::getOrientation ( )

Get Orientation.

Returns
string Orientation

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

Referenced by getHTML().

75  {
76  return $this->orientation;
77  }
+ Here is the caller graph for this function:

◆ getShowAllElement()

ilAccordionGUI::getShowAllElement ( )

Get show all element.

Returns
string ID of show all html element

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

References $show_all_element.

Referenced by getHTML().

295  {
297  }
+ Here is the caller graph for this function:

◆ getUseSessionStorage()

ilAccordionGUI::getUseSessionStorage ( )

Get use session storage.

Returns
bool use session storage

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

References $use_session_storage.

Referenced by getHTML().

255  {
257  }
+ Here is the caller graph for this function:

◆ setActiveHeaderClass()

ilAccordionGUI::setActiveHeaderClass (   $a_h_class)

Set active header class.

Parameters
string$a_h_classActive Header CSS Class

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

145  {
146  $this->active_headerclass = $a_h_class;
147  }

◆ setAllowMultiOpened()

ilAccordionGUI::setAllowMultiOpened (   $a_val)

Set allow multi opened.

Parameters
bool$a_valallow multiple accordions being opened

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

265  {
266  $this->allow_multi_opened = $a_val;
267  }

◆ setBehaviour()

ilAccordionGUI::setBehaviour (   $a_val)

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

Parameters
stringbehaviour

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

225  {
226  $this->behaviour = $a_val;
227  }

◆ setContainerClass()

ilAccordionGUI::setContainerClass (   $a_containerclass)

Set Container CSS Class.

Parameters
string$a_containerclassContainer CSS Class

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

85  {
86  $this->containerclass = $a_containerclass;
87  }

◆ setContentClass()

ilAccordionGUI::setContentClass (   $a_contentclass)

Set Content CSS Class.

Parameters
string$a_contentclassContent CSS Class

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

165  {
166  $this->contentclass = $a_contentclass;
167  }

◆ setContentHeight()

ilAccordionGUI::setContentHeight (   $a_contentheight)

Set ContentHeight.

Parameters
integer$a_contentheightContentHeight

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

205  {
206  $this->contentheight = $a_contentheight;
207  }

◆ setContentWidth()

ilAccordionGUI::setContentWidth (   $a_contentwidth)

Set ContentWidth.

Parameters
integer$a_contentwidthContentWidth

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

185  {
186  $this->contentwidth = $a_contentwidth;
187  }

◆ setHeaderClass()

ilAccordionGUI::setHeaderClass (   $a_headerclass)

Set Header CSS Class.

Parameters
string$a_headerclassHeader CSS Class

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

125  {
126  $this->headerclass = $a_headerclass;
127  }

◆ setHideAllElement()

ilAccordionGUI::setHideAllElement (   $a_val)

Set hide all element.

Parameters
string$a_valID of hide all html element

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

305  {
306  $this->hide_all_element = $a_val;
307  }

◆ setId()

ilAccordionGUI::setId (   $a_val)

Set id.

Parameters
stringid

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

41  {
42  $this->id = $a_val;
43  }

◆ setInnerContainerClass()

ilAccordionGUI::setInnerContainerClass (   $a_containerclass)

Set inner Container CSS Class.

Parameters
string$a_containerclassContainer CSS Class

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

105  {
106  $this->icontainerclass = $a_containerclass;
107  }

◆ setOrientation()

ilAccordionGUI::setOrientation (   $a_orientation)

Set Orientation.

Parameters
string$a_orientationOrientation

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

References HORIZONTAL, and VERTICAL.

Referenced by __construct().

61  {
62  if (in_array($a_orientation,
64  {
65  $this->orientation = $a_orientation;
66  }
67  }
+ Here is the caller graph for this function:

◆ setShowAllElement()

ilAccordionGUI::setShowAllElement (   $a_val)

Set show all element.

Parameters
string$a_valID of show all html element

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

285  {
286  $this->show_all_element = $a_val;
287  }

◆ setUseSessionStorage()

ilAccordionGUI::setUseSessionStorage (   $a_val)

Set use session storage.

Parameters
bool$a_valuse session storage

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

245  {
246  $this->use_session_storage = $a_val;
247  }

Field Documentation

◆ $accordion_cnt

ilAccordionGUI::$accordion_cnt = 0
staticprotected

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

◆ $allow_multi_opened

ilAccordionGUI::$allow_multi_opened = false
protected

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

Referenced by getAllowMultiOpened().

◆ $force_open

ilAccordionGUI::$force_open = array()
protected

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

◆ $hide_all_element

ilAccordionGUI::$hide_all_element = null
protected

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

Referenced by getHideAllElement().

◆ $items

ilAccordionGUI::$items = array()
protected

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

Referenced by addItem(), and getItems().

◆ $show_all_element

ilAccordionGUI::$show_all_element = null
protected

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

Referenced by getShowAllElement().

◆ $use_session_storage

ilAccordionGUI::$use_session_storage = false
protected

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

Referenced by getUseSessionStorage().

◆ ALL_CLOSED

const ilAccordionGUI::ALL_CLOSED = "AllClosed"

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

◆ FIRST_OPEN

const ilAccordionGUI::FIRST_OPEN = "FirstOpen"

◆ FORCE_ALL_OPEN

const ilAccordionGUI::FORCE_ALL_OPEN = "ForceAllOpen"

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

Referenced by ilObjRoleGUI\permObject().

◆ HORIZONTAL

const ilAccordionGUI::HORIZONTAL = "horizontal"

◆ VERTICAL

const ilAccordionGUI::VERTICAL = "vertical"

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