Added option to change sort order of articles
authorMarcel Werk <burntime@woltlab.com>
Thu, 24 Nov 2016 10:23:30 +0000 (11:23 +0100)
committerMarcel Werk <burntime@woltlab.com>
Thu, 24 Nov 2016 10:23:30 +0000 (11:23 +0100)
com.woltlab.wcf/option.xml
constants.php
wcfsetup/install/files/lib/page/ArticleListPage.class.php
wcfsetup/install/files/lib/page/ArticlePage.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index 75a482eef7e6e80d6f577c4d04a8c8f6c84a125d..9d09c471cf968381cdf1505fc78f881ccfe92a32 100644 (file)
@@ -1526,6 +1526,14 @@ DESC:wcf.global.sortOrder.descending</selectoptions>
                                <maxvalue>100</maxvalue>
                                <suffix>percent</suffix>
                        </option>
+                       <option name="article_sort_order">
+                               <categoryname>cms.article</categoryname>
+                               <optiontype>select</optiontype>
+                               <defaultvalue>DESC</defaultvalue>
+                               <selectoptions>ASC:wcf.global.sortOrder.ascending
+DESC:wcf.global.sortOrder.descending</selectoptions>
+                               <options>module_article</options>
+                       </option>
                        <!-- /cms.article -->
                </options>
        </import>
index 2482b5e06a592821c8a63d8a3d455b5fb9033ff1..32f79af2c99821219a6c26ebce635434c73a260f 100644 (file)
@@ -214,3 +214,4 @@ define('ARTICLE_RELATED_ARTICLES_MATCH_THRESHOLD', 1);
 define('SHOW_UPDATE_NOTICE_FRONTEND', 1);
 define('LANGUAGE_USE_INFORMAL_VARIANT', 0);
 define('SHOW_STYLE_CHANGER', 0);
+define('ARTICLE_SORT_ORDER', 'DESC');
index 8d174d0cc904636d1d28fd3250c9905b4f295516..798b6b1de3ac5cd790d1dd481da716b1ca714728 100644 (file)
@@ -27,7 +27,12 @@ class ArticleListPage extends MultipleLinkPage {
        /**
         * @inheritDoc
         */
-       public $sqlOrderBy = 'article.time DESC';
+       public $sortField = 'time';
+       
+       /**
+        * @inheritDoc
+        */
+       public $sortOrder = ARTICLE_SORT_ORDER;
        
        /**
         * @inheritDoc
index b4f163ac167268a78382d6f806abbd54d61f19c7..6c5796860f6881ab1b23befd82de95471fdb0423 100644 (file)
@@ -81,16 +81,16 @@ class ArticlePage extends AbstractArticlePage {
                
                // get next article
                $articleList = new CategoryArticleList($this->article->categoryID);
-               $articleList->getConditionBuilder()->add('article.time > ?', [$this->article->time]);
-               $articleList->sqlOrderBy = 'article.time';
+               $articleList->getConditionBuilder()->add('article.time ' . (ARTICLE_SORT_ORDER == 'DESC' ? '>' : '<') . ' ?', [$this->article->time]);
+               $articleList->sqlOrderBy = 'article.time ' . (ARTICLE_SORT_ORDER == 'DESC' ? 'ASC' : 'DESC');
                $articleList->sqlLimit = 1;
                $articleList->readObjects();
                foreach ($articleList as $article) $this->nextArticle = $article;
                
                // get previous article
                $articleList = new CategoryArticleList($this->article->categoryID);
-               $articleList->getConditionBuilder()->add('article.time < ?', [$this->article->time]);
-               $articleList->sqlOrderBy = 'article.time DESC';
+               $articleList->getConditionBuilder()->add('article.time ' . (ARTICLE_SORT_ORDER == 'DESC' ? '<' : '>') . ' ?', [$this->article->time]);
+               $articleList->sqlOrderBy = 'article.time ' . ARTICLE_SORT_ORDER;
                $articleList->sqlLimit = 1;
                $articleList->readObjects();
                foreach ($articleList as $article) $this->previousArticle = $article;
index 20633865c15f6b12a4ef61cd6f3b738d939debc7..b9e32c5ca93a88070bc2b43be7e699fa3b4165f3 100644 (file)
@@ -1232,7 +1232,8 @@ GmbH=Gesellschaft mit beschränkter Haftung]]></item>
                <item name="wcf.acp.option.media_small_thumbnail_height"><![CDATA[Höhe der kleinen Vorschaugrafiken]]></item>
                <item name="wcf.acp.option.media_small_thumbnail_retain_dimensions"><![CDATA[Bildformat beim Erzeugen von kleinen Vorschaugrafiken beibehalten]]></item>
                <item name="wcf.acp.option.media_small_thumbnail_width"><![CDATA[Breite der kleinen Vorschaugrafiken]]></item>
-       
+               <item name="wcf.acp.option.article_sort_order"><![CDATA[Sortierungsreihenfolge]]></item>
+               <item name="wcf.acp.option.article_sort_order.description"><![CDATA[Standard-Reihenfolge für die Liste der Artikel.]]></item>
        </category>
        
        <category name="wcf.acp.package">
index c6f8a19cedac37081dda0f4dcd003ba46686a0c1..0192d053136a7101f629e8ddf542dc4dd2f8796a 100644 (file)
@@ -1235,6 +1235,8 @@ Examples for medium ID detection:
                <item name="wcf.acp.option.media_small_thumbnail_height"><![CDATA[Small Thumbnail Height]]></item>
                <item name="wcf.acp.option.media_small_thumbnail_retain_dimensions"><![CDATA[Retain thumbnail dimensions (small)]]></item>
                <item name="wcf.acp.option.media_small_thumbnail_width"><![CDATA[Small Thumbnail Width]]></item>
+               <item name="wcf.acp.option.article_sort_order"><![CDATA[Sort Order]]></item>
+               <item name="wcf.acp.option.article_sort_order.description"><![CDATA[Choose default sort order of articles.]]></item>
        </category>
        
        <category name="wcf.acp.package">