Added recent activity event for liked articles
authorMarcel Werk <burntime@woltlab.com>
Wed, 8 Jun 2016 13:50:26 +0000 (15:50 +0200)
committerMarcel Werk <burntime@woltlab.com>
Wed, 8 Jun 2016 13:51:26 +0000 (15:51 +0200)
com.woltlab.wcf/objectType.xml
wcfsetup/install/files/lib/system/user/activity/event/LikeableArticleUserActivityEvent.class.php [new file with mode: 0644]
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index e82d5c7de57b32fc9fb9133066197b0d9534bc99..f2cd197e12105b9f92c019586e0f0de91000a5ba 100644 (file)
                        <definitionname>com.woltlab.wcf.like.likeableObject</definitionname>
                        <classname>wcf\data\article\LikeableArticleProvider</classname>
                </type>
+               <type>
+                       <name>com.woltlab.wcf.likeableArticle.recentActivityEvent</name>
+                       <definitionname>com.woltlab.wcf.user.recentActivityEvent</definitionname>
+                       <classname>wcf\system\user\activity\event\LikeableArticleUserActivityEvent</classname>
+               </type>
                <type>
                        <name>com.woltlab.wcf.article</name>
                        <definitionname>com.woltlab.wcf.searchableObjectType</definitionname>
diff --git a/wcfsetup/install/files/lib/system/user/activity/event/LikeableArticleUserActivityEvent.class.php b/wcfsetup/install/files/lib/system/user/activity/event/LikeableArticleUserActivityEvent.class.php
new file mode 100644 (file)
index 0000000..7fc82bf
--- /dev/null
@@ -0,0 +1,57 @@
+<?php
+namespace wcf\system\user\activity\event;
+use wcf\data\article\ViewableArticleList;
+use wcf\system\SingletonFactory;
+use wcf\system\WCF;
+
+/**
+ * User activity event implementation for liked cms articles.
+ *
+ * @author     Marcel Werk
+ * @copyright  2001-2016 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    com.woltlab.wcf
+ * @subpackage system.user.activity.event
+ * @category   Community Framework
+ * @since       2.2
+ */
+class LikeableArticleUserActivityEvent extends SingletonFactory implements IUserActivityEvent {
+       /**
+        * @inheritDoc
+        */
+       public function prepare(array $events) {
+               $articleIDs = [];
+               foreach ($events as $event) {
+                       $articleIDs[] = $event->objectID;
+               }
+               
+               // fetch articles
+               $articleList = new ViewableArticleList();
+               $articleList->setObjectIDs($articleIDs);
+               $articleList->readObjects();
+               $articles = $articleList->getObjects();
+               
+               // set message
+               foreach ($events as $event) {
+                       if (isset($articles[$event->objectID])) {
+                               $article = $articles[$event->objectID];
+                               
+                               // check permissions
+                               if (!$article->canRead()) {
+                                       continue;
+                               }
+                               $event->setIsAccessible();
+                               
+                               // short output
+                               $text = WCF::getLanguage()->getDynamicVariable('wcf.article.recentActivity.likedArticle', ['article' => $article]);
+                               $event->setTitle($text);
+                               
+                               // output
+                               $event->setDescription($article->getTeaser());
+                       }
+                       else {
+                               $event->setIsOrphaned();
+                       }
+               }
+       }
+}
index 149a61656880d955a5e73393f98dc641b748e454..370076461e0a7af773dd06523f014943bf24899e 100644 (file)
@@ -1733,6 +1733,17 @@ Sie können jetzt den vollen Funktionsumfang der Seite nutzen.]]></item>
                <item name="wcf.ajax.error.sessionExpired"><![CDATA[Ihre Sitzung ist abgelaufen, bitte melden Sie sich erneut an.]]></item>
        </category>
        
