ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilSplitButtonGUI Class Reference

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

+ Inheritance diagram for ilSplitButtonGUI:
+ Collaboration diagram for ilSplitButtonGUI:

Public Member Functions

 addMenuItem (ilSplitButtonMenuItem $menu_item)
 
 removeMenuItem (ilSplitButtonMenuItem $menu_item)
 
 hasMenuItems ()
 
 getMenuItems ()
 
 setMenuItems (array $menu_items)
 
 getDefaultButton ()
 
 hasDefaultButton ()
 
 setDefaultButton (ilButtonBase $default_button)
 
 render ()
 
- Public Member Functions inherited from ilButtonBase
 __clone ()
 
 getType ()
 
 setId (?string $a_value)
 
 getId ()
 
 setCaption (string $a_value, bool $a_is_lng_id=true)
 
 getCaption (bool $a_translate=true)
 
 setPrimary (bool $a_value)
 
 isPrimary ()
 
 setOmitPreventDoubleSubmission (bool $a_value)
 Toggle double submission prevention status. More...
 
 getOmitPreventDoubleSubmission ()
 
 setOnClick (string $a_value)
 
 getOnClick ()
 
 setDisabled (bool $a_value)
 
 isDisabled ()
 
 addCSSClass (string $a_value)
 
 getCSSClasses ()
 
 applyDefaultCss (?bool $apply_default_css=null)
 
 render ()
 
 getToolbarHTML ()
 Get input item HTML to be inserted into ilToolbarGUI. More...
 
 getToolbarHTML ()
 Get input item HTML to be inserted into ilToolbarGUI. More...
 

Static Public Member Functions

static getInstance ()
 
static getInstance ()
 

Protected Member Functions

 __construct (int $a_type)
 
- Protected Member Functions inherited from ilButtonBase
 __construct (int $a_type)
 
 setType (int $a_value)
 
 gatherCssClasses ()
 
 renderAttributesHelper (array $a_attr)
 
 renderAttributes (?array $a_additional_attr=null)
 Render current HTML attributes. More...
 
 prepareRender ()
 

Protected Attributes

ilButtonBase $default_button
 
array $menu_items = []
 
- Protected Attributes inherited from ilButtonBase
ilLanguage $lng
 
int $type = 0
 
string $id = ""
 
string $caption = ""
 
bool $caption_is_lng_id = false
 
bool $primary = false
 
bool $omit_prevent_double_submission = false
 
string $onclick = ""
 
int $acc_key = 0
 
bool $disabled = false
 
array $css = array()
 
bool $apply_default_css = true
 

Additional Inherited Members

- Data Fields inherited from ilButtonBase
const TYPE_SUBMIT = 1
 
const TYPE_LINK = 2
 
const TYPE_SPLIT = 3
 
const TYPE_BUTTON = 4
 

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 Class ilSplitButton

Author
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de
Deprecated:
10

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

Constructor & Destructor Documentation

◆ __construct()

ilSplitButtonGUI::__construct ( int  $a_type)
protected

Reimplemented from ilButtonBase.

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

