ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
show_modal_on_button_click.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24
37{
38 global $DIC;
39 $factory = $DIC->ui()->factory();
40 $renderer = $DIC->ui()->renderer();
41 $refinery = $DIC->refinery();
42 $request_wrapper = $DIC->http()->wrapper()->query();
43 $post_wrapper = $DIC->http()->wrapper()->post();
44 $ctrl = $DIC->ctrl();
45
46 $message = 'Are you sure you want to delete the following items?';
47 $ctrl->setParameterByClass('ilsystemstyledocumentationgui', 'modal_nr', 1);
48 $form_action = $ctrl->getFormActionByClass('ilsystemstyledocumentationgui');
49 $icon = $factory->image()->standard('./assets/images/standard/icon_crs.svg', '');
50
51 $items = [
52 $factory->modal()->interruptiveItem()->standard('10', 'Course 1', $icon, 'Some description text'),
53 $factory->modal()->interruptiveItem()->keyValue('20', 'Item Key', 'item value'),
54 $factory->modal()->interruptiveItem()->standard('30', 'Course 3', $icon, 'Last but not least, a description'),
55 $factory->modal()->interruptiveItem()->keyValue('50', 'Second Item Key', 'another item value'),
56 ];
57 $modal = $factory->modal()->interruptive('My Title', $message, $form_action)->withAffectedItems($items);
58 $button = $factory->button()->standard('Show Modal', '')
59 ->withOnClick($modal->getShowSignal());
60
61 $out = [$button, $modal];
62
63 // Display POST data of affected items in a panel
64 if (
65 $post_wrapper->has('interruptive_items') &&
66 $request_wrapper->retrieve('modal_nr', $refinery->kindlyTo()->string()) === '1'
67 ) {
68 $out[] = $post_wrapper->retrieve('interruptive_items', $refinery->custom()->transformation(
69 static fn(array $item_keys): Standard => $factory->panel()->standard(
70 'Items deleted',
71 $factory->legacy()->content('Number of items deleted: ' . count($item_keys))
72 )
73 ));
74 }
75
76 return $renderer->render($out);
77}
$out
Definition: buildRTE.php:24
$renderer
This describes a Standard Dropdown.
Definition: Standard.php:27
This describes a Standard Panel.
Definition: Standard.php:29
global $DIC
Definition: shib_login.php:26