ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ILIAS\UI\examples\Tree\Expandable Namespace Reference

Functions

 expandable ()
 
 expandable2 ()
 
if( $request_wrapper->has( 'async_ref') &&$request_wrapper->retrieve( 'async_ref', $refinery->kindlyTo() ->bool())) expandable_async_repo ($ref=null)
 

Variables

global $DIC
 
 $refinery = $DIC->refinery()
 
 $request_wrapper = $DIC->http()->wrapper()->query()
 

Function Documentation

◆ expandable()

ILIAS\UI\examples\Tree\Expandable\expandable ( )

description: > Example for rendering an expandable tree.

expected output: > ILIAS shows a navigation tree with different numbered sub-points. The sub-point can be collapsed by clicking the ">".

The last entries in a branch are clickable and open a modal window with an image.

Definition at line 33 of file expandable.php.

34{
35 global $DIC;
36 $f = $DIC->ui()->factory();
37 $renderer = $DIC->ui()->renderer();
38
39 $data = [
40 ['label' => 'root', 'children' => [
41 ['label' => '1', 'children' => [
42 ['label' => '1.1', 'children' => [
43 ['label' => '1.1.1', 'children' => []],
44 ['label' => '1.1.2', 'children' => []]
45 ]],
46 ['label' => '1.2', 'children' => []],
47 ['label' => '1.3', 'children' => []]
48 ]],
49 ['label' => '2', 'children' => [
50 ['label' => '2.1', 'children' => []],
51 ]],
52 ['label' => '3', 'children' => [
53 ['label' => '3.1', 'children' => [
54 ['label' => '3.1.1', 'children' => [
55 ['label' => '3.1.1.1', 'children' => []],
56 ]],
57 ]],
58
59 ]],
60 ]]
61 ];
62
63 $recursion = new class () implements \ILIAS\UI\Component\Tree\TreeRecursion {
64 public function getChildren($record, $environment = null): array
65 {
66 return $record['children'];
67 }
68
69 public function build(
70 \ILIAS\UI\Component\Tree\Node\Factory $factory,
71 $record,
72 $environment = null
73 ): \ILIAS\UI\Component\Tree\Node\Node {
74 $label = $record['label'];
75 $node = $factory->simple($label);
76
77 if (count($record['children']) === 0) {
78 $node = $node->withOnClick($environment['modal']->getShowSignal());
79 }
80
81 if ($label === "root" || $label === "2") {
82 $node = $node->withExpanded(true);
83 }
84 if ($label === "2") {
85 $node = $node->withHighlighted(true);
86 }
87
88 return $node;
89 }
90 };
91
92 $image = $f->image()->responsive("assets/ui-examples/images/Image/mountains.jpg", "Image source: https://stocksnap.io, Creative Commons CC0 license");
93 $page = $f->modal()->lightboxImagePage($image, 'Mountains');
94 $modal = $f->modal()->lightbox($page);
95 $environment = [
96 'modal' => $modal
97 ];
98
99 $tree = $f->tree()->expandable("Label", $recursion)
100 ->withEnvironment($environment)
101 ->withData($data)
102 ->withHighlightOnNodeClick(true);
103
104 return $renderer->render([
105 $modal,
106 $tree
107 ]);
108}
$renderer
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
Definition: UI.php:27
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
global $DIC
Definition: shib_login.php:26
$data
Definition: storeScorm.php:45

References $data, ILIAS\UI\examples\Tree\Expandable\$DIC, Vendor\Package\$f, $page, $renderer, and ILIAS\UI\Component\Clickable\withOnClick().

Referenced by ILIAS\Style\Content\Characteristic\CharacteristicTableBuilder\__construct(), ILIAS\Style\Content\Characteristic\CharacteristicTableBuilder\build(), and ILIAS\Style\Content\Characteristic\CharacteristicTableBuilder\getOrderingCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ expandable2()

ILIAS\UI\examples\Tree\Expandable\expandable2 ( )

description: > Example for rendering an expandable tree.

expected output: > ILIAS shows an example very simliar to the "expandable" example but with less sub-points. Also the sub-points have

got no functions, therefore clicking them will do nothing.

Definition at line 33 of file expandable2.php.

