ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilToolbarGUI Class Reference

Toolbar. More...

+ Inheritance diagram for ilToolbarGUI:
+ Collaboration diagram for ilToolbarGUI:

Public Member Functions

 __construct ()
 
 setFormAction ($a_val, $a_multipart=false, $a_target="")
 Set form action (if form action is set, toolbar is wrapped into form tags) More...
 
 getFormAction ()
 Get form action. More...
 
 setLeadingImage ($a_img, $a_alt)
 Set leading image. More...
 
 setHidden ($a_val)
 Set hidden. More...
 
 getHidden ()
 Get hidden. More...
 
 setId ($a_val)
 Set id. More...
 
 getId ()
 Get id. More...
 
 setPreventDoubleSubmission ($a_val)
 Set prevent double submission. More...
 
 getPreventDoubleSubmission ()
 Get prevent double submission. More...
 
 addButton ( $a_txt, $a_cmd, $a_target="", $a_acc_key="", $a_additional_attrs='', $a_id="", $a_class='submit')
 Add button to toolbar. More...
 
 addFormButton ($a_txt, $a_cmd, $a_acc_key="", $a_primary=false, $a_class=false)
 Add form button to toolbar. More...
 
 addInputItem (ilToolbarItem $a_item, $a_output_label=false)
 Add input item. More...
 
 addStickyItem ($a_item, $a_output_label=false)
 Add a sticky item. More...
 
 addButtonInstance (ilButtonBase $a_button)
 Add button instance. More...
 
 addDropDown ($a_txt, $a_dd_html)
 Add input item. More...
 
 addSeparator ()
 Add separator. More...
 
 addText ($a_text)
 Add text. More...
 
 addSpacer ($a_width=null)
 Add spacer. More...
 
 addComponent (\ILIAS\UI\Component\Component $a_comp)
 Add component. More...
 
 addLink ($a_caption, $a_url, $a_disabled=false)
 Add link. More...
 
 setOpenFormTag ($a_val)
 Set open form tag. More...
 
 getOpenFormTag ()
 Get open form tag. More...
 
 setCloseFormTag ($a_val)
 Set close form tag. More...
 
 getCloseFormTag ()
 Get close form tag. More...
 
 setFormName ($a_val)
 Set form name. More...
 
 getFormName ()
 Get form name. More...
 
 getGroupedItems ()
 Get all groups (items separated by a separator) More...
 
 getItems ()
 
 setItems ($items)
 

Data Fields

 $items = array()
 

Protected Member Functions

 applyAutoStickyToSingleElement ()
 If the toolbar consists of only one button, make it sticky Note: Atm this is only possible for buttons. More...
 

Protected Attributes

 $lng
 
 $id = ''
 
 $form_action = ''
 
 $hidden
 
 $lead_img
 
 $open_form_tag = true
 
 $close_form_tag = true
 
 $form_target = ""
 
 $form_name = ""
 
 $prevent_double_submission = false
 
 $sticky_items = array()
 
 $has_separator = false
 

Static Protected Attributes

static $instances = 0
 

Detailed Description

Toolbar.

The toolbar currently only supports a list of buttons as links.

A default toolbar object is available in the $ilToolbar global object.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Stefan Wanzenried sw@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

ilToolbarGUI::__construct ( )

Definition at line 93 of file class.ilToolbarGUI.php.

References $DIC.

94  {
95  global $DIC;
96  $this->lng = $DIC->language();
97 
98  $this->ui = $DIC->ui();
99 
100  self::$instances++;
101  }
global $DIC
Definition: saml.php:7

Member Function Documentation

◆ addButton()

ilToolbarGUI::addButton (   $a_txt,
  $a_cmd,
  $a_target = "",
  $a_acc_key = "",
  $a_additional_attrs = '',
  $a_id = "",
  $a_class = 'submit' 
)

Add button to toolbar.

Deprecated:
use addButtonInstance() instead!
Parameters
stringtext
stringlink href / submit command
stringframe target
stringaccess key

Definition at line 209 of file class.ilToolbarGUI.php.

References array.

