ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
show_popover_with_async_loaded_content.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
34{
35 global $DIC;
36 $factory = $DIC->ui()->factory();
37 $renderer = $DIC->ui()->renderer();
38 $refinery = $DIC->refinery();
39 $request_wrapper = $DIC->http()->wrapper()->query();
40
41 if (
42 $request_wrapper->has('renderPopoverAsync') &&
43 $request_wrapper->retrieve('renderPopoverAsync', $refinery->kindlyTo()->bool())
44 ) {
45 // This is the ajax request to load the content of the popover. During the ajax request,
46 // a loading spinner is presented to the user. Check the code below on how to construct the popover,
47 // e.g. using Popover::withAsyncContentUrl().
48 $content = $factory->legacy()->content('This text is rendered async');
49 echo $renderer->render($content);
50 exit();
51 }
52
53 $async_url = $_SERVER['REQUEST_URI'] . '&renderPopoverAsync=1';
54 $popover = $factory->popover()->standard($factory->legacy()->content(''))
55 ->withTitle('Popover')
56 ->withAsyncContentUrl($async_url);
57 $button = $factory->button()->standard('Show Popover', '#')
58 ->withOnClick($popover->getShowSignal());
59
60 return $renderer->render([$popover, $button]);
61}
$renderer
exit
$_SERVER['HTTP_HOST']
Definition: raiseError.php:26
global $DIC
Definition: shib_login.php:26