33 : string
34{
35 global $DIC;
36 $f = $DIC->ui()->factory();
37 $renderer = $DIC->ui()->renderer();
38
39 $getDataNode = function (string $label, array $children = []) {
40 return new class ($label, $children) {
41 protected string $label = '';
42 protected array $children = [];
43
44 public function __construct(string $label, array $children = [])
45 {
46 $this->label = $label;
47 $this->children = $children;
48 }
49
50 public function getLabel(): string
51 {
52 return $this->label;
53 }
54
55 public function getChildren(): array
56 {
57 return $this->children;
58 }
59 };
60 };
61
62 $n11 = $getDataNode('1.1');
63 $n12 = $getDataNode('1.2', [$getDataNode('1.2.1')]);
64 $n1 = $getDataNode('1', [$n11, $n12]);
65 $data = [$n1];
66
67 $recursion = new class () implements \ILIAS\UI\Component\Tree\TreeRecursion {
68 public function getChildren($record, $environment = null): array
69 {
70 return $record->getChildren();
71 }
72
73 public function build(
74 \ILIAS\UI\Component\Tree\Node\Factory $factory,
75 $record,
76 $environment = null
77 ): \ILIAS\UI\Component\Tree\Node\Node {
78 return $factory->simple($record->getLabel());
79 }
80 };
81
82 $tree = $f->tree()->expandable("Label", $recursion)
83 ->withData($data);
84
85 return $renderer->render($tree);
86}
return['3gp', '7z', 'ai', 'aif', 'aifc', 'aiff', 'au', 'arw', 'avi', 'backup', 'bak', 'bas', 'bpmn', 'bpmn2', 'bmp', 'bib', 'bibtex', 'bz', 'bz2', 'c', 'c++', 'cc', 'cct', 'cdf', 'cer', 'class', 'cls', 'conf', 'cpp', 'crt', 'crs', 'crw', 'cr2', 'css', 'cst', 'csv', 'cur', 'db', 'dcr', 'des', 'dng', 'doc', 'docx', 'dot', 'dotx', 'dtd', 'dvi', 'el', 'eps', 'epub', 'f', 'f77', 'f90', 'flv', 'for', 'g3', 'gif', 'gl', 'gan', 'ggb', 'gsd', 'gsm', 'gtar', 'gz', 'gzip', 'h', 'hpp', 'htm', 'html', 'htmls', 'ibooks', 'ico', 'ics', 'ini', 'ipynb', 'java', 'jbf', 'jpeg', 'jpg', 'js', 'jsf', 'jso', 'json', 'latex', 'lang', 'less', 'log', 'lsp', 'ltx', 'm1v', 'm2a', 'm2v', 'm3u', 'm4a', 'm4v', 'markdown', 'm', 'mat', 'md', 'mdl', 'mdown', 'mid', 'min', 'midi', 'mobi', 'mod', 'mov', 'movie', 'mp2', 'mp3', 'mp4', 'mpa', 'mpeg', 'mpg', 'mph', 'mpga', 'mpp', 'mpt', 'mpv', 'mpx', 'mv', 'mw', 'mv4', 'nb', 'nbp', 'nef', 'nif', 'niff', 'obj', 'obm', 'odt', 'ods', 'odp', 'odg', 'odf', 'oga', 'ogg', 'ogv', 'old', 'p', 'pas', 'pbm', 'pcl', 'pct', 'pcx', 'pdf', 'pgm', 'pic', 'pict', 'png', 'por', 'pov', 'project', 'properties', 'ppa', 'ppm', 'pps', 'ppsx', 'ppt', 'pptx', 'ppz', 'ps', 'psd', 'pwz', 'qt', 'qtc', 'qti', 'qtif', 'r', 'ra', 'ram', 'rar', 'rast', 'rda', 'rev', 'rexx', 'ris', 'rf', 'rgb', 'rm', 'rmd', 'rmi', 'rmm', 'rmp', 'rt', 'rtf', 'rtx', 'rv', 's', 's3m', 'sav', 'sbs', 'sec', 'sdml', 'sgm', 'sgml', 'smi', 'smil', 'srt', 'sps', 'spv', 'stl', 'svg', 'swa', 'swf', 'swz', 'tar', 'tex', 'texi', 'texinfo', 'text', 'tgz', 'tif', 'tiff', 'ttf', 'txt', 'tmp', 'uvproj', 'vdf', 'vimeo', 'viv', 'vivo', 'vrml', 'vsdx', 'vtt', 'wav', 'webm', 'wmv', 'wmx', 'wmz', 'woff', 'wwd', 'xhtml', 'xif', 'xls', 'xlsx', 'xmind', 'xml', 'xsl', 'xsd', 'zip']
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References $data, ILIAS\UI\examples\Tree\Expandable\$DIC, Vendor\Package\$f, $renderer, ILIAS\__construct(), and ILIAS\Questions\Definitions\getLabel.

