ILIAS  trunk Revision v11.0_alpha-1811-gd2d5443e411
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\UI\examples\ViewControl\Section Namespace Reference

Functions

 base ()
 

description: > Example performing a page reload if switching between sections of some data. More...

 

Function Documentation

◆ base()

ILIAS\UI\examples\ViewControl\Section\base ( )


description: > Example performing a page reload if switching between sections of some data.

expected output: > ILIAS shows three controls next to each other: A "Back" glyph, a label "Engaged Section" and a "Next" glyph. Clicking "Engaged Section" will reload the website. Clicking the other two controls will result in the button in the middle being disenganged and showing the label "Go to Engaged Section (Current Section: 1)". The counter increases with each click onto the "Next" glyph and decreases with each click onto the "Back" glyph. Clicking the button in the middle

with the "Goto..." label will revert the buttons to the original status.

Definition at line 36 of file base.php.

References $DIC, Vendor\Package\$f, $param, ILIAS\UI\examples\Layout\Page\Standard\$refinery, $renderer, and ILIAS\UI\examples\Layout\Page\Standard\$request_wrapper.

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