ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ui_mainbar.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
6 
11 
12 function ui_mainbar(): string
13 {
14  global $DIC;
15  $f = $DIC->ui()->factory();
16  $renderer = $DIC->ui()->renderer();
17 
18  $url = 'src/UI/examples/Layout/Page/Standard/ui_mainbar.php?ui_mainbar=1';
19  $mainbar = $f->link()->standard('Mainbar', $url);
20  $url2 = 'src/UI/examples/Layout/Page/Standard/ui_mainbar.php?ui_mainbar=2';
21  $mainbar_combined = $f->link()->standard('Mainbar Combined', $url2);
22 
23 
24 
25  return $renderer->render([
26  $f->listing()->ordered([$mainbar,$mainbar_combined])
27  ]);
28 }
29 
30 function getUIMainbar(\ILIAS\UI\Factory $f, \ILIAS\Data\URI $uri, bool $condensed = false): MainBar
31 {
32  $symbol = $f->symbol()->icon()->standard('rcat', 'Fischotter');
33  $link010 = $f->link()->bulky($symbol, '2021 - Fischotter', $uri->withParameter('c', 1));
34  $symbol = $f->symbol()->icon()->standard('rcat', 'Maulwurf');
35  $link011 = $f->link()->bulky($symbol, '2020 - Maulwurf', $uri->withParameter('c', 2));
36  $symbol = $f->symbol()->icon()->standard('rcat', 'Reh');
37  $link012 = $f->link()->bulky($symbol, '2019 - Reh', $uri->withParameter('c', 3));
38 
39  $symbol = $f->symbol()->icon()->standard('rcat', 'Bachflohkrebs');
40  $link020 = $f->link()->bulky($symbol, '2021 - Bachflohkrebs', $uri->withParameter('c', 4));
41  $symbol = $f->symbol()->icon()->standard('rcat', 'Wildkatze');
42  $link021 = $f->link()->bulky($symbol, '2020 - Wildkatze', $uri->withParameter('c', 5));
43  $symbol = $f->symbol()->icon()->standard('rcat', 'Glühwürmchen');
44  $link022 = $f->link()->bulky($symbol, '2019 - Glühwürmchen', $uri->withParameter('c', 6));
45 
46  $link10 = $f->link()->bulky($symbol, 'Frühbarock', $uri->withParameter('c', 7));
47  $link11 = $f->link()->bulky($symbol, 'Hochbarock', $uri->withParameter('c', 8));
48  $link12 = $f->link()->bulky($symbol, 'Spätbarock', $uri->withParameter('c', 9));
49 
50  $symbol = $f->symbol()->icon()->standard('cat', 'Deutschland');
51  $slate01 = $f->mainControls()->slate()->combined('Deutschland', $symbol)
52  ->withAdditionalEntry($link010)
53  ->withAdditionalEntry($link011)
54  ->withAdditionalEntry($link012);
55 
56  $contents = <<<EOT
57  <p>Leider gibt es im Takatuka Land kein Tier des Jahres.
58  <br />
59  <b>Aber:</b> Slates in der Main Bar können andere Inhalte als Links enthalten. </p>
60  <p>Zum Beispiel könnten sich hier Inhalte wie der Magazinbaum oder der
61  Mailbaum, komplexe Elemente wie das Notifikation Center, die Hilfe oder
62  auch dieser Text befinden.</p>
63  <p> Die Main Bar ist ganz bewusst nicht nur als 'Menü' gedacht sondern dient auch dazu,
64  komplexe Bedienelemente darzustellen.</p>
65 EOT;
66 
67  $symbol = $f->symbol()->icon()->standard('cat', 'Takatuka Land');
68  $slate02 = $f->mainControls()->slate()->legacy('Takatuka Land', $symbol, $f->legacy($contents));
69 
70  $symbol = $f->symbol()->icon()->standard('cat', 'Schweiz');
71  $slate03 = $f->mainControls()->slate()->combined('Schweiz', $symbol)
72  ->withAdditionalEntry($link020)
73  ->withAdditionalEntry($link021)
74  ->withAdditionalEntry($link022);
75 
76  $symbol = $f->symbol()->icon()->custom('./src/UI/examples/Layout/Page/Standard/layers.svg', '')->withSize('small');
77  $slate0 = $f->mainControls()->slate()->combined('Tier des Jahres', $symbol)
78  ->withAdditionalEntry($slate01)
79  ->withAdditionalEntry($slate02)
80  ->withAdditionalEntry($slate03);
81 
82  $slate1 = $f->mainControls()->slate()->combined('Barock', $symbol)
83  ->withAdditionalEntry($link10)
84  ->withAdditionalEntry($link11)
85  ->withAdditionalEntry($link12);
86 
87 
88  if (!$condensed) {
89  $mainbar = $f->mainControls()->mainBar()
90  ->withAdditionalEntry('slate0', $slate0)
91  ->withAdditionalEntry('slate1', $slate1);
92 
93  $tools_btn = $f->button()->bulky(
94  $f->symbol()->icon()->custom('./src/UI/examples/Layout/Page/Standard/grid.svg', ''),
95  'Tools',
96  '#'
97  );
98  $mainbar = $mainbar->withToolsButton($tools_btn);
99 
100  $symbol = $f->symbol()->icon()->custom('./src/UI/examples/Layout/Page/Standard/question.svg', '')->withSize('small');
101  $slate = $f->mainControls()->slate()->legacy('Help', $symbol, $f->legacy('<h2>tool 1</h2><p>Some Text for Tool 1 entry</p>'));
102  $tools = ['tool1' => $slate];
103  foreach ($tools as $id => $entry) {
104  $mainbar = $mainbar->withAdditionalToolEntry($id, $entry);
105  }
106 
107  return $mainbar;
108  }
109 
110  $slate_base = $f->mainControls()->slate()->combined('Menu', $symbol)
111  ->withAdditionalEntry($slate0)
112  ->withAdditionalEntry($slate1);
113  return $f->mainControls()->mainBar()
114  ->withAdditionalEntry('slate0', $slate_base);
115 }
116 
117 function getUIContent(\ILIAS\UI\Factory $f, RequestInterface $request): array
118 {
119  $params = $request->getQueryParams();
120  $cidx = -1;
121  if (array_key_exists('c', $params)) {
122  $cidx = $params['c'];
123  }
124 
125 
126  switch ($cidx) {
127  case 1:
128  $t = 'Tier des Jahres: Fischotter3';
129  $c = [
130  $f->legacy('<h1>Fischotter</h1><p>Der Fischotter (Lutra lutra) ist ein an das Wasserleben angepasster Marder, der zu den besten Schwimmern unter den Landraubtieren zählt.</p>')
131  ,$f->link()->standard("Quelle: Wikipedia", "https://de.wikipedia.org/wiki/Tier_des_Jahres")
132  ];
133  break;
134  case 2:
135  $t = 'Tier des Jahres: Maulwurf';
136  $c = [
137  $f->legacy('<h1>Maulwurf</h1><p>Der Europäische Maulwurf ist ein mittelgroßer Vertreter der Eurasischen Maulwürfe (Talpa). Er erreicht eine Kopf-Rumpf-Länge von 11,3 bis 15,9 cm, der Schwanz wird 2,5 bis 4,0 cm lang.</p>')
138  ,$f->link()->standard("Quelle: Wikipedia", "https://de.wikipedia.org/wiki/Tier_des_Jahres")
139  ];
140  break;
141  case 3:
142  $t = 'Tier des Jahres: Reh';
143  $c = [
144  $f->legacy('<h1>Reh</h1><p>Das Reh springt hoch,<br> das Reh springt weit.<br> Warum auch nicht? <br>Es hat ja Zeit.</p>')
145  ];
146  break;
147  case 4:
148  $t = 'Tier des Jahres: Bachflohkrebs';
149  $c = [
150  $f->legacy('<h1>Bachflohkrebs</h1><p>Der Bachflohkrebs (Gammarus fossarum) ist ein Flohkrebs aus der Familie der Gammaridae und ein typischer Bachbewohner. <br> Er reagiert als sogenanntes Zeigertier äußerst empfindlich auf Gewässerverschmutzungen.</p>')
151  ,$f->link()->standard("Quelle: Wikipedia", "https://de.wikipedia.org/wiki/Tier_des_Jahres")
152  ];
153  break;
154  case 5:
155  $t = 'Tier des Jahres: Wildkatze';
156  $c = [
157  $f->legacy('<h1>Wildkatze</h1><p>Die Europäische Wildkatze oder Waldkatze (Felis silvestris) ist eine Kleinkatze, die in Europa von der Iberischen Halbinsel bis Osteuropa (westliche Ukraine), in Italien, auf dem Balkan, in Anatolien, im Kaukasus und in den schottischen Highlands vorkommt.</p>')
158  ,$f->link()->standard("Quelle: Wikipedia", "https://de.wikipedia.org/wiki/Tier_des_Jahres")
159  ];
160  break;
161  case 6:
162  $t = 'Frühbarock';
163  $c = [
164  $f->legacy('<h1>Glühwürmchen</h1><p>Der Große Leuchtkäfer bzw. das Große Glühwürmchen oder Große Johannisglühwürmchen (Lampyris noctiluca) ist ein Käfer aus der Familie Leuchtkäfer (Lampyridae).</p>')
165  ,$f->link()->standard("Quelle: Wikipedia", "https://de.wikipedia.org/wiki/Tier_des_Jahres")
166  ];
167  break;
168 
169  case 7:
170  $t = 'Frühbarock';
171  $c = [
172  $f->legacy('<h1>Frühbarock</h1><p><b>etwa 1600 bis 1650</b><br>unter italienischer Dominanz, mit etwa Monteverdi, Gabrieli.</p>')
173  ,$f->link()->standard("Quelle: Wikipedia", "https://de.wikipedia.org/wiki/Tier_des_Jahres")
174  ];
175  break;
176  case 8:
177  $t = 'Hochbarock';
178  $c = [$f->legacy('<h1>Hochbarock</h1><p><b>etwa 1650 bis 1710</b><br>Das französische Musikleben des späten 17. Jahrhunderts wurde maßgeblich von Jean-Baptiste Lully (1632–1687) am Hofe Ludwigs XIV. geprägt.</p>')];
179  break;
180  case 9:
181  $t = 'Spätbarock';
182  $c = [$f->legacy('<h1>Spätbarock</h1><p><b>etwa 1710 bis 1750</b><br>Entwickelte sich im Hochbarock die Musik noch unabhängig in verschiedenen Regionen Europas, so zeichnete sich der Spätbarock durch eine grenzübergreifende Verbreitung der Stile aus. Im deutschen Raum trieb Georg Philipp Telemann (1681–1767) diese Entwicklung voran und wurde schließlich zur „Ikone“ unter den Tonkünstlern.</p>')];
183  break;
184 
185  default:
186  $t = 'Mainbar-Demo';
187  $c = [$f->legacy('Dies ist ein reduziertes Beispiel für die Mainbar des UI-Frameworks.')];
188  }
189 
190  return[$t, $c];
191 }
192 
193 //Render Footer in Fullscreen mode
194 global $DIC;
195 if (basename($_SERVER["SCRIPT_FILENAME"]) == "ui_mainbar.php") {
196  chdir('../../../../../../');
197  require_once("libs/composer/vendor/autoload.php");
199  $refinery = $DIC->refinery();
200  $request_wrapper = $DIC->http()->wrapper()->query();
201 }
202 
203 
204 if (isset($request_wrapper) && isset($refinery) && $request_wrapper->has('ui_mainbar')) {
205  if ($request_wrapper->retrieve('ui_mainbar', $refinery->kindlyTo()->string()) == '1') {
207  }
208  if ($request_wrapper->retrieve('ui_mainbar', $refinery->kindlyTo()->string()) == '2') {
210  }
211 }
212 
213 function getURI(): \ILIAS\Data\URI
214 {
215  $df = new Factory();
216  return $df->uri(
217  ($_SERVER['REQUEST_SCHEME'] ?? "http") . '://'
218  . ($_SERVER['SERVER_NAME'] ?? "localhost") . ':'
219  . ($_SERVER['SERVER_PORT'] ?? "80")
220  . ($_SERVER['SCRIPT_NAME'] ?? "") . '?'
221  . ($_SERVER['QUERY_STRING'] ?? "")
222  );
223 }
224 
225 function getRenderedPage(Container $dic, MainBar $mainbar): string
226 {
227  $f = $dic->ui()->factory();
228  list($page_title, $content) = getUIContent($f, $dic->http()->request());
229 
230  $logo = $f->image()->responsive("templates/default/images/HeaderIcon.svg", "ILIAS");
231  $responsive_logo = $f->image()->responsive("templates/default/images/HeaderIconResponsive.svg", "ILIAS");
232 
233  $breadcrumbs = null;
234  $metabar = null;
235  $footer = null;
236  $short_title = 'DEMO';
237  $view_title = 'UI Mainbar';
238  $tc = $dic->ui()->factory()->toast()->container();
239 
240  $page = $f->layout()->page()->standard(
241  $content,
242  $metabar,
243  $mainbar,
244  $breadcrumbs,
245  $logo,
246  $responsive_logo,
247  "./templates/default/images/favicon.ico",
248  $tc,
249  $footer,
250  $page_title,
251  $short_title,
252  $view_title
253  )->withUIDemo(true);
254 
255  return $dic->ui()->renderer()->render($page);
256 }
257 
259 {
260  return getRenderedPage($dic, getUIMainbar($dic->ui()->factory(), getURI()));
261 }
262 
264 {
265  return getRenderedPage($dic, getUIMainbar($dic->ui()->factory(), getURI(), true));
266 }
Class Factory.
This describes the MainBar.
Definition: MainBar.php:33
$c
Definition: cli.php:38
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:33
getUIMainbar(\ILIAS\UI\Factory $f, \ILIAS\Data\URI $uri, bool $condensed=false)
Definition: ui_mainbar.php:30
getUIContent(\ILIAS\UI\Factory $f, RequestInterface $request)
Definition: ui_mainbar.php:117
Class ChatMainBarProvider .
getRenderedPage(Container $dic, MainBar $mainbar)
Definition: ui_mainbar.php:225
if(basename($_SERVER["SCRIPT_FILENAME"])=="ui_mainbar.php") if(isset($request_wrapper) &&isset($refinery) && $request_wrapper->has('ui_mainbar')) getURI()
Definition: ui_mainbar.php:213
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:31
static initILIAS()
ilias initialisation
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10
The scope of this class is split ilias-conform URI&#39;s into components.
Definition: URI.php:34
withAdditionalEntry(string $id, $entry)
Append an entry.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
$dic
Definition: result.php:32
$url
ui()
Get the interface to get services from UI framework.
Definition: Container.php:118
Refinery Factory $refinery