ILIAS  release_4-4 Revision
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...
 
 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)
 Add form button to toolbar. More...
 
 addInputItem (ilToolbarItem $a_item, $a_output_label=false)
 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 = ""
 

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

22  {
23 
24  }

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.

Parameters
stringtext
stringlink href / submit command
stringframe target
stringaccess key

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

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

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

◆ addFormButton()

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

Add form button to toolbar.

Parameters
stringtext
stringlink href / submit command
stringaccess key

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

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

120  {
121  $this->items[] = array("type" => "fbutton", "txt" => $a_txt, "cmd" => $a_cmd,
122  "acc_key" => $a_acc_key, "primary" => $a_primary);
123  }
+ Here is the caller graph for this function:

◆ addInputItem()

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

Add input item.

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

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

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

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

◆ addSeparator()

ilToolbarGUI::addSeparator ( )

Add separator.

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

137  {
138  $this->items[] = array("type" => "separator");
139  }

◆ addSpacer()

ilToolbarGUI::addSpacer (   $a_width = null)

Add spacer.

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

153  {
154  $this->items[] = array("type" => "spacer", "width" => $a_width);
155  }

◆ addText()

ilToolbarGUI::addText (   $a_text)

Add text.

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

Referenced by ilDidacticTemplateGUI\appendToolbarSwitch().

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

◆ getCloseFormTag()

ilToolbarGUI::getCloseFormTag ( )

Get close form tag.

Returns
boolean close form tag

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

References $close_form_tag.

Referenced by getHTML().

206  {
207  return $this->close_form_tag;
208  }
+ Here is the caller graph for this function:

◆ getFormAction()

ilToolbarGUI::getFormAction ( )

Get form action.

Returns
string form action

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

Referenced by getHTML().

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

◆ getFormName()

ilToolbarGUI::getFormName ( )

Get form name.

Returns
string form name

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

References $form_name.

Referenced by getHTML().

226  {
227  return $this->form_name;
228  }
+ Here is the caller graph for this function:

◆ getHidden()

ilToolbarGUI::getHidden ( )

Get hidden.

Returns
boolean hidden

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

Referenced by getHTML().

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

◆ getHTML()

ilToolbarGUI::getHTML ( )

Get toolbar html.

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

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

