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