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 
18 function base()
19 {
20  global $DIC;
21  $factory = $DIC->ui()->factory();
22  $renderer = $DIC->ui()->renderer();
23  $df = new \ILIAS\Data\Factory();
24  $here_uri = $df->uri($DIC->http()->request()->getUri()->__toString());
25  $url_builder = new URLBuilder($here_uri);
26 
27  //a response may contain Components implementing IsPromptContent interface.
28  $content = $factory->input()->container()->form()->standard(
29  $url_builder->buildURI()->__toString(),
30  [$factory->input()->field()->text("Text Input")]
31  );
32 
33  $response = $factory->prompt()->state()->show($content);
34 
35  //endpoint to return response on (asynch) call
36  $refinery = $DIC['refinery'];
37  $example_namespace = ['prompt', 'response'];
38  list($url_builder, $url_token) = $url_builder->acquireParameters(
39  $example_namespace,
40  "response"
41  );
42  $query = $DIC->http()->wrapper()->query();
43  if ($query->has($url_token->getName())) {
44  echo($renderer->renderAsync($response));
45  exit();
46  }
47 
48  //build the prompt
49  $prompt = $factory->prompt()->standard($url_builder->buildURI());
50  $show_button = $factory->button()->standard('Show Prompt', $prompt->getShowSignal());
51 
52 
53  //show the response contents:
54  $txt_response = $factory->legacy(
55  '<pre>'
56  . htmlentities($renderer->render($response))
57  . '</pre>'
58  );
59 
60  return $renderer->render([
61  $txt_response,
62  $show_button,
63  $prompt
64  ]);
65 
66 }
$renderer
base()
description: > The example displays the HTML of a State.
Definition: base.php:18
$response
Definition: xapitoken.php:90
global $DIC
Definition: shib_login.php:25
URLBuilder.
Definition: URLBuilder.php:39