ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
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 
36 function 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 }
base()
description: > The example demonstrates how to use commands in the Response.
Definition: base.php:36
$renderer
$response
Definition: xapitoken.php:93
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...