ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 (ilToolbarItem $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...
 
 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

 $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 88 of file class.ilToolbarGUI.php.

89  {
90  self::$instances++;
91  }

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 199 of file class.ilToolbarGUI.php.

References array.

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

201  {
202  $this->items[] = array("type" => "button", "txt" => $a_txt, "cmd" => $a_cmd,
203  "target" => $a_target, "acc_key" => $a_acc_key, 'add_attrs' => $a_additional_attrs,
204  "id" => $a_id, "class" => $a_class);
205  }
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 264 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().

265  {
266  if ($a_button->isPrimary()) {
267  $this->addStickyItem($a_button);
268  } else {
269  $this->items[] = array("type" => "button_obj", "instance" => $a_button);
270  }
271  }
isPrimary()
Get primary status.
Create styles array
The data for the language used.
addStickyItem(ilToolbarItem $a_item, $a_output_label=false)
Add a sticky item.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addDropDown()

ilToolbarGUI::addDropDown (   $a_txt,
  $a_dd_html 
)

Add input item.

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

References array.

278  {
279  $this->items[] = array("type" => "dropdown", "txt" => $a_txt, "dd_html" => $a_dd_html);
280  }
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 218 of file class.ilToolbarGUI.php.

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

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

219  {
220  if ($a_primary) {
221  $button = ilSubmitButton::getInstance();
222  $button->setPrimary(true);
223  $button->setCaption($a_txt, false);
224  $button->setCommand($a_cmd);
225  $button->setAccessKey($a_acc_key);
226  $this->addStickyItem($button);
227  } else {
228  $this->items[] = array("type" => "fbutton", "txt" => $a_txt, "cmd" => $a_cmd,
229  "acc_key" => $a_acc_key, "primary" => $a_primary, "class" => $a_class);
230  }
231  }
Create styles array
The data for the language used.
addStickyItem(ilToolbarItem $a_item, $a_output_label=false)
Add a sticky item.
+ 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 240 of file class.ilToolbarGUI.php.

References array.

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

241  {
242  $this->items[] = array("type" => "input", "input" => $a_item, "label" => $a_output_label);
243  }
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 316 of file class.ilToolbarGUI.php.

References array.

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

◆ addSeparator()

ilToolbarGUI::addSeparator ( )

Add separator.

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

References array.

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

287  {
288  $this->items[] = array("type" => "separator");
289  $this->has_separator = true;
290  }
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 303 of file class.ilToolbarGUI.php.

References array.

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

◆ addStickyItem()

ilToolbarGUI::addStickyItem ( ilToolbarItem  $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$a_item
bool$a_output_label

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

References array.

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

254  {
255  $this->sticky_items[] = array("item"=>$a_item, "label"=>$a_output_label);
256  }
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 295 of file class.ilToolbarGUI.php.

References array.

Referenced by ilDidacticTemplateGUI\appendToolbarSwitch().

296  {
297  $this->items[] = array("type" => "text", "text" => $a_text);
298  }
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 656 of file class.ilToolbarGUI.php.

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

Referenced by getGroupedItems().

657  {
658  if (count($this->items) == 1 && count($this->sticky_items) == 0) {
659  $supported_types = array('button', 'fbutton', 'button_obj');
660  $item = $this->items[0];
661  if (!in_array($item['type'], $supported_types)) {
662  return;
663  }
664  $button = null;
665  switch ($item['type']) {
666  case 'button_obj':
667  $button = $item['instance'];
668  break;
669  case 'fbutton':
670  $button = ilSubmitButton::getInstance();
671  $button->setPrimary($item['primary']);
672  $button->setCaption($item['txt'], false);
673  $button->setCommand($item['cmd']);
674  $button->setAccessKey($item['acc_key']);
675  break;
676  case 'button':
677  $button = ilLinkButton::getInstance();
678  $button->setCaption($item['txt'], false);
679  $button->setUrl($item['cmd']);
680  $button->setTarget($item['target']);
681  $button->setId($item['id']);
682  $button->setAccessKey($item['acc_key']);
683  break;
684  }
685  $this->addStickyItem($button);
686  $this->items = array();
687  }
688  }
Create styles array
The data for the language used.
addStickyItem(ilToolbarItem $a_item, $a_output_label=false)
Add a sticky item.
+ 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 356 of file class.ilToolbarGUI.php.

References $close_form_tag.

Referenced by getGroupedItems().

357  {
358  return $this->close_form_tag;
359  }
+ Here is the caller graph for this function:

◆ getFormAction()

ilToolbarGUI::getFormAction ( )

Get form action.

Returns
string form action

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

References $form_action.

Referenced by getGroupedItems().

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

◆ getFormName()

ilToolbarGUI::getFormName ( )

Get form name.

Returns
string form name

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

References $form_name.

Referenced by getGroupedItems().

377  {
378  return $this->form_name;
379  }
+ Here is the caller graph for this function:

◆ getGroupedItems()

ilToolbarGUI::getGroupedItems ( )

Get all groups (items separated by a separator)

Returns
array

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

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

388  {
389  $groups = array();
390  $group = array();
391  foreach ($this->items as $item) {
392  if ($item['type'] == 'separator') {
393  $groups[] = $group;
394  $group = array();
395  } else {
396  $group[] = $item;
397  }
398  }
399  if (count($group)) {
400  $groups[] = $group;
401  }
402 
403  return $groups;
404  }
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 144 of file class.ilToolbarGUI.php.

References $hidden.

Referenced by getGroupedItems().

145  {
146  return $this->hidden;
147  }
+ Here is the caller graph for this function:

◆ getId()

ilToolbarGUI::getId ( )

Get id.

Returns
string id

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

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

165  {
166  return $this->id ? $this->id : self::$instances;
167  }
+ Here is the caller graph for this function:

◆ getItems()

ilToolbarGUI::getItems ( )
Returns
array

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

References $items.

Referenced by ilTestInfoScreenToolbarGUI\build().

637  {
638  return $this->items;
639  }
+ Here is the caller graph for this function:

◆ getOpenFormTag()

ilToolbarGUI::getOpenFormTag ( )

Get open form tag.

Returns
boolean open form tag

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

References $open_form_tag.

Referenced by getGroupedItems().

337  {
338  return $this->open_form_tag;
339  }
+ Here is the caller graph for this function:

◆ getPreventDoubleSubmission()

ilToolbarGUI::getPreventDoubleSubmission ( )

Get prevent double submission.

Returns
bool prevent double submission

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

References $prevent_double_submission.

Referenced by getGroupedItems().

185  {
187  }
+ 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 346 of file class.ilToolbarGUI.php.

347  {
348  $this->close_form_tag = $a_val;
349  }

◆ 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 100 of file class.ilToolbarGUI.php.

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

101  {
102  $this->form_action = $a_val;
103  $this->multipart = $a_multipart;
104  $this->form_target = $a_target;
105  }
+ Here is the caller graph for this function:

◆ setFormName()

ilToolbarGUI::setFormName (   $a_val)

Set form name.

Parameters
string$a_valform name

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

367  {
368  $this->form_name = $a_val;
369  }

◆ setHidden()

ilToolbarGUI::setHidden (   $a_val)

Set hidden.

Parameters
boolean$a_valhidden

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

135  {
136  $this->hidden = $a_val;
137  }

◆ setId()

ilToolbarGUI::setId (   $a_val)

Set id.

Parameters
string$a_valid

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

Referenced by ilTestResultsToolbarGUI\build().

155  {
156  $this->id = $a_val;
157  }
+ Here is the caller graph for this function:

◆ setItems()

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

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

References $items.

Referenced by ilTestInfoScreenToolbarGUI\clearItems().

646  {
647  $this->items = $items;
648  }
+ 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 124 of file class.ilToolbarGUI.php.

References array.

125  {
126  $this->lead_img = array("img" => $a_img, "alt" => $a_alt);
127  }
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 326 of file class.ilToolbarGUI.php.

327  {
328  $this->open_form_tag = $a_val;
329  }

◆ setPreventDoubleSubmission()

ilToolbarGUI::setPreventDoubleSubmission (   $a_val)

Set prevent double submission.

Parameters
bool$a_valprevent double submission

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

175  {
176  $this->prevent_double_submission = $a_val;
177  }

Field Documentation

◆ $close_form_tag

ilToolbarGUI::$close_form_tag = true
protected

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

Referenced by getCloseFormTag().

◆ $form_action

ilToolbarGUI::$form_action = ''
protected

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

Referenced by getFormAction().

◆ $form_name

ilToolbarGUI::$form_name = ""
protected

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

Referenced by getFormName().

◆ $form_target

ilToolbarGUI::$form_target = ""
protected

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

◆ $has_separator

ilToolbarGUI::$has_separator = false
protected

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

◆ $hidden

ilToolbarGUI::$hidden
protected

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

Referenced by getHidden().

◆ $id

ilToolbarGUI::$id = ''
protected

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

◆ $instances

ilToolbarGUI::$instances = 0
staticprotected

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

◆ $items

ilToolbarGUI::$items = array()

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

Referenced by getItems(), and setItems().

◆ $lead_img

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

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

◆ $open_form_tag

ilToolbarGUI::$open_form_tag = true
protected

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

Referenced by getOpenFormTag().

◆ $prevent_double_submission

ilToolbarGUI::$prevent_double_submission = false
protected

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

Referenced by getPreventDoubleSubmission().

◆ $sticky_items

ilToolbarGUI::$sticky_items = array()
protected

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


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