ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
base.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
25
36function base()
37{
38 global $DIC;
39 $factory = $DIC->ui()->factory();
40 $renderer = $DIC->ui()->renderer();
41 $df = new \ILIAS\Data\Factory();
42 $refinery = $DIC['refinery'];
43 $here_uri = $df->uri($DIC->http()->request()->getUri()->__toString());
44 $url_builder = new URLBuilder($here_uri);
45 $example_namespace = ['prompt', 'close'];
46 list($url_builder, $action_token) = $url_builder->acquireParameters(
47 $example_namespace,
48 "action"
49 );
50
51 //the endpoint; act according to parameter
52 $query = $DIC->http()->wrapper()->query();
53 if ($query->has($action_token->getName())) {
54 $action = $query->retrieve($action_token->getName(), $refinery->kindlyTo()->string());
55 if ($action === 'closecommand') {
56 //a state to simply close the modal
57 $response = $factory->prompt()->state()->close();
58 } else {
59 //The messagebox we are going to wrap into the prompt
60 $close = $factory->link()->standard(
61 'send close command',
62 $url_builder->withParameter($action_token, 'closecommand')->buildURI()->__toString()
63 );
64
65 $message = $factory->messageBox()->info('some message box')
66 ->withLinks([$close]);
67 $response = $factory->prompt()->state()->show($message);
68 }
69 echo($renderer->renderAsync($response));
70 exit();
71 }
72
73 //render prompt and button
74 $prompt = $factory->prompt()->standard($url_builder->buildURI());
75 return $renderer->render([
76 $factory->button()->standard('Show Prompt', $prompt->getShowSignal()),
77 $prompt
78 ]);
79
80}
$renderer
exit
Flags some Component to be a valid content of a Prompt.
global $DIC
Definition: shib_login.php:26
$message
Definition: xapiexit.php:31
$response
Definition: xapitoken.php:93