ILIAS  trunk Revision v11.0_alpha-1831-g8615d53dadb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\UI\examples\Modal\RoundTrip Namespace Reference

Functions

 show_form_in_modal ()
 

description: > Example for rendering a round trip modal. More...

 
 show_multi_step_modal ()
 

description: > Example for rendering a round trip multi-step modal. More...

 
 show_the_same_modal_with_different_buttons ()
 

description: > Example for rendering a round trip modal with different buttons. More...

 
 with_custom_labels ()
 

description: > An example showing how you can set a custom label for the modals cancel-button. More...

 

Function Documentation

◆ show_form_in_modal()

ILIAS\UI\examples\Modal\RoundTrip\show_form_in_modal ( )


description: > Example for rendering a round trip modal.

expected output: > ILIAS shows a button titled "open modal". A click onto the button opens the modal including a formular "some text"

and "some number". The entered content will be displayed above the button after hitting "Save".

Definition at line 33 of file show_form_in_modal.php.

References $data, $DIC, $renderer, and null.

34 {
35  global $DIC;
36 
37  $renderer = $DIC->ui()->renderer();
38  $request = $DIC->http()->request();
39  $factory = $DIC->ui()->factory();
40 
41  // declare roundtrip with inputs and form action.
42  $modal = $factory->modal()->roundtrip(
43  'roundtrip with form',
44  null,
45  [
46  $factory->input()->field()->text('some text'),
47  $factory->input()->field()->numeric('some numbere'),
48  ],
49  '#'
50  );
51 
52  // declare something that triggers the modal.
53  $open = $factory->button()->standard('open modal', '#')->withOnClick($modal->getShowSignal());
54 
55  // please use ilCtrl to generate an appropriate link target
56  // and check it's command instead of this.
57  if ('POST' === $request->getMethod()) {
58  $modal = $modal->withRequest($request);
59  $data = $modal->getData();
60  } else {
61  $data = 'no results yet.';
62  }
63 
64  return
65  '<pre>' . print_r($data, true) . '</pre>' .
66  $renderer->render([$open, $modal]);
67 }
$renderer
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
global $DIC
Definition: shib_login.php:22

◆ show_multi_step_modal()

ILIAS\UI\examples\Modal\RoundTrip\show_multi_step_modal ( )


description: > Example for rendering a round trip multi-step modal.

expected output: > ILIAS shows a button titled "Signin". A click onto the button will open a modal with two buttons "Login" and "Registration". Depending on the button a click will switch betweeen the "Login Page" and "Registration Page"

within the modal.

Definition at line 36 of file show_multi_step_modal.php.

References $_SERVER, $DIC, Vendor\Package\$f, $r, ILIAS\UI\examples\Layout\Page\Standard\$refinery, ILIAS\UI\examples\Layout\Page\Standard\$request_wrapper, $url, exit, and null.

