ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
show_modal_on_button_click.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
6 
8 {
9  global $DIC;
10  $factory = $DIC->ui()->factory();
11  $renderer = $DIC->ui()->renderer();
12  $refinery = $DIC->refinery();
13  $request_wrapper = $DIC->http()->wrapper()->query();
14  $post_wrapper = $DIC->http()->wrapper()->post();
15  $ctrl = $DIC->ctrl();
16 
17  $message = 'Are you sure you want to delete the following items?';
18  $ctrl->setParameterByClass('ilsystemstyledocumentationgui', 'modal_nr', 1);
19  $form_action = $ctrl->getFormActionByClass('ilsystemstyledocumentationgui');
20  $icon = $factory->image()->standard('./templates/default/images/standard/icon_crs.svg', '');
21  $modal = $factory->modal()->interruptive('My Title', $message, $form_action)
22  ->withAffectedItems(array(
23  $factory->modal()->interruptiveItem()->standard('10', 'Course 1', $icon, 'Some description text'),
24  $factory->modal()->interruptiveItem()->keyValue('20', 'Item Key', 'item value'),
25  $factory->modal()->interruptiveItem()->standard('30', 'Course 3', $icon, 'Last but not least, a description'),
26  $factory->modal()->interruptiveItem()->keyValue('50', 'Second Item Key', 'another item value'),
27  ));
28  $button = $factory->button()->standard('Show Modal', '')
29  ->withOnClick($modal->getShowSignal());
30 
31  $out = [$button, $modal];
32 
33  // Display POST data of affected items in a panel
34  if (
35  $request_wrapper->has('interruptive_items') &&
36  $request_wrapper->retrieve('modal_nr', $refinery->kindlyTo()->string()) === '1'
37  ) {
38  $panel = $factory->panel()->standard(
39  'Affected Items',
40  $factory->legacy(print_r($post_wrapper->retrieve('interruptive_items', $refinery->kindlyTo()->string()), true))
41  );
42  $out[] = $panel;
43  }
44 
45  return $renderer->render($out);
46 }
global $DIC
Definition: feed.php:28
$out
Definition: buildRTE.php:24
$message
Definition: xapiexit.php:32
Refinery Factory $refinery