3 namespace Friendica\Module\Notifications;
5 use Friendica\Content\Nav;
6 use Friendica\Content\Pager;
7 use Friendica\Core\Renderer;
9 use Friendica\Module\BaseNotifications;
12 * Prints all notification types except introduction:
18 class Notifications extends BaseNotifications
23 public static function getNotifies()
29 // Get the network notifications
30 if ((DI::args()->get(1) == 'network')) {
31 $notif_header = DI::l10n()->t('Network Notifications');
32 $notifs = $nm->getNetworkList(self::$show, self::$start, self::PER_PAGE);
34 // Get the system notifications
35 } elseif ((DI::args()->get(1) == 'system')) {
36 $notif_header = DI::l10n()->t('System Notifications');
37 $notifs = $nm->getSystemList(self::$show, self::$start, self::PER_PAGE);
39 // Get the personal notifications
40 } elseif ((DI::args()->get(1) == 'personal')) {
41 $notif_header = DI::l10n()->t('Personal Notifications');
42 $notifs = $nm->getPersonalList(self::$show, self::$start, self::PER_PAGE);
44 // Get the home notifications
45 } elseif ((DI::args()->get(1) == 'home')) {
46 $notif_header = DI::l10n()->t('Home Notifications');
47 $notifs = $nm->getHomeList(self::$show, self::$start, self::PER_PAGE);
48 // fallback - redirect to main page
50 DI::baseUrl()->redirect('notifications');
54 $pager = new Pager(DI::args()->getQueryString(), self::PER_PAGE);
56 // Add additional informations (needed for json output)
57 $notifs['items_page'] = $pager->getItemsPerPage();
58 $notifs['page'] = $pager->getPage();
61 'header' => $notif_header,
66 public static function content(array $parameters = [])
68 Nav::setSelected('notifications');
71 $notif_nocontent = '';
73 $notif_result = self::getNotifies();
74 $notifs = $notif_result['notifs'] ?? [];
75 $notif_header = $notif_result['header'] ?? '';
78 if (!empty($notifs['notifications'])) {
79 // Loop trough ever notification This creates an array with the output html for each
80 // notification and apply the correct template according to the notificationtype (label).
81 foreach ($notifs['notifications'] as $notif) {
82 $notification_templates = [
83 'like' => 'notifications_likes_item.tpl',
84 'dislike' => 'notifications_dislikes_item.tpl',
85 'attend' => 'notifications_attend_item.tpl',
86 'attendno' => 'notifications_attend_item.tpl',
87 'attendmaybe' => 'notifications_attend_item.tpl',
88 'friend' => 'notifications_friends_item.tpl',
89 'comment' => 'notifications_comments_item.tpl',
90 'post' => 'notifications_posts_item.tpl',
91 'notify' => 'notify.tpl',
94 $tpl_notif = Renderer::getMarkupTemplate($notification_templates[$notif['label']]);
96 $notif_content[] = Renderer::replaceMacros($tpl_notif, [
97 '$item_label' => $notif['label'],
98 '$item_link' => $notif['link'],
99 '$item_image' => $notif['image'],
100 '$item_url' => $notif['url'],
101 '$item_text' => $notif['text'],
102 '$item_when' => $notif['when'],
103 '$item_ago' => $notif['ago'],
104 '$item_seen' => $notif['seen'],
108 $notif_nocontent = DI::l10n()->t('No more %s notifications.', $notifs['ident']);
112 'href' => (self::$show ? 'notifications/' . $notifs['ident'] : 'notifications/' . $notifs['ident'] . '?show=all'),
113 'text' => (self::$show ? DI::l10n()->t('Show unread') : DI::l10n()->t('Show all')),
116 return self::printContent($notif_header, $notif_content, $notif_nocontent, $notif_show_lnk);