37 {
38  global $DIC;
39  $f = $DIC->ui()->factory();
40  $r = $DIC->ui()->renderer();
41  $refinery = $DIC->refinery();
42  $request_wrapper = $DIC->http()->wrapper()->query();
43 
44  $url = $_SERVER['REQUEST_URI'];
45 
46  $page = "";
47  if ($request_wrapper->has('page')) {
48  $page = $request_wrapper->retrieve('page', $refinery->kindlyTo()->string());
49  }
50  if ($page == "") {
51  $modal = $f->modal()->roundtrip("Modal Title", $f->legacy()->content("b"));
52  $asyncUrl = $url . '&page=login&replaceSignal=' . $modal->getReplaceSignal()->getId();
53  $modal = $modal->withAsyncRenderUrl($asyncUrl);
54  $button = $f->button()->standard("Sign In", '#')
55  ->withOnClick($modal->getShowSignal());
56  return $r->render([$modal, $button]);
57  } else {
58  $signalId = "";
59  if ($request_wrapper->has('replaceSignal')) {
60  $signalId = $request_wrapper->retrieve('replaceSignal', $refinery->kindlyTo()->string());
61  }
62  $replaceSignal = new ReplaceSignal($signalId);
63  $button1 = $f->button()->standard('Login', '#')
64  ->withOnClick($replaceSignal->withAsyncRenderUrl($url . '&page=login&replaceSignal=' . $replaceSignal->getId()));
65  $button2 = $f->button()->standard('Registration', '#')
66  ->withOnClick($replaceSignal->withAsyncRenderUrl($url . '&page=register&replaceSignal=' . $replaceSignal->getId()));
67 
68  $modal = null;
69  if ($page == "login") {
70  $legacy = $f->legacy()->content("<p>The Login Page</p>");
71  $modal = $f->modal()->roundtrip("Login", [$legacy])->withActionButtons([$button1, $button2]);
72  }
73  if ($page == "register") {
74  $legacy = $f->legacy()->content("<p>The Registration Page</p>");
75  $modal = $f->modal()->roundtrip("Registration", [$legacy])->withActionButtons([$button1, $button2]);
76  }
77 
78  echo $r->renderAsync([$modal]);
79  exit;
80  }
81 }
$url
Definition: shib_logout.php:66
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$_SERVER['HTTP_HOST']
Definition: raiseError.php:26
global $DIC
Definition: shib_login.php:22
exit
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$r

◆ show_the_same_modal_with_different_buttons()

ILIAS\UI\examples\Modal\RoundTrip\show_the_same_modal_with_different_buttons ( )


description: > Example for rendering a round trip modal with different buttons.

expected output: > ILIAS shows three buttons with different titles. After clicking one of the first two buttonns a modal with primary

and secondary buttons is opened. Both buttons do not have any functions.

Definition at line 33 of file show_the_same_modal_with_different_buttons.php.

References $DIC, $out, and $renderer.

34 {
35  global $DIC;
36  $factory = $DIC->ui()->factory();
37  $renderer = $DIC->ui()->renderer();
38 
39  $modal = $factory->modal()->roundtrip('My Modal 1', $factory->legacy()->content('My Content'))
40  ->withActionButtons([
41  $factory->button()->primary('Primary Action', ''),
42  $factory->button()->standard('Secondary Action', ''),
43  ]);
44 
45  $out = '';
46  $button1 = $factory->button()->standard('Open Modal 1', '#')
47  ->withOnClick($modal->getShowSignal());
48  $out .= ' ' . $renderer->render($button1);
49 
50  $button2 = $button1->withLabel('Also opens modal 1');
51  $out .= ' ' . $renderer->render($button2);
52 
53  $button3 = $button2->withLabel('Does not open modal 1')
54  ->withResetTriggeredSignals();
55  $out .= ' ' . $renderer->render($button3);
56 
57  return $out . $renderer->render($modal);
58 }
$renderer
$out
Definition: buildRTE.php:24
global $DIC
Definition: shib_login.php:22

◆ with_custom_labels()

ILIAS\UI\examples\Modal\RoundTrip\with_custom_labels ( )


description: > An example showing how you can set a custom label for the modals cancel-button.

expected output: > ILIAS shows a button titled "I will show you something". A click onto the button will open a modal including the two

buttons with custom labels.

Definition at line 34 of file with_custom_labels.php.

References $DIC, and $renderer.

35 {
36  global $DIC;
37  $factory = $DIC->ui()->factory();
38  $renderer = $DIC->ui()->renderer();
39 
40  $modal = $factory->modal()->roundtrip(
41  'Showing something off',
42  [
43  $factory->messageBox()->info('I am something.'),
44  ]
45  )->withCancelButtonLabel(
46  'Thank you and goodbye'
47  )->withActionButtons([$factory->button()->standard('Nothing todo here', '#')]);
48 
49  $trigger = $factory->button()->standard('I will show you something', $modal->getShowSignal());
50 
51  return $renderer->render([$modal, $trigger]);
52 }
$renderer
global $DIC
Definition: shib_login.php:22