ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
async.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
6 
18 function async()
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  //Initializing the options, note that the label is taken care of by JS
28  $options = [
29  'default_option' => 'Default',
30  'latest' => 'Most Recent',
31  'oldest' => 'Oldest'
32  ];
33 
34  //Note that the selected option needs to be displayed in the label
35  $select_option = 'default_option';
36  if ($request_wrapper->has('sortation') && $request_wrapper->retrieve('sortation', $refinery->kindlyTo()->string())) {
37  $select_option = $request_wrapper->retrieve('sortation', $refinery->kindlyTo()->string());
38  }
39 
40  //Generation of the UI Component
41  $modal = $f->modal()->lightbox($f->modal()->lightboxTextPage('Note: This is just used to show case, how
42  this control can be used,to change an other components content.', "Sortation has changed: " . $options[$select_option]));
43  $s = $f->viewControl()->sortation($options, $select_option)
44  ->withTargetURL($DIC->http()->request()->getRequestTarget(), 'sortation')
45  ->withOnSort($modal->getShowSignal());
46 
47  //Rendering
48  return $renderer->render([$s,$modal]);
49 }
$renderer
global $DIC
Definition: shib_login.php:25
async()
description: > Async example show-casing how this control can be used, without reloading the page ...
Definition: async.php:18