ILIAS  release_7 Revision v7.30-3-g800a261c036
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 Dropdown. More...
 
 addAdvancedSelectionList (ilAdvancedSelectionListGUI $adv)
 
 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, and ui().

94  {
95  global $DIC;
96  $this->lng = $DIC->language();
97 
98  $this->ui = $DIC->ui();
99 
100  self::$instances++;
101  }
global $DIC
Definition: goto.php:24
ui()
Definition: ui.php:5
+ Here is the call graph for this function:

Member Function Documentation

◆ addAdvancedSelectionList()

ilToolbarGUI::addAdvancedSelectionList ( ilAdvancedSelectionListGUI  $adv)
Parameters
ilAdvancedSelectionListGUI$adv

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

301  {
302  $this->items[] = array("type" => "adv_sel_list", "list" => $adv);
303  }

◆ 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.

Referenced by ilTestResultsToolbarGUI\build(), ilObjStudyProgrammeMembersGUI\initMailToMemberButton(), ilObjTestGUI\populateQuestionBrowserToolbarButtons(), ilBookingScheduleGUI\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  }
+ 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(), and ilButtonBase\isPrimary().

Referenced by ilParticipantsTestResultsGUI\addDeleteAllTestResultsButton(), ilTestParticipantsGUI\addFinishAllPassesButton(), ilTestNavigationToolbarGUI\addFinishTestButton(), ilTestNavigationToolbarGUI\addQuestionListButton(), ilTestNavigationToolbarGUI\addQuestionSelectionButton(), ilTestNavigationToolbarGUI\addQuestionTreeButton(), ilTestNavigationToolbarGUI\addSuspendTestButton(), ilTestParticipantsGUI\addUserSearchControls(), ilAssQuestionPreviewToolbarGUI\build(), and ilTestResultsToolbarGUI\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.
+ 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 334 of file class.ilToolbarGUI.php.

335  {
336  $this->items[] = array("type" => "component", "component" => $a_comp);
337  }

◆ addDropDown()

ilToolbarGUI::addDropDown (   $a_txt,
  $a_dd_html 
)

Add Dropdown.

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

293  {
294  $this->items[] = array("type" => "dropdown", "txt" => $a_txt, "dd_html" => $a_dd_html);
295  }

◆ 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(), and ilSubmitButton\getInstance().

Referenced by ilDidacticTemplateGUI\appendToolbarSwitch(), ilAssQuestionPreviewToolbarGUI\build(), ilTestSkillEvaluationToolbarGUI\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.
+ 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.

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

257  {
258  $this->items[] = array("type" => "input", "input" => $a_item, "label" => $a_output_label);
259  }
+ 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 346 of file class.ilToolbarGUI.php.

347  {
348  $this->items[] = array("type" => "link", "txt" => $a_caption, "cmd" => $a_url, "disabled" => $a_disabled);
349  }

◆ addSeparator()

ilToolbarGUI::addSeparator ( )

Add separator.

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

Referenced by ilTestParticipantsGUI\addUserSearchControls(), ilTestResultsToolbarGUI\build(), ilTestInfoScreenToolbarGUI\build(), ilObjStudyProgrammeMembersGUI\initMailToMemberButton(), ilMembershipGUI\showMailToMemberToolbarButton(), and ilMembershipGUI\showMemberExportToolbarButton().

310  {
311  $this->items[] = array("type" => "separator");
312  $this->has_separator = true;
313  }
+ Here is the caller graph for this function:

◆ addSpacer()

ilToolbarGUI::addSpacer (   $a_width = null)

Add spacer.

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

327  {
328  $this->items[] = array("type" => "spacer", "width" => $a_width);
329  }

◆ 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.

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

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

◆ addText()

ilToolbarGUI::addText (   $a_text)

Add text.

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

Referenced by ilDidacticTemplateGUI\appendToolbarSwitch().

319  {
320  $this->items[] = array("type" => "text", "text" => $a_text);
321  }
+ 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 685 of file class.ilToolbarGUI.php.

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

Referenced by getGroupedItems().

686  {
687  if (count($this->items) == 1 && count($this->sticky_items) == 0) {
688  $supported_types = array('button', 'fbutton', 'button_obj');
689  $item = $this->items[0];
690  if (!in_array($item['type'], $supported_types)) {
691  return;
692  }
693  $button = null;
694  switch ($item['type']) {
695  case 'button_obj':
696  $button = $item['instance'];
697  break;
698  case 'fbutton':
699  $button = ilSubmitButton::getInstance();
700  $button->setPrimary($item['primary']);
701  $button->setCaption($item['txt'], false);
702  $button->setCommand($item['cmd']);
703  $button->setAccessKey($item['acc_key']);
704  break;
705  case 'button':
706  $button = ilLinkButton::getInstance();
707  $button->setCaption($item['txt'], false);
708  $button->setUrl($item['cmd']);
709  $button->setTarget($item['target']);
710  $button->setId($item['id']);
711  $button->setAccessKey($item['acc_key']);
712  break;
713  }
714  $this->addStickyItem($button);
715  $this->items = array();
716  }
717  }
addStickyItem($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 386 of file class.ilToolbarGUI.php.

References $close_form_tag.

Referenced by getGroupedItems().

387  {
388  return $this->close_form_tag;
389  }
+ 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 406 of file class.ilToolbarGUI.php.

References $form_name.

Referenced by getGroupedItems().

407  {
408  return $this->form_name;
409  }
+ Here is the caller graph for this function:

◆ getGroupedItems()

ilToolbarGUI::getGroupedItems ( )

Get all groups (items separated by a separator)

Returns
array

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

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

418  {
419  $groups = array();
420  $group = array();
421  foreach ($this->items as $item) {
422  if ($item['type'] == 'separator') {
423  $groups[] = $group;
424  $group = array();
425  } else {
426  $group[] = $item;
427  }
428  }
429  if (count($group)) {
430  $groups[] = $group;
431  }
432 
433  return $groups;
434  }
+ 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.

References ILIAS\GlobalScreen\Provider\id().

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

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

◆ getItems()

ilToolbarGUI::getItems ( )
Returns
array

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

References $items.

Referenced by ilTestInfoScreenToolbarGUI\build().

666  {
667  return $this->items;
668  }
+ Here is the caller graph for this function:

◆ getOpenFormTag()

ilToolbarGUI::getOpenFormTag ( )

Get open form tag.

Returns
boolean open form tag

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

References $open_form_tag.

Referenced by getGroupedItems().

367  {
368  return $this->open_form_tag;
369  }
+ 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 376 of file class.ilToolbarGUI.php.

377  {
378  $this->close_form_tag = $a_val;
379  }

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

397  {
398  $this->form_name = $a_val;
399  }

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

References $items.

Referenced by ilTestInfoScreenToolbarGUI\clearItems().

675  {
676  $this->items = $items;
677  }
+ 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.

135  {
136  $this->lead_img = array("img" => $a_img, "alt" => $a_alt);
137  }

◆ setOpenFormTag()

ilToolbarGUI::setOpenFormTag (   $a_val)

Set open form tag.

Parameters
boolean$a_valopen form tag

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

357  {
358  $this->open_form_tag = $a_val;
359  }

◆ 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:
= array(
'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: