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