Referenced by ilTestResultsToolbarGUI\build(), ilObjTestGUI\populateQuestionBrowserToolbarButtons(), ilBookingScheduleGUI\render(), ilBookingObjectGUI\render(), ilMembershipGUI\showMailToMemberToolbarButton(), and ilMembershipGUI\showMemberExportToolbarButton().

217  {
218  $this->items[] = array("type" => "button", "txt" => $a_txt, "cmd" => $a_cmd,
219  "target" => $a_target, "acc_key" => $a_acc_key, 'add_attrs' => $a_additional_attrs,
220  "id" => $a_id, "class" => $a_class);
221  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ addButtonInstance()

ilToolbarGUI::addButtonInstance ( ilButtonBase  $a_button)

Add button instance.

Parameters
ilButtonBase$a_button

Definition at line 280 of file class.ilToolbarGUI.php.

References addStickyItem(), array, and ilButtonBase\isPrimary().

Referenced by ilTestNavigationToolbarGUI\addFinishTestButton(), ilTestNavigationToolbarGUI\addQuestionListButton(), ilTestNavigationToolbarGUI\addQuestionSelectionButton(), ilTestNavigationToolbarGUI\addQuestionTreeButton(), ilTestNavigationToolbarGUI\addSuspendTestButton(), ilTestResultsToolbarGUI\build(), and ilTestSkillEvaluationToolbarGUI\build().

281  {
282  if ($a_button->isPrimary()) {
283  $this->addStickyItem($a_button);
284  } else {
285  $this->items[] = array("type" => "button_obj", "instance" => $a_button);
286  }
287  }
addStickyItem($a_item, $a_output_label=false)
Add a sticky item.
isPrimary()
Get primary status.
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addComponent()

ilToolbarGUI::addComponent ( \ILIAS\UI\Component\Component  $a_comp)

Add component.

Definition at line 327 of file class.ilToolbarGUI.php.

References array.

328  {
329  $this->items[] = array("type" => "component", "component" => $a_comp);
330  }
Create styles array
The data for the language used.

◆ addDropDown()

ilToolbarGUI::addDropDown (   $a_txt,
  $a_dd_html 
)

Add input item.

Definition at line 293 of file class.ilToolbarGUI.php.

References array.

294  {
295  $this->items[] = array("type" => "dropdown", "txt" => $a_txt, "dd_html" => $a_dd_html);
296  }
Create styles array
The data for the language used.

◆ addFormButton()

ilToolbarGUI::addFormButton (   $a_txt,
  $a_cmd,
  $a_acc_key = "",
  $a_primary = false,
  $a_class = false 
)

Add form button to toolbar.

Deprecated:
use addButtonInstance() instead!
Parameters
stringtext
stringlink href / submit command
stringaccess key
boolprimary action
stringcss class

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

References addStickyItem(), array, and ilSubmitButton\getInstance().

Referenced by ilDidacticTemplateGUI\appendToolbarSwitch(), ilAssQuestionPreviewToolbarGUI\build(), ilTestSkillEvaluationToolbarGUI\build(), ilTestInfoScreenToolbarGUI\build(), and ilTestRandomQuestionSetSourcePoolDefinitionListToolbarGUI\populateNewQuestionSelectionRuleInputs().

235  {
236  if ($a_primary) {
237  $button = ilSubmitButton::getInstance();
238  $button->setPrimary(true);
239  $button->setCaption($a_txt, false);
240  $button->setCommand($a_cmd);
241  $button->setAccessKey($a_acc_key);
242  $this->addStickyItem($button);
243  } else {
244  $this->items[] = array("type" => "fbutton", "txt" => $a_txt, "cmd" => $a_cmd,
245  "acc_key" => $a_acc_key, "primary" => $a_primary, "class" => $a_class);
246  }
247  }
addStickyItem($a_item, $a_output_label=false)
Add a sticky item.
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addInputItem()

ilToolbarGUI::addInputItem ( ilToolbarItem  $a_item,
  $a_output_label = false 
)

Add input item.

Parameters
ilToolbarItem$a_item
bool$a_output_label

Definition at line 256 of file class.ilToolbarGUI.php.

References array.

Referenced by ilDidacticTemplateGUI\appendToolbarSwitch(), ilTestResultsToolbarGUI\build(), and ilTestSkillEvaluationToolbarGUI\build().

257  {
258  $this->items[] = array("type" => "input", "input" => $a_item, "label" => $a_output_label);
259  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ addLink()

ilToolbarGUI::addLink (   $a_caption,
  $a_url,
  $a_disabled = false 
)

Add link.

Parameters
string$a_caption
string$a_url
boolean$a_disabled

Definition at line 339 of file class.ilToolbarGUI.php.

References array.

340  {
341  $this->items[] = array("type" => "link", "txt" => $a_caption, "cmd" => $a_url, "disabled" => $a_disabled);
342  }
Create styles array
The data for the language used.

◆ addSeparator()

ilToolbarGUI::addSeparator ( )

Add separator.

Definition at line 302 of file class.ilToolbarGUI.php.

References array.

Referenced by ilTestResultsToolbarGUI\build(), ilTestSkillEvaluationToolbarGUI\build(), ilTestInfoScreenToolbarGUI\build(), ilMembershipGUI\showMailToMemberToolbarButton(), and ilMembershipGUI\showMemberExportToolbarButton().

303  {
304  $this->items[] = array("type" => "separator");
305  $this->has_separator = true;
306  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ addSpacer()

ilToolbarGUI::addSpacer (   $a_width = null)

Add spacer.

Definition at line 319 of file class.ilToolbarGUI.php.

References array.

320  {
321  $this->items[] = array("type" => "spacer", "width" => $a_width);
322  }
Create styles array
The data for the language used.

◆ addStickyItem()

ilToolbarGUI::addStickyItem (   $a_item,
  $a_output_label = false 
)

Add a sticky item.

Sticky items are always visible, also if the toolbar is collapsed (responsive view). Sticky items are displayed first in the toolbar.

Parameters
ilToolbarItem | \ILIAS\UI\Component\Component$a_item
bool$a_output_label

Definition at line 269 of file class.ilToolbarGUI.php.

References array.

Referenced by addButtonInstance(), addFormButton(), and applyAutoStickyToSingleElement().

270  {
271  $this->sticky_items[] = array("item"=>$a_item, "label"=>$a_output_label);
272  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ addText()

ilToolbarGUI::addText (   $a_text)

Add text.

Definition at line 311 of file class.ilToolbarGUI.php.

References array.

Referenced by ilDidacticTemplateGUI\appendToolbarSwitch().

312  {
313  $this->items[] = array("type" => "text", "text" => $a_text);
314  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ applyAutoStickyToSingleElement()

ilToolbarGUI::applyAutoStickyToSingleElement ( )
protected

If the toolbar consists of only one button, make it sticky Note: Atm this is only possible for buttons.

If we are dealing with objects implementing the ilToolbarItem interface one day, other elements can be added as sticky.

Definition at line 669 of file class.ilToolbarGUI.php.

References addStickyItem(), array, ilSubmitButton\getInstance(), and ilLinkButton\getInstance().

Referenced by getGroupedItems().

670  {
671  if (count($this->items) == 1 && count($this->sticky_items) == 0) {
672  $supported_types = array('button', 'fbutton', 'button_obj');
673  $item = $this->items[0];
674  if (!in_array($item['type'], $supported_types)) {
675  return;
676  }
677  $button = null;
678  switch ($item['type']) {
679  case 'button_obj':
680  $button = $item['instance'];
681  break;
682  case 'fbutton':
683  $button = ilSubmitButton::getInstance();
684  $button->setPrimary($item['primary']);
685  $button->setCaption($item['txt'], false);
686  $button->setCommand($item['cmd']);
687  $button->setAccessKey($item['acc_key']);
688  break;
689  case 'button':
690  $button = ilLinkButton::getInstance();
691  $button->setCaption($item['txt'], false);
692  $button->setUrl($item['cmd']);
693  $button->setTarget($item['target']);
694  $button->setId($item['id']);
695  $button->setAccessKey($item['acc_key']);
696  break;
697  }
698  $this->addStickyItem($button);
699  $this->items = array();
700  }
701  }
addStickyItem($a_item, $a_output_label=false)
Add a sticky item.
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCloseFormTag()

ilToolbarGUI::getCloseFormTag ( )

Get close form tag.

Returns
boolean close form tag

Definition at line 379 of file class.ilToolbarGUI.php.

References $close_form_tag.

Referenced by getGroupedItems().

380  {
381  return $this->close_form_tag;
382  }
+ Here is the caller graph for this function:

◆ getFormAction()

ilToolbarGUI::getFormAction ( )

Get form action.

Returns
string form action

Definition at line 122 of file class.ilToolbarGUI.php.

References $form_action.

Referenced by getGroupedItems().

123  {
124  return $this->form_action;
125  }
+ Here is the caller graph for this function:

◆ getFormName()

ilToolbarGUI::getFormName ( )

Get form name.

Returns
string form name

Definition at line 399 of file class.ilToolbarGUI.php.

References $form_name.

Referenced by getGroupedItems().

400  {
401  return $this->form_name;
402  }
+ Here is the caller graph for this function:

◆ getGroupedItems()

ilToolbarGUI::getGroupedItems ( )

Get all groups (items separated by a separator)

Returns
array

Definition at line 410 of file class.ilToolbarGUI.php.

References $GLOBALS, $i, $lng, $tpl, applyAutoStickyToSingleElement(), array, ilAccessKeyGUI\getAttribute(), getCloseFormTag(), getFormAction(), getFormName(), getHidden(), getId(), getOpenFormTag(), and getPreventDoubleSubmission().

411  {
412  $groups = array();
413  $group = array();
414  foreach ($this->items as $item) {
415  if ($item['type'] == 'separator') {
416  $groups[] = $group;
417  $group = array();
418  } else {
419  $group[] = $item;
420  }
421  }
422  if (count($group)) {
423  $groups[] = $group;
424  }
425 
426  return $groups;
427  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ getHidden()

ilToolbarGUI::getHidden ( )

Get hidden.

Returns
boolean hidden

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

References $hidden.

Referenced by getGroupedItems().

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

◆ getId()

ilToolbarGUI::getId ( )

Get id.

Returns
string id

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

Referenced by ilTestInfoScreenToolbarGUI\build(), and getGroupedItems().

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

◆ getItems()

ilToolbarGUI::getItems ( )
Returns
array

Definition at line 649 of file class.ilToolbarGUI.php.

References $items.

Referenced by ilTestInfoScreenToolbarGUI\build().

650  {
651  return $this->items;
652  }
+ Here is the caller graph for this function:

◆ getOpenFormTag()

ilToolbarGUI::getOpenFormTag ( )

Get open form tag.

Returns
boolean open form tag

Definition at line 359 of file class.ilToolbarGUI.php.

References $open_form_tag.

Referenced by getGroupedItems().

360  {
361  return $this->open_form_tag;
362  }
+ Here is the caller graph for this function:

◆ getPreventDoubleSubmission()

ilToolbarGUI::getPreventDoubleSubmission ( )

Get prevent double submission.

Returns
bool prevent double submission

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

References $prevent_double_submission.

Referenced by getGroupedItems().

195  {
197  }
+ Here is the caller graph for this function:

◆ setCloseFormTag()

ilToolbarGUI::setCloseFormTag (   $a_val)

Set close form tag.

Parameters
boolean$a_valclose form tag

Definition at line 369 of file class.ilToolbarGUI.php.

370  {
371  $this->close_form_tag = $a_val;
372  }

◆ setFormAction()

ilToolbarGUI::setFormAction (   $a_val,
  $a_multipart = false,
  $a_target = "" 
)

Set form action (if form action is set, toolbar is wrapped into form tags)

Parameters
string$a_valform action
bool$a_multipart
string$a_target

Definition at line 110 of file class.ilToolbarGUI.php.

Referenced by ilTestRandomQuestionSetSourcePoolDefinitionListToolbarGUI\build(), and ilTestSkillEvaluationToolbarGUI\build().

111  {
112  $this->form_action = $a_val;
113  $this->multipart = $a_multipart;
114  $this->form_target = $a_target;
115  }
+ Here is the caller graph for this function:

◆ setFormName()

ilToolbarGUI::setFormName (   $a_val)

Set form name.

Parameters
string$a_valform name

Definition at line 389 of file class.ilToolbarGUI.php.

390  {
391  $this->form_name = $a_val;
392  }

◆ setHidden()

ilToolbarGUI::setHidden (   $a_val)

Set hidden.

Parameters
boolean$a_valhidden

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

145  {
146  $this->hidden = $a_val;
147  }

◆ setId()

ilToolbarGUI::setId (   $a_val)

Set id.

Parameters
string$a_valid

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

Referenced by ilTestResultsToolbarGUI\build().

165  {
166  $this->id = $a_val;
167  }
+ Here is the caller graph for this function:

◆ setItems()

ilToolbarGUI::setItems (   $items)
Parameters
array$items

Definition at line 658 of file class.ilToolbarGUI.php.

References $items.

Referenced by ilTestInfoScreenToolbarGUI\clearItems().

659  {
660  $this->items = $items;
661  }
+ Here is the caller graph for this function:

◆ setLeadingImage()

ilToolbarGUI::setLeadingImage (   $a_img,
  $a_alt 
)

Set leading image.

Parameters
string$a_img
string$a_alt

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

References array.

135  {
136  $this->lead_img = array("img" => $a_img, "alt" => $a_alt);
137  }
Create styles array
The data for the language used.

◆ setOpenFormTag()

ilToolbarGUI::setOpenFormTag (   $a_val)

Set open form tag.

Parameters
boolean$a_valopen form tag

Definition at line 349 of file class.ilToolbarGUI.php.

350  {
351  $this->open_form_tag = $a_val;
352  }

◆ setPreventDoubleSubmission()

ilToolbarGUI::setPreventDoubleSubmission (   $a_val)

Set prevent double submission.

Parameters
bool$a_valprevent double submission

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

185  {
186  $this->prevent_double_submission = $a_val;
187  }

Field Documentation

◆ $close_form_tag

ilToolbarGUI::$close_form_tag = true
protected

Definition at line 66 of file class.ilToolbarGUI.php.

Referenced by getCloseFormTag().

◆ $form_action

ilToolbarGUI::$form_action = ''
protected

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

Referenced by getFormAction().

◆ $form_name

ilToolbarGUI::$form_name = ""
protected

Definition at line 76 of file class.ilToolbarGUI.php.

Referenced by getFormName().

◆ $form_target

ilToolbarGUI::$form_target = ""
protected

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

◆ $has_separator

ilToolbarGUI::$has_separator = false
protected

Definition at line 91 of file class.ilToolbarGUI.php.

◆ $hidden

ilToolbarGUI::$hidden
protected

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

Referenced by getHidden().

◆ $id

ilToolbarGUI::$id = ''
protected

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

◆ $instances

ilToolbarGUI::$instances = 0
staticprotected

Definition at line 28 of file class.ilToolbarGUI.php.

◆ $items

ilToolbarGUI::$items = array()

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

Referenced by getItems(), and setItems().

◆ $lead_img

ilToolbarGUI::$lead_img
protected
Initial value:
'img' => '',
'alt' => '',
)

Definition at line 53 of file class.ilToolbarGUI.php.

◆ $lng

ilToolbarGUI::$lng
protected

Definition at line 22 of file class.ilToolbarGUI.php.

Referenced by getGroupedItems().

◆ $open_form_tag

ilToolbarGUI::$open_form_tag = true
protected

Definition at line 61 of file class.ilToolbarGUI.php.

Referenced by getOpenFormTag().

◆ $prevent_double_submission

ilToolbarGUI::$prevent_double_submission = false
protected

Definition at line 81 of file class.ilToolbarGUI.php.

Referenced by getPreventDoubleSubmission().

◆ $sticky_items

ilToolbarGUI::$sticky_items = array()
protected

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


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