ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
with_additional_links.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
33 function with_additional_links(): string
34 {
35  global $DIC;
36  $tc = $DIC->ui()->factory()->toast()->container();
37 
38  $toasts = [
39  $DIC->ui()->factory()->toast()->standard(
40  'Example',
41  $DIC->ui()->factory()->symbol()->icon()->standard('info', 'Example')
42  )
43  ->withAdditionalLink($DIC->ui()->factory()->link()->standard('ILIAS', 'https://www.ilias.de'))
44  ->withAdditionalLink($DIC->ui()->factory()->link()->standard('GitHub', 'https://www.github.com'))
45  ];
46 
47  $toasts = base64_encode($DIC->ui()->renderer()->renderAsync($toasts));
48  $button = $DIC->ui()->factory()->button()->standard($DIC->language()->txt('show'), '');
49  $button = $button->withAdditionalOnLoadCode(function ($id) use ($toasts) {
50  return "$id.addEventListener('click', () => {
51  $id.parentNode.querySelector('.il-toast-container').innerHTML = atob('$toasts');
52  $id.parentNode.querySelector('.il-toast-container').querySelectorAll('script').forEach(element => {
53  let newScript = document.createElement('script');
54  newScript.innerHTML = element.innerHTML;
55  element.parentNode.appendChild(newScript);
56  })
57  });";
58  });
59 
60  return $DIC->ui()->renderer()->render([$button,$tc]);
61 }
global $DIC
Definition: shib_login.php:22
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
with_additional_links()
description: > Example for rendering a standard toast with additional links.