ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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  $target = $DIC->http()->request()->getUri()->__toString() . '&ui_mainbar=1';
19  $mainbar = $f->link()->standard('Mainbar', $target);
20 
21  $target = $DIC->http()->request()->getUri()->__toString() . '&ui_mainbar=2';
22  $mainbar_combined = $f->link()->standard('Mainbar Combined', $target);
23 
24  return $renderer->render([
25  $f->listing()->ordered([$mainbar,$mainbar_combined])
26  ]);
27 }
28 
29 function getUIMainbar(\ILIAS\UI\Factory $f, \ILIAS\Data\URI $uri, bool $condensed = false): MainBar
30 {
31  $symbol = $f->symbol()->icon()->standard('rcat', 'Fischotter');
32  $link010 = $f->link()->bulky($symbol, '2021 - Fischotter', $uri->withParameter('c', 1));
33  $symbol = $f->symbol()->icon()->standard('rcat', 'Maulwurf');
34  $link011 = $f->link()->bulky($symbol, '2020 - Maulwurf', $uri->withParameter('c', 2));
35  $symbol = $f->symbol()->icon()->standard('rcat', 'Reh');
36  $link012 = $f->link()->bulky($symbol, '2019 - Reh', $uri->withParameter('c', 3));
37 
38  $symbol = $f->symbol()->icon()->standard('rcat', 'Bachflohkrebs');
39  $link020 = $f->link()->bulky($symbol, '2021 - Bachflohkrebs', $uri->withParameter('c', 4));
40  $symbol = $f->symbol()->icon()->standard('rcat', 'Wildkatze');
41  $link021 = $f->link()->bulky($symbol, '2020 - Wildkatze', $uri->withParameter('c', 5));
42  $symbol = $f->symbol()->icon()->standard('rcat', 'Glühwürmchen');
43  $link022 = $f->link()->bulky($symbol, '2019 - Glühwürmchen', $uri->withParameter('c', 6));
44 
45  $link10 = $f->link()->bulky($symbol, 'Frühbarock', $uri->withParameter('c', 7));
46  $link11 = $f->link()->bulky($symbol, 'Hochbarock', $uri->withParameter('c', 8));
47  $link12 = $f->link()->bulky($symbol, 'Spätbarock', $uri->withParameter('c', 9));
48 
49  $symbol = $f->symbol()->icon()->standard('cat', 'Deutschland');
50  $slate01 = $f->mainControls()->slate()->combined('Deutschland', $symbol)
51  ->withAdditionalEntry($link010)
52  ->withAdditionalEntry($link011)
53  ->withAdditionalEntry($link012);
54 
55  $contents = <<<EOT
56  <p>Leider gibt es im Takatuka Land kein Tier des Jahres.
57  <br />
58  <b>Aber:</b> Slates in der Main Bar können andere Inhalte als Links enthalten. </p>
59  <p>Zum Beispiel könnten sich hier Inhalte wie der Magazinbaum oder der
60  Mailbaum, komplexe Elemente wie das Notifikation Center, die Hilfe oder
61  auch dieser Text befinden.</p>
62  <p> Die Main Bar ist ganz bewusst nicht nur als 'Menü' gedacht sondern dient auch dazu,
63  komplexe Bedienelemente darzustellen.</p>
64 EOT;
65 
66  $symbol = $f->symbol()->icon()->standard('cat', 'Takatuka Land');
67  $slate02 = $f->mainControls()->slate()->legacy('Takatuka Land', $symbol, $f->legacy($contents));
68 
69  $symbol = $f->symbol()->icon()->standard('cat', 'Schweiz');
70  $slate03 = $f->mainControls()->slate()->combined('Schweiz', $symbol)
71  ->withAdditionalEntry($link020)
72  ->withAdditionalEntry($link021)
73  ->withAdditionalEntry($link022);
74 
75  $symbol = $f->symbol()->icon()->custom('./src/UI/examples/Layout/Page/Standard/layers.svg', '')->withSize('small');
76  $slate0 = $f->mainControls()->slate()->combined('Tier des Jahres', $symbol)
77  ->withAdditionalEntry($slate01)
78  ->withAdditionalEntry($slate02)
79  ->withAdditionalEntry($slate03);
80 
81  $slate1 = $f->mainControls()->slate()->combined('Barock', $symbol)
82  ->withAdditionalEntry($link10)
83  ->withAdditionalEntry($link11)
84  ->withAdditionalEntry($link12);
85 
86 
87  if (!$condensed) {
88  $mainbar = $f->mainControls()->mainBar()
89  ->withAdditionalEntry('slate0', $slate0)
90  ->withAdditionalEntry('slate1', $slate1);
91 
92  $tools_btn = $f->button()->bulky(
93  $f->symbol()->icon()->custom('./src/UI/examples/Layout/Page/Standard/grid.svg', ''),
94  'Tools',
95  '#'
96  );
97  $mainbar = $mainbar->withToolsButton($tools_btn);
98 
99  $symbol = $f->symbol()->icon()->custom('./src/UI/examples/Layout/Page/Standard/question.svg', '')->withSize('small');
100  $slate = $f->mainControls()->slate()->legacy('Help', $symbol, $f->legacy('<h2>tool 1</h2><p>Some Text for Tool 1 entry</p>'));
101  $tools = ['tool1' => $slate];
102  foreach ($tools as $id => $entry) {
103  $mainbar = $mainbar->withAdditionalToolEntry($id, $entry);
104  }
105 
106  return $mainbar;
107  }
108 
109  $slate_base = $f->mainControls()->slate()->combined('Menu', $symbol)
110  ->withAdditionalEntry($slate0)
111  ->withAdditionalEntry($slate1);
112  return $f->mainControls()->mainBar()
113  ->withAdditionalEntry('slate0', $slate_base);
114 }
115 
116 function getUIContent(\ILIAS\UI\Factory $f, RequestInterface $request): array
117 {
118  $params = $request->getQueryParams();
119  $cidx = -1;
120  if (array_key_exists('c', $params)) {
121  $cidx = $params['c'];
122  }
123 
124 
125  switch ($cidx) {
126  case 1:
127  $t = 'Tier des Jahres: Fischotter3';
128  $c = [
129  $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>')
130  ,$f->link()->standard("Quelle: Wikipedia", "https://de.wikipedia.org/wiki/Tier_des_Jahres")
131  ];
132  break;
133  case 2:
134  $t = 'Tier des Jahres: Maulwurf';
135  $c = [
136  $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>')
137  ,$f->link()->standard("Quelle: Wikipedia", "https://de.wikipedia.org/wiki/Tier_des_Jahres")
138  ];
139  break;
140  case 3:
141  $t = 'Tier des Jahres: Reh';
142  $c = [
143  $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>')
144  ];
145  break;
146  case 4:
147  $t = 'Tier des Jahres: Bachflohkrebs';
148  $c = [
149  $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>')
150  ,$f->link()->standard("Quelle: Wikipedia", "https://de.wikipedia.org/wiki/Tier_des_Jahres")
151  ];
152  break;
153  case 5:
154  $t = 'Tier des Jahres: Wildkatze';
155  $c = [
156  $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>')
157  ,$f->link()->standard("Quelle: Wikipedia", "https://de.wikipedia.org/wiki/Tier_des_Jahres")
158  ];
159  break;
160  case 6:
161  $t = 'Frühbarock';
162  $c = [
163  $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>')
164  ,$f->link()->standard("Quelle: Wikipedia", "https://de.wikipedia.org/wiki/Tier_des_Jahres")
165  ];
166  break;
167 
168  case 7:
169  $t = 'Frühbarock';
170  $c = [
171  $f->legacy('<h1>Frühbarock</h1><p><b>etwa 1600 bis 1650</b><br>unter italienischer Dominanz, mit etwa Monteverdi, Gabrieli.</p>')
172  ,$f->link()->standard("Quelle: Wikipedia", "https://de.wikipedia.org/wiki/Tier_des_Jahres")
173  ];
174  break;
175  case 8:
176  $t = 'Hochbarock';
177  $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>')];
178  break;
179  case 9:
180  $t = 'Spätbarock';
181  $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>')];
182  break;
183 
184  default:
185  $t = 'Mainbar-Demo';
186  $c = [$f->legacy('Dies ist ein reduziertes Beispiel für die Mainbar des UI-Frameworks.')];
187  }
188 
189  return[$t, $c];
190 }
191 
192 
193 global $DIC;
194 $request_wrapper = $DIC->http()->wrapper()->query();
195 $refinery = $DIC->refinery();
196 
197 if ($request_wrapper->has('ui_mainbar')
198 ) {
200  switch ($request_wrapper->retrieve('ui_mainbar', $refinery->kindlyTo()->int())) {
201  case 1:
203  break;
204  case 2:
206  break;
207  }
208 
209  exit();
210 }
211 
212 
213 function getURI(): \ILIAS\Data\URI
214 {
215  $df = new Factory();
216  return $df->uri(
217  $_SERVER['REQUEST_SCHEME'] . '://'
218  . $_SERVER['SERVER_NAME'] . ':'
219  . $_SERVER['SERVER_PORT']
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/logo/HeaderIcon.svg", "ILIAS");
231  $responsive_logo = $f->image()->responsive("templates/default/images/logo/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/logo/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 }
exit
Definition: login.php:29
This describes the MainBar.
Definition: MainBar.php:33
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:29
getUIContent(\ILIAS\UI\Factory $f, RequestInterface $request)
Definition: ui_mainbar.php:116
Class ChatMainBarProvider .
getRenderedPage(Container $dic, MainBar $mainbar)
Definition: ui_mainbar.php:225
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:213
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:18
withAdditionalEntry(string $id, $entry)
Append an entry.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
$dic
Definition: result.php:32
ui()
Get the interface to get services from UI framework.
Definition: Container.php:127