http://www.mediawiki.org/wiki/Special:Code/MediaWiki/89539

Revision: 89539
Author:   reedy
Date:     2011-06-05 22:51:58 +0000 (Sun, 05 Jun 2011)
Log Message:
-----------
* (bug 29237) add interwiki target url attribute to api/query/interwiki

Modified Paths:
--------------
    trunk/phase3/RELEASE-NOTES-1.19
    trunk/phase3/includes/api/ApiQuery.php

Modified: trunk/phase3/RELEASE-NOTES-1.19
===================================================================
--- trunk/phase3/RELEASE-NOTES-1.19     2011-06-05 21:56:27 UTC (rev 89538)
+++ trunk/phase3/RELEASE-NOTES-1.19     2011-06-05 22:51:58 UTC (rev 89539)
@@ -101,6 +101,7 @@
 * (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 ===
 

Modified: trunk/phase3/includes/api/ApiQuery.php
===================================================================
--- trunk/phase3/includes/api/ApiQuery.php      2011-06-05 21:56:27 UTC (rev 
89538)
+++ trunk/phase3/includes/api/ApiQuery.php      2011-06-05 22:51:58 UTC (rev 
89539)
@@ -49,7 +49,7 @@
         */
        private $mPageSet;
 
-       private $params, $redirects, $convertTitles;
+       private $params, $redirects, $convertTitles, $iwUrl;
 
        private $mQueryPropModules = array(
                'info' => 'ApiQueryInfo',
@@ -232,6 +232,7 @@
                $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 @@
                // 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 @@
                        'indexpageids' => false,
                        'export' => false,
                        'exportnowrap' => false,
+                       'iwurl' => false,
                );
        }
 
@@ -672,6 +679,7 @@
                        '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',
                );
        }
 


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to