ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
with_view_controls.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
33function with_view_controls(): string
34{
35 global $DIC;
36 $f = $DIC->ui()->factory();
37 $renderer = $DIC->ui()->renderer();
38 $refinery = $DIC->refinery();
39 $request_wrapper = $DIC->http()->wrapper()->query();
40
41 $url = $DIC->http()->request()->getRequestTarget();
42
43 $actions = $f->dropdown()->standard([
44 $f->button()->shy("ILIAS", "https://www.ilias.de"),
45 $f->button()->shy("GitHub", "https://www.github.com")
46 ]);
47 $current_sortation = 'abc';
48 if ($request_wrapper->has('sort')) {
49 $current_sortation = $request_wrapper->retrieve('sort', $refinery->kindlyTo()->string());
50 }
51
52 $sortation_options = [
53 'abc' => 'Sort by Alphabet',
54 'date' => 'Sort by Date',
55 'location' => 'Sort by Location'
56 ];
57 $sortation = $f->viewControl()->sortation($sortation_options, $current_sortation)
58 ->withTargetURL($url, "sort");
59
60 $current_presentation = 'list';
61 if ($request_wrapper->has('mode')) {
62 $current_presentation = $request_wrapper->retrieve('mode', $refinery->kindlyTo()->string());
63 }
64 $presentation_options = [
65 'list' => 'List View',
66 'tile' => 'Tile View'
67 ];
68 $modes = $f->viewControl()->mode(
69 array_reduce(
70 array_keys($presentation_options),
71 static function ($carry, $item) use ($presentation_options, $url) {
72 $carry[$presentation_options[$item]] = "$url&mode=$item";
73 return $carry;
74 },
75 []
76 ),
77 'Presentation Mode'
78 )
79 ->withActive($presentation_options[$current_presentation]);
80
81 $current_page = 0;
82 if ($request_wrapper->has('page')) {
83 $current_page = $request_wrapper->retrieve('page', $refinery->kindlyTo()->int());
84 }
85 $pagination = $f->viewControl()->pagination()
86 ->withTargetURL($url, "page")
87 ->withTotalEntries(98)
88 ->withPageSize(10)
89 ->withCurrentPage($current_page);
90
91 $view_controls = [
92 $sortation,
93 $modes,
94 $pagination
95 ];
96
97 if ($current_presentation === 'list') {
98 $item1 = $f->item()->standard("Item Title")
99 ->withActions($actions)
100 ->withProperties([
101 "Origin" => "Course Title 1",
102 "Last Update" => "24.11.2011",
103 "Location" => "Room 123, Main Street 44, 3012 Bern"
104 ])
105 ->withDescription(
106 "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua."
107 );
108
109 $item2 = $f->item()->standard("Item 2 Title")
110 ->withActions($actions)
111 ->withDescription(
112 "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua."
113 );
114
115 $item3 = $f->item()->standard("Item 3 Title")
116 ->withActions($actions)
117 ->withDescription(
118 "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua."
119 );
120 } else {
121 $image = $f->image()->responsive(
122 "./assets/images/logo/HeaderIcon.svg",
123 "Thumbnail Example"
124 );
125 $content = $f->listing()->descriptive(
126 [
127 "Entry 1" => "Some text",
128 "Entry 2" => "Some more text",
129 ]
130 );
131 $item1 = $item2 = $item3 = $f->card()->standard("Item Title", $image)
132 ->withSections([$content]);
133 }
134
135 $std_list = $f->panel()->standard("List Title", [
136 $f->item()->group("Subtitle 1", [
137 $item1,
138 $item2
139 ]),
140 $f->item()->group("Subtitle 2", [
141 $item3
142 ])
143 ])
144 ->withActions($actions)
145 ->withViewControls($view_controls);
146
147 return $renderer->render($std_list);
148}
$renderer
global $DIC
Definition: shib_login.php:26
$url
Definition: shib_logout.php:68