ILIAS  trunk Revision v11.0_alpha-1749-g1a06bdef097
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
base.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
25 
40 function base()
41 {
42  global $DIC;
43  $factory = $DIC->ui()->factory();
44  $renderer = $DIC->ui()->renderer();
45 
46  $df = new \ILIAS\Data\Factory();
47  $refinery = $DIC['refinery'];
48 
49  $here_uri = $df->uri($DIC->http()->request()->getUri()->__toString());
50  $url_builder = new URLBuilder($here_uri);
51 
52  //The messagebox we are going to wrap into the prompt
53  $message = $factory->messageBox()->success('some message box')
54  ->withButtons([$factory->button()->standard('some Action', '#')]);
55 
56  //when expecting a state, we do not want to render other examples
57  $example_namespace = ['prompt', 'endpoints'];
58  list($url_builder, $endpointtoken) = $url_builder->acquireParameters($example_namespace, "endpoint");
59  $url_builder = $url_builder->withParameter($endpointtoken, "true");
60 
61  //build the prompt
62  $query_namespace = ['prompt', 'example0'];
63  list($url_builder, $token) = $url_builder->acquireParameters($query_namespace, "show");
64  $url_builder = $url_builder->withParameter($token, "true");
65  $prompt = $factory->prompt()->standard($url_builder->buildURI());
66 
67  //build the endpoint returning the wrapped message
68  $query = $DIC->http()->wrapper()->query();
69  if ($query->has($token->getName())) {
70  $response = $factory->prompt()->state()->show($message);
71  echo($renderer->renderAsync($response));
72  exit();
73  }
74 
75  //a button to open the prompt:
76  $show_button = $factory->button()->standard('Show Simple Prompt', $prompt->getShowSignal());
77 
78  if (!$query->has($endpointtoken->getName())) {
79  return $renderer->render([
80  $message,
81  $prompt,
82  $show_button
83  ]);
84  }
85 }
$renderer
base()
description: > This example wraps a Message Box into a Prompt (State).
Definition: base.php:40
$response
Definition: xapitoken.php:93
$token
Definition: xapitoken.php:70
global $DIC
Definition: shib_login.php:22
$message
Definition: xapiexit.php:31
URLBuilder.
Definition: URLBuilder.php:40
exit
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...