234  {
235  global $lng;
236 
237  $tpl = new ilTemplate("tpl.toolbar.html", true, true, "Services/UIComponent/Toolbar");
238  if (count($this->items) > 0)
239  {
240  foreach($this->items as $item)
241  {
242  switch ($item["type"])
243  {
244  case "button":
245  $tpl->setCurrentBlock("button");
246  $tpl->setVariable("BTN_TXT", $item["txt"]);
247  $tpl->setVariable("BTN_LINK", $item["cmd"]);
248  if ($item["target"] != "")
249  {
250  $tpl->setVariable("BTN_TARGET", 'target="'.$item["target"].'"');
251  }
252  if ($item["id"] != "")
253  {
254  $tpl->setVariable("BID", 'id="'.$item["id"].'"');
255  }
256  if ($item["acc_key"] != "")
257  {
258  include_once("./Services/Accessibility/classes/class.ilAccessKeyGUI.php");
259  $tpl->setVariable("BTN_ACC_KEY",
260  ilAccessKeyGUI::getAttribute($item["acc_key"]));
261  }
262  if(($item['add_attrs']))
263  {
264  $tpl->setVariable('BTN_ADD_ARG',$item['add_attrs']);
265  }
266  $tpl->setVariable('BTN_CLASS',$item['class']);
267  $tpl->parseCurrentBlock();
268  $tpl->touchBlock("item");
269  break;
270 
271  case "fbutton":
272  $tpl->setCurrentBlock("form_button");
273  $tpl->setVariable("SUB_TXT", $item["txt"]);
274  $tpl->setVariable("SUB_CMD", $item["cmd"]);
275  if($item["primary"])
276  {
277  $tpl->setVariable("SUB_CLASS", " emphsubmit");
278  }
279  $tpl->parseCurrentBlock();
280  $tpl->touchBlock("item");
281  break;
282 
283  case "input":
284  if ($item["label"])
285  {
286  $tpl->setCurrentBlock("input_label");
287  $tpl->setVariable("TXT_INPUT", $item["input"]->getTitle());
288  $tpl->parseCurrentBlock();
289  }
290  $tpl->setCurrentBlock("input");
291  $tpl->setVariable("INPUT_HTML", $item["input"]->getToolbarHTML());
292  $tpl->parseCurrentBlock();
293  $tpl->touchBlock("item");
294  break;
295 
296  case "separator":
297  $tpl->touchBlock("separator");
298  $tpl->touchBlock("item");
299  break;
300 
301  case "text":
302  $tpl->setCurrentBlock("text");
303  $tpl->setVariable("VAL_TEXT", $item["text"]);
304  $tpl->touchBlock("item");
305  break;
306 
307  case "spacer":
308  $tpl->touchBlock("spacer");
309  if(!$item["width"])
310  {
311  $item["width"] = 2;
312  }
313  $tpl->setVariable("SPACER_WIDTH", $item["width"]);
314  $tpl->touchBlock("item");
315  break;
316 
317  case "link":
318  if ($item["disabled"] == false) {
319  $tpl->setCurrentBlock("link");
320  $tpl->setVariable("LINK_TXT", $item["txt"]);
321  $tpl->setVariable("LINK_URL", $item["cmd"]);
322  $tpl->parseCurrentBlock();
323  $tpl->touchBlock("item");
324  break;
325  }
326  else {
327  $tpl->setCurrentBlock("link_disabled");
328  $tpl->setVariable("LINK_DISABLED_TXT", $item["txt"]);
329  //$tpl->setVariable("LINK_URL", $item["cmd"]);
330  $tpl->parseCurrentBlock();
331  $tpl->touchBlock("item");
332  break;
333  }
334  }
335  }
336 
337  $tpl->setVariable("TXT_FUNCTIONS", $lng->txt("functions"));
338  if ($this->lead_img["img"] != "")
339  {
340  $tpl->setCurrentBlock("lead_image");
341  $tpl->setVariable("IMG_SRC", $this->lead_img["img"]);
342  $tpl->setVariable("IMG_ALT", $this->lead_img["alt"]);
343  $tpl->parseCurrentBlock();
344  }
345 
346  // form?
347  if ($this->getFormAction() != "")
348  {
349  if ($this->getOpenFormTag())
350  {
351  $tpl->setCurrentBlock("form_open");
352  $tpl->setVariable("FORMACTION", $this->getFormAction());
353  if ($this->multipart)
354  {
355  $tpl->setVariable("ENC_TYPE", 'enctype="multipart/form-data"');
356  }
357  if ($this->form_target != "")
358  {
359  $tpl->setVariable("TARGET", ' target="'.$this->form_target.'" ');
360  }
361  if ($this->form_name != "")
362  {
363  $tpl->setVariable("FORMNAME", 'name="'.$this->getFormName().'"');
364  }
365 
366  $tpl->parseCurrentBlock();
367  }
368  if ($this->getCloseFormTag())
369  {
370  $tpl->touchBlock("form_close");
371  }
372  }
373 
374  // id
375  if ($this->getId() != "")
376  {
377  $tpl->setVariable("ID", ' id="'.$this->getId().'" ');
378  }
379 
380  // hidden style
381  if ($this->getHidden())
382  {
383  $tpl->setVariable("STYLE", ' style="display:none;" ');
384  }
385 
386  return $tpl->get();
387  }
388  return "";
389  }
getFormName()
Get form name.
special template class to simplify handling of ITX/PEAR
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
getOpenFormTag()
Get open form tag.
global $lng
Definition: privfeed.php:40
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 91 of file class.ilToolbarGUI.php.

Referenced by getHTML().

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

◆ getOpenFormTag()

ilToolbarGUI::getOpenFormTag ( )

Get open form tag.

Returns
boolean open form tag

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

References $open_form_tag.

Referenced by getHTML().

186  {
187  return $this->open_form_tag;
188  }
+ Here is the caller graph for this function:

◆ setCloseFormTag()

ilToolbarGUI::setCloseFormTag (   $a_val)

Set close form tag.

Parameters
booleanclose form tag

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

196  {
197  $this->close_form_tag = $a_val;
198  }

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

Referenced by ilTestRandomQuestionSetSourcePoolDefinitionListToolbarGUI\build().

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

◆ setFormName()

ilToolbarGUI::setFormName (   $a_val)

Set form name.

Parameters
stringform name

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

216  {
217  $this->form_name = $a_val;
218  }

◆ setHidden()

ilToolbarGUI::setHidden (   $a_val)

Set hidden.

Parameters
boolean$a_valhidden

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

62  {
63  $this->hidden = $a_val;
64  }

◆ setId()

ilToolbarGUI::setId (   $a_val)

Set id.

Parameters
string$a_valid

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

82  {
83  $this->id = $a_val;
84  }

◆ setLeadingImage()

ilToolbarGUI::setLeadingImage (   $a_img,
  $a_alt 
)

Set leading image.

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

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

◆ setOpenFormTag()

ilToolbarGUI::setOpenFormTag (   $a_val)

Set open form tag.

Parameters
booleanopen form tag

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

176  {
177  $this->open_form_tag = $a_val;
178  }

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().


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