From: Sam Reed Date: Thu, 22 Jul 2010 21:03:36 +0000 (+0000) Subject: * (bug 24485) Make iwbacklinks a generator, display iwprefix and iwtitle optional X-Git-Tag: 1.31.0-rc.0~36006 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dmes_infos.php?a=commitdiff_plain;h=5149cff642b8663b38d9c8af1019989e84c6b5d1;p=lhc%2Fweb%2Fwiklou.git * (bug 24485) Make iwbacklinks a generator, display iwprefix and iwtitle optional Second part, make ApiQueryIWBacklinks a Generator --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index eb8213470a..729dad4ffd 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -282,7 +282,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 24296) Added converttitles parameter to convert titles to their canonical language variant. * Fixed "link" parameter in image links with "thumb" parameter. -* (bug 23936) - Add "displaytitle" to query/info API +* (bug 23936) Add "displaytitle" to query/info API +* (bug 24485) Make iwbacklinks a generator, display iwprefix and iwtitle optional === Languages updated in 1.17 === diff --git a/includes/api/ApiQueryIWBacklinks.php b/includes/api/ApiQueryIWBacklinks.php index 7e539fc95a..e593f4e15a 100644 --- a/includes/api/ApiQueryIWBacklinks.php +++ b/includes/api/ApiQueryIWBacklinks.php @@ -33,13 +33,21 @@ if ( !defined( 'MEDIAWIKI' ) ) { * This gives links pointing to the given interwiki * @ingroup API */ -class ApiQueryIWBacklinks extends ApiQueryBase { +class ApiQueryIWBacklinks extends ApiQueryGeneratorBase { public function __construct( $query, $moduleName ) { parent::__construct( $query, $moduleName, 'iwbl' ); } - + public function execute() { + $this->run(); + } + + public function executeGenerator( $resultPageSet ) { + $this->run( $resultPageSet ); + } + + public function run( $resultPageSet = null ) { $params = $this->extractRequestParams(); if ( isset( $params['title'] ) && !isset( $params['prefix'] ) ) { @@ -91,6 +99,8 @@ class ApiQueryIWBacklinks extends ApiQueryBase { $db = $this->getDB(); $res = $this->select( __METHOD__ ); + + $pages = array(); $count = 0; $result = $this->getResult(); @@ -102,35 +112,40 @@ class ApiQueryIWBacklinks extends ApiQueryBase { break; } - $entry = array(); - - $entry['pageid'] = intval( $row->page_id ); - $entry['ns'] = $row->page_namespace; - $entry['title'] = $row->page_title; - - if ( $row->page_is_redirect ) { - $entry['redirect'] = ''; - } - - if ( $iwprefix ) { - $entry['iwprefix'] = $row->iwl_prefix; - } - - if ( $iwtitle ) { - $entry['iwtitle'] = $row->iwl_title; - } - - $fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $entry ); - if ( !$fit ) { - $this->setContinueEnumParameter( 'continue', "{$row->iwl_prefix}|{$row->iwl_title}|{$row->iwl_from}" ); - break; + if ( !is_null( $resultPageSet ) ) { + $pages[] = Title::makeTitle( $row->page_namespace, $row->page_title )->getPrefixedText(); + } else { + $entry = array(); + + $entry['pageid'] = intval( $row->page_id ); + $entry['ns'] = $row->page_namespace; + $entry['title'] = $row->page_title; + + if ( $row->page_is_redirect ) { + $entry['redirect'] = ''; + } + + if ( $iwprefix ) { + $entry['iwprefix'] = $row->iwl_prefix; + } + + if ( $iwtitle ) { + $entry['iwtitle'] = $row->iwl_title; + } + + $fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $entry ); + if ( !$fit ) { + $this->setContinueEnumParameter( 'continue', "{$row->iwl_prefix}|{$row->iwl_title}|{$row->iwl_from}" ); + break; + } } } - - $this->getResult()->setIndexedTagName_internal( - array( 'query', $this->getModuleName() ), - 'iw' - ); + + if ( is_null( $resultPageSet ) ) { + $result->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'iw' ); + } else { + $resultPageSet->populateFromTitles( $pages ); + } } public function getAllowedParams() { @@ -188,7 +203,7 @@ class ApiQueryIWBacklinks extends ApiQueryBase { protected function getExamples() { return array( 'api.php?action=query&list=iwbacklinks&iwbltitle=Test&iwblprefix=wikibooks', - //'api.php?action=query&generator=iwbacklinks&giwbltitle=Test&iwblprefix=wikibooks&prop=info' + 'api.php?action=query&generator=iwbacklinks&giwbltitle=Test&iwblprefix=wikibooks&prop=info' ); }