Added condition to filter article box by category
authorMarcel Werk <burntime@woltlab.com>
Wed, 22 Jun 2016 15:05:35 +0000 (17:05 +0200)
committerMarcel Werk <burntime@woltlab.com>
Wed, 22 Jun 2016 15:05:35 +0000 (17:05 +0200)
com.woltlab.wcf/box.xml
com.woltlab.wcf/objectType.xml
com.woltlab.wcf/objectTypeDefinition.xml
wcfsetup/install/files/lib/system/box/ArticleListBoxController.class.php
wcfsetup/install/files/lib/system/condition/article/ArticleCategoryCondition.class.php [new file with mode: 0644]

index 0762f43ecfb03f14da34c34e63518929117f9816..0c67a873ccbe183d8899ccbbe8a3fa8bf97090dd 100644 (file)
                        </content>
                </box>
                
-               <box identifier="com.woltlab.wcf.RecentActivitySidebar">
-                       <name language="de">Letzte Aktivitäten (Sidebar)</name>
-                       <name language="en">Recent Activities (Sidebar)</name>
+               <box identifier="com.woltlab.wcf.RegisterButton">
+                       <name language="de">Registrierungs-Button</name>
+                       <name language="en">Register Button</name>
                        <boxType>system</boxType>
-                       <objectType>com.woltlab.wcf.recentActivityList</objectType>
+                       <objectType>com.woltlab.wcf.registerButton</objectType>
                        <position>sidebarRight</position>
                        <showHeader>1</showHeader>
                        <visibleEverywhere>0</visibleEverywhere>
+                       <cssClassName>boxInfo</cssClassName>
                        <visibilityExceptions>
                                <page>com.woltlab.wcf.Dashboard</page>
                        </visibilityExceptions>
-                       <limit>10</limit>
                        
                        <content language="de">
-                               <title>Letzte Aktivitäten</title>
-                       </content>
-                       <content language="en">
-                               <title>Recent Activities</title>
-                       </content>
-               </box>
-               
-               <box identifier="com.woltlab.wcf.PaidSubscriptions">
-                       <name language="de">Bezahlte Mitgliedschaften</name>
-                       <name language="en">Paid Subscriptions</name>
-                       <boxType>system</boxType>
-                       <objectType>com.woltlab.wcf.paidSubscriptions</objectType>
-                       <position>contentBottom</position>
-                       <showHeader>1</showHeader>
-                       <visibleEverywhere>0</visibleEverywhere>
-                       
-                       <content language="de">
-                               <title>Bezahlte Mitgliedschaften</title>
+                               <title>Registrierung</title>
                        </content>
                        <content language="en">
-                               <title>Paid Subscriptions</title>
+                               <title>Registration</title>
                        </content>
                </box>
                
-               <box identifier="com.woltlab.wcf.PaidSubscriptionsSidebar">
-                       <name language="de">Bezahlte Mitgliedschaften (Sidebar)</name>
-                       <name language="en">Paid Subscriptions (Sidebar)</name>
+               <box identifier="com.woltlab.wcf.SignedInAs">
+                       <name language="de">Angemeldet als</name>
+                       <name language="en">Signed In As</name>
                        <boxType>system</boxType>
-                       <objectType>com.woltlab.wcf.paidSubscriptions</objectType>
+                       <objectType>com.woltlab.wcf.signedInAs</objectType>
                        <position>sidebarRight</position>
-                       <showHeader>1</showHeader>
+                       <showHeader>0</showHeader>
                        <visibleEverywhere>0</visibleEverywhere>
+                       <visibilityExceptions>
+                               <page>com.woltlab.wcf.Dashboard</page>
+                       </visibilityExceptions>
                        
                        <content language="de">
-                               <title>Bezahlte Mitgliedschaften</title>
+                               <title>Angemeldet als</title>
                        </content>
                        <content language="en">
-                               <title>Paid Subscriptions</title>
+                               <title>Signed In As</title>
                        </content>
                </box>
                
-               <box identifier="com.woltlab.wcf.RegisterButton">
-                       <name language="de">Registrierungs-Button</name>
-                       <name language="en">Register Button</name>
+               <box identifier="com.woltlab.wcf.StaffOnline">
+                       <name language="de">Team-Mitglieder online</name>
+                       <name language="en">Staff-Members Online</name>
                        <boxType>system</boxType>
-                       <objectType>com.woltlab.wcf.registerButton</objectType>
+                       <objectType>com.woltlab.wcf.staffOnlineList</objectType>
                        <position>sidebarRight</position>
                        <showHeader>1</showHeader>
                        <visibleEverywhere>0</visibleEverywhere>
-                       <cssClassName>boxInfo</cssClassName>
                        <visibilityExceptions>
                                <page>com.woltlab.wcf.Dashboard</page>
                        </visibilityExceptions>
                        
                        <content language="de">
-                               <title>Registrierung</title>
+                               <title>Team-Mitglieder online</title>
                        </content>
                        <content language="en">
