ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ui.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
6 
10 
102 function ui(): string
103 {
104  global $DIC;
105  $f = $DIC->ui()->factory();
106  $renderer = $DIC->ui()->renderer();
107 
108  $icon = $f->symbol()->icon()->standard('root', '')->withSize('large');
109  $target = new \ILIAS\Data\URI(
110  $DIC->http()->request()->getUri()->__toString() . '&new_ui=1'
111  );
112  return $renderer->render(
113  $f->link()->bulky($icon, 'See UI in fullscreen-mode', $target),
114  );
115 }
116 
117 
118 
119 global $DIC;
120 $request_wrapper = $DIC->http()->wrapper()->query();
121 $refinery = $DIC->refinery();
122 
123 if ($request_wrapper->has('new_ui')
124  && $request_wrapper->retrieve('new_ui', $refinery->kindlyTo()->int()) === 1
125 ) {
127  echo(renderFullDemoPage($DIC));
128  exit();
129 }
130 
132 {
133  $refinery = $dic->refinery();
134  $request_wrapper = $dic->http()->wrapper()->query();
135 
136  $f = $dic->ui()->factory();
137  $renderer = $dic->ui()->renderer();
138  $logo = $f->image()->responsive("assets/images/logo/HeaderIcon.svg", "ILIAS");
139  $responsive_logo = $f->image()->responsive("assets/images/logo/HeaderIconResponsive.svg", "ILIAS");
140  $breadcrumbs = pagedemoCrumbs($f);
141  $metabar = pagedemoMetabar($f);
142  $mainbar = pagedemoMainbar($f, $renderer);
143  $footer = pagedemoFooter($f);
144  $content = pagedemoContent($f, $renderer, $mainbar);
145  $tc = $dic->ui()->factory()->toast()->container();
146 
147  $page = $f->layout()->page()->standard(
148  $content,
149  $metabar,
150  $mainbar,
151  $breadcrumbs,
152  $logo,
153  $responsive_logo,
154  "./assets/images/logo/favicon.ico",
155  $tc,
156  $footer,
157  'UI PAGE DEMO', //page title
158  'ILIAS', //short title
159  'Std. Page Demo' //view title
160  )
161  ->withHeaders(true)
162  ->withUIDemo(true);
163 
164  return $renderer->render($page);
165 }
166 
167 if (isset($request_wrapper) && isset($refinery) && $request_wrapper->has('replaced') && $request_wrapper->retrieve('replaced', $refinery->kindlyTo()->string()) == '1') {
168  echo('Helo. Content from RPC.');
169  exit();
170 }
171 
176 {
177  $crumbs = [
178  $f->link()->standard("entry1", '#'),
179  $f->link()->standard("entry2", '#'),
180  $f->link()->standard("entry3", '#'),
181  $f->link()->standard("entry4", '#')
182  ];
183  return $f->breadcrumbs($crumbs);
184 }
185 
186 function pagedemoContent(\ILIAS\UI\Factory $f, Renderer $r, MainBar $mainbar): array
187 {
188  $tools = $mainbar->getToolEntries();
189 
190  $second_tool = array_values($tools)[1];
191  $url = "./components/ILIAS/UI/src/examples/Layout/Page/Standard/ui.php?replaced=1";
192  $replace_signal = $second_tool->getReplaceSignal()->withAsyncRenderUrl($url);
193  $replace_btn = $f->button()->standard('replace contents in 2nd tool', $replace_signal);
194 
195  $engage_signal = $mainbar->getEngageToolSignal(array_keys($tools)[2]);
196  $invisible_tool_btn = $f->button()->standard('show the hidden tool', $engage_signal);
197 
198  return [
199  $f->panel()->standard(
200  'Using Signals',
201  $f->legacy(
202  "This button will replace the contents of the second tool-slate.<br />"
203  . "Goto Tools, second entry and click it.<br />"
204  . $r->render($replace_btn)
205  . "<br><br>This will unhide and activate another tool<br />"
206  . $r->render($invisible_tool_btn)
207  )
208  ),
209 
210  $f->panel()->standard(
211  'Demo Content 2',
212  $f->legacy("some content<br>some content<br>some content<br>x.")
213  ),
214  $f->panel()->standard(
215  'Demo Content 3',
216  $f->legacy(loremIpsum())
217  ),
218  $f->panel()->standard(
219  'Demo Content 4',
220  $f->legacy("some content<br>some content<br>some content<br>x.")
221  )
222  ];
223 }
224 
225 function pagedemoFooter(\ILIAS\UI\Factory $f): \ILIAS\UI\Component\MainControls\Footer
226 {
227  $df = new \ILIAS\Data\Factory();
228  $text = 'Additional info:';
229  $links = [];
230  $links[] = $f->link()->standard("Goto ILIAS", "http://www.ilias.de");
231  $links[] = $f->link()->standard("Goto ILIAS", "http://www.ilias.de");
232 
233  return $f->mainControls()->footer()
234  ->withAdditionalLink(...$links)
235  ->withAdditionalText($text)
236  ->withPermanentURL(
237  $df->uri(
238  ($_SERVER['REQUEST_SCHEME'] ?? "http") . '://'
239  . ($_SERVER['SERVER_NAME'] ?? "localhost") . ':'
240  . ($_SERVER['SERVER_PORT'] ?? "80")
241  . ($_SERVER['SCRIPT_NAME'] ?? "") . '?'
242  . ($_SERVER['QUERY_STRING'] ?? "")
243  )
244  );
245 }
246 
247 function pagedemoMetabar(\ILIAS\UI\Factory $f): \ILIAS\UI\Component\MainControls\MetaBar
248 {
249  $help = $f->button()->bulky($f->symbol()->glyph()->help(), 'Help', '#');
250  $user = $f->button()->bulky($f->symbol()->glyph()->user(), 'User', '#');
251  $search = $f->maincontrols()->slate()->legacy(
252  'Search',
253  $f->symbol()->glyph()->search()->withCounter($f->counter()->status(1)),
254  $f->legacy(substr(loremIpsum(), 0, 180))
255  );
256  $notes = $f->maincontrols()->slate()->legacy(
257  'Notification',
258  $f->symbol()->glyph()->notification()->withCounter($f->counter()->novelty(3)),
259  $f->legacy('<p>some content</p>')
260  );
261 
262  return $f->mainControls()->metaBar()
263  ->withAdditionalEntry('search', $search)
264  ->withAdditionalEntry('help', $help)
265  ->withAdditionalEntry('notes', $notes)
266  ->withAdditionalEntry('user', $user);
267 }
268 
270 {
271  $tools_btn = $f->button()->bulky(
272  $f->symbol()->icon()->custom('./assets/ui-examples/images/Page/grid.svg', ''),
273  'Tools',
274  '#'
275  );
276 
277  $mainbar = $f->mainControls()->mainBar()
278  ->withToolsButton($tools_btn);
279 
280  $entries = [];
281  $entries['repository'] = getDemoEntryRepository($f);
282  $entries['pws'] = getDemoEntryPersonalWorkspace($f, $r);
283  $entries['achievements'] = getDemoEntryAchievements($f);
284  $entries['communication'] = getDemoEntryCommunication($f);
285  $entries['organisation'] = getDemoEntryOrganisation($f);
286  $entries['administration'] = getDemoEntryAdministration($f);
287 
288  foreach ($entries as $id => $entry) {
289  $mainbar = $mainbar->withAdditionalEntry($id, $entry);
290  }
291 
292  $tools = getDemoEntryTools($f);
293 
294  return $mainbar
295  ->withAdditionalToolEntry('tool1', $tools['tool1'], false, $f->button()->close())
296  ->withAdditionalToolEntry('tool2', $tools['tool2'])
297  ->withAdditionalToolEntry('tool3', $tools['tool3'], true, $f->button()->close())
298  ->withAdditionalToolEntry('tool4', $tools['tool4'], false, $f->button()->close());
299 }
300 
301 
302 function getDemoEntryRepository(\ILIAS\UI\Factory $f): \ILIAS\UI\Component\MainControls\Slate\Combined
303 {
304  $symbol = $f->symbol()->icon()
305  ->custom('./assets/ui-examples/images/Page/layers.svg', '')
306  ->withSize('small');
307  $slate = $f->maincontrols()->slate()->combined('Repository', $symbol);
308 
309  $icon = $f->symbol()->icon()
310  ->standard('', '')
311  ->withSize('small')
312  ->withAbbreviation('X');
313 
314  $button = $f->button()->bulky(
315  $icon,
316  'Button 1',
317  './components/ILIAS/UI/src/examples/Layout/Page/Standard/ui.php?new_ui=1'
318  );
319 
320  $df = new \ILIAS\Data\Factory();
321  $url = $df->uri(
322  $_SERVER['REQUEST_SCHEME'] . '://'
323  . $_SERVER['SERVER_NAME'] . ':'
324  . $_SERVER['SERVER_PORT']
325  . $_SERVER['SCRIPT_NAME'] . '?'
326  . $_SERVER['QUERY_STRING']
327  );
328  $link1 = $f->link()->bulky($icon, 'Favorites (Link)', $url);
329  $link2 = $f->link()->bulky($icon, 'Courses (Link2)', $url);
330  $link3 = $f->link()->bulky($icon, 'Groups (Link)', $url);
331 
332  $slate = $slate
333  ->withAdditionalEntry($button->withLabel('Repository - Home'))
334  ->withAdditionalEntry($button->withLabel('Repository - Tree'))
335  ->withAdditionalEntry($button->withLabel('Repository - Last visited'))
336  ->withAdditionalEntry($link1)
337  ->withAdditionalEntry($link2)
338  ->withAdditionalEntry($link3)
339  ->withAdditionalEntry($button->withLabel('Study Programme'))
340  ->withAdditionalEntry($button->withLabel('Own Repository-Objects'));
341 
342  foreach (range(1, 20) as $cnt) {
343  $slate = $slate->withAdditionalEntry($button->withLabel('fillup ' . $cnt));
344  }
345 
346  return $slate;
347 }
348 
349 function getDemoEntryPersonalWorkspace(\ILIAS\UI\Factory $f, Renderer $r): \ILIAS\UI\Component\MainControls\Slate\Combined
350 {
351  $icon = $f->symbol()->icon()
352  ->standard('', '')
353  ->withSize('small')
354  ->withAbbreviation('X');
355 
356  $button = $f->button()->bulky(
357  $icon,
358  'Button 1',
359  './components/ILIAS/UI/src/examples/Layout/Page/Standard/ui.php?new_ui=1'
360  );
361 
362  $symbol = $f->symbol()->icon()
363  ->custom('./assets/ui-examples/images/Page/user.svg', '')
364  ->withSize('small');
365 
366  $slate = $f->maincontrols()->slate()
367  ->combined('Personal Workspace', $symbol);
368 
369  $symbol = $f->symbol()->icon()
370  ->custom('./assets/ui-examples/images/Page/bookmarks.svg', '')
371  ->withSize('small');
372 
373  $bookmarks = $f->legacy(implode('<br />', [
374  $r->render($f->button()->shy('my bookmark 1', '#')),
375  $r->render($f->button()->shy('my bookmark 2', '#'))
376  ]));
377  $slate_bookmarks = $f->maincontrols()->slate()
378  ->legacy('Bookmarks', $symbol, $bookmarks);
379 
380  return $slate
381  ->withAdditionalEntry($button->withLabel('Overview'))
382  ->withAdditionalEntry($slate_bookmarks)
383  ->withAdditionalEntry($button->withLabel('Calendar'))
384  ->withAdditionalEntry($button->withLabel('Task'))
385  ->withAdditionalEntry($button->withLabel('Portfolios'))
386  ->withAdditionalEntry($button->withLabel('Personal Resources'))
387  ->withAdditionalEntry($button->withLabel('Shared Resources'))
388  ->withAdditionalEntry($button->withLabel('Notes'))
389  ->withAdditionalEntry($button->withLabel('News'))
390  ->withAdditionalEntry($button->withLabel('Background Tasks'));
391 }
392 
394 {
395  $symbol = $f->symbol()->icon()
396  ->custom('./assets/ui-examples/images/Page/achievements.svg', '')
397  ->withSize('small');
398  return $f->maincontrols()->slate()->legacy(
399  'Achievements',
400  $symbol,
401  $f->legacy('content: Achievements')
402  );
403 }
404 
406 {
407  $symbol = $f->symbol()->icon()
408  ->custom('./assets/ui-examples/images/Page/communication.svg', '')
409  ->withSize('small');
410  return $f->maincontrols()->slate()->legacy(
411  'Communication',
412  $symbol,
413  $f->legacy('content: Communication')
414  );
415 }
416 
417 function getDemoEntryOrganisation(\ILIAS\UI\Factory $f): \ILIAS\UI\Component\MainControls\Slate\Combined
418 {
419  $symbol = $f->symbol()->icon()
420  ->custom('./assets/ui-examples/images/Page/organisation.svg', '')
421  ->withSize('small');
422 
423  $sf = $f->maincontrols()->slate();
424  return $sf->combined('Organisation', $symbol)
425  ->withAdditionalEntry(
426  $sf->combined('1', $symbol)
427  ->withAdditionalEntry($sf->combined('1.1', $symbol))
428  ->withAdditionalEntry(
429  $sf->combined('1.2', $symbol)
430  ->withAdditionalEntry($sf->combined('1.2.1', $symbol))
431  ->withAdditionalEntry($sf->combined('1.2.2', $symbol))
432  )
433  )
434  ->withAdditionalEntry(
435  $sf->combined('2', $symbol)
436  ->withAdditionalEntry($sf->combined('2.1', $symbol))
437  )
438  ->withAdditionalEntry($sf->combined('3', $symbol))
439  ->withAdditionalEntry($sf->combined('4', $symbol));
440 }
441 
443 {
444  $symbol = $f->symbol()->icon()
445  ->custom('./assets/ui-examples/images/Page/administration.svg', '')
446  ->withSize('small');
447  return $f->maincontrols()->slate()->legacy(
448  'Administration',
449  $symbol,
450  $f->legacy('content: Administration')
451  );
452 }
453 
455 {
456  $tools = [];
457 
458  $symbol = $f->symbol()->icon()
459  ->custom('./assets/ui-examples/images/Page/question.svg', '')
460  ->withSize('small');
461  $slate = $f->maincontrols()->slate()->legacy(
462  'Help',
463  $symbol,
464  $f->legacy('
465  <h2>Help</h2>
466  <p>
467  Some Text for help entry
468  </p>
469  <p>
470  <button onclick="alert(\'helo - tool 1 \');">Some Dummybutton</button>
471  <br>
472  <button onclick="alert(\'helo - tool 1, button 2 \');">some other dummybutton</button>
473  </p>
474  ')
475  );
476  $tools['tool1'] = $slate;
477 
478  $symbol = $f->symbol()->icon()
479  ->custom('./assets/ui-examples/images/Page/pencil.svg', '')
480  ->withSize('small');
481  $slate = $f->maincontrols()->slate()->legacy(
482  'Editor',
483  $symbol,
484  $f->legacy('
485  <h2>Editor</h2>
486  <p>
487  Some Text for editor entry
488  <br><br>
489  <button onclick="alert(\'helo\');">Some Dummybutton</button>
490  <br><br>
491  end of tool.
492  </p>
493  ')
494  );
495  $tools['tool2'] = $slate;
496 
497  $symbol = $f->symbol()->icon()
498  ->custom('./assets/ui-examples/images/Page/notebook.svg', '')
499  ->withSize('small');
500  $slate = $f->maincontrols()->slate()->legacy(
501  'Initially hidden',
502  $symbol,
503  $f->legacy(loremIpsum())
504  );
505  $tools['tool3'] = $slate;
506 
507  $slate = $f->maincontrols()->slate()->legacy(
508  'Closable Tool',
509  $symbol,
510  $f->legacy(loremIpsum())
511  );
512  $tools['tool4'] = $slate;
513 
514 
515  return $tools;
516 }
517 
518 function loremIpsum(): string
519 {
520  return <<<EOT
521  <h2>Lorem ipsum</h2>
522  <p>
523  Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
524  tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
525  At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,
526  no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet,
527  consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et
528  dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo
529  duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus
530  est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur
531  sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore
532  magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo
533  dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est
534  Lorem ipsum dolor sit amet.
535  </p>
536  <p>
537  Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie
538  consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan
539  et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis
540  dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer
541  adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore
542  magna aliquam erat volutpat.
543  </p>
544  <p>
545  Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit
546  lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure
547  dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore
548  eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui
549  blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.
550  </p>
551  <p>
552  Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming
553  id quod mazim placerat facer
554  </p>
555 EOT;
556 }
if($request_wrapper->has('new_ui') && $request_wrapper->retrieve('new_ui', $refinery->kindlyTo() ->int())===1) renderFullDemoPage(\ILIAS\DI\Container $dic)
Definition: ui.php:131
getDemoEntryAdministration(\ILIAS\UI\Factory $f)
Definition: ui.php:442
$renderer
getDemoEntryRepository(\ILIAS\UI\Factory $f)
Definition: ui.php:302
getDemoEntryAchievements(\ILIAS\UI\Factory $f)
Definition: ui.php:393
ui()
description: > Example for rendering a UI.
Definition: ui.php:102
This describes the MainBar.
Definition: MainBar.php:33
pagedemoContent(\ILIAS\UI\Factory $f, Renderer $r, MainBar $mainbar)
Definition: ui.php:186
render($component, ?Renderer $root=null)
Render given component.
Interface Observer Contains several chained tasks and infos about them.
getDemoEntryCommunication(\ILIAS\UI\Factory $f)
Definition: ui.php:405
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:269
pagedemoMetabar(\ILIAS\UI\Factory $f)
Definition: ui.php:247
$url
Definition: shib_logout.php:63
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:175
Class HTTPServicesTest.
$text
Definition: xapiexit.php:21
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10
getDemoEntryOrganisation(\ILIAS\UI\Factory $f)
Definition: ui.php:417
Builds data types.
Definition: Factory.php:35
getDemoEntryTools(\ILIAS\UI\Factory $f)
Definition: ui.php:454
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:24
pagedemoFooter(\ILIAS\UI\Factory $f)
Definition: ui.php:225
$dic
Definition: ltiresult.php:33
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:349
$r