ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
key_value.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
6 
7 function key_value()
8 {
9  global $DIC;
10  $f = $DIC->ui()->factory();
11  $renderer = $DIC->ui()->renderer();
12 
13  $icon = $f->symbol()->icon()->standard("crs", 'Example');
14  $long_value = 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr,
15  sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquy';
16 
17  $node1 = $f->tree()->node()->keyValue('label', 'value');
18  $node2 = $f->tree()->node()->keyValue('label', $long_value)
19  ->withLink(new \ILIAS\Data\URI('https://docu.ilias.de'));
20  $node3 = $f->tree()->node()->keyValue('label', 'value', $icon);
21  $node4 = $f->tree()->node()->keyValue('label', 'value', $icon)
22  ->withLink(new \ILIAS\Data\URI('https://docu.ilias.de'));
23  $data = [['node' => $node1, 'children' => [
24  ['node' => $node2]]],
25  ['node' => $node3, 'children' => [
26  ['node' => $node4]],
27  ]
28  ];
29 
30  $recursion = new class () implements \ILIAS\UI\Component\Tree\TreeRecursion {
31  public function getChildren($record, $environment = null): array
32  {
33  return $record['children'] ?? [];
34  }
35 
36  public function build(
37  \ILIAS\UI\Component\Tree\Node\Factory $factory,
38  $record,
39  $environment = null
41  $node = $record['node'];
42  if (isset($record['children'])) {
43  $node = $node->withExpanded(true);
44  }
45  return $node;
46  }
47  };
48 
49  $tree = $f->tree()->expandable('Label', $recursion)
50  ->withData($data);
51 
52  return $renderer->render($tree);
53 }
Class ChatMainBarProvider .
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This describes a Tree Node.
Definition: Node.php:30
global $DIC
Definition: feed.php:28
The scope of this class is split ilias-conform URI&#39;s into components.
Definition: URI.php:18
withExpanded(bool $expanded)
Set $expanded to true to have this node expanded on loading.