add feed page for user notifications
authorjoshuaruesweg <josh@joshsboard.de>
Tue, 7 Jun 2016 22:39:18 +0000 (00:39 +0200)
committerjoshuaruesweg <josh@joshsboard.de>
Tue, 7 Jun 2016 22:39:18 +0000 (00:39 +0200)
CHANGELOG.md
com.woltlab.wcf/templates/notificationList.tpl
wcfsetup/install/files/lib/page/AbstractFeedPage.class.php
wcfsetup/install/files/lib/page/NotificationFeedPage.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/user/notification/event/AbstractUserNotificationEvent.class.php

index 89bf9d88728365ba648d8b59c3dade3861b16583..47b30e04bf5b540fdde41472aa67386a933c49da 100644 (file)
@@ -58,6 +58,7 @@
 * Overhauled language import form
 * Removed sitemap function/overlay
 * Added rebuild polls worker
+* Added notification feed page
 
 #### CMS
 
index e96652fcd36648d39ddd1fa81c05be012ba00b97..666f018c2be99a9967827cb68d16993cdbe29bef 100644 (file)
        </header>
 {/capture}
 
+{capture assign='headContent'}
+       <link rel="alternate" type="application/rss+xml" title="{lang}wcf.global.button.rss{/lang}" href="{link controller='NotificationFeed' appendSession=false}at={@$__wcf->getUser()->userID}-{@$__wcf->getUser()->accessToken}{/link}" />
+{/capture}
+
+{capture assign='headerNavigation'}
+       <li><a rel="alternate" href="{link controller='NotificationFeed' appendSession=false}at={@$__wcf->getUser()->userID}-{@$__wcf->getUser()->accessToken}{/link}" title="{lang}wcf.global.button.rss{/lang}" class="jsTooltip"><span class="icon icon16 fa-rss"></span> <span class="invisible">{lang}wcf.global.button.rss{/lang}</span></a></li>
+{/capture}
+
 {include file='userMenuSidebar'}
 
 {include file='header'}
index 4574e54849df4fb1d6be4a70c38e1be0a78b4112..1d518225766b65abd0cdc9af54afd36248cb8dd5 100644 (file)
@@ -37,8 +37,8 @@ abstract class AbstractFeedPage extends AbstractAuthedPage {
        public $objectIDs = [];
        
        /**
-        * list of feed-entries for the current page
-        * @var \wcf\data\DatabaseObjectList
+        * list of feed-entries for the current page object must be an \Iterator with \wcf\data\IFeedEntry-Elements
+        * @var \Iterator
         */
        public $items = null;
        
diff --git a/wcfsetup/install/files/lib/page/NotificationFeedPage.class.php b/wcfsetup/install/files/lib/page/NotificationFeedPage.class.php
new file mode 100644 (file)
index 0000000..c6ae8b7
--- /dev/null
@@ -0,0 +1,46 @@
+<?php
+namespace wcf\page;
+use wcf\system\exception\IllegalLinkException;
+use wcf\system\user\notification\UserNotificationHandler;
+use wcf\system\WCF;
+
+/**
+ * Shows a list of own user notifications in feed.
+ *
+ * @author     Joshua Ruesweg
+ * @copyright  2001-2016 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage page
+ * @category   Community Framework
+ * @since       2.2
+ */
+class NotificationFeedPage extends AbstractFeedPage {
+       /**
+        * @inheritDoc
+        */
+       public function readParameters() {
+               parent::readParameters();
+               
+               if (!WCF::getUser()->userID) {
+                       throw new IllegalLinkException(); 
+               }
+               
+               $this->title = WCF::getLanguage()->get('wcf.user.menu.community.notification');
+       }
+       
+       /**
+        * @inheritDoc
+        */
+       public function readData() {
+               parent::readData();
+               
+               $this->items = new \ArrayIterator();
+               
+               $notifications = UserNotificationHandler::getInstance()->getNotifications(20);
+               
+               foreach ($notifications['notifications'] as $notification) {
+                       $this->items->append($notification['event']);
+               } 
+       }
+}
index 36af722166310caae1981950fc5c7c37b3cef17d..fa15b54852010af80d5741eb0d088b1323ec4d59 100644 (file)
@@ -5,14 +5,16 @@ use wcf\data\user\notification\event\UserNotificationEvent;
 use wcf\data\user\notification\UserNotification;
 use wcf\data\user\UserProfile;
 use wcf\data\DatabaseObjectDecorator;
+use wcf\data\IFeedEntry;
 use wcf\system\user\notification\object\IUserNotificationObject;
 use wcf\system\WCF;
 use wcf\util\DateUtil;
+use wcf\util\StringUtil;
 
 /**
  * Provides a default implementation for user notification events.
  * 
- * @author     Marcel Werk, Oliver Kliebisch
+ * @author     Joshua Ruesweg, Marcel Werk, Oliver Kliebisch
  * @copyright  2001-2016 WoltLab GmbH, Oliver Kliebisch
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @package    com.woltlab.wcf
@@ -22,7 +24,7 @@ use wcf\util\DateUtil;
  * @method     UserNotificationEvent   getDecoratedObject()
  * @mixin      UserNotificationEvent
  */
-abstract class AbstractUserNotificationEvent extends DatabaseObjectDecorator implements IUserNotificationEvent {
+abstract class AbstractUserNotificationEvent extends DatabaseObjectDecorator implements IUserNotificationEvent, IFeedEntry {
        /**
         * @inheritDoc
         */
@@ -240,4 +242,62 @@ abstract class AbstractUserNotificationEvent extends DatabaseObjectDecorator imp
        public function getUserNotificationObject() {
                return $this->userNotificationObject;
        }
+       
+       /**
+        * @inheritdoc
+        */
+       public function getComments() {
+               return 0; 
+       }
+       
+       /**
+        * @inheritdoc
+        */
+       public function getCategories() {
+               return [
+                       $this->notification->objectType
+               ];
+       }
+       
+       /**
+        * @inheritdoc
+        */
+       public function getExcerpt($maxLength = 255) {
+               return StringUtil::truncateHTML($this->getFormattedMessage(), $maxLength);
+       }
+       
+       /**
+        * @inheritdoc
+        */
+       public function getFormattedMessage() {
+               return $this->getMessage(); 
+       }
+       
+       /**
+        * @inheritdoc
+        */
+       public function __toString() {
+               return $this->getFormattedMessage(); 
+       }
+       
+       /**
+        * @inheritdoc
+        */
+       public function getTime() {
+               return $this->getNotification()->time; 
+       }
+       
+       /**
+        * @inheritdoc
+        */
+       public function getUserID() {
+               return $this->getAuthorID(); 
+       }
+       
+       /**
+        * @inheritdoc
+        */
+       public function getUsername() {
+               return $this->getAuthor()->username; 
+       }
 }