3 declare(strict_types=1);
43 $f = $DIC->ui()->factory();
49 $icon =
$f->symbol()->icon()->standard(
"chtr",
"chtr");
50 $title =
$f->link()->standard(
"Some Title",
"#");
51 $item =
$f->item()->notification($title, $icon);
55 $async_close =
$_SERVER[
'REQUEST_URI'] .
'&close_item=true&async_load_replace=false&async_load_replace_content=false&async_add_aggregate=false';
57 $closable_item = $item->withCloseAction($async_close);
59 $async_replace_url =
$_SERVER[
'REQUEST_URI'] .
'&close_item=false&async_load_replace=true&async_load_replace_content=false&async_add_aggregate=false';
61 $async_replace_content_load_url =
$_SERVER[
'REQUEST_URI'] .
'&close_item=false&async_load_replace=false&async_load_replace_content=true&async_add_aggregate=false';
63 $async_add_aggregate =
$_SERVER[
'REQUEST_URI'] .
'&close_item=false&async_load_replace=false&async_load_replace_content=false&async_add_aggregate=true';
67 $js =
$f->legacy(
"")->withOnLoadCode(
function (
$id) use ($async_replace_content_load_url) {
69 il.DemoScopeRemaining--; 70 il.DemoScopeItem.replaceContentByAsyncItemContent('$async_replace_content_load_url',{remaining: il.DemoScopeRemaining,added: il.DemoScopeAdded}); 84 for ($i = 1; $i < $added + 1; $i++) {
85 $items[] = $closable_item->withDescription(
"This item is number: " . $i .
" of a fix set of 10 entries.");
87 $replacement = $item->withDescription(
"Number of Async non-closed Aggregates: " . $remaining .
", totally created: " . $added)
88 ->withAggregateNotifications($items);
90 echo
$renderer->renderAsync([$replacement]);
97 $replacement = $item->withDescription(
"Number of Async non-closed Aggregates: " . $remaining .
", totally created: " . $added);
98 echo
$renderer->renderAsync([$replacement]);
105 $new_aggregate = $closable_item->withDescription(
"The item has been added, Nr: " . $added);
107 echo
$renderer->renderAsync([$new_aggregate]);
114 $add_button =
$f->button()->standard(
"Add Chat Notification",
"#")
115 ->withAdditionalOnLoadCode(
function (
$id) use ($async_replace_url, $async_add_aggregate) {
117 $('#$id').click(function() { 118 il.DemoScopeItem.getCounterObjectIfAny().incrementNoveltyCount(1); 120 il.DemoScopeRemaining++; 121 il.DemoScopeItem.addAsyncAggregate('$async_add_aggregate',{remaining: il.DemoScopeAdded,added: il.DemoScopeAdded}); 122 il.DemoScopeItem.replaceContentByAsyncItemContent('$async_replace_url',{remaining: il.DemoScopeRemaining,added: il.DemoScopeAdded}); 127 $reset_button =
$f->button()->standard(
"Reset Chat",
"#")
128 ->withAdditionalOnLoadCode(
function (
$id) use ($async_replace_url) {
130 $('#$id').click(function() { 131 il.DemoScopeItem.getCounterObjectIfAny().decrementNoveltyCount(il.DemoScopeRemaining); 132 il.DemoScopeAdded = 0; 133 il.DemoScopeRemaining = 0; 134 il.DemoScopeItem.replaceByAsyncItem('$async_replace_url',{remaining: il.DemoScopeAdded,added: il.DemoScopeAdded}); 139 $set_button =
$f->button()->standard(
"Set to 10 chat entries",
"#")
140 ->withAdditionalOnLoadCode(
function (
$id) use ($async_replace_url) {
142 $('#$id').click(function() { 143 il.DemoScopeItem.getCounterObjectIfAny().decrementNoveltyCount(il.DemoScopeRemaining); 144 il.DemoScopeItem.getCounterObjectIfAny().incrementNoveltyCount(10); 145 il.DemoScopeAdded = 10; 146 il.DemoScopeRemaining = 10; 147 il.DemoScopeItem.replaceByAsyncItem('$async_replace_url',{remaining: il.DemoScopeAdded,added: il.DemoScopeAdded}); 157 ->withDescription(
"This is the original Version after the Page has loaded. Will be replaced completely.")
158 ->withAdditionalOnLoadCode(
function (
$id) {
160 il.DemoScopeAdded = 0; 161 il.DemoScopeRemaining = 0; 162 il.DemoScopeItem = il.UI.item.notification.getNotificationItemObject($($id)); 177 $async_slate =
$f->mainControls()->slate()->notification(
"Chat", [$async_item]);
181 $mail_icon =
$f->symbol()->icon()->standard(
"mail",
"mail");
182 $mail_title =
$f->link()->standard(
"Inbox",
"link_to_inbox");
183 $mail_notification_item =
$f->item()->notification($mail_title, $mail_icon)
184 ->withDescription(
"You have 23 unread mails in your inbox")
185 ->withProperties([
"Time" =>
"3 days ago"]);
186 $mail_slate =
$f->mainControls()->slate()->notification(
"Mail", [$mail_notification_item]);
190 $notification_glyph =
$f->symbol()->glyph()->notification(
"notification",
"notification")
191 ->withCounter(
$f->counter()->novelty(1));
193 $notification_center =
$f->mainControls()->slate()
194 ->combined(
"Notification Center", $notification_glyph)
195 ->withAdditionalEntry($async_slate)
196 ->withAdditionalEntry($mail_slate);
198 $css_fix =
"<style>.panel-primary .il-maincontrols-metabar{flex-direction: column;} .panel-primary .il-metabar-slates{position: relative;top: 0px;}</style>";
204 $help =
$f->button()->bulky(
$f->symbol()->glyph()->help(),
'Help',
'#');
205 $search =
$f->button()->bulky(
$f->symbol()->glyph()->search(),
'Search',
'#');
206 $user =
$f->button()->bulky(
$f->symbol()->glyph()->user(),
'User',
'#');
209 $metabar =
$f->mainControls()->metabar()
210 ->withAdditionalEntry(
'search', $search)
211 ->withAdditionalEntry(
'help', $help)
212 ->withAdditionalEntry(
'notification', $notification_center)
213 ->withAdditionalEntry(
'user', $user);
extended_example_for_developers()
description: > This is a rather extended example on the usage of the Notification Item async functio...
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
usuallyDoneByGlobalScreenProbablyIgnore($async_item, $f, $renderer, $add_button, $set_button, $reset_button)
buildMetabarWithNotifications($f, $notification_center)