ILIAS  trunk Revision v11.0_alpha-1851-ga8564da6fed
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
multi_column_drilldown_in_modal.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
24 
37 function multi_column_drilldown_in_modal()
38 {
39  global $DIC;
41  $f = $DIC->ui()->factory();
43  $r = $DIC->ui()->renderer();
44  $refinery = $DIC->refinery();
45  $request_wrapper = $DIC->http()->wrapper()->query();
46 
47  $url = $_SERVER['REQUEST_URI'];
48 
49  if ($request_wrapper->has('content')) {
50  renderModalAsync(
51  $request_wrapper->retrieve(
52  'content',
53  $refinery->kindlyTo()->string()
54  )
55  );
56  }
57 
58  $drilldown_modal = $f->modal()->roundtrip(
59  'My Modal',
60  []
61  );
62 
63  $drilldown_modal = $drilldown_modal->withAsyncRenderUrl(
64  $url . '&content=drilldown&replaceSignal=' . $drilldown_modal->getReplaceSignal()->getId()
65  );
66 
67  $button = $f->button()->standard('Open Animals', $drilldown_modal->getShowSignal());
68 
69  return $r->render([
70  $button,
71  $drilldown_modal
72  ]);
73 }
74 
75 function renderModalAsync(string $content): void
76 {
77  global $DIC;
79  $f = $DIC->ui()->factory();
81  $r = $DIC->ui()->renderer();
82  $refinery = $DIC->refinery();
83  $request_wrapper = $DIC->http()->wrapper()->query();
84 
85  $url = $_SERVER['REQUEST_URI'];
86 
87  $signal_id = "";
88  if ($request_wrapper->has('replaceSignal')) {
89  $signal_id = $request_wrapper->retrieve('replaceSignal', $refinery->kindlyTo()->string());
90  }
91  $replace_signal = new ReplaceSignal($signal_id);
92 
93  switch ($content) {
94  case 'image':
95  $image = $f->image()->responsive('assets/ui-examples/images/Image/mountains.jpg', 'Some mountains in the dusk');
96  $replace_signal_with_url = $replace_signal->withAsyncRenderUrl(
97  $url . '&content=drilldown&replaceSignal=' . $replace_signal->getId()
98  );
99  $button = $f->button()->standard('Back to Drilldown', '')->withOnClick($replace_signal_with_url);
100  echo $r->renderAsync(
101  $f->modal()->roundtrip(
102  'My Modal',
103  [$image]
104  )->withActionButtons([$button])
105  );
106  exit;
107  default:
108  $ico = $f->symbol()->icon()->standard('', '')->withSize('small')->withAbbreviation('+');
109  $button = $f->button()->bulky($ico->withAbbreviation('>'), 'Modal', '')
110  ->withOnClick($replace_signal->withAsyncRenderUrl($url . '&content=image&replaceSignal=' . $replace_signal->getId()));
111 
112  $uri = new \ILIAS\Data\URI('https://ilias.de');
113  $link = $f->link()->bulky($ico->withAbbreviation('>'), 'Link', $uri);
114  $divider = $f->divider()->horizontal();
115 
116  $items = [
117  $f->menu()->sub('Switzerland', [
118  $f->menu()->sub('Riverine Amphipod', [$button, $link]),
119  $f->menu()->sub('Wildcat', [
120  $f->menu()->sub('European Wildcat', [$button, $link]),
121  $f->menu()->sub('African Wildcat', [$button, $link, $divider, $link])
122  ]),
123  $button,
124  $link
125  ]),
126 
127  $f->menu()->sub('Germany', [
128  $f->menu()->sub('Otter', [$button, $link]),
129  $f->menu()->sub('Mole', [$button, $link]),
130  $divider,
131  $f->menu()->sub('Deer', [$button, $link])
132  ])
133  ];
134 
135  echo $r->renderAsync(
136  $f->modal()->roundtrip(
137  'My Modal',
138  [$f->menu()->drilldown('Animal of the year', $items)]
139  )
140  );
141  exit;
142  }
143 }
$url
Definition: shib_logout.php:66
$_SERVER['HTTP_HOST']
Definition: raiseError.php:26
global $DIC
Definition: shib_login.php:22
exit
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$r