From 9fef1a5f194b7904404673ccdc3d0320a63ff9e5 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Tue, 25 May 2010 13:33:24 +0000 Subject: [PATCH] bug 23524 - &url for ApiQueryIWLinks to expand full URL --- includes/api/ApiQueryIWLinks.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/includes/api/ApiQueryIWLinks.php b/includes/api/ApiQueryIWLinks.php index 84b3185a8a..da664f3341 100644 --- a/includes/api/ApiQueryIWLinks.php +++ b/includes/api/ApiQueryIWLinks.php @@ -54,6 +54,14 @@ class ApiQueryIWLinks extends ApiQueryBase { $this->addTables( 'iwlinks' ); $this->addWhereFld( 'iwl_from', array_keys( $this->getPageSet()->getGoodTitles() ) ); + + $url = !is_null( $params['url'] ); + if ( $url ) { + $this->addTables( 'interwiki' ); + $this->addJoinConds( array( 'interwiki' => array( 'INNER JOIN', 'iw_prefix=iwl_prefix' ) ) ); + $this->addFields( 'iw_url' ); + } + if ( !is_null( $params['continue'] ) ) { $cont = explode( '|', $params['continue'] ); if ( count( $cont ) != 3 ) { @@ -91,6 +99,12 @@ class ApiQueryIWLinks extends ApiQueryBase { break; } $entry = array( 'prefix' => $row->iwl_prefix ); + + if ( $url ) { + $rowUrl = str_replace( '$1', $row->iwl_title, $row->iw_url ); + $entry = array_merge( $entry, array( 'url' => $rowUrl ) ); + } + ApiResult::setContent( $entry, $row->iwl_title ); $fit = $this->addPageSubItem( $row->iwl_from, $entry ); if ( !$fit ) { @@ -103,6 +117,7 @@ class ApiQueryIWLinks extends ApiQueryBase { public function getAllowedParams() { return array( + 'url' => null, 'limit' => array( ApiBase::PARAM_DFLT => 10, ApiBase::PARAM_TYPE => 'limit', @@ -116,6 +131,7 @@ class ApiQueryIWLinks extends ApiQueryBase { public function getParamDescription() { return array( + 'url' => 'Whether to get the full URL', 'limit' => 'How many interwiki links to return', 'continue' => 'When more results are available, use this to continue', ); -- 2.20.1