From 72c9341d1d28f981893b109a415cf8199417ca75 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Sun, 7 Jun 2009 18:20:01 +0000 Subject: [PATCH] API: (bug 18785) Add siprop=languages to meta=siteinfo --- RELEASE-NOTES | 1 + includes/api/ApiQuerySiteinfo.php | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 058fa2765a..ac9d9ff99e 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -204,6 +204,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * Make action=block respect $wgEnableUserEmail and $wgSysopEmailBans * Made deleting file description pages without files possible * (bug 18773) Add content flag to siprop=namespaces output +* (bug 18785) Add siprop=languages to meta=siteinfo === Languages updated in 1.16 === diff --git a/includes/api/ApiQuerySiteinfo.php b/includes/api/ApiQuerySiteinfo.php index d8ef4b3ef2..67764146c3 100644 --- a/includes/api/ApiQuerySiteinfo.php +++ b/includes/api/ApiQuerySiteinfo.php @@ -83,6 +83,9 @@ class ApiQuerySiteinfo extends ApiQueryBase { case 'rightsinfo': $fit = $this->appendRightsInfo( $p ); break; + case 'languages': + $fit = $this->appendLanguages( $p ); + break; default : ApiBase :: dieDebug( __METHOD__, "Unknown prop=$p" ); } @@ -389,6 +392,18 @@ class ApiQuerySiteinfo extends ApiQueryBase { return $this->getResult()->addValue( 'query', $property, $data ); } + public function appendLanguages( $property ) { + global $wgLanguageNames; + $data = array(); + foreach( $wgLanguageNames as $code => $name ) { + $lang = array( 'code' => $code ); + ApiResult::setContent( $lang, $name ); + $data[] = $lang; + } + $this->getResult()->setIndexedTagName( $data, 'lang' ); + return $this->getResult()->addValue( 'query', $property, $data ); + } + public function getAllowedParams() { return array( @@ -408,6 +423,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { 'extensions', 'fileextensions', 'rightsinfo', + 'languages', ) ), 'filteriw' => array( @@ -436,6 +452,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { ' extensions - Returns extensions installed on the wiki', ' fileextensions - Returns list of file extensions allowed to be uploaded', ' rightsinfo - Returns wiki rights (license) information if available', + ' languages - Returns a list of languages MediaWiki supports', ), 'filteriw' => 'Return only local or only nonlocal entries of the interwiki map', 'showalldb' => 'List all database servers, not just the one lagging the most', -- 2.20.1