ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
base.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
6 
9 
24 function base()
25 {
26  global $DIC;
27  $factory = $DIC->ui()->factory();
28  $renderer = $DIC->ui()->renderer();
29 
30  $df = new \ILIAS\Data\Factory();
31  $refinery = $DIC['refinery'];
32 
33  $here_uri = $df->uri($DIC->http()->request()->getUri()->__toString());
34  $url_builder = new URLBuilder($here_uri);
35 
36  //The messagebox we are going to wrap into the prompt
37  $message = $factory->messageBox()->success('some message box')
38  ->withButtons([$factory->button()->standard('some Action', '#')]);
39 
40  //when expecting a state, we do not want to render other examples
41  $example_namespace = ['prompt', 'endpoints'];
42  list($url_builder, $endpointtoken) = $url_builder->acquireParameters($example_namespace, "endpoint");
43  $url_builder = $url_builder->withParameter($endpointtoken, "true");
44 
45  //build the prompt
46  $query_namespace = ['prompt', 'example0'];
47  list($url_builder, $token) = $url_builder->acquireParameters($query_namespace, "show");
48  $url_builder = $url_builder->withParameter($token, "true");
49  $prompt = $factory->prompt()->standard($url_builder->buildURI());
50 
51  //build the endpoint returning the wrapped message
52  $query = $DIC->http()->wrapper()->query();
53  if ($query->has($token->getName())) {
54  $response = $factory->prompt()->state()->show($message);
55  echo($renderer->renderAsync($response));
56  exit();
57  }
58 
59  //a button to open the prompt:
60  $show_button = $factory->button()->standard('Show Simple Prompt', $prompt->getShowSignal());
61 
62  if (!$query->has($endpointtoken->getName())) {
63  return $renderer->render([
64  $message,
65  $prompt,
66  $show_button
67  ]);
68  }
69 }
$renderer
base()
description: > This example wraps a Message Box into a Prompt (State).
Definition: base.php:24
$response
Definition: xapitoken.php:90
$token
Definition: xapitoken.php:67
global $DIC
Definition: shib_login.php:25
URLBuilder.
Definition: URLBuilder.php:39