2 require_once(
'./Services/UIComponent/Button/classes/class.ilSubmitButton.php');
3 require_once(
'./Services/UIComponent/Button/classes/class.ilLinkButton.php');
102 $this->form_action = $a_val;
103 $this->multipart = $a_multipart;
104 $this->form_target = $a_target;
126 $this->lead_img =
array(
"img" => $a_img,
"alt" => $a_alt);
136 $this->hidden = $a_val;
166 return $this->
id ? $this->id : self::$instances;
176 $this->prevent_double_submission = $a_val;
199 public function addButton($a_txt, $a_cmd, $a_target =
"", $a_acc_key =
"", $a_additional_attrs =
'',
200 $a_id =
"", $a_class =
'submit')
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);
218 function addFormButton($a_txt, $a_cmd, $a_acc_key =
"", $a_primary =
false, $a_class =
false)
222 $button->setPrimary(
true);
223 $button->setCaption($a_txt,
false);
224 $button->setCommand($a_cmd);
225 $button->setAccessKey($a_acc_key);
228 $this->items[] =
array(
"type" =>
"fbutton",
"txt" => $a_txt,
"cmd" => $a_cmd,
229 "acc_key" => $a_acc_key,
"primary" => $a_primary,
"class" => $a_class);
242 $this->items[] =
array(
"type" =>
"input",
"input" => $a_item,
"label" => $a_output_label);
255 $this->sticky_items[] =
array(
"item"=>$a_item,
"label"=>$a_output_label);
269 $this->items[] =
array(
"type" =>
"button_obj",
"instance" => $a_button);
279 $this->items[] =
array(
"type" =>
"dropdown",
"txt" => $a_txt,
"dd_html" => $a_dd_html);
288 $this->items[] =
array(
"type" =>
"separator");
289 $this->has_separator =
true;
297 $this->items[] =
array(
"type" =>
"text",
"text" => $a_text);
305 $this->items[] =
array(
"type" =>
"spacer",
"width" => $a_width);
316 public function addLink($a_caption, $a_url, $a_disabled =
false)
318 $this->items[] =
array(
"type" =>
"link",
"txt" => $a_caption,
"cmd" => $a_url,
"disabled" => $a_disabled);
328 $this->open_form_tag = $a_val;
348 $this->close_form_tag = $a_val;
368 $this->form_name = $a_val;
391 foreach ($this->items as $item) {
392 if ($item[
'type'] ==
'separator') {
409 public function getHTML()
415 if (count($this->items) || count($this->sticky_items))
417 $tpl =
new ilTemplate(
"tpl.toolbar.html",
true,
true,
"Services/UIComponent/Toolbar");
418 $tpl->setVariable(
'TOOLBAR_ID', $this->
getId());
419 if (count($this->sticky_items)) {
420 $tpl_sticky =
new ilTemplate(
"tpl.toolbar_sticky_items.html",
true,
true,
"Services/UIComponent/Toolbar");
422 foreach ($this->sticky_items as $sticky_item)
424 if($sticky_item[
'label'])
426 $tpl_sticky->setCurrentBlock(
'input_label');
427 $tpl_sticky->setVariable(
'TXT_INPUT', $sticky_item[
'item']->getTitle());
428 $tpl_sticky->parseCurrentBlock();
430 $tpl_sticky->setCurrentBlock(
'sticky_item');
431 $tpl_sticky->setVariable(
'STICKY_ITEM_HTML', $sticky_item[
'item']->getToolbarHTML());
432 $tpl_sticky->parseCurrentBlock();
434 $tpl->setCurrentBlock(
'sticky_items');
435 $tpl->setVariable(
'STICKY_ITEMS', $tpl_sticky->get());
436 $tpl->parseCurrentBlock();
440 if (count($this->items) == 0) {
441 $tpl->setVariable(
'HIDE_TOGGLE_CLASS',
' hidden');
447 $tpl_items =
new ilTemplate(
"tpl.toolbar_items.html",
true,
true,
"Services/UIComponent/Toolbar");
449 static $tpl_separator;
450 if ($tpl_separator === null) {
451 $tpl_separator =
new ilTemplate(
'tpl.toolbar_separator.html',
true,
true,
'Services/UIComponent/Toolbar');
453 $tpl_separator->touchBlock(
'separator');
454 $markup_items .= $tpl_separator->get();
456 foreach ($group as $item) {
457 switch ($item[
"type"])
460 $tpl_items->setCurrentBlock(
"button");
461 $tpl_items->setVariable(
"BTN_TXT", $item[
"txt"]);
462 $tpl_items->setVariable(
"BTN_LINK", $item[
"cmd"]);
463 if ($item[
"target"] !=
"")
465 $tpl_items->setVariable(
"BTN_TARGET",
'target="'.$item[
"target"].
'"');
467 if ($item[
"id"] !=
"")
469 $tpl_items->setVariable(
"BID",
'id="'.$item[
"id"].
'"');
471 if ($item[
"acc_key"] !=
"")
473 include_once(
"./Services/Accessibility/classes/class.ilAccessKeyGUI.php");
474 $tpl_items->setVariable(
"BTN_ACC_KEY",
477 if(($item[
'add_attrs']))
479 $tpl_items->setVariable(
'BTN_ADD_ARG',$item[
'add_attrs']);
481 $tpl_items->setVariable(
'BTN_CLASS',$item[
'class']);
482 $tpl_items->parseCurrentBlock();
483 $tpl_items->touchBlock(
"item");
487 $tpl_items->setCurrentBlock(
"form_button");
488 $tpl_items->setVariable(
"SUB_TXT", $item[
"txt"]);
489 $tpl_items->setVariable(
"SUB_CMD", $item[
"cmd"]);
492 $tpl_items->setVariable(
"SUB_CLASS",
" emphsubmit");
494 else if($item[
"class"])
496 $tpl_items->setVariable(
"SUB_CLASS",
" ".$item[
"class"]);
498 $tpl_items->parseCurrentBlock();
499 $tpl_items->touchBlock(
"item");
503 $tpl_items->setCurrentBlock(
"button_instance");
504 $tpl_items->setVariable(
"BUTTON_OBJ", $item[
"instance"]->render());
505 $tpl_items->parseCurrentBlock();
506 $tpl_items->touchBlock(
"item");
512 $tpl_items->setCurrentBlock(
"input_label");
513 $tpl_items->setVariable(
"TXT_INPUT", $item[
"input"]->getTitle());
514 $tpl_items->parseCurrentBlock();
516 $tpl_items->setCurrentBlock(
"input");
517 $tpl_items->setVariable(
"INPUT_HTML", $item[
"input"]->getToolbarHTML());
518 $tpl_items->parseCurrentBlock();
519 $tpl_items->touchBlock(
"item");
524 $tpl_items->setCurrentBlock(
"dropdown");
525 $tpl_items->setVariable(
"TXT_DROPDOWN", $item[
"txt"]);
526 $tpl_items->setVariable(
"DROP_DOWN", $item[
"dd_html"]);
527 $tpl_items->parseCurrentBlock();
528 $tpl_items->touchBlock(
"item");
532 $tpl_items->setCurrentBlock(
"text");
533 $tpl_items->setVariable(
"VAL_TEXT", $item[
"text"]);
534 $tpl_items->touchBlock(
"item");
538 $tpl_items->touchBlock(
"spacer");
543 $tpl_items->setVariable(
"SPACER_WIDTH", $item[
"width"]);
544 $tpl_items->touchBlock(
"item");
548 if ($item[
"disabled"] ==
false) {
549 $tpl_items->setCurrentBlock(
"link");
550 $tpl_items->setVariable(
"LINK_TXT", $item[
"txt"]);
551 $tpl_items->setVariable(
"LINK_URL", $item[
"cmd"]);
552 $tpl_items->parseCurrentBlock();
553 $tpl_items->touchBlock(
"item");
557 $tpl_items->setCurrentBlock(
"link_disabled");
558 $tpl_items->setVariable(
"LINK_DISABLED_TXT", $item[
"txt"]);
560 $tpl_items->parseCurrentBlock();
561 $tpl_items->touchBlock(
"item");
566 $li = (count($group) > 1) ?
"<li class='ilToolbarGroup'>" :
"<li>";
567 $markup_items .=
$li . $tpl_items->get() .
'</li>';
570 $tpl->setVariable(
'ITEMS', $markup_items);
571 $tpl->setVariable(
"TXT_FUNCTIONS", $lng->txt(
"functions"));
572 if ($this->lead_img[
"img"] !=
"")
574 $tpl->setCurrentBlock(
"lead_image");
575 $tpl->setVariable(
"IMG_SRC", $this->lead_img[
"img"]);
576 $tpl->setVariable(
"IMG_ALT", $this->lead_img[
"alt"]);
577 $tpl->parseCurrentBlock();
584 $GLOBALS[
"tpl"]->addJavaScript(
"Services/Form/js/Form.js");
588 $tpl->setCurrentBlock(
"form_open");
592 $tpl->setVariable(
"FORM_CLASS",
"preventDoubleSubmission");
594 if ($this->multipart)
596 $tpl->setVariable(
"ENC_TYPE",
'enctype="multipart/form-data"');
598 if ($this->form_target !=
"")
600 $tpl->setVariable(
"TARGET",
' target="'.$this->form_target.
'" ');
602 if ($this->form_name !=
"")
607 $tpl->parseCurrentBlock();
611 $tpl->touchBlock(
"form_close");
616 if ($this->
getId() !=
"")
618 $tpl->setVariable(
"ID",
' id="'.$this->
getId().
'" ');
624 $tpl->setVariable(
"HIDDEN_CLASS",
'ilNoDisplay');
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)) {
665 switch ($item[
'type']) {
667 $button = $item[
'instance'];
671 $button->setPrimary($item[
'primary']);
672 $button->setCaption($item[
'txt'],
false);
673 $button->setCommand($item[
'cmd']);
674 $button->setAccessKey($item[
'acc_key']);
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']);
686 $this->items =
array();
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
special template class to simplify handling of ITX/PEAR
Create styles array
The data for the language used.
static getAttribute($a_func_id)
Get accesskey HTML attribute.