Add box controller for article comments
authorMatthias Schmidt <gravatronics@live.com>
Thu, 6 Oct 2016 15:24:03 +0000 (17:24 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Thu, 6 Oct 2016 15:29:43 +0000 (17:29 +0200)
com.woltlab.wcf/objectType.xml
wcfsetup/install/files/lib/system/box/ArticleCommentListBoxController.class.php [new file with mode: 0644]
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index 83917747659dab45dcdc2c15605c43b093fdb204..5e14c1269de197ced4179a695f5497ea4e5cdb26 100644 (file)
                        <definitionname>com.woltlab.wcf.boxController</definitionname>
                        <classname>wcf\system\box\ArticleListBoxController</classname>
                </type>
+               <type>
+                       <name>com.woltlab.wcf.articleCommentList</name>
+                       <definitionname>com.woltlab.wcf.boxController</definitionname>
+                       <classname>wcf\system\box\ArticleCommentListBoxController</classname>
+               </type>
                <type>
                        <name>com.woltlab.wcf.whoWasOnline</name>
                        <definitionname>com.woltlab.wcf.boxController</definitionname>
diff --git a/wcfsetup/install/files/lib/system/box/ArticleCommentListBoxController.class.php b/wcfsetup/install/files/lib/system/box/ArticleCommentListBoxController.class.php
new file mode 100644 (file)
index 0000000..f83d04e
--- /dev/null
@@ -0,0 +1,45 @@
+<?php
+namespace wcf\system\box;
+use wcf\data\article\Article;
+use wcf\data\article\category\ArticleCategory;
+use wcf\data\comment\ViewableCommentList;
+use wcf\system\language\LanguageFactory;
+use wcf\system\WCF;
+
+/**
+ * Box controller implementation for a list of article comments.
+ * 
+ * @author     Matthias Schmidt
+ * @copyright  2001-2016 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    WoltLabSuite\Core\System\Box
+ */
+class ArticleCommentListBoxController extends AbstractCommentListBoxController {
+       /**
+        * @inheritDoc
+        */
+       protected $objectTypeName = 'com.woltlab.wcf.articleComment';
+       
+       /**
+        * @inheritDoc
+        */
+       protected function applyObjectTypeFilters(ViewableCommentList $commentList) {
+               $accessibleCategoryIDs = ArticleCategory::getAccessibleCategoryIDs();
+               if (!empty($accessibleCategoryIDs)) {
+                       $commentList->sqlJoins .= ' INNER JOIN wcf' . WCF_N . '_article_content article_content ON (article_content.articleContentID = comment.objectID)';
+                       $commentList->sqlJoins .= ' INNER JOIN wcf' . WCF_N . '_article article ON (article.articleID = article_content.articleID)';
+                       $commentList->sqlSelects = 'article_content.title';
+                       
+                       $commentList->getConditionBuilder()->add('article.categoryID IN (?)', [$accessibleCategoryIDs]);
+                       $commentList->getConditionBuilder()->add('article.publicationStatus = ?', [Article::PUBLISHED]);
+                       
+                       // apply language filter
+                       if (LanguageFactory::getInstance()->multilingualismEnabled() && !empty(WCF::getUser()->getLanguageIDs())) {
+                               $commentList->getConditionBuilder()->add('(article_content.languageID IN (?) OR article_content.languageID IS NULL)', [WCF::getUser()->getLanguageIDs()]);
+                       }
+               }
+               else {
+                       $commentList->getConditionBuilder()->add('0 = 1');
+               }
+       }
+}
index a367266d18e5465e4c5f2c194a6da621aba6e542..02662fa00e90ad0f22010bc598a30da85d764adf 100644 (file)
                <item name="wcf.acp.box.visibilityException.visible"><![CDATA[Box auf ausgewählten Seiten <strong>explizit anzeigen</strong>]]></item>
                <item name="wcf.acp.box.visibilityException.hidden"><![CDATA[Box auf ausgewählten Seiten <strong>nicht anzeigen</strong>]]></item>
                <item name="wcf.acp.box.boxController.com.woltlab.wcf.articleCategories"><![CDATA[Artikel-Kategorien]]></item>
+               <item name="wcf.acp.box.boxController.com.woltlab.wcf.articleCommentList"><![CDATA[Artikel-Kommentare]]></item>
                <item name="wcf.acp.box.boxController.com.woltlab.wcf.articleList"><![CDATA[Artikel]]></item>
                <item name="wcf.acp.box.boxController.com.woltlab.wcf.followingsOnline"><![CDATA[Benutzer online, denen der aktive Nutzer folgt]]></item>
                <item name="wcf.acp.box.boxController.com.woltlab.wcf.pageCommentList"><![CDATA[Seiten-Kommentare]]></item>
index f065d85ec51775b919bded167c9a412e891ce91b..594eff83cf098a9d41e9c0a03ac233295b49815c 100644 (file)
@@ -193,6 +193,7 @@ Examples for medium ID detection:
                <item name="wcf.acp.box.visibilityException.visible"><![CDATA[Choose Where the Box Will be Explicitly <strong>Visible</strong>]]></item>
                <item name="wcf.acp.box.visibilityException.hidden"><![CDATA[Choose Where the Box Will be Explicitly <strong>Hidden</strong>]]></item>
                <item name="wcf.acp.box.boxController.com.woltlab.wcf.articleCategories"><![CDATA[Article Categories]]></item>
+               <item name="wcf.acp.box.boxController.com.woltlab.wcf.articleCommentList"><![CDATA[Article Comments]]></item>
                <item name="wcf.acp.box.boxController.com.woltlab.wcf.articleList"><![CDATA[Articles]]></item>
                <item name="wcf.acp.box.boxController.com.woltlab.wcf.followingsOnline"><![CDATA[Users Online Followed by Active User]]></item>
                <item name="wcf.acp.box.boxController.com.woltlab.wcf.pageCommentList"><![CDATA[Page Comments]]></item>