-                               <title>Registration</title>
+                               <title>Staff-Members Online</title>
                        </content>
                </box>
                
-               <box identifier="com.woltlab.wcf.SignedInAs">
-                       <name language="de">Angemeldet als</name>
-                       <name language="en">Signed In As</name>
-                       <boxType>system</boxType>
-                       <objectType>com.woltlab.wcf.signedInAs</objectType>
-                       <position>sidebarRight</position>
-                       <showHeader>0</showHeader>
-                       <visibleEverywhere>0</visibleEverywhere>
-                       <visibilityExceptions>
-                               <page>com.woltlab.wcf.Dashboard</page>
-                       </visibilityExceptions>
-                       
-                       <!-- TODO: content title -->
-               </box>
-               
                <box identifier="com.woltlab.wcf.Statistics">
                        <name language="de">Statistiken</name>
                        <name language="en">Statistics</name>
                        <position>sidebarRight</position>
                        <showHeader>1</showHeader>
                        <visibleEverywhere>0</visibleEverywhere>
+                       <visibilityExceptions>
+                               <page>com.woltlab.wcf.MembersList</page>
+                       </visibilityExceptions>
                        <sortField>registrationDate</sortField>
                        <sortOrder>DESC</sortOrder>
                        
                        <position>sidebarRight</position>
                        <showHeader>1</showHeader>
                        <visibleEverywhere>0</visibleEverywhere>
+                       <visibilityExceptions>
+                               <page>com.woltlab.wcf.MembersList</page>
+                       </visibilityExceptions>
                        <sortField>activityPoints</sortField>
                        <sortOrder>DESC</sortOrder>
                        
                        </content>
                </box>
                
-               <box identifier="com.woltlab.wcf.MostLikedMembers">
-                       <name language="de">Mitglieder mit den meisten Likes</name>
-                       <name language="en">Most Liked Members</name>
-                       <boxType>system</boxType>
-                       <objectType>com.woltlab.wcf.userList</objectType>
-                       <position>sidebarRight</position>
-                       <showHeader>1</showHeader>
-                       <visibleEverywhere>0</visibleEverywhere>
-                       <sortField>likesReceived</sortField>
-                       <sortOrder>DESC</sortOrder>
-                       
-                       <content language="de">
-                               <title>Mitglieder mit den meisten Likes</title>
-                       </content>
-                       <content language="en">
-                               <title>Most Liked Members</title>
-                       </content>
-               </box>
-               
                <box identifier="com.woltlab.wcf.TodaysBirthdays">
                        <name language="de">Heutige Geburtstage</name>
                        <name language="en">Today’s Birthdays</name>
                        <position>sidebarRight</position>
                        <showHeader>1</showHeader>
                        <visibleEverywhere>0</visibleEverywhere>
+                       <visibilityExceptions>
+                               <page>com.woltlab.wcf.MembersList</page>
+                       </visibilityExceptions>
                        
                        <content language="de">
                                <title>Heutige Geburtstage</title>
                                <title>Today’s Birthdays</title>
                        </content>
                </box>
-               
-               <box identifier="com.woltlab.wcf.TodaysFollowingBirthdays">
-                       <name language="de">Heutige Geburtstage von Nutzern, denen der Nutzer folgt</name>
-                       <name language="en">Today’s Birthdays of Users the User Follows</name>
-                       <boxType>system</boxType>
-                       <objectType>com.woltlab.wcf.todaysFollowingBirthdays</objectType>
-                       <position>sidebarRight</position>
-                       <showHeader>1</showHeader>
-                       <visibleEverywhere>0</visibleEverywhere>
-                       
-                       <!-- TODO: content title -->
-               </box>
-               
+                               
                <box identifier="com.woltlab.wcf.UsersOnline">
                        <name language="de">Benutzer online</name>
                        <name language="en">Users Online</name>
                        </content>
                </box>
                
-               <box identifier="com.woltlab.wcf.UsersOnlineSidebar">
-                       <name language="de">Benutzer online (Sidebar)</name>
-                       <name language="en">Users Online (Sidebar)</name>
-                       <boxType>system</boxType>
-                       <objectType>com.woltlab.wcf.userOnlineList</objectType>
-                       <position>sidebarRight</position>
-                       <showHeader>1</showHeader>
-                       <visibleEverywhere>0</visibleEverywhere>
-                       
-                       <content language="de">
-                               <title>Benutzer online</title>
-                       </content>
-                       <content language="en">
-                               <title>Users Online</title>
-                       </content>
-               </box>
-               
-               <box identifier="com.woltlab.wcf.StaffOnline">
-                       <name language="de">Team-Mitglieder online</name>
-                       <name language="en">Staff-Members Online</name>
-                       <boxType>system</boxType>
-                       <objectType>com.woltlab.wcf.staffOnlineList</objectType>
-                       <position>sidebarRight</position>
-                       <showHeader>1</showHeader>
-                       <visibleEverywhere>0</visibleEverywhere>
-                       
-                       <content language="de">
-                               <title>Team-Mitglieder online</title>
-                       </content>
-                       <content language="en">
-                               <title>Staff-Members Online</title>
-                       </content>
-               </box>
-               
-               <box identifier="com.woltlab.wcf.FollowingsOnline">
-                       <name language="de">Benutzer online, denen der Nutzer folgt</name>
-                       <name language="en">Users Online the User Follows</name>
-                       <boxType>system</boxType>
-                       <objectType>com.woltlab.wcf.followingsOnline</objectType>
-                       <position>sidebarRight</position>
-                       <showHeader>1</showHeader>
-                       <visibleEverywhere>0</visibleEverywhere>
-                       <limit>10</limit>
-                       
-                       <!-- TODO: content title -->
-               </box>
-               
                <box identifier="com.woltlab.wcf.PageComments">
                        <name language="de">Seiten-Kommentare</name>
                        <name language="en">Page Comments</name>