34 {
35 parent::__construct($a_type);
36 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

Member Function Documentation

◆ addMenuItem()

ilSplitButtonGUI::addMenuItem ( ilSplitButtonMenuItem  $menu_item)

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

43 : void
44 {
45 $this->menu_items[] = $menu_item;
46 }

◆ getDefaultButton()

ilSplitButtonGUI::getDefaultButton ( )

Definition at line 87 of file class.ilSplitButtonGUI.php.

88 {
90 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References $default_button.

Referenced by render().

+ Here is the caller graph for this function:

◆ getInstance()

static ilSplitButtonGUI::getInstance ( )
static

Reimplemented from ilButtonBase.

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

38 : self
39 {
40 return new self(self::TYPE_SPLIT);
41 }

References ilButtonBase\TYPE_SPLIT.

◆ getMenuItems()

ilSplitButtonGUI::getMenuItems ( )
Returns
ilSplitButtonMenuItem[]

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

64 : array
65 {
66 return $this->menu_items;
67 }

References $menu_items.

Referenced by render().

+ Here is the caller graph for this function:

◆ hasDefaultButton()

ilSplitButtonGUI::hasDefaultButton ( )

Definition at line 92 of file class.ilSplitButtonGUI.php.

92 : bool
93 {
94 return ($this->default_button instanceof ilButtonBase);
95 }

Referenced by render().

+ Here is the caller graph for this function:

◆ hasMenuItems()

ilSplitButtonGUI::hasMenuItems ( )

Definition at line 56 of file class.ilSplitButtonGUI.php.

56 : bool
57 {
58 return count($this->menu_items) > 0;
59 }

Referenced by render().

+ Here is the caller graph for this function:

◆ removeMenuItem()

ilSplitButtonGUI::removeMenuItem ( ilSplitButtonMenuItem  $menu_item)

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

48 : void
49 {
50 $key = array_search($menu_item, $this->menu_items);
51 if ($key !== false) {
52 unset($this->menu_items[$key]);
53 }
54 }

◆ render()

ilSplitButtonGUI::render ( )
Exceptions
ilSplitButtonException

Reimplemented from ilButtonBase.

Definition at line 105 of file class.ilSplitButtonGUI.php.

105 : string
106 {
107 $tpl = new ilTemplate('tpl.split_button.html', true, true, 'components/ILIAS/UIComponent/SplitButton');
108
109 if (!$this->hasDefaultButton()) {
110 throw new ilSplitButtonException(
111 "Cannot render a split button without a default button"
112 );
113 }
114
115 $tpl->setVariable('DEFAULT_ITEM_CONTENT', $this->getDefaultButton()->render());
116 if ($this->hasMenuItems()) {
117 $btn_classes = $this->getDefaultButton()->getCSSClasses();
118 if ($this->getDefaultButton()->isPrimary()) {
119 $btn_classes[] = 'btn-primary';
120 }
121 $tpl->setVariable('BTN_CSS_CLASS', implode(' ', $btn_classes));
122
123 foreach ($this->getMenuItems() as $item) {
124 if ($item instanceof ilSplitButtonSeparatorMenuItem) {
125 $tpl->setCurrentBlock('separator');
126 $tpl->touchBlock('separator');
127 } else {
128 $tpl->setCurrentBlock('item');
129 $tpl->setVariable('CONTENT', $item->getContent());
130 }
131 $tpl->parseCurrentBlock();
132
133 $tpl->setCurrentBlock('items');
134 $tpl->parseCurrentBlock();
135 }
136
137 $tpl->setVariable('TXT_TOGGLE_DROPDOWN', $this->lng->txt('toggle_dropdown'));
138 }
139
140 return $tpl->get();
141 }
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
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References getDefaultButton(), getMenuItems(), hasDefaultButton(), hasMenuItems(), ilButtonBase\isPrimary(), ILIAS\Repository\lng(), and render().

Referenced by render().

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

◆ setDefaultButton()

ilSplitButtonGUI::setDefaultButton ( ilButtonBase  $default_button)

Definition at line 97 of file class.ilSplitButtonGUI.php.

97 : void
98 {
99 $this->default_button = $default_button;
100 }

References $default_button.

◆ setMenuItems()

ilSplitButtonGUI::setMenuItems ( array  $menu_items)
Parameters
ilSplitButtonMenuItem[]$menu_items
Exceptions
ilSplitButtonException

Definition at line 73 of file class.ilSplitButtonGUI.php.

73 : void
74 {
75 array_walk($menu_items, static function ($item, $idx): void {
76 if (!($item instanceof ilSplitButtonMenuItem)) {
77 throw new ilSplitButtonException(sprintf(
78 "Cannot set menu items, element at index '%s' is not of type 'ilSplitButtonItem'",
79 $idx
80 ));
81 }
82 });
83
84 $this->menu_items = $menu_items;
85 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References $menu_items.

Field Documentation

◆ $default_button

ilButtonBase ilSplitButtonGUI::$default_button
protected

Definition at line 27 of file class.ilSplitButtonGUI.php.

Referenced by getDefaultButton(), and setDefaultButton().

◆ $menu_items

array ilSplitButtonGUI::$menu_items = []
protected

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

Referenced by getMenuItems(), and setMenuItems().


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