ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 $message = 'Are you sure you want to delete the following item?';
8 $form_action = $DIC->ctrl()->getFormActionByClass('ilsystemstyledocumentationgui');
9 $items = ['First Item', 'Second Item', 'Third Item'];
10
11 // Check if this is the ajax request to deliver the new modal showing the affected item
12 if (isset($_GET['item'])) {
13 $item = $items[(int) $_GET['item']];
14 $affected_item = $factory->modal()->interruptiveItem((int) $_GET['item'], $item);
15 $modal = $factory->modal()->interruptive('Delete Items', $message, $form_action)
16 ->withAffectedItems([$affected_item]);
17 echo $renderer->render($modal);
18 exit();
19 }
20
21 // Create a button per item
22 $out = '';
23 foreach ($items as $i => $item) {
24 $ajax_url = $_SERVER['REQUEST_URI'] . '&item=' . $i;
25 $modal = $factory->modal()->interruptive('', '', '')
26 ->withAsyncRenderUrl($ajax_url);
27 $button = $factory->button()->standard('Delete ' . $item, '#')
28 ->withOnClick($modal->getShowSignal());
29 $out .= ' ' . $renderer->render([$button, $modal]);
30 }
31
32 return $out;
33}
$factory
Definition: metadata.php:43
exit
Definition: backend.php:16
$_GET["client_id"]
$i
Definition: disco.tpl.php:19
catch(Exception $e) $message
global $DIC
Definition: saml.php:7
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']

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