ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilSplitButtonGUI Class Reference

Class ilSplitButton. More...

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

Public Member Functions

 addMenuItem (ilSplitButtonMenuItem $menu_item)
 
 removeMenuItem (ilSplitButtonMenuItem $menu_item)
 
 hasMenuItems ()
 
 getMenuItems ()
 
 setMenuItems ($menu_items)
 
 getDefaultButton ()
 
 hasDefaultButton ()
 
 setDefaultButton (ilButtonBase $default_button)
 
 render ()
 
- Public Member Functions inherited from ilButtonBase
 __clone ()
 Clone instance. More...
 
 getType ()
 Get button type. More...
 
 setId ($a_value)
 Set id. More...
 
 getId ()
 Get id. More...
 
 setCaption ($a_value, $a_is_lng_id=true)
 Set caption. More...
 
 getCaption ($a_translate=true)
 Get caption. More...
 
 setPrimary ($a_value)
 Toggle primary status. More...
 
 isPrimary ()
 Get primary status. More...
 
 setOmitPreventDoubleSubmission ($a_value)
 Toggle double submission prevention status. More...
 
 getOmitPreventDoubleSubmission ()
 Get double submission prevention status. More...
 
 setOnClick ($a_value)
 Set onclick. More...
 
 getOnClick ()
 Get onclick. More...
 
 setAccessKey ($a_value)
 Set access key. More...
 
 getAccessKey ()
 Get access key. More...
 
 setDisabled ($a_value)
 Toggle disabled status. More...
 
 isDisabled ()
 Get disabled status. More...
 
 addCSSClass ($a_value)
 Add CSS class. More...
 
 getCSSClasses ()
 Get CSS class(es) More...
 
 applyDefaultCss ($apply_default_css=null)
 
 render ()
 Render HTML. More...
 
 getToolbarHTML ()
 

Static Public Member Functions

static getInstance ()
 
- Static Public Member Functions inherited from ilButtonBase
static getInstance ()
 Factory. More...
 

Protected Attributes

 $lng
 
 $default_button
 
 $menu_items = array()
 
- Protected Attributes inherited from ilButtonBase
 $lng
 
 $type
 
 $id
 
 $caption
 
 $caption_is_lng_id
 
 $primary
 
 $omit_prevent_double_submission
 
 $onclick
 
 $acc_key
 
 $disabled
 
 $css = array()
 
 $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
 
- Protected Member Functions inherited from ilButtonBase
 __construct ($a_type)
 Constructor. More...
 
 setType ($a_value)
 Set button type. More...
 
 gatherCssClasses ()
 Gather all active CSS classes. More...
 
 renderAttributesHelper (array $a_attr)
 Render HTML node attributes. More...
 
 renderAttributes (array $a_additional_attr=null)
 Render current HTML attributes. More...
 
 prepareRender ()
 Prepare render. More...
 

Detailed Description

Class ilSplitButton.

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

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

Member Function Documentation

◆ addMenuItem()

ilSplitButtonGUI::addMenuItem ( ilSplitButtonMenuItem  $menu_item)
Parameters
ilSplitButtonMenuItem$menu_item

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

60  {
61  $this->menu_items[] = $menu_item;
62  }

◆ getDefaultButton()

ilSplitButtonGUI::getDefaultButton ( )
Returns
ilButtonBase

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

References $default_button.

Referenced by render().

113  {
114  return $this->default_button;
115  }
+ Here is the caller graph for this function:

◆ getInstance()

static ilSplitButtonGUI::getInstance ( )
static
Returns
self;

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

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

52  {
53  return new self(self::TYPE_SPLIT);
54  }
+ Here is the caller graph for this function:

◆ getMenuItems()

ilSplitButtonGUI::getMenuItems ( )
Returns
ilSplitButtonMenuItem[]

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

References $menu_items.

Referenced by render().

87  {
88  return $this->menu_items;
89  }
+ Here is the caller graph for this function:

