ILIAS  release_8 Revision v8.24
base.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
6
10function base()
11{
12 //Loading factories
13 global $DIC;
14 $f = $DIC->ui()->factory();
15 $renderer = $DIC->ui()->renderer();
16 $refinery = $DIC->refinery();
17 $request_wrapper = $DIC->http()->wrapper()->query();
18
19 //Some Target magic to get a behaviour closer to some real use case
20 $target = $DIC->http()->request()->getRequestTarget();
21 $param = "Mode";
22
23 $active = 1;
24 if ($request_wrapper->has($param) && $request_wrapper->retrieve($param, $refinery->kindlyTo()->int())) {
25 $active = $request_wrapper->retrieve($param, $refinery->kindlyTo()->int());
26 }
27
28 //Here the real magic to draw the controls
29 $actions = array(
30 "$param 1" => "$target&$param=1",
31 "$param 2" => "$target&$param=2",
32 "$param 3" => "$target&$param=3",
33 );
34
35 $aria_label = "change_the_currently_displayed_mode";
36 $view_control = $f->viewControl()->mode($actions, $aria_label)->withActive("$param $active");
37 $html = $renderer->render($view_control);
38
39 return $html;
40}
global $DIC
Definition: feed.php:28
Refinery Factory $refinery
base()
Base example performing a page reload if active view is changed.
Definition: base.php:10
$param
Definition: xapitoken.php:46