API: (bug 18785) Add siprop=languages to meta=siteinfo
authorRoan Kattouw <catrope@users.mediawiki.org>
Sun, 7 Jun 2009 18:20:01 +0000 (18:20 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Sun, 7 Jun 2009 18:20:01 +0000 (18:20 +0000)
RELEASE-NOTES
includes/api/ApiQuerySiteinfo.php

index 058fa27..ac9d9ff 100644 (file)
@@ -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 ===
 
index d8ef4b3..6776414 100644 (file)
@@ -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',