3 declare(strict_types=1);
38 $f = $DIC->ui()->factory();
39 $renderer = $DIC->ui()->renderer();
44 $icon =
$f->symbol()->icon()->standard(
"chtr",
"chtr");
45 $title =
$f->link()->standard(
"Some Title",
"#");
46 $item =
$f->item()->notification($title, $icon);
50 $async_close =
$_SERVER[
'REQUEST_URI'] .
'&close_item=true&async_load_replace=false&async_load_replace_content=false&async_add_aggregate=false';
52 $closable_item = $item->withCloseAction($async_close);
54 $async_replace_url =
$_SERVER[
'REQUEST_URI'] .
'&close_item=false&async_load_replace=true&async_load_replace_content=false&async_add_aggregate=false';
56 $async_replace_content_load_url =
$_SERVER[
'REQUEST_URI'] .
'&close_item=false&async_load_replace=false&async_load_replace_content=true&async_add_aggregate=false';
58 $async_add_aggregate =
$_SERVER[
'REQUEST_URI'] .
'&close_item=false&async_load_replace=false&async_load_replace_content=false&async_add_aggregate=true';
62 $js =
$f->legacy(
"")->withOnLoadCode(
function (
$id) use ($async_replace_content_load_url) {
64 il.DemoScopeRemaining--; 65 il.DemoScopeItem.replaceContentByAsyncItemContent('$async_replace_content_load_url',{remaining: il.DemoScopeRemaining,added: il.DemoScopeAdded}); 68 echo $renderer->renderAsync($js);
79 for (
$i = 1;
$i < $added + 1;
$i++) {
80 $items[] = $closable_item->withDescription(
"This item is number: " .
$i .
" of a fix set of 10 entries.");
82 $replacement = $item->withDescription(
"Number of Async non-closed Aggregates: " . $remaining .
", totally created: " . $added)
83 ->withAggregateNotifications($items);
85 echo $renderer->renderAsync([$replacement]);
92 $replacement = $item->withDescription(
"Number of Async non-closed Aggregates: " . $remaining .
", totally created: " . $added);
93 echo $renderer->renderAsync([$replacement]);
100 $new_aggregate = $closable_item->withDescription(
"The item has been added, Nr: " . $added);
102 echo $renderer->renderAsync([$new_aggregate]);
109 $add_button =
$f->button()->standard(
"Add Chat Notification",
"#")
110 ->withAdditionalOnLoadCode(
function (
$id) use ($async_replace_url, $async_add_aggregate) {
112 $('#$id').click(function() { 113 il.DemoScopeItem.getCounterObjectIfAny().incrementNoveltyCount(1); 115 il.DemoScopeRemaining++; 116 il.DemoScopeItem.addAsyncAggregate('$async_add_aggregate',{remaining: il.DemoScopeAdded,added: il.DemoScopeAdded}); 117 il.DemoScopeItem.replaceContentByAsyncItemContent('$async_replace_url',{remaining: il.DemoScopeRemaining,added: il.DemoScopeAdded}); 122 $reset_button =
$f->button()->standard(
"Reset Chat",
"#")
123 ->withAdditionalOnLoadCode(
function (
$id) use ($async_replace_url) {
125 $('#$id').click(function() { 126 il.DemoScopeItem.getCounterObjectIfAny().decrementNoveltyCount(il.DemoScopeRemaining); 127 il.DemoScopeAdded = 0; 128 il.DemoScopeRemaining = 0; 129 il.DemoScopeItem.replaceByAsyncItem('$async_replace_url',{remaining: il.DemoScopeAdded,added: il.DemoScopeAdded}); 134 $set_button =
$f->button()->standard(
"Set to 10 chat entries",
"#")
135 ->withAdditionalOnLoadCode(
function (
$id) use ($async_replace_url) {
137 $('#$id').click(function() { 138 il.DemoScopeItem.getCounterObjectIfAny().decrementNoveltyCount(il.DemoScopeRemaining); 139 il.DemoScopeItem.getCounterObjectIfAny().incrementNoveltyCount(10); 140 il.DemoScopeAdded = 10; 141 il.DemoScopeRemaining = 10; 142 il.DemoScopeItem.replaceByAsyncItem('$async_replace_url',{remaining: il.DemoScopeAdded,added: il.DemoScopeAdded}); 152 ->withDescription(
"This is the original Version after the Page has loaded. Will be replaced completely.")
153 ->withAdditionalOnLoadCode(
function (
$id) {
155 il.DemoScopeAdded = 0; 156 il.DemoScopeRemaining = 0; 157 il.DemoScopeItem = il.UI.item.notification.getNotificationItemObject($($id)); 172 $async_slate =
$f->mainControls()->slate()->notification(
"Chat", [$async_item]);
176 $mail_icon =
$f->symbol()->icon()->standard(
"mail",
"mail");
177 $mail_title =
$f->link()->standard(
"Inbox",
"link_to_inbox");
178 $mail_notification_item =
$f->item()->notification($mail_title, $mail_icon)
179 ->withDescription(
"You have 23 unread mails in your inbox")
180 ->withProperties([
"Time" =>
"3 days ago"]);
181 $mail_slate =
$f->mainControls()->slate()->notification(
"Mail", [$mail_notification_item]);
185 $notification_glyph =
$f->symbol()->glyph()->notification(
"notification",
"notification")
186 ->withCounter(
$f->counter()->novelty(1));
188 $notification_center =
$f->mainControls()->slate()
189 ->combined(
"Notification Center", $notification_glyph)
190 ->withAdditionalEntry($async_slate)
191 ->withAdditionalEntry($mail_slate);
193 $css_fix =
"<style>.panel-primary .il-maincontrols-metabar{flex-direction: column;} .panel-primary .il-metabar-slates{position: relative;top: 0px;}</style>";
199 $help =
$f->button()->bulky(
$f->symbol()->glyph()->help(),
'Help',
'#');
200 $search =
$f->button()->bulky(
$f->symbol()->glyph()->search(),
'Search',
'#');
201 $user =
$f->button()->bulky(
$f->symbol()->glyph()->user(),
'User',
'#');
204 $metabar =
$f->mainControls()->metabar()
205 ->withAdditionalEntry(
'search', $search)
206 ->withAdditionalEntry(
'help', $help)
207 ->withAdditionalEntry(
'notification', $notification_center)
208 ->withAdditionalEntry(
'user', $user);
extended_example_for_developers()
This is a rather extended example on the usage of the Notification Item async functionality provided ...
usuallyDoneByGlobalScreenProbablyIgnore($async_item, $f, $renderer, $add_button, $set_button, $reset_button)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
buildMetabarWithNotifications($f, $notification_center)
Refinery Factory $refinery