31 protected string $id =
'';
46 protected \ILIAS\DI\UIServices
$ui;
54 $this->
lng = $DIC->language();
55 $this->
ui = $DIC->ui();
65 bool $a_multipart =
false,
68 $this->form_action = $a_val;
69 $this->multipart = $a_multipart;
70 $this->form_target = $a_target;
75 return $this->form_action;
82 $this->lead_img = array(
"img" => $a_img,
"alt" => $a_alt);
87 $this->hidden = $a_val;
95 public function setId(
string $a_val): void
102 return $this->
id ?: self::$instances;
107 $this->prevent_double_submission = $a_val;
112 return $this->prevent_double_submission;
121 string $a_target =
"",
122 ?
int $a_acc_key =
null,
123 string $a_additional_attrs =
'',
125 string $a_class =
'submit'
127 $this->items[] = array(
"type" =>
"button",
"txt" => $a_txt,
"cmd" => $a_cmd,
128 "target" => $a_target,
"acc_key" => $a_acc_key,
'add_attrs' => $a_additional_attrs,
129 "id" => $a_id,
"class" => $a_class);
138 ?
int $a_acc_key =
null,
139 bool $a_primary =
false,
140 ?
string $a_class =
null
144 $button->setPrimary(
true);
145 $button->setCaption($a_txt,
false);
146 $button->setCommand($a_cmd);
147 $this->addStickyItem($button);
149 $this->items[] = array(
"type" =>
"fbutton",
"txt" => $a_txt,
"cmd" => $a_cmd,
150 "acc_key" => $a_acc_key,
"primary" => $a_primary,
"class" => $a_class);
156 bool $a_output_label =
false
158 $this->items[] = array(
"type" =>
"input",
"input" => $a_item,
"label" => $a_output_label);
169 bool $a_output_label =
false
171 $this->sticky_items[] = array(
"item" => $a_item,
"label" => $a_output_label);
181 $this->addStickyItem($a_button);
183 $this->items[] = array(
"type" =>
"button_obj",
"instance" => $a_button);
191 $this->items[] = array(
"type" =>
"dropdown",
"txt" => $a_txt,
"dd_html" => $a_dd_html);
197 $this->items[] = array(
"type" =>
"separator");
198 $this->has_separator =
true;
203 $this->items[] = array(
"type" =>
"text",
"text" => $a_text);
206 public function addSpacer(?
string $a_width =
null): void
208 $this->items[] = array(
"type" =>
"spacer",
"width" => $a_width);
213 $this->items[] = array(
"type" =>
"component",
"component" => $a_comp);
219 bool $a_disabled =
false
221 $this->items[] = array(
"type" =>
"link",
"txt" => $a_caption,
"cmd" => $a_url,
"disabled" => $a_disabled);
227 $this->open_form_tag = $a_val;
232 return $this->open_form_tag;
237 $this->close_form_tag = $a_val;
242 return $this->close_form_tag;
247 $this->form_name = $a_val;
252 return $this->form_name;
263 foreach ($this->items as $item) {
264 if ($item[
'type'] ===
'separator') {
278 public function getHTML(): string
282 $this->applyAutoStickyToSingleElement();
284 if (count($this->items) || count($this->sticky_items)) {
285 $tpl =
new ilTemplate(
"tpl.toolbar.html",
true,
true,
"components/ILIAS/UIComponent/Toolbar");
286 $tpl->setVariable(
'TOOLBAR_ID', $this->
getId());
287 $tpl->setVariable(
'MORE_LABEL', $this->
lng->txt(
'toolbar_more_actions'));
289 if (count($this->sticky_items)) {
290 $tpl_sticky =
new ilTemplate(
"tpl.toolbar_sticky_items.html",
true,
true,
"components/ILIAS/UIComponent/Toolbar");
292 foreach ($this->sticky_items as $sticky_item) {
293 if ($sticky_item[
'label']) {
294 $tpl_sticky->setCurrentBlock(
'input_label');
295 $tpl_sticky->setVariable(
'INPUT_ID', $sticky_item[
'item']->getFieldId());
296 $tpl_sticky->setVariable(
'TXT_INPUT', $sticky_item[
'item']->
getTitle());
297 $tpl_sticky->parseCurrentBlock();
301 $tpl_sticky->setCurrentBlock(
'sticky_item');
302 $tpl_sticky->setVariable(
'STICKY_ITEM_HTML', $sticky_item[
'item']->getToolbarHTML());
303 $tpl_sticky->parseCurrentBlock();
305 $tpl_sticky->setCurrentBlock(
"sticky_item");
306 $tpl_sticky->setVariable(
"STICKY_ITEM_HTML", $this->
ui->renderer()->render($sticky_item[
'item']));
307 $tpl_sticky->parseCurrentBlock();
310 $tpl->setCurrentBlock(
'sticky_items');
311 $tpl->setVariable(
'STICKY_ITEMS', $tpl_sticky->get());
312 $tpl->parseCurrentBlock();
316 foreach ($this->getGroupedItems() as $i => $group) {
317 $tpl_items =
new ilTemplate(
"tpl.toolbar_items.html",
true,
true,
"components/ILIAS/UIComponent/Toolbar");
319 static $tpl_separator;
320 if ($tpl_separator ===
null) {
321 $tpl_separator =
new ilTemplate(
'tpl.toolbar_separator.html',
true,
true,
'components/ILIAS/UIComponent/Toolbar');
323 $tpl_separator->touchBlock(
'separator');
324 $markup_items .= $tpl_separator->get();
326 foreach ($group as $item) {
327 $tpl_items->setCurrentBlock(
"item");
328 switch ($item[
"type"]) {
330 $tpl_items->setVariable(
"BTN_TXT", $item[
"txt"]);
331 $tpl_items->setVariable(
"BTN_LINK", $item[
"cmd"]);
332 if ($item[
"target"] !=
"") {
333 $tpl_items->setVariable(
"BTN_TARGET",
'target="' . $item[
"target"] .
'"');
335 if ($item[
"id"] !=
"") {
336 $tpl_items->setVariable(
"BID",
'id="' . $item[
"id"] .
'"');
338 if (($item[
'add_attrs'])) {
339 $tpl_items->setVariable(
'BTN_ADD_ARG', $item[
'add_attrs']);
341 $tpl_items->setVariable(
'BTN_CLASS', $item[
'class']);
345 $tpl_items->setVariable(
"SUB_TXT", $item[
"txt"]);
346 $tpl_items->setVariable(
"SUB_CMD", $item[
"cmd"]);
347 if ($item[
"primary"]) {
348 $tpl_items->setVariable(
"SUB_CLASS",
" emphsubmit");
349 } elseif ($item[
"class"]) {
350 $tpl_items->setVariable(
"SUB_CLASS",
" " . $item[
"class"]);
355 $tpl_items->setVariable(
"BUTTON_OBJ", $item[
"instance"]->render());
359 if ($item[
"label"]) {
360 $tpl_items->setVariable(
"TXT_INPUT", $item[
"input"]->
getTitle());
361 $tpl_items->setVariable(
"INPUT_ID", $item[
"input"]->getFieldId());
363 $tpl_items->setVariable(
"INPUT_HTML", $item[
"input"]->getToolbarHTML());
368 $tpl_items->setVariable(
"TXT_DROPDOWN", $item[
"txt"]);
369 $tpl_items->setVariable(
"DROP_DOWN", $item[
"dd_html"]);
373 $tpl_items->setVariable(
"VAL_TEXT", $item[
"text"]);
377 $tpl_items->setVariable(
"COMPONENT", $this->
ui->renderer()->render($item[
"component"]));
381 if ($item[
"disabled"] ==
false) {
382 $tpl_items->setVariable(
"LINK_TXT", $item[
"txt"]);
383 $tpl_items->setVariable(
"LINK_URL", $item[
"cmd"]);
385 $tpl_items->setVariable(
"LINK_DISABLED_TXT", $item[
"txt"]);
389 $tpl_items->parseCurrentBlock();
391 $tpl_itemgroups =
new ilTemplate(
"tpl.toolbar_itemgroup.html",
true,
true,
'components/ILIAS/UIComponent/Toolbar');
392 $tpl_itemgroups->setCurrentBlock(
"itemgroup");
393 $tpl_itemgroups->setVariable(
"ITEMS", $tpl_items->get());
394 $tpl_itemgroups->parseCurrentBlock();
395 $markup_items .= $tpl_itemgroups->get();
398 $tpl->setVariable(
'ITEMS', $markup_items);
399 $tpl->setVariable(
"TXT_FUNCTIONS",
$lng->txt(
"functions"));
400 if ($this->lead_img[
"img"] !=
"") {
401 $tpl->setCurrentBlock(
"lead_image");
402 $tpl->setVariable(
"IMG_SRC", $this->lead_img[
"img"]);
403 $tpl->setVariable(
"IMG_ALT", $this->lead_img[
"alt"]);
404 $tpl->parseCurrentBlock();
408 if ($this->getFormAction() !==
"") {
410 $GLOBALS[
"tpl"]->addJavaScript(
"assets/js/Form.js");
412 if ($this->getOpenFormTag()) {
413 $tpl->setCurrentBlock(
"form_open");
414 $tpl->setVariable(
"FORMACTION", $this->getFormAction());
415 if ($this->getPreventDoubleSubmission()) {
416 $tpl->setVariable(
"FORM_CLASS",
"preventDoubleSubmission");
418 if ($this->multipart) {
419 $tpl->setVariable(
"ENC_TYPE",
'enctype="multipart/form-data"');
421 if ($this->form_target !==
"") {
422 $tpl->setVariable(
"TARGET",
' target="' . $this->form_target .
'" ');
424 if ($this->form_name !==
"") {
425 $tpl->setVariable(
"FORMNAME",
'name="' . $this->getFormName() .
'"');
428 $tpl->parseCurrentBlock();
430 if ($this->getCloseFormTag()) {
431 $tpl->touchBlock(
"form_close");
436 if ($this->
getId() !==
"") {
437 $tpl->setVariable(
"ID",
' id="' . $this->
getId() .
'" ');
441 if ($this->getHidden()) {
442 $tpl->setVariable(
"HIDDEN_CLASS",
'ilNoDisplay');
457 $this->items = $items;
467 if (count($this->items) === 1 && count($this->sticky_items) === 0) {
468 $supported_types = [
'button',
'fbutton',
'button_obj'];
469 $item = $this->items[0];
470 if (!in_array($item[
'type'], $supported_types)) {
474 switch ($item[
'type']) {
476 $button = $item[
'instance'];
480 $button->setPrimary($item[
'primary']);
481 $button->setCaption($item[
'txt'],
false);
482 $button->setCommand($item[
'cmd']);
486 $button->setCaption($item[
'txt'],
false);
487 $button->setUrl($item[
'cmd']);
488 $button->setTarget($item[
'target']);
489 $button->setId($item[
'id']);
492 $this->addStickyItem($button);
special template class to simplify handling of ITX/PEAR
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
if(!file_exists('../ilias.ini.php'))