diff options
author | Roan Kattouw <catrope@users.mediawiki.org> | 2011-11-14 08:19:55 +0000 |
---|---|---|
committer | Roan Kattouw <catrope@users.mediawiki.org> | 2011-11-14 08:19:55 +0000 |
commit | 2563e19c39a2d7e28860e99b46b459734d0a247e (patch) | |
tree | f6d1c1969ec811c78f419cf00272d751dba34ab5 /includes/api/ApiQueryLangLinks.php | |
parent | 6ff2162ffee7a8e84ce1f102eac5cd0f5d1b5f94 (diff) | |
download | mediawikicore-2563e19c39a2d7e28860e99b46b459734d0a247e.tar.gz mediawikicore-2563e19c39a2d7e28860e99b46b459734d0a247e.zip |
(bug 26909) Add dir parameter for prop= API modules. Modified patch by Umherirrender
Notes
Notes:
http://mediawiki.org/wiki/Special:Code/MediaWiki/102947
Diffstat (limited to 'includes/api/ApiQueryLangLinks.php')
-rw-r--r-- | includes/api/ApiQueryLangLinks.php | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/includes/api/ApiQueryLangLinks.php b/includes/api/ApiQueryLangLinks.php index b0880bb5ef80..aafa2947e293 100644 --- a/includes/api/ApiQueryLangLinks.php +++ b/includes/api/ApiQueryLangLinks.php @@ -74,20 +74,27 @@ class ApiQueryLangLinks extends ApiQueryBase { ); } + $dir = ( $params['dir'] == 'descending' ? ' DESC' : '' ); if ( isset( $params['lang'] ) ) { $this->addWhereFld( 'll_lang', $params['lang'] ); if ( isset( $params['title'] ) ) { $this->addWhereFld( 'll_title', $params['title'] ); - $this->addOption( 'ORDER BY', 'll_from' ); + $this->addOption( 'ORDER BY', 'll_from' . $dir ); } else { - $this->addOption( 'ORDER BY', 'll_title, ll_from' ); + $this->addOption( 'ORDER BY', array( + 'll_title' . $dir, + 'll_from' . $dir + )); } } else { // Don't order by ll_from if it's constant in the WHERE clause if ( count( $this->getPageSet()->getGoodTitles() ) == 1 ) { - $this->addOption( 'ORDER BY', 'll_lang' ); + $this->addOption( 'ORDER BY', 'll_lang' . $dir ); } else { - $this->addOption( 'ORDER BY', 'll_from, ll_lang' ); + $this->addOption( 'ORDER BY', array( + 'll_from' . $dir, + 'll_lang' . $dir + )); } } @@ -135,6 +142,13 @@ class ApiQueryLangLinks extends ApiQueryBase { 'url' => false, 'lang' => null, 'title' => null, + 'dir' => array( + ApiBase::PARAM_DFLT => 'ascending', + ApiBase::PARAM_TYPE => array( + 'ascending', + 'descending' + ) + ), ); } @@ -145,6 +159,7 @@ class ApiQueryLangLinks extends ApiQueryBase { 'url' => 'Whether to get the full URL', 'lang' => 'Language code', 'title' => "Link to search for. Must be used with {$this->getModulePrefix()}lang", + 'dir' => 'The direction in which to list', ); } |