◆ hasDefaultButton()

ilSplitButtonGUI::hasDefaultButton ( )
Returns
boolean

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

Referenced by render().

121  {
122  return ($this->default_button instanceof ilButtonBase);
123  }
+ Here is the caller graph for this function:

◆ hasMenuItems()

ilSplitButtonGUI::hasMenuItems ( )
Returns
boolean

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

Referenced by render().

79  {
80  return count($this->menu_items) > 0;
81  }
+ Here is the caller graph for this function:

◆ removeMenuItem()

ilSplitButtonGUI::removeMenuItem ( ilSplitButtonMenuItem  $menu_item)
Parameters
ilSplitButtonMenuItem$menu_item

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

References $key.

68  {
69  $key = array_search($menu_item, $this->menu_items);
70  if ($key !== false) {
71  unset($this->menu_items[$key]);
72  }
73  }
$key
Definition: croninfo.php:18

◆ render()

ilSplitButtonGUI::render ( )
Returns
string
Exceptions
ilSplitButtonException

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

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

138  {
139  $tpl = new ilTemplate('tpl.split_button.html', true, true, 'Services/UIComponent/SplitButton');
140 
141  if (!$this->hasDefaultButton()) {
142  throw new ilSplitButtonException(
143  "Cannot render a split button without a default button"
144  );
145  }
146 
147  $tpl->setVariable('DEFAULT_ITEM_CONTENT', $this->getDefaultButton()->render());
148  if ($this->hasMenuItems()) {
149  $btn_classes = $this->getDefaultButton()->getCSSClasses();
150  if ($this->getDefaultButton()->isPrimary()) {
151  $btn_classes[] = 'btn-primary';
152  }
153  $tpl->setVariable('BTN_CSS_CLASS', implode(' ', $btn_classes));
154 
155  foreach ($this->getMenuItems() as $item) {
156  if ($item instanceof ilSplitButtonSeparatorMenuItem) {
157  $tpl->setCurrentBlock('separator');
158  $tpl->touchBlock('separator');
159  $tpl->parseCurrentBlock();
160  } else {
161  $tpl->setCurrentBlock('item');
162  $tpl->setVariable('CONTENT', $item->getContent());
163  $tpl->parseCurrentBlock();
164  }
165 
166  $tpl->setCurrentBlock('items');
167  $tpl->parseCurrentBlock();
168  }
169 
170  $tpl->setVariable('TXT_TOGGLE_DROPDOWN', $this->lng->txt('toggle_dropdown'));
171  }
172 
173  return $tpl->get();
174  }
Interface ilSplitButtonSeparatorMenuItem.
$tpl
Definition: ilias.php:10
isPrimary()
Get primary status.
special template class to simplify handling of ITX/PEAR
Class ilSplittButtonException.
+ Here is the call graph for this function:

◆ setDefaultButton()

ilSplitButtonGUI::setDefaultButton ( ilButtonBase  $default_button)
Parameters
ilButtonBase$default_button

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

References $default_button.

129  {
130  $this->default_button = $default_button;
131  }

◆ setMenuItems()

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

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

References $menu_items.

96  {
97  array_walk($menu_items, function (&$item, $idx) {
98  if (!($item instanceof ilSplitButtonMenuItem)) {
99  throw new ilSplitButtonException(sprintf(
100  "Cannot set menu items, element at index '%s' is not of type 'ilSplitButtonItem'",
101  $idx
102  ));
103  }
104  });
105 
106  $this->menu_items = $menu_items;
107  }
Interface ilSplitButtonMenuItem.
Class ilSplittButtonException.

Field Documentation

◆ $default_button

ilSplitButtonGUI::$default_button
protected

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

Referenced by getDefaultButton(), and setDefaultButton().

◆ $lng

ilSplitButtonGUI::$lng
protected

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

◆ $menu_items

ilSplitButtonGUI::$menu_items = array()
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: