ILIAS  release_8 Revision v8.24
async.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
6
7//Async example show-casing how this control can be used, without reloading the page
8function async()
9{
10 //Loading factories
11 global $DIC;
12 $f = $DIC->ui()->factory();
13 $renderer = $DIC->ui()->renderer();
14 $refinery = $DIC->refinery();
15 $request_wrapper = $DIC->http()->wrapper()->query();
16
17 //Initializing the options, note that the label is taken care of by JS
18 $options = [
19 'default_option' => 'Default Ordering',
20 'latest' => 'Most Recent Ordering',
21 'oldest' => 'Oldest Ordering'
22 ];
23
24 //Note that the selected option needs to be displayed in the label
25 $select_option = 'default_option';
26 if ($request_wrapper->has('sortation') && $request_wrapper->retrieve('sortation', $refinery->kindlyTo()->string())) {
27 $select_option = $request_wrapper->retrieve('sortation', $refinery->kindlyTo()->string());
28 }
29
30 //Generation of the UI Component
31 $modal = $f->modal()->lightbox($f->modal()->lightboxTextPage('Note: This is just used to show case, how
32 this control can be used,to change an other components content.', "Sortation has changed: " . $options[$select_option]));
33 $s = $f->viewControl()->sortation($options)
34 ->withTargetURL($DIC->http()->request()->getRequestTarget(), 'sortation')
35 ->withLabel($options[$select_option])
36 ->withOnSort($modal->getShowSignal());
37
38 //Rendering
39 return $renderer->render([$s,$modal]);
40}
global $DIC
Definition: feed.php:28
Refinery Factory $refinery