From b5b6f83a7ef1a287e696e21f651c0bd7f5b2f7c0 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Sun, 5 Jun 2011 22:51:58 +0000 Subject: [PATCH] * (bug 29237) add interwiki target url attribute to api/query/interwiki --- RELEASE-NOTES-1.19 | 1 + includes/api/ApiQuery.php | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/RELEASE-NOTES-1.19 b/RELEASE-NOTES-1.19 index e7279cdab1..d5417fce73 100644 --- a/RELEASE-NOTES-1.19 +++ b/RELEASE-NOTES-1.19 @@ -101,6 +101,7 @@ production. * (bug 28002) Internal error in ApiFormatRaw::getMimeType * (bug 26597) Allow toggling of persistent cookies ("remember me") in API action=login +* (bug 29237) add interwiki target url attribute to api/query/interwiki === Languages updated in 1.19 === diff --git a/includes/api/ApiQuery.php b/includes/api/ApiQuery.php index ac679ae552..f8b8bfc1a8 100644 --- a/includes/api/ApiQuery.php +++ b/includes/api/ApiQuery.php @@ -49,7 +49,7 @@ class ApiQuery extends ApiBase { */ private $mPageSet; - private $params, $redirects, $convertTitles; + private $params, $redirects, $convertTitles, $iwUrl; private $mQueryPropModules = array( 'info' => 'ApiQueryInfo', @@ -232,6 +232,7 @@ class ApiQuery extends ApiBase { $this->params = $this->extractRequestParams(); $this->redirects = $this->params['redirects']; $this->convertTitles = $this->params['converttitles']; + $this->iwUrl = $this->params['wurl']; // Create PageSet $this->mPageSet = new ApiPageSet( $this, $this->redirects, $this->convertTitles ); @@ -367,10 +368,15 @@ class ApiQuery extends ApiBase { // Interwiki titles $intrwValues = array(); foreach ( $pageSet->getInterwikiTitles() as $rawTitleStr => $interwikiStr ) { - $intrwValues[] = array( + $item = array( 'title' => $rawTitleStr, - 'iw' => $interwikiStr + 'iw' => $interwikiStr, ); + if ( $this->iwUrl ) { + $title = Title::newFromText( "{$interwikiStr}:{$rawTitleStr}" ); + $item['url'] = $title->getFullURL(); + } + $intrwValues[] = $item; } if ( count( $intrwValues ) ) { @@ -586,6 +592,7 @@ class ApiQuery extends ApiBase { 'indexpageids' => false, 'export' => false, 'exportnowrap' => false, + 'iwurl' => false, ); } @@ -672,6 +679,7 @@ class ApiQuery extends ApiBase { 'indexpageids' => 'Include an additional pageids section listing all returned page IDs', 'export' => 'Export the current revisions of all given or generated pages', 'exportnowrap' => 'Return the export XML without wrapping it in an XML result (same format as Special:Export). Can only be used with export', + 'iwurl' => 'Whether to get the full URL if the title is an interwiki link', ); } -- 2.20.1