ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ui_mainbar.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
6 
11 
84 function ui_mainbar(): string
85 {
86  global $DIC;
87  $f = $DIC->ui()->factory();
88  $renderer = $DIC->ui()->renderer();
89 
90  $target = $DIC->http()->request()->getUri()->__toString() . '&ui_mainbar=1';
91  $mainbar = $f->link()->standard('Mainbar', $target);
92 
93  $target = $DIC->http()->request()->getUri()->__toString() . '&ui_mainbar=2';
94  $mainbar_combined = $f->link()->standard('Mainbar Combined', $target);
95 
96  return $renderer->render([
97  $f->listing()->ordered([$mainbar,$mainbar_combined])
98  ]);
99 }
100 
101 function getUIMainbar(\ILIAS\UI\Factory $f, \ILIAS\Data\URI $uri, bool $condensed = false): MainBar
102 {
103  $symbol = $f->symbol()->icon()->standard('rcat', 'Fischotter');
104  $link010 = $f->link()->bulky($symbol, '2021 - Fischotter', $uri->withParameter('c', 1));
105  $symbol = $f->symbol()->icon()->standard('rcat', 'Maulwurf');
106  $link011 = $f->link()->bulky($symbol, '2020 - Maulwurf', $uri->withParameter('c', 2));
107  $symbol = $f->symbol()->icon()->standard('rcat', 'Reh');
108  $link012 = $f->link()->bulky($symbol, '2019 - Reh', $uri->withParameter('c', 3));
109 
110  $symbol = $f->symbol()->icon()->standard('rcat', 'Bachflohkrebs');
111  $link020 = $f->link()->bulky($symbol, '2021 - Bachflohkrebs', $uri->withParameter('c', 4));
112  $symbol = $f->symbol()->icon()->standard('rcat', 'Wildkatze');
113  $link021 = $f->link()->bulky($symbol, '2020 - Wildkatze', $uri->withParameter('c', 5));
114  $symbol = $f->symbol()->icon()->standard('rcat', 'Glühwürmchen');
115  $link022 = $f->link()->bulky($symbol, '2019 - Glühwürmchen', $uri->withParameter('c', 6));
116 
117  $link10 = $f->link()->bulky($symbol, 'Frühbarock', $uri->withParameter('c', 7));
118  $link11 = $f->link()->bulky($symbol, 'Hochbarock', $uri->withParameter('c', 8));
119  $link12 = $f->link()->bulky($symbol, 'Spätbarock', $uri->withParameter('c', 9));
120 
121  $symbol = $f->symbol()->icon()->standard('cat', 'Deutschland');
122  $slate01 = $f->mainControls()->slate()->combined('Deutschland', $symbol)
123  ->withAdditionalEntry($link010)
124  ->withAdditionalEntry($link011)
125  ->withAdditionalEntry($link012);
126 
127  $contents = <<<EOT
128  <p>Leider gibt es im Takatuka Land kein Tier des Jahres.
129  <br />
130  <b>Aber:</b> Slates in der Main Bar können andere Inhalte als Links enthalten. </p>
131  <p>Zum Beispiel könnten sich hier Inhalte wie der Magazinbaum oder der
132  Mailbaum, komplexe Elemente wie das Notifikation Center, die Hilfe oder
133  auch dieser Text befinden.</p>
134  <p> Die Main Bar ist ganz bewusst nicht nur als 'Menü' gedacht sondern dient auch dazu,
135  komplexe Bedienelemente darzustellen.</p>
136 EOT;
137 
138  $symbol = $f->symbol()->icon()->standard('cat', 'Takatuka Land');
139  $slate02 = $f->mainControls()->slate()->legacy('Takatuka Land', $symbol, $f->legacy($contents));
140 
141  $symbol = $f->symbol()->icon()->standard('cat', 'Schweiz');
142  $slate03 = $f->mainControls()->slate()->combined('Schweiz', $symbol)
143  ->withAdditionalEntry($link020)
144  ->withAdditionalEntry($link021)
145  ->withAdditionalEntry($link022);
146 
147  $symbol = $f->symbol()->icon()->custom('./components/ILIAS/UI/src/examples/Layout/Page/Standard/layers.svg', '')->withSize('small');
148  $slate0 = $f->mainControls()->slate()->combined('Tier des Jahres', $symbol)
149  ->withAdditionalEntry($slate01)
150  ->withAdditionalEntry($slate02)
151  ->withAdditionalEntry($slate03);
152 
153  $slate1 = $f->mainControls()->slate()->combined('Barock', $symbol)
154  ->withAdditionalEntry($link10)
155  ->withAdditionalEntry($link11)
156  ->withAdditionalEntry($link12);
157 
158 
159  if (!$condensed) {
160  $mainbar = $f->mainControls()->mainBar()
161  ->withAdditionalEntry('slate0', $slate0)
162  ->withAdditionalEntry('slate1', $slate1);
163 
164  $tools_btn = $f->button()->bulky(
165  $f->symbol()->icon()->custom('./components/ILIAS/UI/src/examples/Layout/Page/Standard/grid.svg', ''),
166  'Tools',
167  '#'
168  );
169  $mainbar = $mainbar->withToolsButton($tools_btn);
170 
171  $symbol = $f->symbol()->icon()->custom('./components/ILIAS/UI/src/examples/Layout/Page/Standard/question.svg', '')->withSize('small');
172  $slate = $f->mainControls()->slate()->legacy('Help', $symbol, $f->legacy('<h2>tool 1</h2><p>Some Text for Tool 1 entry</p>'));
173  $tools = ['tool1' => $slate];
174  foreach ($tools as $id => $entry) {
175  $mainbar = $mainbar->withAdditionalToolEntry($id, $entry);
176  }
177 
178  return $mainbar;
179  }
180 
181  $slate_base = $f->mainControls()->slate()->combined('Menu', $symbol)
182  ->withAdditionalEntry($slate0)
183  ->withAdditionalEntry($slate1);
184  return $f->mainControls()->mainBar()
185  ->withAdditionalEntry('slate0', $slate_base);
186 }
187 
188 function getUIContent(\ILIAS\UI\Factory $f, RequestInterface $request): array
189 {
190  $params = $request->getQueryParams();
191  $cidx = -1;
192  if (array_key_exists('c', $params)) {
193  $cidx = $params['c'];
194  }
195 
196 
197  switch ($cidx) {
198  case 1:
199  $t = 'Tier des Jahres: Fischotter3';
200  $c = [
201  $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>')
202  ,$f->link()->standard("Quelle: Wikipedia", "https://de.wikipedia.org/wiki/Tier_des_Jahres")
203  ];
204  break;
205  case 2:
206  $t = 'Tier des Jahres: Maulwurf';
207  $c = [
208  $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>')
209  ,$f->link()->standard("Quelle: Wikipedia", "https://de.wikipedia.org/wiki/Tier_des_Jahres")
210  ];
211  break;
212  case 3:
213  $t = 'Tier des Jahres: Reh';
214  $c = [
215  $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>')
216  ];
217  break;
218  case 4:
219  $t = 'Tier des Jahres: Bachflohkrebs';
220  $c = [
221  $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>')
222  ,$f->link()->standard("Quelle: Wikipedia", "https://de.wikipedia.org/wiki/Tier_des_Jahres")
223  ];
224  break;
225  case 5:
226  $t = 'Tier des Jahres: Wildkatze';
227  $c = [
228  $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>')
229  ,$f->link()->standard("Quelle: Wikipedia", "https://de.wikipedia.org/wiki/Tier_des_Jahres")
230  ];
231  break;
232  case 6:
233  $t = 'Frühbarock';
234  $c = [
235  $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>')
236  ,$f->link()->standard("Quelle: Wikipedia", "https://de.wikipedia.org/wiki/Tier_des_Jahres")
237  ];
238  break;
239 
240  case 7:
241  $t = 'Frühbarock';
242  $c = [
243  $f->legacy('<h1>Frühbarock</h1><p><b>etwa 1600 bis 1650</b><br>unter italienischer Dominanz, mit etwa Monteverdi, Gabrieli.</p>')
244  ,$f->link()->standard("Quelle: Wikipedia", "https://de.wikipedia.org/wiki/Tier_des_Jahres")
245  ];
246  break;
247  case 8:
248  $t = 'Hochbarock';
249  $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>')];
250  break;
251  case 9:
252  $t = 'Spätbarock';
253  $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>')];
254  break;
255 
256  default:
257  $t = 'Mainbar-Demo';
258  $c = [$f->legacy('Dies ist ein reduziertes Beispiel für die Mainbar des UI-Frameworks.')];
259  }
260 
261  return[$t, $c];
262 }
263 
264 
265 global $DIC;
266 $request_wrapper = $DIC->http()->wrapper()->query();
267 $refinery = $DIC->refinery();
268 
269 if ($request_wrapper->has('ui_mainbar')
270 ) {
272  switch ($request_wrapper->retrieve('ui_mainbar', $refinery->kindlyTo()->int())) {
273  case 1:
275  break;
276  case 2:
278  break;
279  }
280 
281  exit();
282 }
283 
284 
285 function getURI(): \ILIAS\Data\URI
286 {
287  $df = new Factory();
288  return $df->uri(
289  $_SERVER['REQUEST_SCHEME'] . '://'
290  . $_SERVER['SERVER_NAME'] . ':'
291  . $_SERVER['SERVER_PORT']
292  . $_SERVER['SCRIPT_NAME'] . '?'
293  . $_SERVER['QUERY_STRING']
294  );
295 }
296 
297 function getRenderedPage(Container $dic, MainBar $mainbar): string
298 {
299  $f = $dic->ui()->factory();
300  list($page_title, $content) = getUIContent($f, $dic->http()->request());
301 
302  $logo = $f->image()->responsive("assets/images/logo/HeaderIcon.svg", "ILIAS");
303  $responsive_logo = $f->image()->responsive("assets/images/logo/HeaderIconResponsive.svg", "ILIAS");
304 
305  $breadcrumbs = null;
306  $metabar = null;
307  $footer = null;
308  $short_title = 'DEMO';
309  $view_title = 'UI Mainbar';
310  $tc = $dic->ui()->factory()->toast()->container();
311 
312  $page = $f->layout()->page()->standard(
313  $content,
314  $metabar,
315  $mainbar,
316  $breadcrumbs,
317  $logo,
318  $responsive_logo,
319  "./assets/images/logo/favicon.ico",
320  $tc,
321  $footer,
322  $page_title,
323  $short_title,
324  $view_title
325  )->withUIDemo(true);
326 
327  return $dic->ui()->renderer()->render($page);
328 }
329 
331 {
332  return getRenderedPage($dic, getUIMainbar($dic->ui()->factory(), getURI()));
333 }
334 
336 {
337  return getRenderedPage($dic, getUIMainbar($dic->ui()->factory(), getURI(), true));
338 }
$renderer
This describes the MainBar.
Definition: MainBar.php:33
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:31
getUIMainbar(\ILIAS\UI\Factory $f, \ILIAS\Data\URI $uri, bool $condensed=false)
Definition: ui_mainbar.php:101
getUIContent(\ILIAS\UI\Factory $f, RequestInterface $request)
Definition: ui_mainbar.php:188
Interface Observer Contains several chained tasks and infos about them.
$c
Definition: deliver.php:9
getRenderedPage(Container $dic, MainBar $mainbar)
Definition: ui_mainbar.php:297
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:35
static initILIAS()
ilias initialisation
if($request_wrapper->has('ui_mainbar')) getURI()
Definition: ui_mainbar.php:285
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$_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
ui_mainbar()
description: > Example for rendering a UI mainbar.
Definition: ui_mainbar.php:84
Builds data types.
Definition: Factory.php:35
withAdditionalEntry(string $id, $entry)
Append an entry.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:24
$dic
Definition: ltiresult.php:33
ui()
Get the interface to get services from UI framework.
Definition: Container.php:127