ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
show_popover_with_async_loaded_content.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
6 
8 {
9  global $DIC;
10  $factory = $DIC->ui()->factory();
11  $renderer = $DIC->ui()->renderer();
12  $refinery = $DIC->refinery();
13  $request_wrapper = $DIC->http()->wrapper()->query();
14 
15  if (
16  $request_wrapper->has('renderPopoverAsync') &&
17  $request_wrapper->retrieve('renderPopoverAsync', $refinery->kindlyTo()->bool())
18  ) {
19  // This is the ajax request to load the content of the popover. During the ajax request,
20  // a loading spinner is presented to the user. Check the code below on how to construct the popover,
21  // e.g. using Popover::withAsyncContentUrl().
22  $content = $factory->legacy('This text is rendered async');
23  echo $renderer->render($content);
24  exit();
25  }
26 
27  $async_url = $_SERVER['REQUEST_URI'] . '&renderPopoverAsync=1';
28  $popover = $factory->popover()->standard($factory->legacy(''))
29  ->withTitle('Popover')
30  ->withAsyncContentUrl($async_url);
31  $button = $factory->button()->standard('Show Popover', '#')
32  ->withOnClick($popover->getShowSignal());
33 
34  return $renderer->render([$popover, $button]);
35 }
exit
Definition: login.php:28
global $DIC
Definition: feed.php:28
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10
$factory
Definition: metadata.php:75
Refinery Factory $refinery