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

Functions

 base ()
 

description: > Base example performing a page reload if active view is changed. More...

 

Function Documentation

◆ base()

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


description: > Base example performing a page reload if active view is changed.

expected output: > ILIAS shows three controls next to each other. The first control is highlighted especially ("active/engaged"). Clicking the first control won't activate any actions. Clicking the other controls activates/engages the

appropriate control while the other control will be deactived/disengaged.

Definition at line 34 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.

35 {
36  //Loading factories
37  global $DIC;
38  $f = $DIC->ui()->factory();
39  $renderer = $DIC->ui()->renderer();
40  $refinery = $DIC->refinery();
41  $request_wrapper = $DIC->http()->wrapper()->query();
42 
43  //Some Target magic to get a behaviour closer to some real use case
44  $target = $DIC->http()->request()->getRequestTarget();
45  $param = "Mode";
46 
47  $active = 1;
48  if ($request_wrapper->has($param) && $request_wrapper->retrieve($param, $refinery->kindlyTo()->int())) {
49  $active = $request_wrapper->retrieve($param, $refinery->kindlyTo()->int());
50  }
51 
52  //Here the real magic to draw the controls
53  $actions = array(
54  "$param 1" => "$target&$param=1",
55  "$param 2" => "$target&$param=2",
56  "$param 3" => "$target&$param=3",
57  );
58 
59  $aria_label = "change_the_currently_displayed_mode";
60  $view_control = $f->viewControl()->mode($actions, $aria_label)->withActive("$param $active");
61  $html = $renderer->render($view_control);
62 
63  return $html;
64 }
$renderer
$param
Definition: xapitoken.php:46
global $DIC
Definition: shib_login.php:22