2 require_once(
'./Services/UIComponent/Button/classes/class.ilSubmitButton.php');
3 require_once(
'./Services/UIComponent/Button/classes/class.ilLinkButton.php');
96 $this->lng = $DIC->language();
98 $this->ui = $DIC->ui();
112 $this->form_action = $a_val;
113 $this->multipart = $a_multipart;
114 $this->form_target = $a_target;
136 $this->lead_img = array(
"img" => $a_img,
"alt" => $a_alt);
146 $this->hidden = $a_val;
176 return $this->
id ? $this->id : self::$instances;
186 $this->prevent_double_submission = $a_val;
214 $a_additional_attrs =
'',
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);
234 public function addFormButton($a_txt, $a_cmd, $a_acc_key =
"", $a_primary =
false, $a_class =
false)
238 $button->setPrimary(
true);
239 $button->setCaption($a_txt,
false);
240 $button->setCommand($a_cmd);
241 $button->setAccessKey($a_acc_key);
244 $this->items[] = array(
"type" =>
"fbutton",
"txt" => $a_txt,
"cmd" => $a_cmd,
245 "acc_key" => $a_acc_key,
"primary" => $a_primary,
"class" => $a_class);
258 $this->items[] = array(
"type" =>
"input",
"input" => $a_item,
"label" => $a_output_label);
271 $this->sticky_items[] = array(
"item" => $a_item,
"label" => $a_output_label);
285 $this->items[] = array(
"type" =>
"button_obj",
"instance" => $a_button);
295 $this->items[] = array(
"type" =>
"dropdown",
"txt" => $a_txt,
"dd_html" => $a_dd_html);
304 $this->items[] = array(
"type" =>
"separator");
305 $this->has_separator =
true;
313 $this->items[] = array(
"type" =>
"text",
"text" => $a_text);
321 $this->items[] = array(
"type" =>
"spacer",
"width" => $a_width);
329 $this->items[] = array(
"type" =>
"component",
"component" => $a_comp);
339 public function addLink($a_caption, $a_url, $a_disabled =
false)
341 $this->items[] = array(
"type" =>
"link",
"txt" => $a_caption,
"cmd" => $a_url,
"disabled" => $a_disabled);
351 $this->open_form_tag = $a_val;
371 $this->close_form_tag = $a_val;
391 $this->form_name = $a_val;
414 foreach ($this->items as $item) {
415 if ($item[
'type'] ==
'separator') {
432 public function getHTML()
438 if (count($this->items) || count($this->sticky_items)) {
439 $tpl =
new ilTemplate(
"tpl.toolbar.html",
true,
true,
"Services/UIComponent/Toolbar");
440 $tpl->setVariable(
'TOOLBAR_ID', $this->
getId());
441 if (count($this->sticky_items)) {
442 $tpl_sticky =
new ilTemplate(
"tpl.toolbar_sticky_items.html",
true,
true,
"Services/UIComponent/Toolbar");
444 foreach ($this->sticky_items as $sticky_item) {
445 if ($sticky_item[
'label']) {
446 $tpl_sticky->setCurrentBlock(
'input_label');
447 $tpl_sticky->setVariable(
'TXT_INPUT', $sticky_item[
'item']->getTitle());
448 $tpl_sticky->parseCurrentBlock();
452 $tpl_sticky->setCurrentBlock(
'sticky_item');
453 $tpl_sticky->setVariable(
'STICKY_ITEM_HTML', $sticky_item[
'item']->getToolbarHTML());
454 $tpl_sticky->parseCurrentBlock();
456 $tpl_sticky->setCurrentBlock(
"sticky_item");
457 $tpl_sticky->setVariable(
"STICKY_ITEM_HTML", $this->ui->renderer()->render($sticky_item[
'item']));
458 $tpl_sticky->parseCurrentBlock();
461 $tpl->setCurrentBlock(
'sticky_items');
462 $tpl->setVariable(
'STICKY_ITEMS', $tpl_sticky->get());
463 $tpl->parseCurrentBlock();
467 if (count($this->items) == 0) {
468 $tpl->setVariable(
'HIDE_TOGGLE_CLASS',
' hidden');
473 $tpl_items =
new ilTemplate(
"tpl.toolbar_items.html",
true,
true,
"Services/UIComponent/Toolbar");
475 static $tpl_separator;
476 if ($tpl_separator === null) {
477 $tpl_separator =
new ilTemplate(
'tpl.toolbar_separator.html',
true,
true,
'Services/UIComponent/Toolbar');
479 $tpl_separator->touchBlock(
'separator');
480 $markup_items .= $tpl_separator->get();
482 foreach ($group as $item) {
483 switch ($item[
"type"]) {
485 $tpl_items->setCurrentBlock(
"button");
486 $tpl_items->setVariable(
"BTN_TXT", $item[
"txt"]);
487 $tpl_items->setVariable(
"BTN_LINK", $item[
"cmd"]);
488 if ($item[
"target"] !=
"") {
489 $tpl_items->setVariable(
"BTN_TARGET",
'target="' . $item[
"target"] .
'"');
491 if ($item[
"id"] !=
"") {
492 $tpl_items->setVariable(
"BID",
'id="' . $item[
"id"] .
'"');
494 if ($item[
"acc_key"] !=
"") {
495 include_once(
"./Services/Accessibility/classes/class.ilAccessKeyGUI.php");
496 $tpl_items->setVariable(
501 if (($item[
'add_attrs'])) {
502 $tpl_items->setVariable(
'BTN_ADD_ARG', $item[
'add_attrs']);
504 $tpl_items->setVariable(
'BTN_CLASS', $item[
'class']);
505 $tpl_items->parseCurrentBlock();
506 $tpl_items->touchBlock(
"item");
510 $tpl_items->setCurrentBlock(
"form_button");
511 $tpl_items->setVariable(
"SUB_TXT", $item[
"txt"]);
512 $tpl_items->setVariable(
"SUB_CMD", $item[
"cmd"]);
513 if ($item[
"primary"]) {
514 $tpl_items->setVariable(
"SUB_CLASS",
" emphsubmit");
515 } elseif ($item[
"class"]) {
516 $tpl_items->setVariable(
"SUB_CLASS",
" " . $item[
"class"]);
518 $tpl_items->parseCurrentBlock();
519 $tpl_items->touchBlock(
"item");
523 $tpl_items->setCurrentBlock(
"button_instance");
524 $tpl_items->setVariable(
"BUTTON_OBJ", $item[
"instance"]->render());
525 $tpl_items->parseCurrentBlock();
526 $tpl_items->touchBlock(
"item");
530 if ($item[
"label"]) {
531 $tpl_items->setCurrentBlock(
"input_label");
532 $tpl_items->setVariable(
"TXT_INPUT", $item[
"input"]->getTitle());
533 $tpl_items->parseCurrentBlock();
535 $tpl_items->setCurrentBlock(
"input");
536 $tpl_items->setVariable(
"INPUT_HTML", $item[
"input"]->getToolbarHTML());
537 $tpl_items->parseCurrentBlock();
538 $tpl_items->touchBlock(
"item");
543 $tpl_items->setCurrentBlock(
"dropdown");
544 $tpl_items->setVariable(
"TXT_DROPDOWN", $item[
"txt"]);
545 $tpl_items->setVariable(
"DROP_DOWN", $item[
"dd_html"]);
546 $tpl_items->parseCurrentBlock();
547 $tpl_items->touchBlock(
"item");
551 $tpl_items->setCurrentBlock(
"text");
552 $tpl_items->setVariable(
"VAL_TEXT", $item[
"text"]);
553 $tpl_items->touchBlock(
"item");
557 $tpl_items->setCurrentBlock(
"component");
558 $tpl_items->setVariable(
"COMPONENT", $this->ui->renderer()->render($item[
"component"]));
559 $tpl_items->touchBlock(
"item");
563 $tpl_items->touchBlock(
"spacer");
564 if (!$item[
"width"]) {
567 $tpl_items->setVariable(
"SPACER_WIDTH", $item[
"width"]);
568 $tpl_items->touchBlock(
"item");
572 if ($item[
"disabled"] ==
false) {
573 $tpl_items->setCurrentBlock(
"link");
574 $tpl_items->setVariable(
"LINK_TXT", $item[
"txt"]);
575 $tpl_items->setVariable(
"LINK_URL", $item[
"cmd"]);
576 $tpl_items->parseCurrentBlock();
577 $tpl_items->touchBlock(
"item");
580 $tpl_items->setCurrentBlock(
"link_disabled");
581 $tpl_items->setVariable(
"LINK_DISABLED_TXT", $item[
"txt"]);
583 $tpl_items->parseCurrentBlock();
584 $tpl_items->touchBlock(
"item");
589 $li = (count($group) > 1) ?
"<li class='ilToolbarGroup'>" :
"<li>";
590 $markup_items .=
$li . $tpl_items->get() .
'</li>';
593 $tpl->setVariable(
'ITEMS', $markup_items);
594 $tpl->setVariable(
"TXT_FUNCTIONS",
$lng->txt(
"functions"));
595 if ($this->lead_img[
"img"] !=
"") {
596 $tpl->setCurrentBlock(
"lead_image");
597 $tpl->setVariable(
"IMG_SRC", $this->lead_img[
"img"]);
598 $tpl->setVariable(
"IMG_ALT", $this->lead_img[
"alt"]);
599 $tpl->parseCurrentBlock();
605 $GLOBALS[
"tpl"]->addJavaScript(
"Services/Form/js/Form.js");
608 $tpl->setCurrentBlock(
"form_open");
611 $tpl->setVariable(
"FORM_CLASS",
"preventDoubleSubmission");
613 if ($this->multipart) {
614 $tpl->setVariable(
"ENC_TYPE",
'enctype="multipart/form-data"');
616 if ($this->form_target !=
"") {
617 $tpl->setVariable(
"TARGET",
' target="' . $this->form_target .
'" ');
619 if ($this->form_name !=
"") {
623 $tpl->parseCurrentBlock();
626 $tpl->touchBlock(
"form_close");
631 if ($this->
getId() !=
"") {
632 $tpl->setVariable(
"ID",
' id="' . $this->
getId() .
'" ');
637 $tpl->setVariable(
"HIDDEN_CLASS",
'ilNoDisplay');
671 if (count($this->items) == 1 && count($this->sticky_items) == 0) {
672 $supported_types = array(
'button',
'fbutton',
'button_obj');
673 $item = $this->items[0];
674 if (!in_array($item[
'type'], $supported_types)) {
678 switch ($item[
'type']) {
680 $button = $item[
'instance'];
684 $button->setPrimary($item[
'primary']);
685 $button->setCaption($item[
'txt'],
false);
686 $button->setCommand($item[
'cmd']);
687 $button->setAccessKey($item[
'acc_key']);
691 $button->setCaption($item[
'txt'],
false);
692 $button->setUrl($item[
'cmd']);
693 $button->setTarget($item[
'target']);
694 $button->setId($item[
'id']);
695 $button->setAccessKey($item[
'acc_key']);
699 $this->items = array();
special template class to simplify handling of ITX/PEAR
static getAttribute($a_func_id)
Get accesskey HTML attribute.
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.