r51571 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r51570‎ | r51571 | r51572 >
Date:18:20, 7 June 2009
Author:catrope
Status:ok (Comments)
Tags:
Comment:
API: (bug 18785) Add siprop=languages to meta=siteinfo
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/api/ApiQuerySiteinfo.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQuerySiteinfo.php
@@ -83,6 +83,9 @@
8484 case 'rightsinfo':
8585 $fit = $this->appendRightsInfo( $p );
8686 break;
 87+ case 'languages':
 88+ $fit = $this->appendLanguages( $p );
 89+ break;
8790 default :
8891 ApiBase :: dieDebug( __METHOD__, "Unknown prop=$p" );
8992 }
@@ -389,7 +392,19 @@
390393 return $this->getResult()->addValue( 'query', $property, $data );
391394 }
392395
 396+ public function appendLanguages( $property ) {
 397+ global $wgLanguageNames;
 398+ $data = array();
 399+ foreach( $wgLanguageNames as $code => $name ) {
 400+ $lang = array( 'code' => $code );
 401+ ApiResult::setContent( $lang, $name );
 402+ $data[] = $lang;
 403+ }
 404+ $this->getResult()->setIndexedTagName( $data, 'lang' );
 405+ return $this->getResult()->addValue( 'query', $property, $data );
 406+ }
393407
 408+
394409 public function getAllowedParams() {
395410 return array(
396411 'prop' => array(
@@ -408,6 +423,7 @@
409424 'extensions',
410425 'fileextensions',
411426 'rightsinfo',
 427+ 'languages',
412428 )
413429 ),
414430 'filteriw' => array(
@@ -436,6 +452,7 @@
437453 ' extensions - Returns extensions installed on the wiki',
438454 ' fileextensions - Returns list of file extensions allowed to be uploaded',
439455 ' rightsinfo - Returns wiki rights (license) information if available',
 456+ ' languages - Returns a list of languages MediaWiki supports',
440457 ),
441458 'filteriw' => 'Return only local or only nonlocal entries of the interwiki map',
442459 'showalldb' => 'List all database servers, not just the one lagging the most',
Index: trunk/phase3/RELEASE-NOTES
@@ -204,6 +204,7 @@
205205 * Make action=block respect $wgEnableUserEmail and $wgSysopEmailBans
206206 * Made deleting file description pages without files possible
207207 * (bug 18773) Add content flag to siprop=namespaces output
 208+* (bug 18785) Add siprop=languages to meta=siteinfo
208209
209210 === Languages updated in 1.16 ===
210211

Comments

#Comment by Tim Starling (talk | contribs)   03:27, 11 June 2009

Use Language::getLanguageNames(), that global variable only exists for backwards-compatibility.

#Comment by 😂 (talk | contribs)   04:49, 11 June 2009

Resolved in r51727

Status & tagging log