ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
key_value.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
34 function 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
67  ): \ILIAS\UI\Component\Tree\Node\Node {
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
Interface Observer Contains several chained tasks and infos about them.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
key_value()
description: > Example for rendering a tree node with key values.
Definition: key_value.php:34
global $DIC
Definition: shib_login.php:22