*(bug 11275) Enable descending sort in API categorymembers
authorRoan Kattouw <catrope@users.mediawiki.org>
Mon, 10 Sep 2007 14:17:33 +0000 (14:17 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Mon, 10 Sep 2007 14:17:33 +0000 (14:17 +0000)
RELEASE-NOTES
includes/api/ApiQueryCategoryMembers.php

index a37cc5f..cfe1cb7 100644 (file)
@@ -48,6 +48,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 
 Full API documentation is available at http://www.mediawiki.org/wiki/API
 
+* (bug 11275) Enable descending sort in categorymembers
+
 === Languages updated in 1.12 ===
 
 * Arabic (ar)
index 79dc9b4..487fea8 100644 (file)
@@ -78,12 +78,12 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase {
                if($params['sort'] == 'timestamp')
                {
                        $this->addOption('USE INDEX', 'cl_timestamp');
-                       $this->addOption('ORDER BY', 'cl_to, cl_timestamp');
+                       $this->addOption('ORDER BY', 'cl_to, cl_timestamp' . ($params['dir'] == 'desc' ? ' DESC' : ''));
                }
                else
                {
                        $this->addOption('USE INDEX', 'cl_sortkey');
-                       $this->addOption('ORDER BY', 'cl_to, cl_sortkey, cl_from');
+                       $this->addOption('ORDER BY', 'cl_to, cl_sortkey' . ($params['dir'] == 'desc' ? ' DESC' : '') . ', cl_from');
                }
 
                $this->addWhere('cl_from=page_id');
@@ -203,6 +203,13 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase {
                                        'sortkey',
                                        'timestamp'
                                )
+                       ),
+                       'dir' => array(
+                               ApiBase :: PARAM_DFLT => 'asc',
+                               ApiBase :: PARAM_TYPE => array(
+                                       'asc',
+                                       'desc'
+                               )
                        )
                );
        }
@@ -213,6 +220,7 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase {
                        'prop' => 'What pieces of information to include',
                        'namespace' => 'Only include pages in these namespaces',
                        'sort' => 'Property to sort by',
+                       'dir' => 'In which direction to sort',
                        'continue' => 'For large categories, give the value retured from previous query',
                        'limit' => 'The maximum number of pages to return.',
                );