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