ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
bylined.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
6 
21 function bylined()
22 {
23  global $DIC;
24  $f = $DIC->ui()->factory();
25  $renderer = $DIC->ui()->renderer();
26 
27  $icon = $f->symbol()->icon()->standard("crs", 'Example');
28  $long_byline = 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr,
29  sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquy';
30 
31  $node1 = $f->tree()->node()->bylined('label', 'byline');
32  $node2 = $f->tree()->node()->bylined('label', $long_byline)
33  ->withLink(new \ILIAS\Data\URI('https://docu.ilias.de'));
34  $node3 = $f->tree()->node()->bylined('label', 'byline', $icon);
35  $node4 = $f->tree()->node()->bylined('label', 'byline', $icon)
36  ->withLink(new \ILIAS\Data\URI('https://docu.ilias.de'));
37  $data = [['node' => $node1, 'children' => [
38  ['node' => $node2]]],
39  ['node' => $node3, 'children' => [
40  ['node' => $node4]],
41  ]
42  ];
43 
44  $recursion = new class () implements \ILIAS\UI\Component\Tree\TreeRecursion {
45  public function getChildren($record, $environment = null): array
46  {
47  return $record['children'] ?? [];
48  }
49 
50  public function build(
51  \ILIAS\UI\Component\Tree\Node\Factory $factory,
52  $record,
53  $environment = null
54  ): \ILIAS\UI\Component\Tree\Node\Node {
55  $node = $record['node'];
56  if (isset($record['children'])) {
57  $node = $node->withExpanded(true);
58  }
59  return $node;
60  }
61  };
62 
63  $tree = $f->tree()->expandable('Label', $recursion)
64  ->withData($data);
65 
66  return $renderer->render($tree);
67 }
$renderer
Interface Observer Contains several chained tasks and infos about them.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This is how the factory for UI elements looks.
Definition: Factory.php:37
global $DIC
Definition: shib_login.php:25
bylined()
description: > Example for rendering a bylined tree node.
Definition: bylined.php:21
The scope of this class is split ilias-conform URI&#39;s into components.
Definition: URI.php:34