r66873 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r66872‎ | r66873 | r66874 >
Date:13:47, 25 May 2010
Author:reedy
Status:ok (Comments)
Tags:
Comment:
Part of bug 23254 - Add interwiki links to parse output
Modified paths:
  • /trunk/phase3/includes/api/ApiParse.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiParse.php
@@ -51,7 +51,7 @@
5252 }
5353 $prop = array_flip( $params['prop'] );
5454 $revid = false;
55 -
 55+
5656 if ( isset( $params['section'] ) ) {
5757 $this->section = $params['section'];
5858 } else {
@@ -211,6 +211,7 @@
212212 if ( isset( $prop['sections'] ) ) {
213213 $result_array['sections'] = $p_result->getSections();
214214 }
 215+
215216 if ( isset( $prop['displaytitle'] ) ) {
216217 $result_array['displaytitle'] = $p_result->getDisplayTitle() ?
217218 $p_result->getDisplayTitle() :
@@ -238,6 +239,10 @@
239240 $result_array['headhtml'] = array();
240241 $result->setContent( $result_array['headhtml'], $out->headElement( $userSkin ) );
241242 }
 243+
 244+ if ( isset( $prop['iwlinks'] ) ) {
 245+ $result_array['iwlinks'] = $this->formatIWLinks( $p_result->getInterwikiLinks() );
 246+ }
242247
243248 if ( !is_null( $oldid ) ) {
244249 $result_array['revid'] = intval( $oldid );
@@ -251,6 +256,7 @@
252257 'templates' => 'tl',
253258 'images' => 'img',
254259 'externallinks' => 'el',
 260+ 'iwlinks' => 'iw',
255261 'sections' => 's',
256262 'headitems' => 'hi',
257263 );
@@ -310,6 +316,19 @@
311317 return $result;
312318 }
313319
 320+ private function formatIWLinks( $iw ) {
 321+ $result = array();
 322+ foreach ( $iw as $prefix => $titles ) {
 323+ foreach ( $titles as $title => $id ) {
 324+ $entry = array();
 325+ $entry['prefix'] = $prefix;
 326+ $this->getResult()->setContent( $entry, Title::makeTitle( $ns, $title )->getFullText() );
 327+ $result[] = $entry;
 328+ }
 329+ }
 330+ return $result;
 331+ }
 332+
314333 private function formatHeadItems( $headItems ) {
315334 $result = array();
316335 foreach ( $headItems as $tag => $content ) {
@@ -366,7 +385,8 @@
367386 'revid',
368387 'displaytitle',
369388 'headitems',
370 - 'headhtml'
 389+ 'headhtml',
 390+ 'iwlinks',
371391 )
372392 ),
373393 'pst' => false,

Follow-up revisions

RevisionCommit summaryAuthorDate
r66887Followup to r66873...reedy18:37, 25 May 2010

Comments

#Comment by Reedy (talk | contribs)   15:39, 25 May 2010
$this->getResult()->setContent( $entry, Title::makeTitle( $ns, $title )->getFullText() );

$ns is undefined there...

#Comment by Catrope (talk | contribs)   19:29, 8 June 2010

Was this actually fixed ever?

#Comment by Reedy (talk | contribs)   19:31, 8 June 2010
#Comment by Catrope (talk | contribs)   19:32, 8 June 2010

I am clearly blind. Thanks.

Status & tagging log