Merge "Deprecate no longer used Skin::getCommonStylePath."
[lhc/web/wiklou.git] / includes / api / ApiQuerySiteinfo.php
index 3c61824..e7102e0 100644 (file)
  * @file
  */
 
-if ( !defined( 'MEDIAWIKI' ) ) {
-       // Eclipse helper - will be ignored in production
-       require_once( 'ApiQueryBase.php' );
-}
-
 /**
  * A query action to return meta information about the wiki site.
  *
@@ -118,7 +113,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                $data = array();
                $mainPage = Title::newMainPage();
                $data['mainpage'] = $mainPage->getPrefixedText();
-               $data['base'] = wfExpandUrl( $mainPage->getFullUrl() );
+               $data['base'] = wfExpandUrl( $mainPage->getFullUrl(), PROTO_CURRENT );
                $data['sitename'] = $GLOBALS['wgSitename'];
                $data['generator'] = "MediaWiki {$GLOBALS['wgVersion']}";
                $data['phpversion'] = phpversion();
@@ -147,6 +142,15 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                $data['fallback'] = $fallbacks;
                $this->getResult()->setIndexedTagName( $data['fallback'], 'lang' );
 
+               if( $wgContLang->hasVariants() ) {
+                       $variants = array();
+                       foreach( $wgContLang->getVariants() as $code ) {
+                               $variants[] = array( 'code' => $code );
+                       }
+                       $data['variants'] = $variants;
+                       $this->getResult()->setIndexedTagName( $data['variants'], 'lang' );
+               }
+
                if ( $wgContLang->isRTL() ) {
                        $data['rtl'] = '';
                }
@@ -182,6 +186,8 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                        $data['misermode'] = '';
                }
 
+               $data['maxuploadsize'] = UploadBase::getMaxUploadSize();
+
                wfRunHooks( 'APIQuerySiteInfoGeneralInfo', array( $this, &$data ) );
 
                return $this->getResult()->addValue( 'query', $property, $data );
@@ -209,6 +215,10 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                        if ( MWNamespace::isContent( $ns ) ) {
                                $data[$ns]['content'] = '';
                        }
+
+                       if ( MWNamespace::isNonincludable( $ns ) ) {
+                               $data[$ns]['nonincludable'] = '';
+                       }
                }
 
                $this->getResult()->setIndexedTagName( $data, 'ns' );
@@ -275,13 +285,8 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                }
 
                $params = $this->extractRequestParams();
-               $langCode = isset( $params['inlanguagecode '] ) ? $params['inlanguagecode '] : '';
-
-               if( $langCode ) {
-                       $langNames = Language::getTranslatedLanguageNames( $langCode );
-               } else {
-                       $langNames = Language::getLanguageNames();
-               }
+               $langCode = isset( $params['inlanguagecode'] ) ? $params['inlanguagecode'] : '';
+               $langNames = Language::fetchLanguageNames( $langCode );
 
                $getPrefixes = Interwiki::getAllPrefixes( $local );
                $data = array();
@@ -297,7 +302,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                        if ( isset( $langNames[$prefix] ) ) {
                                $val['language'] = $langNames[$prefix];
                        }
-                       $val['url'] = wfExpandUrl( $row['iw_url'] );
+                       $val['url'] = wfExpandUrl( $row['iw_url'], PROTO_CURRENT );
                        if( isset( $row['iw_wikiid'] ) ) {
                                $val['wikiid'] = $row['iw_wikiid'];
                        }
@@ -465,7 +470,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
        protected function appendRightsInfo( $property ) {
                global $wgRightsPage, $wgRightsUrl, $wgRightsText;
                $title = Title::newFromText( $wgRightsPage );
-               $url = $title ? wfExpandUrl( $title->getFullURL() ) : $wgRightsUrl;
+               $url = $title ? wfExpandUrl( $title->getFullURL(), PROTO_CURRENT ) : $wgRightsUrl;
                $text = $wgRightsText;
                if ( !$text && $title ) {
                        $text = $title->getPrefixedText();
@@ -481,13 +486,8 @@ class ApiQuerySiteinfo extends ApiQueryBase {
 
        public function appendLanguages( $property ) {
                $params = $this->extractRequestParams();
-               $langCode = isset( $params['inlanguagecode '] ) ? $params['inlanguagecode '] : '';
-
-               if( $langCode ) {
-                       $langNames = Language::getTranslatedLanguageNames( $langCode );
-               } else {
-                       $langNames = Language::getLanguageNames();
-               }
+               $langCode = isset( $params['inlanguagecode'] ) ? $params['inlanguagecode'] : '';
+               $langNames = Language::fetchLanguageNames( $langCode );
 
                $data = array();
 
@@ -588,7 +588,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                        ),
                        'showalldb' => false,
                        'numberingroup' => false,
-                       'inlanguagecode ' => null,
+                       'inlanguagecode' => null,
                );
        }
 
@@ -618,7 +618,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                        'filteriw' =>  'Return only local or only nonlocal entries of the interwiki map',
                        'showalldb' => 'List all database servers, not just the one lagging the most',
                        'numberingroup' => 'Lists the number of users in user groups',
-                       'inlanguagecode ' => 'Language code for localised language names (best effort, use CLDR extension)',
+                       'inlanguagecode' => 'Language code for localised language names (best effort, use CLDR extension)',
                );
        }
 
@@ -641,7 +641,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
        }
 
        public function getHelpUrls() {
-               return 'http://www.mediawiki.org/wiki/API:Meta#siteinfo_.2F_si';
+               return 'https://www.mediawiki.org/wiki/API:Meta#siteinfo_.2F_si';
        }
 
        public function getVersion() {