ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
base.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
36 function base()
37 {
38  //Loading factories
39  global $DIC;
40  $f = $DIC->ui()->factory();
41  $renderer = $DIC->ui()->renderer();
42  $refinery = $DIC->refinery();
43  $request_wrapper = $DIC->http()->wrapper()->query();
44 
45  //Some Target magic to get a behaviour closer to some real use case
46  $target = $DIC->http()->request()->getRequestTarget();
47  $param = "Section";
48  $active = 0;
49  if ($request_wrapper->has($param) && $request_wrapper->retrieve($param, $refinery->kindlyTo()->int())) {
50  $active = $request_wrapper->retrieve($param, $refinery->kindlyTo()->int());
51  }
52 
53  //Here the real magic to draw the controls
54  $back = $f->button()->standard("Back", "$target&$param=" . ($active - 1));
55  $next = $f->button()->standard("Next" . " " . ($active - 1), "$target&$param=" . ($active + 1));
56  $middle = $f->button()->standard("Go to Engaged Section (Current Section: $active)", "$target&$param=0");
57  //Note that the if the middle button needs to be engaged by the surrounding component, as so, if need to be drawn
58  //as engaged. This can e.g. be the case for rendering a button labeled "Today" or similar.
59  if ($active == 0) {
60  $middle = $middle->withLabel("Engaged Section")->withEngagedState(true);
61  }
62  $view_control_section = $f->viewControl()->section($back, $middle, $next);
63  $html = $renderer->render($view_control_section);
64  return $html;
65 }
$renderer
$param
Definition: xapitoken.php:46
global $DIC
Definition: shib_login.php:22
base()
description: > Example performing a page reload if switching between sections of some data...
Definition: base.php:36