+       <category name="wcf.article">
+               <item name="wcf.article.comments"><![CDATA[Kommentare]]></item>
+               <item name="wcf.article.nextArticle"><![CDATA[Nächster Artikel]]></item>
+               <item name="wcf.article.previousArticle"><![CDATA[Vorheriger Artikel]]></item>
+               <item name="wcf.article.relatedArticles"><![CDATA[Verwandte Artikel]]></item>
+               <item name="wcf.article.aboutAuthor"><![CDATA[Über den Autor]]></item>
+               <item name="wcf.article.articleComments"><![CDATA[{#$article->comments} Kommentar{if $article->comments != 1}e{/if}]]></item>
+               <item name="wcf.article.articleViews"><![CDATA[{#$article->views} mal gelesen]]></item>
+               <item name="wcf.article.recentActivity.likedArticle"><![CDATA[Mag den Artikel <a href="{$article->getLink()}">{$article->getTitle()}</a>.]]></item>
+       </category>
+       
        <category name="wcf.attachment">
                <item name="wcf.attachment.file.info"><![CDATA[({@$attachment->filesize|filesize}, <b>{#$attachment->downloads}</b> mal heruntergeladen{if $attachment->downloads > 0}, zuletzt: {@$attachment->lastDownloadTime|time}{/if})]]></item>
                <item name="wcf.attachment.image.info"><![CDATA[{@$attachment->filesize|filesize}, {#$attachment->width}×{#$attachment->height}, {#$attachment->downloads} mal angesehen]]></item>
@@ -2956,6 +2967,7 @@ Sollten Sie sich nicht auf der Website: {@PAGE_TITLE|language} angemeldet haben,
                <item name="wcf.user.recentActivity.com.woltlab.wcf.user.recentActivityEvent.follow"><![CDATA[Folgen]]></item>
                <item name="wcf.user.recentActivity.com.woltlab.wcf.user.profileComment.recentActivityEvent"><![CDATA[Pinnwand-Kommentar]]></item>
                <item name="wcf.user.recentActivity.com.woltlab.wcf.user.profileComment.response.recentActivityEvent"><![CDATA[Pinnwand-Antwort]]></item>
+               <item name="wcf.user.recentActivity.com.woltlab.wcf.likeableArticle.recentActivityEvent"><![CDATA[Like (Artikel)]]></item>
                <item name="wcf.user.recentActivity.scope.all"><![CDATA[Aktivitäten aller Benutzer]]></item>
                <item name="wcf.user.recentActivity.scope.followedUsers"><![CDATA[Aktivitäten von Benutzern, denen Sie folgen]]></item>
        </category>
index c6dd700b31a64e49dbffd3e435e3a25cf28ee8a4..c2c80ec3cc7667fbdbdaefbc8bc66b905cd025c1 100644 (file)
@@ -1740,6 +1740,17 @@ You can now fully access the website.]]></item>
                <item name="wcf.ajax.error.sessionExpired"><![CDATA[Your session expired, please login again.]]></item>
        </category>
        
+       <category name="wcf.article">
+               <item name="wcf.article.comments"><![CDATA[Comments]]></item>
+               <item name="wcf.article.nextArticle"><![CDATA[Next Article]]></item>
+               <item name="wcf.article.previousArticle"><![CDATA[Previous Article]]></item>
+               <item name="wcf.article.relatedArticles"><![CDATA[Related Articles]]></item>
+               <item name="wcf.article.aboutAuthor"><![CDATA[About the Author]]></item>
+               <item name="wcf.article.articleComments"><![CDATA[{#$article->comments} Comment{if $article->comments != 1}s{/if}]]></item>
+               <item name="wcf.article.articleViews"><![CDATA[{#$article->views} View{if $article->views != 1}s{/if}]]></item>
+               <item name="wcf.article.recentActivity.likedArticle"><![CDATA[Liked the article <a href="{$article->getLink()}">{$article->getTitle()}</a>.]]></item>
+       </category>
+       
        <category name="wcf.attachment">
                <item name="wcf.attachment.file.info"><![CDATA[({@$attachment->filesize|filesize}, downloaded <b>{#$attachment->downloads}</b> times{if $attachment->downloads > 0}, last: {@$attachment->lastDownloadTime|time}{/if})]]></item>
                <item name="wcf.attachment.image.info"><![CDATA[{@$attachment->filesize|filesize}, {#$attachment->width}×{#$attachment->height}, viewed {#$attachment->downloads} times]]></item>
@@ -2989,6 +3000,7 @@ You can safely ignore this email if you did not register with the website: {@PAG
                <item name="wcf.user.recentActivity.com.woltlab.wcf.user.recentActivityEvent.follow"><![CDATA[Follow]]></item>
                <item name="wcf.user.recentActivity.com.woltlab.wcf.user.profileComment.recentActivityEvent"><![CDATA[Wall Comment]]></item>
                <item name="wcf.user.recentActivity.com.woltlab.wcf.user.profileComment.response.recentActivityEvent"><![CDATA[Wall Reply]]></item>
+               <item name="wcf.user.recentActivity.com.woltlab.wcf.likeableArticle.recentActivityEvent"><![CDATA[Like (Article)]]></item>
                <item name="wcf.user.recentActivity.scope.all"><![CDATA[All Activities]]></item>
                <item name="wcf.user.recentActivity.scope.followedUsers"><![CDATA[Filter by Followed Users]]></item>
        </category>