Apply PSR-12 code style (#3886)
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / lib / page / CategoryArticleListPage.class.php
index 138468042c2d4d9762f285e297e236de87cdac51..a14fd3bb55f83ed433eb870e9712e0d671d11275 100644 (file)
@@ -1,5 +1,7 @@
 <?php
+
 namespace wcf\page;
+
 use wcf\data\article\category\ArticleCategory;
 use wcf\data\article\CategoryArticleList;
 use wcf\system\exception\IllegalLinkException;
@@ -11,113 +13,130 @@ use wcf\system\WCF;
 /**
  * Shows a list of cms articles in a certain category.
  *
- * @author     Marcel Werk
- * @copyright  2001-2019 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package    WoltLabSuite\Core\Page
- * @since      3.0 
+ * @author  Marcel Werk
+ * @copyright   2001-2019 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core\Page
+ * @since   3.0
  */
-class CategoryArticleListPage extends ArticleListPage {
-       /**
-        * category the listed articles belong to
-        * @var ArticleCategory
-        */
-       public $category;
-       
-       /**
-        * id of the category the listed articles belong to
-        * @var int
-        */
-       public $categoryID = 0;
-       
-       /**
-        * @inheritDoc
-        */
-       public $controllerName = 'CategoryArticleList';
-       
-       /**
-        * @inheritDoc
-        */
-       public function readParameters() {
-               if (isset($_REQUEST['id'])) $this->categoryID = intval($_REQUEST['id']);
-               $this->category = ArticleCategory::getCategory($this->categoryID);
-               if ($this->category === null) {
-                       throw new IllegalLinkException();
-               }
-               $this->controllerParameters['object'] = $this->category;
-               parent::readParameters();
-               
-               $this->canonicalURL = LinkHandler::getInstance()->getLink('CategoryArticleList', [
-                       'object' => $this->category
-               ], ($this->pageNo > 1 ? 'pageNo=' . $this->pageNo : ''));
-               
-               if ($this->category->sortField) {
-                       if ($this->category->sortField === 'title') {
-                               $this->sortField = 'article_content.title';
-                               $this->sortOrder = $this->category->sortOrder;
-                       }
-                       else {
-                               $this->sortField = $this->category->sortField;
-                               $this->sortOrder = $this->category->sortOrder;
-                       }
-               }
-       }
-       
-       /**
-        * @inheritDoc
-        */
-       protected function getLabelGroups(): array {
-               return $this->category->getLabelGroups('canViewLabel');
-       }
-       
-       /**
-        * @inheritDoc
-        */
-       public function checkPermissions() {
-               parent::checkPermissions();
-               
-               if (!$this->category->isAccessible()) {
-                       throw new PermissionDeniedException();
-               }
-       }
-       
-       /**
-        * @inheritDoc
-        */
-       protected function initObjectList() {
-               $this->objectList = new CategoryArticleList($this->categoryID, true);
-               if ($this->category->sortField === 'title') {
-                       $this->objectList->sqlJoins .= ' LEFT JOIN wcf' . WCF_N . '_article_content article_content ON (article_content.articleID = article.articleID AND (
-                               article_content.languageID IS NULL
-                               OR article_content.languageID = ' . WCF::getLanguage()->languageID . '
-                       ))';
-               }
-               
-               $this->applyFilters();
-       }
-       
-       /**
-        * @inheritDoc
-        */
-       public function readData() {
-               parent::readData();
-               
-               // set location
-               foreach ($this->category->getParentCategories() as $parentCategory) {
-                       PageLocationManager::getInstance()->addParentLocation('com.woltlab.wcf.CategoryArticleList', $parentCategory->categoryID, $parentCategory);
-               }
-       }
-       
-       /**
-        * @inheritDoc
-        */
-       public function assignVariables() {
-               parent::assignVariables();
-               
-               WCF::getTPL()->assign([
-                       'categoryID' => $this->categoryID,
-                       'category' => $this->category,
-                       'controllerObject' => $this->category
-               ]);
-       }
+class CategoryArticleListPage extends ArticleListPage
+{
+    /**
+     * category the listed articles belong to
+     * @var ArticleCategory
+     */
+    public $category;
+
+    /**
+     * id of the category the listed articles belong to
+     * @var int
+     */
+    public $categoryID = 0;
+
+    /**
+     * @inheritDoc
+     */
+    public $controllerName = 'CategoryArticleList';
+
+    /**
+     * @inheritDoc
+     */
+    public function readParameters()
+    {
+        if (isset($_REQUEST['id'])) {
+            $this->categoryID = \intval($_REQUEST['id']);
+        }
+        $this->category = ArticleCategory::getCategory($this->categoryID);
+        if ($this->category === null) {
+            throw new IllegalLinkException();
+        }
+        $this->controllerParameters['object'] = $this->category;
+        parent::readParameters();
+
+        $this->canonicalURL = LinkHandler::getInstance()->getLink('CategoryArticleList', [
+            'object' => $this->category,
+        ], ($this->pageNo > 1 ? 'pageNo=' . $this->pageNo : ''));
+
+        if ($this->category->sortField) {
+            if ($this->category->sortField === 'title') {
+                $this->sortField = 'article_content.title';
+                $this->sortOrder = $this->category->sortOrder;
+            } else {
+                $this->sortField = $this->category->sortField;
+                $this->sortOrder = $this->category->sortOrder;
+            }
+        }
+    }
+
+    /**
+     * @inheritDoc
+     */
+    protected function getLabelGroups(): array
+    {
+        return $this->category->getLabelGroups('canViewLabel');
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public function checkPermissions()
+    {
+        parent::checkPermissions();
+
+        if (!$this->category->isAccessible()) {
+            throw new PermissionDeniedException();
+        }
+    }
+
+    /**
+     * @inheritDoc
+     */
+    protected function initObjectList()
+    {
+        $this->objectList = new CategoryArticleList($this->categoryID, true);
+        if ($this->category->sortField === 'title') {
+            $this->objectList->sqlJoins .= '
+                LEFT JOIN   wcf' . WCF_N . '_article_content article_content
+                ON          (
+                                    article_content.articleID = article.articleID
+                                AND (
+                                        article_content.languageID IS NULL
+                                     OR article_content.languageID = ' . WCF::getLanguage()->languageID . '
+                                )
+                            )';
+        }
+
+        $this->applyFilters();
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public function readData()
+    {
+        parent::readData();
+
+        // set location
+        foreach ($this->category->getParentCategories() as $parentCategory) {
+            PageLocationManager::getInstance()->addParentLocation(
+                'com.woltlab.wcf.CategoryArticleList',
+                $parentCategory->categoryID,
+                $parentCategory
+            );
+        }
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public function assignVariables()
+    {
+        parent::assignVariables();
+
+        WCF::getTPL()->assign([
+            'categoryID' => $this->categoryID,
+            'category' => $this->category,
+            'controllerObject' => $this->category,
+        ]);
+    }
 }