ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
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...
 
 addButtonInstance (ilButton $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...
 
 getHTML ()
 Get toolbar html. More...
 

Data Fields

 $items = array()
 
 $open_form_tag = true
 
 $close_form_tag = true
 
 $form_target = ""
 
 $form_name = ""
 

Protected Attributes

 $prevent_double_submission = false
 

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
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

ilToolbarGUI::__construct ( )

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

24  {
25 
26  }

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

Referenced by ilTestResultsToolbarGUI\build(), ilBookingScheduleGUI\render(), and ilBookingObjectGUI\render().

130  {
131  $this->items[] = array("type" => "button", "txt" => $a_txt, "cmd" => $a_cmd,
132  "target" => $a_target, "acc_key" => $a_acc_key, 'add_attrs' => $a_additional_attrs,
133  "id" => $a_id, "class" => $a_class);
134  }
+ Here is the caller graph for this function:

◆ addButtonInstance()

ilToolbarGUI::addButtonInstance ( ilButton  $a_button)

Add button instance.

Parameters
ilButton$a_button

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

Referenced by ilTestResultsToolbarGUI\build().

167  {
168  $this->items[] = array("type" => "button_obj", "instance" => $a_button);
169  }
+ Here is the caller graph for this function:

◆ addDropDown()

ilToolbarGUI::addDropDown (   $a_txt,
  $a_dd_html 
)

Add input item.

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

176  {
177  $this->items[] = array("type" => "dropdown", "txt" => $a_txt, "dd_html" => $a_dd_html);
178  }

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

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

148  {
149  $this->items[] = array("type" => "fbutton", "txt" => $a_txt, "cmd" => $a_cmd,
150  "acc_key" => $a_acc_key, "primary" => $a_primary, "class" => $a_class);
151  }
+ Here is the caller graph for this function:

◆ addInputItem()

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

Add input item.

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

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

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

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

◆ addSeparator()

ilToolbarGUI::addSeparator ( )

Add separator.

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

Referenced by ilTestResultsToolbarGUI\build().

185  {
186  $this->items[] = array("type" => "separator");
187  }
+ Here is the caller graph for this function:

◆ addSpacer()

ilToolbarGUI::addSpacer (   $a_width = null)

Add spacer.

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

201  {
202  $this->items[] = array("type" => "spacer", "width" => $a_width);
203  }

◆ addText()

ilToolbarGUI::addText (   $a_text)

Add text.

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

Referenced by ilDidacticTemplateGUI\appendToolbarSwitch().

193  {
194  $this->items[] = array("type" => "text", "text" => $a_text);
195  }
+ Here is the caller graph for this function:

◆ getCloseFormTag()

ilToolbarGUI::getCloseFormTag ( )

Get close form tag.

Returns
boolean close form tag

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

References $close_form_tag.

Referenced by getHTML().

254  {
255  return $this->close_form_tag;
256  }
+ Here is the caller graph for this function:

◆ getFormAction()

ilToolbarGUI::getFormAction ( )

Get form action.

Returns
string form action

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

Referenced by getHTML().

46  {
47  return $this->form_action;
48  }
+ Here is the caller graph for this function:

◆ getFormName()

ilToolbarGUI::getFormName ( )

Get form name.

Returns
string form name

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

References $form_name.

Referenced by getHTML().

274  {
275  return $this->form_name;
276  }
+ Here is the caller graph for this function:

◆ getHidden()

ilToolbarGUI::getHidden ( )

Get hidden.

Returns
boolean hidden

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

Referenced by getHTML().

74  {
75  return $this->hidden;
76  }
+ Here is the caller graph for this function:

◆ getHTML()

ilToolbarGUI::getHTML ( )

Get toolbar html.

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

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

282  {
283  global $lng;
284 
285  $tpl = new ilTemplate("tpl.toolbar.html", true, true, "Services/UIComponent/Toolbar");
286  if (count($this->items) > 0)
287  {
288  foreach($this->items as $item)
289  {
290  switch ($item["type"])
291  {
292  case "button":
293  $tpl->setCurrentBlock("button");
294  $tpl->setVariable("BTN_TXT", $item["txt"]);
295  $tpl->setVariable("BTN_LINK", $item["cmd"]);
296  if ($item["target"] != "")
297  {
298  $tpl->setVariable("BTN_TARGET", 'target="'.$item["target"].'"');
299  }
300  if ($item["id"] != "")
301  {
302  $tpl->setVariable("BID", 'id="'.$item["id"].'"');
303  }
304  if ($item["acc_key"] != "")
305  {
306  include_once("./Services/Accessibility/classes/class.ilAccessKeyGUI.php");
307  $tpl->setVariable("BTN_ACC_KEY",
308  ilAccessKeyGUI::getAttribute($item["acc_key"]));
309  }
310  if(($item['add_attrs']))
311  {
312  $tpl->setVariable('BTN_ADD_ARG',$item['add_attrs']);
313  }
314  $tpl->setVariable('BTN_CLASS',$item['class']);
315  $tpl->parseCurrentBlock();
316  $tpl->touchBlock("item");
317  break;
318 
319  case "fbutton":
320  $tpl->setCurrentBlock("form_button");
321  $tpl->setVariable("SUB_TXT", $item["txt"]);
322  $tpl->setVariable("SUB_CMD", $item["cmd"]);
323  if($item["primary"])
324  {
325  $tpl->setVariable("SUB_CLASS", " emphsubmit");
326  }
327  else if($item["class"])
328  {
329  $tpl->setVariable("SUB_CLASS", " ".$item["class"]);
330  }
331  $tpl->parseCurrentBlock();
332  $tpl->touchBlock("item");
333  break;
334 
335  case "button_obj":
336  $tpl->setCurrentBlock("button_instance");
337  $tpl->setVariable("BUTTON_OBJ", $item["instance"]->render());
338  $tpl->parseCurrentBlock();
339  $tpl->touchBlock("item");
340  break;
341 
342  case "input":
343  if ($item["label"])
344  {
345  $tpl->setCurrentBlock("input_label");
346  $tpl->setVariable("TXT_INPUT", $item["input"]->getTitle());
347  $tpl->parseCurrentBlock();
348  }
349  $tpl->setCurrentBlock("input");
350  $tpl->setVariable("INPUT_HTML", $item["input"]->getToolbarHTML());
351  $tpl->parseCurrentBlock();
352  $tpl->touchBlock("item");
353  break;
354 
355  // bs-patch start
356  case "dropdown":
357  $tpl->setCurrentBlock("dropdown");
358  $tpl->setVariable("TXT_DROPDOWN", $item["txt"]);
359  $tpl->setVariable("DROP_DOWN", $item["dd_html"]);
360  $tpl->parseCurrentBlock();
361  $tpl->touchBlock("item");
362  break;
363  // bs-patch end
364 
365 
366  case "separator":
367  $tpl->touchBlock("separator");
368  $tpl->touchBlock("item");
369  break;
370 
371  case "text":
372  $tpl->setCurrentBlock("text");
373  $tpl->setVariable("VAL_TEXT", $item["text"]);
374  $tpl->touchBlock("item");
375  break;
376 
377  case "spacer":
378  $tpl->touchBlock("spacer");
379  if(!$item["width"])
380  {
381  $item["width"] = 2;
382  }
383  $tpl->setVariable("SPACER_WIDTH", $item["width"]);
384  $tpl->touchBlock("item");
385  break;
386 
387  case "link":
388  if ($item["disabled"] == false) {
389  $tpl->setCurrentBlock("link");
390  $tpl->setVariable("LINK_TXT", $item["txt"]);
391  $tpl->setVariable("LINK_URL", $item["cmd"]);
392  $tpl->parseCurrentBlock();
393  $tpl->touchBlock("item");
394  break;
395  }
396  else {
397  $tpl->setCurrentBlock("link_disabled");
398  $tpl->setVariable("LINK_DISABLED_TXT", $item["txt"]);
399  //$tpl->setVariable("LINK_URL", $item["cmd"]);
400  $tpl->parseCurrentBlock();
401  $tpl->touchBlock("item");
402  break;
403  }
404  }
405  }
406 
407  $tpl->setVariable("TXT_FUNCTIONS", $lng->txt("functions"));
408  if ($this->lead_img["img"] != "")
409  {
410  $tpl->setCurrentBlock("lead_image");
411  $tpl->setVariable("IMG_SRC", $this->lead_img["img"]);
412  $tpl->setVariable("IMG_ALT", $this->lead_img["alt"]);
413  $tpl->parseCurrentBlock();
414  }
415 
416  // form?
417  if ($this->getFormAction() != "")
418  {
419  if ($this->getOpenFormTag())
420  {
421  $tpl->setCurrentBlock("form_open");
422  $tpl->setVariable("FORMACTION", $this->getFormAction());
423  if($this->getPreventDoubleSubmission())
424  {
425  $tpl->setVariable("FORM_CLASS", "preventDoubleSubmission");
426  }
427  if ($this->multipart)
428  {
429  $tpl->setVariable("ENC_TYPE", 'enctype="multipart/form-data"');
430  }
431  if ($this->form_target != "")
432  {
433  $tpl->setVariable("TARGET", ' target="'.$this->form_target.'" ');
434  }
435  if ($this->form_name != "")
436  {
437  $tpl->setVariable("FORMNAME", 'name="'.$this->getFormName().'"');
438  }
439 
440  $tpl->parseCurrentBlock();
441  }
442  if ($this->getCloseFormTag())
443  {
444  $tpl->touchBlock("form_close");
445  }
446  }
447 
448  // id
449  if ($this->getId() != "")
450  {
451  $tpl->setVariable("ID", ' id="'.$this->getId().'" ');
452  }
453 
454  // hidden style
455  if ($this->getHidden())
456  {
457  $tpl->setVariable("HIDDEN_CLASS", 'ilNoDisplay');
458  }
459 
460  return $tpl->get();
461  }
462  return "";
463  }
getFormName()
Get form name.
global $tpl
Definition: ilias.php:8
special template class to simplify handling of ITX/PEAR
getOpenFormTag()
Get open form tag.
global $lng
Definition: privfeed.php:40
getPreventDoubleSubmission()
Get prevent double submission.
getFormAction()
Get form action.
getCloseFormTag()
Get close form tag.
static getAttribute($a_func_id)
Get accesskey HTML attribute.
getHidden()
Get hidden.
+ Here is the call graph for this function:

◆ getId()

ilToolbarGUI::getId ( )

Get id.

Returns
string id

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

Referenced by getHTML().

94  {
95  return $this->id;
96  }
+ Here is the caller graph for this function:

◆ getOpenFormTag()

ilToolbarGUI::getOpenFormTag ( )

Get open form tag.

Returns
boolean open form tag

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

References $open_form_tag.

Referenced by getHTML().

234  {
235  return $this->open_form_tag;
236  }
+ Here is the caller graph for this function:

◆ getPreventDoubleSubmission()

ilToolbarGUI::getPreventDoubleSubmission ( )

Get prevent double submission.

Returns
bool prevent double submission

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

References $prevent_double_submission.

Referenced by getHTML().

114  {
116  }
+ Here is the caller graph for this function:

◆ setCloseFormTag()

ilToolbarGUI::setCloseFormTag (   $a_val)

Set close form tag.

Parameters
booleanclose form tag

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

244  {
245  $this->close_form_tag = $a_val;
246  }

◆ 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
stringform action

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

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

34  {
35  $this->form_action = $a_val;
36  $this->multipart = $a_multipart;
37  $this->form_target = $a_target;
38  }
+ Here is the caller graph for this function:

◆ setFormName()

ilToolbarGUI::setFormName (   $a_val)

Set form name.

Parameters
stringform name

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

264  {
265  $this->form_name = $a_val;
266  }

◆ setHidden()

ilToolbarGUI::setHidden (   $a_val)

Set hidden.

Parameters
boolean$a_valhidden

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

64  {
65  $this->hidden = $a_val;
66  }

◆ setId()

ilToolbarGUI::setId (   $a_val)

Set id.

Parameters
string$a_valid

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

Referenced by ilTestResultsToolbarGUI\build().

84  {
85  $this->id = $a_val;
86  }
+ Here is the caller graph for this function:

◆ setLeadingImage()

ilToolbarGUI::setLeadingImage (   $a_img,
  $a_alt 
)

Set leading image.

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

54  {
55  $this->lead_img = array("img" => $a_img, "alt" => $a_alt);
56  }

◆ setOpenFormTag()

ilToolbarGUI::setOpenFormTag (   $a_val)

Set open form tag.

Parameters
booleanopen form tag

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

224  {
225  $this->open_form_tag = $a_val;
226  }

◆ setPreventDoubleSubmission()

ilToolbarGUI::setPreventDoubleSubmission (   $a_val)

Set prevent double submission.

Parameters
bool$a_valprevent double submission

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

104  {
105  $this->prevent_double_submission = $a_val;
106  }

Field Documentation

◆ $close_form_tag

ilToolbarGUI::$close_form_tag = true

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

Referenced by getCloseFormTag().

◆ $form_name

ilToolbarGUI::$form_name = ""

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

Referenced by getFormName().

◆ $form_target

ilToolbarGUI::$form_target = ""

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

◆ $items

ilToolbarGUI::$items = array()

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

◆ $open_form_tag

ilToolbarGUI::$open_form_tag = true

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

Referenced by getOpenFormTag().

◆ $prevent_double_submission

ilToolbarGUI::$prevent_double_submission = false
protected

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

Referenced by getPreventDoubleSubmission().


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