+ Here is the call graph for this function:

◆ expandable_async_repo()

if($request_wrapper->has('async_ref') && $request_wrapper->retrieve('async_ref', $refinery->kindlyTo() ->bool())) ILIAS\UI\examples\Tree\Expandable\expandable_async_repo (   $ref = null)

description: > Example for rendering an expandable tree with asynchronous repositories.

expected output: >

This example can be ignored for the time being.

Definition at line 42 of file expandable_async_repo.php.

43{
44 global $DIC;
45 $ilTree = $DIC['tree'];
46
47 if (is_null($ref)) {
48 $do_async = false;
49 $ref = 1;
50 $data = array(
51 $ilTree->getNodeData(1)
52 );
53 } else {
54 $do_async = true;
55 $data = $ilTree->getChilds($ref);
56 if (count($data) === 0) {
57 return;
58 }
59 }
60
61 $recursion = new class () implements \ILIAS\UI\Component\Tree\TreeRecursion {
62 public function getChildren($record, $environment = null): array
63 {
64 return [];
65 }
66
67 public function build(
68 \ILIAS\UI\Component\Tree\Node\Factory $factory,
69 $record,
70 $environment = null
71 ): \ILIAS\UI\Component\Tree\Node\Node {
72 $ref_id = $record['ref_id'];
73 $label = $record['title']
74 . ' (' . $record['type'] . ', ' . $ref_id . ')';
75
76 $icon = $environment['icon_factory']->standard($record["type"], '');
77 $url = $this->getAsyncURL($environment, (string) $ref_id);
78
79 $node = $factory->simple($label, $icon)
80 ->withAsyncURL($url);
81
82 //find these under ILIAS->Administration in the example tree
83 if ((int) $ref_id > 9 && (int) $ref_id < 20) {
84 $label = $environment['modal']->getShowSignal()->getId();
85 $node = $factory->simple($label)
86 ->withAsyncURL($url)
87 ->withOnClick($environment['modal']->getShowSignal());
88 }
89
90 return $node;
91 }
92
93 protected function getAsyncURL($environment, string $ref_id): string
94 {
95 $url = $environment['url'];
96 $base = substr($url, 0, strpos($url, '?') + 1);
97 $query = parse_url($url, PHP_URL_QUERY);
98 if ($query) {
99 parse_str($query, $params);
100 } else {
101 $params = [];
102 }
103 $params['async_ref'] = $ref_id;
104 $url = $base . http_build_query($params);
105 return $url;
106 }
107 };
108
109 $f = $DIC->ui()->factory();
110 $renderer = $DIC->ui()->renderer();
111 $image = $f->image()->responsive("assets/ui-examples/images/Image/mountains.jpg", "Image source: https://stocksnap.io, Creative Commons CC0 license");
112 $page = $f->modal()->lightboxImagePage($image, 'Mountains');
113 $modal = $f->modal()->lightbox($page);
114
115 $environment = [
116 'url' => $DIC->http()->request()->getRequestTarget(),
117 'modal' => $modal,
118 'icon_factory' => $f->symbol()->icon()
119 ];
120
121 $tree = $f->tree()->expandable("Label", $recursion)
122 ->withEnvironment($environment)
123 ->withData($data);
124
125 if (!$do_async) {
126 return $renderer->render([$modal, $tree]);
127 } else {
128 echo $renderer->renderAsync([$modal, $tree->withIsSubTree(true)]);
129 }
130}

References $data, ILIAS\UI\examples\Tree\Expandable\$DIC, Vendor\Package\$f, $page, and $renderer.

Variable Documentation

◆ $DIC

◆ $refinery

ILIAS::UI::examples::Tree::Expandable\$refinery = $DIC->refinery()

Definition at line 24 of file expandable_async_repo.php.

◆ $request_wrapper

ILIAS::UI::examples::Tree::Expandable\$request_wrapper = $DIC->http()->wrapper()->query()

Definition at line 25 of file expandable_async_repo.php.