ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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
 $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 57 of file class.ilSplitButtonGUI.php.

58  {
59  $this->menu_items[] = $menu_item;
60  }

◆ getDefaultButton()

ilSplitButtonGUI::getDefaultButton ( )
Returns
ilButtonBase

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

References $default_button.

Referenced by render().

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

◆ getInstance()

static ilSplitButtonGUI::getInstance ( )
static
Returns
self;

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

Referenced by ilObjForumGUI\autosaveThreadDraftAsyncObject(), ilRepositorySearchGUI\fillAutoCompleteToolbar(), ilObjForumGUI\getForumObjects(), and assClozeTestGUI\populateQuestionSpecificFormPart().

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

◆ getMenuItems()

ilSplitButtonGUI::getMenuItems ( )
Returns
ilSplitButtonMenuItem[]

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

References $menu_items.

Referenced by render().

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

◆ hasDefaultButton()

ilSplitButtonGUI::hasDefaultButton ( )
Returns
boolean

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

Referenced by render().

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

◆ hasMenuItems()

ilSplitButtonGUI::hasMenuItems ( )
Returns
boolean

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

Referenced by render().

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

◆ removeMenuItem()

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

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

66  {
67  $key = array_search($menu_item, $this->menu_items);
68  if($key !== false)
69  {
70  unset($this->menu_items[$key]);
71  }
72  }

◆ render()

ilSplitButtonGUI::render ( )
Returns
string
Exceptions
ilSplitButtonException

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

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

137  {
138  $tpl = new ilTemplate('tpl.split_button.html', true, true, 'Services/UIComponent/SplitButton');
139 
140  if(!$this->hasDefaultButton())
141  {
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  {
150  $btn_classes = $this->getDefaultButton()->getCSSClasses();
151  if($this->getDefaultButton()->isPrimary())
152  {
153  $btn_classes[] = 'btn-primary';
154  }
155  $tpl->setVariable('BTN_CSS_CLASS', implode(' ', $btn_classes));
156 
157  foreach($this->getMenuItems() as $item)
158  {
159  if($item instanceof ilSplitButtonSeparatorMenuItem)
160  {
161  $tpl->setCurrentBlock('separator');
162  $tpl->touchBlock('separator');
163  $tpl->parseCurrentBlock();
164  }
165  else
166  {
167  $tpl->setCurrentBlock('item');
168  $tpl->setVariable('CONTENT', $item->getContent());
169  $tpl->parseCurrentBlock();
170  }
171 
172  $tpl->setCurrentBlock('items');
173  $tpl->parseCurrentBlock();
174  }
175 
176  $tpl->setVariable('TXT_TOGGLE_DROPDOWN', $this->lng->txt('toggle_dropdown'));
177  }
178 
179  return $tpl->get();
180  }
Interface ilSplitButtonSeparatorMenuItem.
isPrimary()
Get primary status.
global $tpl
Definition: ilias.php:8
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 127 of file class.ilSplitButtonGUI.php.

References $default_button.

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

◆ setMenuItems()

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

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

References $menu_items.

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