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 
20 function base()
21 {
22  //Loading factories
23  global $DIC;
24  $f = $DIC->ui()->factory();
25  $renderer = $DIC->ui()->renderer();
26  $refinery = $DIC->refinery();
27  $request_wrapper = $DIC->http()->wrapper()->query();
28 
29  //Some Target magic to get a behaviour closer to some real use case
30  $target = $DIC->http()->request()->getRequestTarget();
31  $param = "Section";
32  $active = 0;
33  if ($request_wrapper->has($param) && $request_wrapper->retrieve($param, $refinery->kindlyTo()->int())) {
34  $active = $request_wrapper->retrieve($param, $refinery->kindlyTo()->int());
35  }
36 
37  //Here the real magic to draw the controls
38  $back = $f->button()->standard("Back", "$target&$param=" . ($active - 1));
39  $next = $f->button()->standard("Next" . " " . ($active - 1), "$target&$param=" . ($active + 1));
40  $middle = $f->button()->standard("Go to Engaged Section (Current Section: $active)", "$target&$param=0");
41  //Note that the if the middle button needs to be engaged by the surrounding component, as so, if need to be drawn
42  //as engaged. This can e.g. be the case for rendering a button labeled "Today" or similar.
43  if ($active == 0) {
44  $middle = $middle->withLabel("Engaged Section")->withEngagedState(true);
45  }
46  $view_control_section = $f->viewControl()->section($back, $middle, $next);
47  $html = $renderer->render($view_control_section);
48  return $html;
49 }
$renderer
$param
Definition: xapitoken.php:44
global $DIC
Definition: shib_login.php:25
base()
description: > Example performing a page reload if switching between sections of some data...
Definition: base.php:20