ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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.

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

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 (isset($_POST['interruptive_items']) && @$_GET['modal_nr'] === '2') {
37  $panel = $factory->panel()->standard(
38  'Affected Items',
39  $factory->legacy(print_r($_POST['interruptive_items'], true))
40  );
41  $out[] = $panel;
42  }
43 
44  return $renderer->render($out);
45 }
exit
Definition: login.php:29
$_GET["client_id"]
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10
$DIC
Definition: xapitoken.php:46
$message
Definition: xapiexit.php:14
$_POST["username"]
$factory
Definition: metadata.php:58
$i
Definition: metadata.php:24