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