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