ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
bylined.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
37function bylined()
38{
39 global $DIC;
40 $f = $DIC->ui()->factory();
41 $renderer = $DIC->ui()->renderer();
42
43 $icon = $f->symbol()->icon()->standard("crs", 'Example');
44 $long_byline = 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr,
45 sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquy';
46
47 $node1 = $f->tree()->node()->bylined('label', 'byline');
48 $node2 = $f->tree()->node()->bylined('label', $long_byline)
49 ->withLink(new \ILIAS\Data\URI('https://docu.ilias.de'));
50 $node3 = $f->tree()->node()->bylined('label', 'byline', $icon);
51 $node4 = $f->tree()->node()->bylined('label', 'byline', $icon)
52 ->withLink(new \ILIAS\Data\URI('https://docu.ilias.de'));
53 $data = [['node' => $node1, 'children' => [
54 ['node' => $node2]]],
55 ['node' => $node3, 'children' => [
56 ['node' => $node4]],
57 ]
58 ];
59
60 $recursion = new class () implements \ILIAS\UI\Component\Tree\TreeRecursion {
61 public function getChildren($record, $environment = null): array
62 {
63 return $record['children'] ?? [];
64 }
65
66 public function build(
67 \ILIAS\UI\Component\Tree\Node\Factory $factory,
68 $record,
69 $environment = null
71 $node = $record['node'];
72 if (isset($record['children'])) {
73 $node = $node->withExpanded(true);
74 }
75 return $node;
76 }
77 };
78
79 $tree = $f->tree()->expandable('Label', $recursion)
80 ->withData($data);
81
82 return $renderer->render($tree);
83}
$renderer
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
The scope of this class is split ilias-conform URI's into components.
Definition: URI.php:35
Definition: UI.php:24
This describes a Tree Node.
Definition: Node.php:31
withExpanded(bool $expanded)
Set $expanded to true to have this node expanded on loading.
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
global $DIC
Definition: shib_login.php:26