ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
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...
 

Static Public Member Functions

static getInstance ()
 
- Static Public Member Functions inherited from ilButtonBase
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

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

Constructor & Destructor Documentation

◆ __construct()

ilSplitButtonGUI::__construct ( int  $a_type)
protected

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

References ILIAS\GlobalScreen\Provider\__construct().

32  {
33  parent::__construct($a_type);
34  }
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ addMenuItem()

ilSplitButtonGUI::addMenuItem ( ilSplitButtonMenuItem  $menu_item)

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

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

◆ getDefaultButton()

ilSplitButtonGUI::getDefaultButton ( )

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

References $default_button.

Referenced by render().

85  : ilButtonBase
86  {
87  return $this->default_button;
88  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the caller graph for this function:

◆ getInstance()

static ilSplitButtonGUI::getInstance ( )
static

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

Referenced by ilRepositorySearchGUI\fillAutoCompleteToolbar(), ilPortfolioPageTableGUI\fillRow(), assClozeTestGUI\populateQuestionSpecificFormPart(), ilObjForumGUI\renderSplitButton(), and ilObjForumGUI\viewThreadObject().

36  : self
37  {
38  return new self(self::TYPE_SPLIT);
39  }
+ Here is the caller graph for this function:

◆ getMenuItems()

ilSplitButtonGUI::getMenuItems ( )
Returns
ilSplitButtonMenuItem[]

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

References $menu_items.

Referenced by render().

62  : array
63  {
64  return $this->menu_items;
65  }
+ Here is the caller graph for this function:

◆ hasDefaultButton()

ilSplitButtonGUI::hasDefaultButton ( )

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

Referenced by render().

90  : bool
91  {
92  return ($this->default_button instanceof ilButtonBase);
93  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the caller graph for this function:

◆ hasMenuItems()

ilSplitButtonGUI::hasMenuItems ( )

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

Referenced by render().

54  : bool
55  {
56  return count($this->menu_items) > 0;
57  }
+ Here is the caller graph for this function:

◆ removeMenuItem()

ilSplitButtonGUI::removeMenuItem ( ilSplitButtonMenuItem  $menu_item)

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

References ILIAS\LTI\ToolProvider\$key.

46  : void
47  {
48  $key = array_search($menu_item, $this->menu_items);
49  if ($key !== false) {
50  unset($this->menu_items[$key]);
51  }
52  }
string $key
Consumer key/client ID value.
Definition: System.php:193

◆ render()

ilSplitButtonGUI::render ( )
Exceptions
ilSplitButtonException

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

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

103  : string
104  {
105  $tpl = new ilTemplate('tpl.split_button.html', true, true, 'Services/UIComponent/SplitButton');
106 
107  if (!$this->hasDefaultButton()) {
108  throw new ilSplitButtonException(
109  "Cannot render a split button without a default button"
110  );
111  }
112 
113  $tpl->setVariable('DEFAULT_ITEM_CONTENT', $this->getDefaultButton()->render());
114  if ($this->hasMenuItems()) {
115  $btn_classes = $this->getDefaultButton()->getCSSClasses();
116  if ($this->getDefaultButton()->isPrimary()) {
117  $btn_classes[] = 'btn-primary';
118  }
119  $tpl->setVariable('BTN_CSS_CLASS', implode(' ', $btn_classes));
120 
121  foreach ($this->getMenuItems() as $item) {
122  if ($item instanceof ilSplitButtonSeparatorMenuItem) {
123  $tpl->setCurrentBlock('separator');
124  $tpl->touchBlock('separator');
125  } else {
126  $tpl->setCurrentBlock('item');
127  $tpl->setVariable('CONTENT', $item->getContent());
128  }
129  $tpl->parseCurrentBlock();
130 
131  $tpl->setCurrentBlock('items');
132  $tpl->parseCurrentBlock();
133  }
134 
135  $tpl->setVariable('TXT_TOGGLE_DROPDOWN', $this->lng->txt('toggle_dropdown'));
136  }
137 
138  return $tpl->get();
139  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ setDefaultButton()

ilSplitButtonGUI::setDefaultButton ( ilButtonBase  $default_button)

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

References $default_button.

95  : void
96  {
97  $this->default_button = $default_button;
98  }

◆ setMenuItems()

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

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

References $menu_items.

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

Field Documentation

◆ $default_button

ilButtonBase ilSplitButtonGUI::$default_button
protected

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

Referenced by getDefaultButton(), and setDefaultButton().

◆ $menu_items

array ilSplitButtonGUI::$menu_items = []
protected

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

Referenced by getMenuItems(), and setMenuItems().


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