ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
key_value.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
34function key_value()
35{
36 global $DIC;
37 $f = $DIC->ui()->factory();
38 $renderer = $DIC->ui()->renderer();
39
40 $icon = $f->symbol()->icon()->standard("crs", 'Example');
41 $long_value = 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr,
42 sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquy';
43
44 $node1 = $f->tree()->node()->keyValue('label', 'value');
45 $node2 = $f->tree()->node()->keyValue('label', $long_value)
46 ->withLink(new \ILIAS\Data\URI('https://docu.ilias.de'));
47 $node3 = $f->tree()->node()->keyValue('label', 'value', $icon);
48 $node4 = $f->tree()->node()->keyValue('label', 'value', $icon)
49 ->withLink(new \ILIAS\Data\URI('https://docu.ilias.de'));
50 $data = [['node' => $node1, 'children' => [
51 ['node' => $node2]]],
52 ['node' => $node3, 'children' => [
53 ['node' => $node4]],
54 ]
55 ];
56
57 $recursion = new class () implements \ILIAS\UI\Component\Tree\TreeRecursion {
58 public function getChildren($record, $environment = null): array
59 {
60 return $record['children'] ?? [];
61 }
62
63 public function build(
64 \ILIAS\UI\Component\Tree\Node\Factory $factory,
65 $record,
66 $environment = null
68 $node = $record['node'];
69 if (isset($record['children'])) {
70 $node = $node->withExpanded(true);
71 }
72 return $node;
73 }
74 };
75
76 $tree = $f->tree()->expandable('Label', $recursion)
77 ->withData($data);
78
79 return $renderer->render($tree);
80}
$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