Created
April 27, 2015 23:48
-
-
Save jdlrobson/cc3ed6592b3334d66a57 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/i18n/en.json b/i18n/en.json | |
index 63ca958..942352a 100644 | |
--- a/i18n/en.json | |
+++ b/i18n/en.json | |
@@ -105,6 +105,7 @@ | |
"gather-overlay-edit-button": "Edit title and description", | |
"gather-overlay-continue": "Next", | |
"right-gather-hidelist": "Force a public user list to become hidden", | |
+ "gather-api-help-param-sortby": "Specify the sorting mechanism to use on collection.", | |
"apihelp-gather-description": "List and edit Gather collections.", | |
"apihelp-gather-param-gather": "Action to perform on collections.", | |
"apihelp-gather-param-owner": "Owner of the collections to search for. If omitted, defaults to current user.", | |
diff --git a/i18n/qqq.json b/i18n/qqq.json | |
index 1411a02..2cfc74e 100644 | |
--- a/i18n/qqq.json | |
+++ b/i18n/qqq.json | |
@@ -107,6 +107,7 @@ | |
"gather-overlay-edit-button": "Label for button that enables editing of description and name of a collection.", | |
"gather-overlay-continue": "Label for button inside overlay to take you to another screen.", | |
"right-gather-hidelist": "With gather, users can create lists and make them public. This right gives admins a way to hide or restore a list that violates WP policy.\n\n{{Doc-right|gather-hidelist}}", | |
+ "gather-api-help-param-sortby": "Specify the sorting mechanism to use on collection.", | |
"apihelp-gather-description": "{{doc-apihelp-description|gather}}", | |
"apihelp-gather-param-gather": "{{doc-apihelp-param|gather|gather}}", | |
"apihelp-gather-param-owner": "{{doc-apihelp-param|gather|owner}}", | |
diff --git a/includes/api/ApiQueryListPages.php b/includes/api/ApiQueryListPages.php | |
index 15ce75e..49f2f37 100644 | |
--- a/includes/api/ApiQueryListPages.php | |
+++ b/includes/api/ApiQueryListPages.php | |
@@ -134,20 +134,26 @@ class ApiQueryListPages extends ApiQueryGeneratorBase { | |
$this->addFields( array( 'gli_namespace', 'gli_title', 'gli_order' ) ); | |
$this->addWhereFld( 'gli_gl_id', $params['id'] ); | |
$this->addWhereFld( 'gli_namespace', $params['namespace'] ); | |
+ switch( $params['sortby'] ) { | |
+ case 'namespace': | |
+ $sortField = 'gli_namespace'; | |
+ break; | |
+ default: | |
+ $sortField = 'gli_order'; | |
+ } | |
if ( isset( $params['continue'] ) ) { | |
$cont = $params['continue']; | |
$this->dieContinueUsageIf( strval( floatval( $cont ) ) !== $cont ); | |
$cont = $this->getDB()->addQuotes( $cont ); | |
$op = $params['dir'] == 'ascending' ? '>=' : '<='; | |
- $this->addWhere( "gli_order $op $cont" ); | |
+ $this->addWhere( "$sortField $op $cont" ); | |
} | |
$sort = ( $params['dir'] == 'descending' ? ' DESC' : '' ); | |
- $this->addOption( 'ORDER BY', 'gli_order' . $sort ); | |
+ $this->addOption( 'ORDER BY', $sortField . $sort ); | |
$this->addOption( 'LIMIT', $params['limit'] + 1 ); | |
$res = $this->select( __METHOD__ ); | |
- | |
$titles = array(); | |
$count = 0; | |
foreach ( $res as $row ) { | |
@@ -270,6 +276,14 @@ class ApiQueryListPages extends ApiQueryGeneratorBase { | |
'token' => array( | |
ApiBase::PARAM_TYPE => 'string', | |
), | |
+ 'sortby' => array( | |
+ ApiBase::PARAM_DFLT => 'position', | |
+ ApiBase::PARAM_TYPE => array( | |
+ 'position', | |
+ 'namespace', | |
+ ), | |
+ ApiBase::PARAM_HELP_MSG => 'gather-api-help-param-sortby', | |
+ ), | |
'dir' => array( | |
ApiBase::PARAM_DFLT => 'ascending', | |
ApiBase::PARAM_TYPE => array( | |
diff --git a/includes/models/Collection.php b/includes/models/Collection.php | |
index b1d5b24..a03eeb2 100644 | |
--- a/includes/models/Collection.php | |
+++ b/includes/models/Collection.php | |
@@ -159,6 +159,7 @@ class Collection extends CollectionBase implements IteratorAggregate { | |
'lstprop' => 'label|description|public|image|owner', | |
'prop' => 'pageimages|extracts', | |
'generator' => 'listpages', | |
+ 'glspsortby' => 'namespace', | |
'glspid' => $id, | |
'explaintext' => true, | |
'exintro' => true, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment