ILIAS  release_7 Revision v7.30-3-g800a261c036
show_modal_on_button_click_async_rendered.php File Reference

Go to the source code of this file.

Functions

 show_modal_on_button_click_async_rendered ()
 

Function Documentation

◆ show_modal_on_button_click_async_rendered()

show_modal_on_button_click_async_rendered ( )

Definition at line 2 of file show_modal_on_button_click_async_rendered.php.

3{
4 global $DIC;
5 $factory = $DIC->ui()->factory();
6 $renderer = $DIC->ui()->renderer();
7 $ctrl = $DIC->ctrl();
8 $message = 'Are you sure you want to delete the following item?';
9 $ctrl->setParameterByClass('ilsystemstyledocumentationgui', 'modal_nr', 2);
10 $form_action = $ctrl->getFormActionByClass('ilsystemstyledocumentationgui');
11 $items = ['First Item', 'Second Item', 'Third Item'];
12
13 // Check if this is the ajax request to deliver the new modal showing the affected item
14 if (isset($_GET['item'])) {
15 $item = $items[(int) $_GET['item']];
16 $affected_item = $factory->modal()->interruptiveItem((int) $_GET['item'], $item);
17 $modal = $factory->modal()->interruptive('Delete Items', $message, $form_action)
18 ->withAffectedItems([$affected_item]);
19 echo $renderer->render($modal);
20 exit();
21 }
22
23 // Create a button per item
24 $out = [];
25 foreach ($items as $i => $item) {
26 $ajax_url = $_SERVER['REQUEST_URI'] . '&item=' . $i;
27 $modal = $factory->modal()->interruptive('', '', '')
28 ->withAsyncRenderUrl($ajax_url);
29 $button = $factory->button()->standard('Delete ' . $item, '#')
30 ->withOnClick($modal->getShowSignal());
31 $out[] = $button;
32 $out[] = $modal;
33 }
34
35 // Display POST data of affected items in a panel
36 if (array_key_exists('interruptive_items', $_POST)
37 && array_key_exists('modal_nr', $_GET) && $_GET['modal_nr'] === '2') {
38 $panel = $factory->panel()->standard(
39 'Affected Items',
40 $factory->legacy(print_r($_POST['interruptive_items'], true))
41 );
42 $out[] = $panel;
43 }
44
45 return $renderer->render($out);
46}
$_GET["client_id"]
$_POST["username"]
global $DIC
Definition: goto.php:24
if(isset($_FILES['img_file']) &&is_array($_FILES['img_file'])) $panel
Definition: imgupload.php:138
exit
Definition: login.php:29
$factory
Definition: metadata.php:58
$i
Definition: metadata.php:24
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10
$message
Definition: xapiexit.php:14

References $_GET, $_POST, $_SERVER, $DIC, $factory, $i, $message, $out, $panel, and exit.