19declare(strict_types=1);
63 $f =
$DIC->ui()->factory();
66 $url =
$DIC->http()->request()->getUri()->__toString() .
'&extended_metabar_ui=1';
67 $txt =
$f->legacy()->content(
'<p>
68 The extended MetaBar example opens in fullscreen to showcase the
69 Notification Item async functionality in the proper page layout.
70 Use the Notification Center (bell icon) in the MetaBar and the
71 buttons below to try the async features.
74 $page_demo =
$f->link()->standard(
'See UI in fullscreen-mode',
$url);
84 $help =
$f->button()->bulky(
$f->symbol()->glyph()->help(),
'Help',
'#');
85 $search =
$f->button()->bulky(
$f->symbol()->glyph()->search(),
'Search',
'#');
86 $user =
$f->button()->bulky(
$f->symbol()->glyph()->user(),
'User',
'#');
89 $metabar =
$f->mainControls()->metabar()
90 ->withAdditionalEntry(
'search', $search)
91 ->withAdditionalEntry(
'help', $help)
92 ->withAdditionalEntry(
'notification', $notification_center)
93 ->withAdditionalEntry(
'user', $user);
103 $f =
$dic->ui()->factory();
108 $icon =
$f->symbol()->icon()->standard(
"chtr",
"chtr");
109 $title =
$f->link()->standard(
"Some Title",
"#");
110 $item =
$f->item()->notification($title, $icon);
112 $async_close =
$_SERVER[
'REQUEST_URI'] .
'&close_item=true&async_load_replace=false&async_load_replace_content=false&async_add_aggregate=false';
113 $closable_item = $item->withCloseAction($async_close);
114 $async_replace_url =
$_SERVER[
'REQUEST_URI'] .
'&close_item=false&async_load_replace=true&async_load_replace_content=false&async_add_aggregate=false';
115 $async_replace_content_load_url =
$_SERVER[
'REQUEST_URI'] .
'&close_item=false&async_load_replace=false&async_load_replace_content=true&async_add_aggregate=false';
116 $async_add_aggregate =
$_SERVER[
'REQUEST_URI'] .
'&close_item=false&async_load_replace=false&async_load_replace_content=false&async_add_aggregate=true';
119 $js =
$f->legacy()->content(
"")->withOnLoadCode(
function (
$id) use ($async_replace_content_load_url) {
121 il.DemoScopeRemaining--;
122 il.DemoScopeItem.replaceContentByAsyncItemContent('$async_replace_content_load_url',{remaining: il.DemoScopeRemaining,added: il.DemoScopeAdded});
134 for ($i = 1; $i < $added + 1; $i++) {
135 $items[] = $closable_item->withDescription(
"This item is number: " . $i .
" of a fix set of 10 entries.");
137 $replacement = $item->withDescription(
"Number of Async non-closed Aggregates: " . $remaining .
", totally created: " . $added)
138 ->withAggregateNotifications($items);
140 echo
$renderer->renderAsync([$replacement]);
147 $replacement = $item->withDescription(
"Number of Async non-closed Aggregates: " . $remaining .
", totally created: " . $added);
148 echo
$renderer->renderAsync([$replacement]);
154 $new_aggregate = $closable_item->withDescription(
"The item has been added, Nr: " . $added);
155 echo
$renderer->renderAsync([$new_aggregate]);
162 $f =
$dic->ui()->factory();
165 $async_replace_url =
$_SERVER[
'REQUEST_URI'] .
'&close_item=false&async_load_replace=true&async_load_replace_content=false&async_add_aggregate=false';
166 $async_add_aggregate =
$_SERVER[
'REQUEST_URI'] .
'&close_item=false&async_load_replace=false&async_load_replace_content=false&async_add_aggregate=true';
168 $icon =
$f->symbol()->icon()->standard(
"chtr",
"chtr");
169 $title =
$f->link()->standard(
"Some Title",
"#");
170 $item =
$f->item()->notification($title, $icon);
171 $async_close =
$_SERVER[
'REQUEST_URI'] .
'&close_item=true&async_load_replace=false&async_load_replace_content=false&async_add_aggregate=false';
172 $closable_item = $item->withCloseAction($async_close);
174 $add_button =
$f->button()->standard(
"Add Chat Notification",
"#")
175 ->withAdditionalOnLoadCode(
function (
$id) use ($async_replace_url, $async_add_aggregate) {
177 $('#$id').click(function() {
178 il.DemoScopeItem.getCounterObjectIfAny().incrementNoveltyCount(1);
180 il.DemoScopeRemaining++;
181 il.DemoScopeItem.addAsyncAggregate('$async_add_aggregate',{remaining: il.DemoScopeAdded,added: il.DemoScopeAdded});
182 il.DemoScopeItem.replaceContentByAsyncItemContent('$async_replace_url',{remaining: il.DemoScopeRemaining,added: il.DemoScopeAdded});
186 $reset_button =
$f->button()->standard(
"Reset Chat",
"#")
187 ->withAdditionalOnLoadCode(
function (
$id) use ($async_replace_url) {
189 $('#$id').click(function() {
190 il.DemoScopeItem.getCounterObjectIfAny().decrementNoveltyCount(il.DemoScopeRemaining);
191 il.DemoScopeAdded = 0;
192 il.DemoScopeRemaining = 0;
193 il.DemoScopeItem.replaceByAsyncItem('$async_replace_url',{remaining: il.DemoScopeAdded,added: il.DemoScopeAdded});
197 $set_button =
$f->button()->standard(
"Set to 10 chat entries",
"#")
198 ->withAdditionalOnLoadCode(
function (
$id) use ($async_replace_url) {
200 $('#$id').click(function() {
201 il.DemoScopeItem.getCounterObjectIfAny().decrementNoveltyCount(il.DemoScopeRemaining);
202 il.DemoScopeItem.getCounterObjectIfAny().incrementNoveltyCount(10);
203 il.DemoScopeAdded = 10;
204 il.DemoScopeRemaining = 10;
205 il.DemoScopeItem.replaceByAsyncItem('$async_replace_url',{remaining: il.DemoScopeAdded,added: il.DemoScopeAdded});
210 ->withDescription(
"This is the original Version after the Page has loaded. Will be replaced completely.")
211 ->withAdditionalOnLoadCode(
function (
$id) {
213 il.DemoScopeAdded = 0;
214 il.DemoScopeRemaining = 0;
215 il.DemoScopeItem = il.UI.item.notification.getNotificationItemObject($($id));
219 $async_slate =
$f->mainControls()->slate()->notification(
"Chat", [$async_item]);
221 $mail_icon =
$f->symbol()->icon()->standard(
"mail",
"mail");
222 $mail_title =
$f->link()->standard(
"Inbox",
"link_to_inbox");
223 $mail_notification_item =
$f->item()->notification($mail_title, $mail_icon)
224 ->withDescription(
"You have 23 unread mails in your inbox")
225 ->withProperties([
"Time" =>
"3 days ago"]);
226 $mail_slate =
$f->mainControls()->slate()->notification(
"Mail", [$mail_notification_item]);
229 $notification_glyph =
$f->symbol()->glyph()->notification()
230 ->withCounter(
$f->counter()->novelty(1));
232 $notification_center =
$f->mainControls()->slate()
233 ->combined(
"Notification Center", $notification_glyph)
234 ->withAdditionalEntry($async_slate)
235 ->withAdditionalEntry($mail_slate);
239 $logo =
$f->image()->responsive(
"assets/images/logo/HeaderIcon.svg",
"ILIAS");
240 $responsive_logo =
$f->image()->responsive(
"assets/images/logo/HeaderIconResponsive.svg",
"ILIAS");
241 $breadcrumbs =
$f->breadcrumbs([]);
242 $mainbar =
$f->mainControls()->mainBar();
243 $footer =
$f->mainControls()->footer()->withAdditionalText(
'Footer');
244 $tc =
$dic->ui()->factory()->toast()->container();
247 $f->panel()->standard(
248 'Notification Item Async Demo',
249 $f->legacy()->content(
250 "Use the Notification Center (bell icon) in the MetaBar above, then try these buttons:<br /><br />"
251 .
$renderer->render([$add_button, $set_button, $reset_button])
256 $page =
$f->layout()->page()->standard(
263 "./assets/images/logo/favicon.ico",
266 'UI MetaBar Extended Demo',
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Customizing of pimple-DIC for ILIAS.
static initILIAS()
ilias initialisation
extended_example_for_developers()
buildMetabarWithNotifications($f, $notification_center)
handleAsyncRequestsIfAny(Container $dic)
Handle async requests for the notification item.
renderExtendedMetaBarInFullscreenMode(Container $dic)