ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ui.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
6 
10 
11 function ui(): string
12 {
13  global $DIC;
14  $f = $DIC->ui()->factory();
15  $renderer = $DIC->ui()->renderer();
16 
17  $icon = $f->symbol()->icon()->standard('root', '')->withSize('large');
18  $target = new \ILIAS\Data\URI(
19  $DIC->http()->request()->getUri()->__toString() . '&new_ui=1'
20  );
21  return $renderer->render(
22  $f->link()->bulky($icon, 'See UI in fullscreen-mode', $target),
23  );
24 }
25 
26 
27 
28 global $DIC;
29 $request_wrapper = $DIC->http()->wrapper()->query();
30 $refinery = $DIC->refinery();
31 
32 if ($request_wrapper->has('new_ui')
33  && $request_wrapper->retrieve('new_ui', $refinery->kindlyTo()->int()) === 1
34 ) {
36  echo(renderFullDemoPage($DIC));
37  exit();
38 }
39 
41 {
42  $refinery = $dic->refinery();
43  $request_wrapper = $dic->http()->wrapper()->query();
44 
45  $f = $dic->ui()->factory();
46  $renderer = $dic->ui()->renderer();
47  $logo = $f->image()->responsive("templates/default/images/logo/HeaderIcon.svg", "ILIAS");
48  $responsive_logo = $f->image()->responsive("templates/default/images/logo/HeaderIconResponsive.svg", "ILIAS");
49  $breadcrumbs = pagedemoCrumbs($f);
50  $metabar = pagedemoMetabar($f);
51  $mainbar = pagedemoMainbar($f, $renderer);
52  $footer = pagedemoFooter($f);
53  $content = pagedemoContent($f, $renderer, $mainbar);
54  $tc = $dic->ui()->factory()->toast()->container();
55 
56  $page = $f->layout()->page()->standard(
57  $content,
58  $metabar,
59  $mainbar,
60  $breadcrumbs,
61  $logo,
62  $responsive_logo,
63  "./templates/default/images/logo/favicon.ico",
64  $tc,
65  $footer,
66  'UI PAGE DEMO', //page title
67  'ILIAS', //short title
68  'Std. Page Demo' //view title
69  )
70  ->withHeaders(true)
71  ->withUIDemo(true);
72 
73  return $renderer->render($page);
74 }
75 
76 if (isset($request_wrapper) && isset($refinery) && $request_wrapper->has('replaced') && $request_wrapper->retrieve('replaced', $refinery->kindlyTo()->string()) == '1') {
77  echo('Helo. Content from RPC.');
78  exit();
79 }
80 
84 function pagedemoCrumbs($f)
85 {
86  $crumbs = [
87  $f->link()->standard("entry1", '#'),
88  $f->link()->standard("entry2", '#'),
89  $f->link()->standard("entry3", '#'),
90  $f->link()->standard("entry4", '#')
91  ];
92  return $f->breadcrumbs($crumbs);
93 }
94 
95 function pagedemoContent(\ILIAS\UI\Factory $f, Renderer $r, MainBar $mainbar): array
96 {
97  $tools = $mainbar->getToolEntries();
98 
99  $second_tool = array_values($tools)[1];
100  $url = "./src/UI/examples/Layout/Page/Standard/ui.php?replaced=1";
101  $replace_signal = $second_tool->getReplaceSignal()->withAsyncRenderUrl($url);
102  $replace_btn = $f->button()->standard('replace contents in 2nd tool', $replace_signal);
103 
104  $engage_signal = $mainbar->getEngageToolSignal(array_keys($tools)[2]);
105  $invisible_tool_btn = $f->button()->standard('show the hidden tool', $engage_signal);
106 
107  return [
108  $f->panel()->standard(
109  'Using Signals',
110  $f->legacy(
111  "This button will replace the contents of the second tool-slate.<br />"
112  . "Goto Tools, second entry and click it.<br />"
113  . $r->render($replace_btn)
114  . "<br><br>This will unhide and activate another tool<br />"
115  . $r->render($invisible_tool_btn)
116  )
117  ),
118 
119  $f->panel()->standard(
120  'Demo Content 2',
121  $f->legacy("some content<br>some content<br>some content<br>x.")
122  ),
123  $f->panel()->standard(
124  'Demo Content 3',
125  $f->legacy(loremIpsum())
126  ),
127  $f->panel()->standard(
128  'Demo Content 4',
129  $f->legacy("some content<br>some content<br>some content<br>x.")
130  )
131  ];
132 }
133 
134 function pagedemoFooter(\ILIAS\UI\Factory $f): \ILIAS\UI\Component\MainControls\Footer
135 {
136  $df = new \ILIAS\Data\Factory();
137  $text = 'Additional info:';
138  $links = [];
139  $links[] = $f->link()->standard("Goto ILIAS", "http://www.ilias.de");
140  $links[] = $f->link()->standard("Goto ILIAS", "http://www.ilias.de");
141 
142  return $f->mainControls()->footer($links, $text)
143  ->withPermanentURL(
144  $df->uri(
145  ($_SERVER['REQUEST_SCHEME'] ?? "http") . '://'
146  . ($_SERVER['SERVER_NAME'] ?? "localhost") . ':'
147  . ($_SERVER['SERVER_PORT'] ?? "80")
148  . ($_SERVER['SCRIPT_NAME'] ?? "") . '?'
149  . ($_SERVER['QUERY_STRING'] ?? "")
150  )
151  );
152 }
153 
154 function pagedemoMetabar(\ILIAS\UI\Factory $f): \ILIAS\UI\Component\MainControls\MetaBar
155 {
156  $help = $f->button()->bulky($f->symbol()->glyph()->help(), 'Help', '#');
157  $user = $f->button()->bulky($f->symbol()->glyph()->user(), 'User', '#');
158  $search = $f->maincontrols()->slate()->legacy(
159  'Search',
160  $f->symbol()->glyph()->search()->withCounter($f->counter()->status(1)),
161  $f->legacy(substr(loremIpsum(), 0, 180))
162  );
163  $notes = $f->maincontrols()->slate()->legacy(
164  'Notification',
165  $f->symbol()->glyph()->notification()->withCounter($f->counter()->novelty(3)),
166  $f->legacy('<p>some content</p>')
167  );
168 
169  return $f->mainControls()->metaBar()
170  ->withAdditionalEntry('search', $search)
171  ->withAdditionalEntry('help', $help)
172  ->withAdditionalEntry('notes', $notes)
173  ->withAdditionalEntry('user', $user);
174 }
175 
177 {
178  $tools_btn = $f->button()->bulky(
179  $f->symbol()->icon()->custom('./src/UI/examples/Layout/Page/Standard/grid.svg', ''),
180  'Tools',
181  '#'
182  );
183 
184  $mainbar = $f->mainControls()->mainBar()
185  ->withToolsButton($tools_btn);
186 
187  $entries = [];
188  $entries['repository'] = getDemoEntryRepository($f);
189  $entries['pws'] = getDemoEntryPersonalWorkspace($f, $r);
190  $entries['achievements'] = getDemoEntryAchievements($f);
191  $entries['communication'] = getDemoEntryCommunication($f);
192  $entries['organisation'] = getDemoEntryOrganisation($f);
193  $entries['administration'] = getDemoEntryAdministration($f);
194 
195  foreach ($entries as $id => $entry) {
196  $mainbar = $mainbar->withAdditionalEntry($id, $entry);
197  }
198 
199  $tools = getDemoEntryTools($f);
200 
201  return $mainbar
202  ->withAdditionalToolEntry('tool1', $tools['tool1'], false, $f->button()->close())
203  ->withAdditionalToolEntry('tool2', $tools['tool2'])
204  ->withAdditionalToolEntry('tool3', $tools['tool3'], true, $f->button()->close())
205  ->withAdditionalToolEntry('tool4', $tools['tool4'], false, $f->button()->close());
206 }
207 
208 
209 function getDemoEntryRepository(\ILIAS\UI\Factory $f): \ILIAS\UI\Component\MainControls\Slate\Combined
210 {
211  $symbol = $f->symbol()->icon()
212  ->custom('./src/UI/examples/Layout/Page/Standard/layers.svg', '')
213  ->withSize('small');
214  $slate = $f->maincontrols()->slate()->combined('Repository', $symbol);
215 
216  $icon = $f->symbol()->icon()
217  ->standard('', '')
218  ->withSize('small')
219  ->withAbbreviation('X');
220 
221  $button = $f->button()->bulky(
222  $icon,
223  'Button 1',
224  './src/UI/examples/Layout/Page/Standard/ui.php?new_ui=1'
225  );
226 
227  $df = new \ILIAS\Data\Factory();
228  $url = $df->uri(
229  $_SERVER['REQUEST_SCHEME'] . '://'
230  . $_SERVER['SERVER_NAME'] . ':'
231  . $_SERVER['SERVER_PORT']
232  . $_SERVER['SCRIPT_NAME'] . '?'
233  . $_SERVER['QUERY_STRING']
234  );
235  $link1 = $f->link()->bulky($icon, 'Favorites (Link)', $url);
236  $link2 = $f->link()->bulky($icon, 'Courses (Link2)', $url);
237  $link3 = $f->link()->bulky($icon, 'Groups (Link)', $url);
238 
239  $slate = $slate
240  ->withAdditionalEntry($button->withLabel('Repository - Home'))
241  ->withAdditionalEntry($button->withLabel('Repository - Tree'))
242  ->withAdditionalEntry($button->withLabel('Repository - Last visited'))
243  ->withAdditionalEntry($link1)
244  ->withAdditionalEntry($link2)
245  ->withAdditionalEntry($link3)
246  ->withAdditionalEntry($button->withLabel('Study Programme'))
247  ->withAdditionalEntry($button->withLabel('Own Repository-Objects'));
248 
249  foreach (range(1, 20) as $cnt) {
250  $slate = $slate->withAdditionalEntry($button->withLabel('fillup ' . $cnt));
251  }
252 
253  return $slate;
254 }
255 
256 function getDemoEntryPersonalWorkspace(\ILIAS\UI\Factory $f, Renderer $r): \ILIAS\UI\Component\MainControls\Slate\Combined
257 {
258  $icon = $f->symbol()->icon()
259  ->standard('', '')
260  ->withSize('small')
261  ->withAbbreviation('X');
262 
263  $button = $f->button()->bulky(
264  $icon,
265  'Button 1',
266  './src/UI/examples/Layout/Page/Standard/ui.php?new_ui=1'
267  );
268 
269  $symbol = $f->symbol()->icon()
270  ->custom('./src/UI/examples/Layout/Page/Standard/user.svg', '')
271  ->withSize('small');
272 
273  $slate = $f->maincontrols()->slate()
274  ->combined('Personal Workspace', $symbol);
275 
276  $symbol = $f->symbol()->icon()
277  ->custom('./src/UI/examples/Layout/Page/Standard/bookmarks.svg', '')
278  ->withSize('small');
279 
280  $bookmarks = $f->legacy(implode('<br />', [
281  $r->render($f->button()->shy('my bookmark 1', '#')),
282  $r->render($f->button()->shy('my bookmark 2', '#'))
283  ]));
284  $slate_bookmarks = $f->maincontrols()->slate()
285  ->legacy('Bookmarks', $symbol, $bookmarks);
286 
287  return $slate
288  ->withAdditionalEntry($button->withLabel('Overview'))
289  ->withAdditionalEntry($slate_bookmarks)
290  ->withAdditionalEntry($button->withLabel('Calendar'))
291  ->withAdditionalEntry($button->withLabel('Task'))
292  ->withAdditionalEntry($button->withLabel('Portfolios'))
293  ->withAdditionalEntry($button->withLabel('Personal Resources'))
294  ->withAdditionalEntry($button->withLabel('Shared Resources'))
295  ->withAdditionalEntry($button->withLabel('Notes'))
296  ->withAdditionalEntry($button->withLabel('News'))
297  ->withAdditionalEntry($button->withLabel('Background Tasks'))
298  ->withAdditionalEntry($slate_bookmarks);
299 }
300 
302 {
303  $symbol = $f->symbol()->icon()
304  ->custom('./src/UI/examples/Layout/Page/Standard/achievements.svg', '')
305  ->withSize('small');
306  return $f->maincontrols()->slate()->legacy(
307  'Achievements',
308  $symbol,
309  $f->legacy('content: Achievements')
310  );
311 }
312 
314 {
315  $symbol = $f->symbol()->icon()
316  ->custom('./src/UI/examples/Layout/Page/Standard/communication.svg', '')
317  ->withSize('small');
318  return $f->maincontrols()->slate()->legacy(
319  'Communication',
320  $symbol,
321  $f->legacy('content: Communication')
322  );
323 }
324 
325 function getDemoEntryOrganisation(\ILIAS\UI\Factory $f): \ILIAS\UI\Component\MainControls\Slate\Combined
326 {
327  $symbol = $f->symbol()->icon()
328  ->custom('./src/UI/examples/Layout/Page/Standard/organisation.svg', '')
329  ->withSize('small');
330 
331  $sf = $f->maincontrols()->slate();
332  return $sf->combined('Organisation', $symbol)
333  ->withAdditionalEntry(
334  $sf->combined('1', $symbol)
335  ->withAdditionalEntry($sf->combined('1.1', $symbol))
336  ->withAdditionalEntry(
337  $sf->combined('1.2', $symbol)
338  ->withAdditionalEntry($sf->combined('1.2.1', $symbol))
339  ->withAdditionalEntry($sf->combined('1.2.2', $symbol))
340  )
341  )
342  ->withAdditionalEntry(
343  $sf->combined('2', $symbol)
344  ->withAdditionalEntry($sf->combined('2.1', $symbol))
345  )
346  ->withAdditionalEntry($sf->combined('3', $symbol))
347  ->withAdditionalEntry($sf->combined('4', $symbol));
348 }
349 
351 {
352  $symbol = $f->symbol()->icon()
353  ->custom('./src/UI/examples/Layout/Page/Standard/administration.svg', '')
354  ->withSize('small');
355  return $f->maincontrols()->slate()->legacy(
356  'Administration',
357  $symbol,
358  $f->legacy('content: Administration')
359  );
360 }
361 
363 {
364  $tools = [];
365 
366  $symbol = $f->symbol()->icon()
367  ->custom('./src/UI/examples/Layout/Page/Standard/question.svg', '')
368  ->withSize('small');
369  $slate = $f->maincontrols()->slate()->legacy(
370  'Help',
371  $symbol,
372  $f->legacy('
373  <h2>Help</h2>
374  <p>
375  Some Text for help entry
376  </p>
377  <p>
378  <button onclick="alert(\'helo - tool 1 \');">Some Dummybutton</button>
379  <br>
380  <button onclick="alert(\'helo - tool 1, button 2 \');">some other dummybutton</button>
381  </p>
382  ')
383  );
384  $tools['tool1'] = $slate;
385 
386  $symbol = $f->symbol()->icon()
387  ->custom('./src/UI/examples/Layout/Page/Standard/pencil.svg', '')
388  ->withSize('small');
389  $slate = $f->maincontrols()->slate()->legacy(
390  'Editor',
391  $symbol,
392  $f->legacy('
393  <h2>Editor</h2>
394  <p>
395  Some Text for editor entry
396  <br><br>
397  <button onclick="alert(\'helo\');">Some Dummybutton</button>
398  <br><br>
399  end of tool.
400  </p>
401  ')
402  );
403  $tools['tool2'] = $slate;
404 
405  $symbol = $f->symbol()->icon()
406  ->custom('./src/UI/examples/Layout/Page/Standard/notebook.svg', '')
407  ->withSize('small');
408  $slate = $f->maincontrols()->slate()->legacy(
409  'Initially hidden',
410  $symbol,
411  $f->legacy(loremIpsum())
412  );
413  $tools['tool3'] = $slate;
414 
415  $slate = $f->maincontrols()->slate()->legacy(
416  'Closable Tool',
417  $symbol,
418  $f->legacy(loremIpsum())
419  );
420  $tools['tool4'] = $slate;
421 
422 
423  return $tools;
424 }
425 
426 function loremIpsum(): string
427 {
428  return <<<EOT
429  <h2>Lorem ipsum</h2>
430  <p>
431  Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
432  tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
433  At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,
434  no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet,
435  consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et
436  dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo
437  duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus
438  est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur
439  sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore
440  magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo
441  dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est
442  Lorem ipsum dolor sit amet.
443  </p>
444  <p>
445  Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie
446  consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan
447  et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis
448  dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer
449  adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore
450  magna aliquam erat volutpat.
451  </p>
452  <p>
453  Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit
454  lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure
455  dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore
456  eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui
457  blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.
458  </p>
459  <p>
460  Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming
461  id quod mazim placerat facer
462  </p>
463 EOT;
464 }
if($request_wrapper->has('new_ui') && $request_wrapper->retrieve('new_ui', $refinery->kindlyTo() ->int())===1) renderFullDemoPage(\ILIAS\DI\Container $dic)
Definition: ui.php:40
An entity that renders components to a string output.
Definition: Renderer.php:30
getDemoEntryAdministration(\ILIAS\UI\Factory $f)
Definition: ui.php:350
exit
Definition: login.php:29
getDemoEntryRepository(\ILIAS\UI\Factory $f)
Definition: ui.php:209
getDemoEntryAchievements(\ILIAS\UI\Factory $f)
Definition: ui.php:301
This describes the MainBar.
Definition: MainBar.php:33
pagedemoContent(\ILIAS\UI\Factory $f, Renderer $r, MainBar $mainbar)
Definition: ui.php:95
render($component, ?Renderer $root=null)
Render given component.
Class ChatMainBarProvider .
getDemoEntryCommunication(\ILIAS\UI\Factory $f)
Definition: ui.php:313
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
pagedemoMainbar(\ILIAS\UI\Factory $f, Renderer $r)
Definition: ui.php:176
pagedemoMetabar(\ILIAS\UI\Factory $f)
Definition: ui.php:154
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:35
static initILIAS()
ilias initialisation
if(isset($request_wrapper) &&isset($refinery) && $request_wrapper->has('replaced') && $request_wrapper->retrieve('replaced', $refinery->kindlyTo() ->string())=='1') pagedemoCrumbs($f)
Below are helpers for the construction of demo-content.
Definition: ui.php:84
Class HTTPServicesTest.
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10
getDemoEntryOrganisation(\ILIAS\UI\Factory $f)
Definition: ui.php:325
$url
Definition: ltiregstart.php:35
getDemoEntryTools(\ILIAS\UI\Factory $f)
Definition: ui.php:362
pagedemoFooter(\ILIAS\UI\Factory $f)
Definition: ui.php:134
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
$dic
Definition: result.php:32
withToolsButton(Button\Bulky $button)
Set button for the tools-trigger.
getEngageToolSignal(string $tool_id)
Signal to engage a tool from outside the MainBar.
getDemoEntryPersonalWorkspace(\ILIAS\UI\Factory $f, Renderer $r)
Definition: ui.php:256
$r