10{
12 $ilTree =
$DIC[
'tree'];
13
14 if (is_null($ref)) {
15 $do_async = false;
16 $ref = 1;
18 $ilTree->getNodeData(1)
19 );
20 } else {
21 $do_async = true;
22 $data = $ilTree->getChilds($ref);
23 if (count(
$data) === 0) {
24 return;
25 }
26 }
27
28 $recursion =
new class implements \
ILIAS\
UI\Component\Tree\TreeRecursion {
29 public function getChildren($record, $environment = null) : array
30 {
31 return [];
32 }
33
34 public function build(
36 $record,
37 $environment = null
38 ) : \
ILIAS\
UI\Component\Tree\Node\Node {
39 $ref_id = $record['ref_id'];
40 $label = $record['title']
41 . ' (' . $record['type'] . ', ' . $ref_id . ')';
42
43 $icon = $environment['icon_factory']->standard($record["type"], '');
44 $url = $this->getAsyncURL($environment, $ref_id);
45
46 $node =
$factory->simple($label, $icon)
48
49
50 if ((int) $ref_id > 9 && (int) $ref_id < 20) {
51 $label = $environment['modal']->getShowSignal()->getId();
54 ->withOnClick($environment['modal']->getShowSignal());
55 }
56
57 return $node;
58 }
59
60 protected function getAsyncURL($environment, string $ref_id) : string
61 {
62 $url = $environment[
'url'];
65 parse_str(
$query, $params);
66 $params['async_ref'] = $ref_id;
69 }
70 };
71
72 $f =
$DIC->ui()->factory();
73 $renderer =
$DIC->ui()->renderer();
74 $image =
$f->image()->responsive(
"src/UI/examples/Image/mountains.jpg",
"Image source: https://stocksnap.io, Creative Commons CC0 license");
75 $page =
$f->modal()->lightboxImagePage($image,
'Mountains');
76 $modal =
$f->modal()->lightbox($page);
77
78 $environment = [
79 'url' =>
$DIC->http()->request()->getRequestTarget(),
80 'modal' => $modal,
81 'icon_factory' =>
$f->symbol()->icon()
82 ];
83
84 $tree =
$f->tree()->expandable(
"Label", $recursion)
85 ->withEnvironment($environment)
87
88 if (!$do_async) {
89 return $renderer->render([$modal, $tree]);
90 } else {
91 echo $renderer->renderAsync([$modal, $tree]);
92 }
93}
Class ChatMainBarProvider \MainMenu\Provider.