diff options
Diffstat (limited to 'includes/api/ApiQueryIWLinks.php')
-rw-r--r-- | includes/api/ApiQueryIWLinks.php | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/includes/api/ApiQueryIWLinks.php b/includes/api/ApiQueryIWLinks.php index 13256ad8..30c7f5a8 100644 --- a/includes/api/ApiQueryIWLinks.php +++ b/includes/api/ApiQueryIWLinks.php @@ -5,7 +5,7 @@ * Created on May 14, 2010 * * Copyright © 2010 Sam Reed - * Copyright © 2006 Yuri Astrakhan <Firstname><Lastname>@gmail.com + * Copyright © 2006 Yuri Astrakhan "<Firstname><Lastname>@gmail.com" * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -62,38 +62,40 @@ class ApiQueryIWLinks extends ApiQueryBase { $this->dieUsage( 'Invalid continue param. You should pass the ' . 'original value returned by the previous query', '_badcontinue' ); } + $op = $params['dir'] == 'descending' ? '<' : '>'; + $db = $this->getDB(); $iwlfrom = intval( $cont[0] ); - $iwlprefix = $this->getDB()->strencode( $cont[1] ); - $iwltitle = $this->getDB()->strencode( $this->titleToKey( $cont[2] ) ); + $iwlprefix = $db->addQuotes( $cont[1] ); + $iwltitle = $db->addQuotes( $cont[2] ); $this->addWhere( - "iwl_from > $iwlfrom OR " . + "iwl_from $op $iwlfrom OR " . "(iwl_from = $iwlfrom AND " . - "(iwl_prefix > '$iwlprefix' OR " . - "(iwl_prefix = '$iwlprefix' AND " . - "iwl_title >= '$iwltitle')))" + "(iwl_prefix $op $iwlprefix OR " . + "(iwl_prefix = $iwlprefix AND " . + "iwl_title $op= $iwltitle)))" ); } - $dir = ( $params['dir'] == 'descending' ? ' DESC' : '' ); + $sort = ( $params['dir'] == 'descending' ? ' DESC' : '' ); if ( isset( $params['prefix'] ) ) { $this->addWhereFld( 'iwl_prefix', $params['prefix'] ); if ( isset( $params['title'] ) ) { $this->addWhereFld( 'iwl_title', $params['title'] ); - $this->addOption( 'ORDER BY', 'iwl_from' . $dir ); + $this->addOption( 'ORDER BY', 'iwl_from' . $sort ); } else { $this->addOption( 'ORDER BY', array( - 'iwl_title' . $dir, - 'iwl_from' . $dir + 'iwl_title' . $sort, + 'iwl_from' . $sort )); } } else { // Don't order by iwl_from if it's constant in the WHERE clause if ( count( $this->getPageSet()->getGoodTitles() ) == 1 ) { - $this->addOption( 'ORDER BY', 'iwl_prefix' . $dir ); + $this->addOption( 'ORDER BY', 'iwl_prefix' . $sort ); } else { $this->addOption( 'ORDER BY', array ( - 'iwl_from' . $dir, - 'iwl_prefix' . $dir + 'iwl_from' . $sort, + 'iwl_prefix' . $sort )); } } @@ -165,6 +167,19 @@ class ApiQueryIWLinks extends ApiQueryBase { ); } + public function getResultProperties() { + return array( + '' => array( + 'prefix' => 'string', + 'url' => array( + ApiBase::PROP_TYPE => 'string', + ApiBase::PROP_NULLABLE => true + ), + '*' => 'string' + ) + ); + } + public function getDescription() { return 'Returns all interwiki links from the given page(s)'; } |