ILIAS  release_8 Revision v8.24
standard.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
6
16function standard()
17{
18 global $DIC;
19 $f = $DIC->ui()->factory();
20 $renderer = $DIC->ui()->renderer();
21 $refinery = $DIC->refinery();
22 $request_wrapper = $DIC->http()->wrapper()->query();
23
24 //Creating a mail Notification Item, note that Additional Content is only to be used
25 //if content needs to be provided, for which no UI Component yet exists.
26 $mail_icon = $f->symbol()->icon()->standard("mail", "mail");
27 $mail_title = $f->link()->standard("Inbox", "link_to_inbox");
28 $mail_notification_item = $f->item()->notification($mail_title, $mail_icon)
29 ->withDescription("You have 23 unread mails in your inbox")
30 ->withProperties(["Time" => "3 days ago"])
31 ->withAdditionalContent($f->legacy("<b>Additional Content</b>"));
32
33 //Creating a badge Notification Item with a specific close action here.
34 $close_url = $_SERVER['REQUEST_URI'] . '&badge_closed=true';
35 if ($request_wrapper->has('badge_closed') && $request_wrapper->retrieve('badge_closed', $refinery->kindlyTo()->bool())) {
36 //Whatever needs to be done, if the badge notification is closed
37 exit;
38 } else {
39 $badge_icon = $f->symbol()->icon()->standard("bdga", "mail");
40 $badge_title = $f->link()->standard("Badges", "link_to_achievement_badges");
41 $badge_notification_item1 = $f->item()->notification($badge_title, $badge_icon)
42 ->withDescription("You received 1 Badge.")
43 ->withProperties(["Time" => "2 days ago"])
44 ->withCloseAction($close_url);
45 $badge_icon = $f->symbol()->icon()->standard("bdga", "mail");
46 $badge_title = $f->link()->standard("Badges 2", "link_to_achievement_badges");
47 $close_url = $_SERVER['REQUEST_URI'] . '&badge_closed=true';
48 $badge_notification_item2 = $f->item()->notification($badge_title, $badge_icon)
49 ->withDescription("You received 1 Badge.")
50 ->withProperties(["Time" => "2 days ago"])
51 ->withCloseAction($close_url);
52 }
53 //Some generic notification Items
54 $generic_icon1 = $f->symbol()->icon()->standard("cal", "generic");
55 $generic_title1 = $f->link()->standard("Generic 1", "link_to_generic_repo");
56 $generic_item1 = $f->item()->notification($generic_title1, $generic_icon1)
57 ->withDescription("Some description.")
58 ->withProperties(["Property 1" => "Content 1", "Property 2" => "Content 2"])
59 ->withActions(
60 $f->dropdown()->standard([
61 $f->button()->shy("Possible Action of this Item", "https://www.ilias.de"),
62 $f->button()->shy("Other Possible Action of this Item", "https://www.github.com")
63 ])
64 );
65 $generic_item1_with_aggregates = $generic_item1->withAggregateNotifications([$mail_notification_item]);
66 $generic_title2 = $f->link()->standard("Generic 2", "just_opens_the_list_of_aggregates");
67 $generic_item2 = $f->item()->notification($generic_title2, $generic_icon1)
68 ->withDescription("Some description describing the aggregates attached.")
69 ->withProperties(["Property 1" => "Content 1", "Property 2" => "Content 2"])
70 ->withAggregateNotifications([$generic_item1, $generic_item1]);
71
72 //Now, one could fill the Notification Slates for those 3 Services (normally done by global screen)
73 $mail_slate = $f->mainControls()->slate()->notification("Mail", [$mail_notification_item]);
74 $badge_slate = $f->mainControls()->slate()->notification("Badge", [$badge_notification_item1, $badge_notification_item2]);
75 $generic_slate = $f->mainControls()->slate()->notification("Generic", [
76 $generic_item1_with_aggregates,
77 $generic_item2
78 ]);
79
80 //Add them to the center which is added to the top bar.
81 $notification_center = $f->mainControls()->slate()->combined(
82 "Notification Center",
83 $f->symbol()->icon()->standard("notification", "notification")
84 )
85 ->withEngaged(true)
86 ->withAdditionalEntry($mail_slate)
87 ->withAdditionalEntry($badge_slate)
88 ->withAdditionalEntry($generic_slate);
89 return $renderer->render($notification_center);
90}
global $DIC
Definition: feed.php:28
exit
Definition: login.php:28
Refinery Factory $refinery
standard()
This is an example, of how the Notification Slate is generated by assigning Notification Items to it.
Definition: standard.php:16
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10