index 1ab32cde25f55a4081bdfb87e5ed6c6fae97395b..434855c36162e60fc40bcb0ae86f6de4f79d6494 100644 (file)
                </type>
                <!-- /box controllers -->
                
+               <!-- article list box condition -->
+               <type>
+                       <name>com.woltlab.wcf.articleCategory</name>
+                       <definitionname>com.woltlab.wcf.box.articleList.condition</definitionname>
+                       <classname>wcf\system\condition\article\ArticleCategoryCondition</classname>
+               </type>
+               <!-- /thread list box condition -->
+               
                <!-- deprecated -->
                <type>
                        <name>com.woltlab.wcf.page.controller</name>
index 26c32bbeef2056ded4abeed5c5c642f131a8ed56..2ec0b03738d1975e9ceac7cfc7c4eef195d4aed6 100644 (file)
                        <interfacename>wcf\system\box\IBoxController</interfacename>
                </definition>
                
+               <!-- box conditions -->
+               <definition>
+                       <name>com.woltlab.wcf.box.articleList.condition</name>
+                       <interfacename>wcf\system\condition\IObjectListCondition</interfacename>
+               </definition>
+               <!-- /box conditions -->
+               
                <!-- deprecated -->
                <definition>
                        <name>com.woltlab.wcf.page</name>
index b9fdf18761abbfb33ddc00cb7a8394664185fa6e..3dd0d4efedcba18235806e9ba3531a118c126ce4 100644 (file)
@@ -28,6 +28,11 @@ class ArticleListBoxController extends AbstractDatabaseObjectListBoxController {
         */
        public $defaultLimit = 3;
        
+       /**
+        * @inheritDoc
+        */
+       protected $conditionDefinition = 'com.woltlab.wcf.box.articleList.condition';
+       
        /**
         * @inheritDoc
         */
@@ -61,9 +66,6 @@ class ArticleListBoxController extends AbstractDatabaseObjectListBoxController {
                        case 'views':
                                $objectList->getConditionBuilder()->add('article.views > ?', [0]);
                                break;
-                       case 'cumulativeLikes':
-                               $objectList->getConditionBuilder()->add('article.cumulativeLikes > ?', [0]);
-                               break;
                }
                
                return $objectList;
diff --git a/wcfsetup/install/files/lib/system/condition/article/ArticleCategoryCondition.class.php b/wcfsetup/install/files/lib/system/condition/article/ArticleCategoryCondition.class.php
new file mode 100644 (file)
index 0000000..439d58b
--- /dev/null
@@ -0,0 +1,43 @@
+<?php
+namespace wcf\system\condition\article;
+use wcf\data\article\ArticleList;
+use wcf\data\DatabaseObjectList;
+use wcf\system\condition\AbstractMultiCategoryCondition;
+use wcf\system\condition\IObjectListCondition;
+
+/**
+ * Condition implementation for the category an article belongs to.
+ *
+ * @author     Marcel Werk
+ * @copyright  2001-2016 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    WoltLabSuite\Core\System\Condition\Article
+ * @since      3.0
+ */
+class ArticleCategoryCondition extends AbstractMultiCategoryCondition implements IObjectListCondition {
+       /**
+        * @inheritDoc
+        */
+       public $objectType = 'com.woltlab.wcf.article.category';
+       
+       /**
+        * @inheritDoc
+        */
+       protected $fieldName = 'articleCategoryIDs';
+       
+       /**
+        * @inheritDoc
+        */
+       protected $label = 'wcf.acp.article.category';
+       
+       /**
+        * @inheritDoc
+        */
+       public function addObjectListCondition(DatabaseObjectList $objectList, array $conditionData) {
+               if (!($objectList instanceof ArticleList)) {
+                       throw new \InvalidArgumentException("Object list is no instance of '".ArticleList::class."', instance of '".get_class($objectList)."' given.");
+               }
+               
+               $objectList->getConditionBuilder()->add('article.categoryID IN (?)', [$conditionData[$this->fieldName]]);
+       }
+}