Merge "(bug 32297) Use symbolic names, not offsets for a default timezone."
[lhc/web/wiklou.git] / includes / api / ApiQuerySiteinfo.php
index 1f93416..38e37c0 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.
  *
@@ -43,6 +38,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
        public function execute() {
                $params = $this->extractRequestParams();
                $done = array();
+               $fit = false;
                foreach ( $params['prop'] as $p ) {
                        switch ( $p ) {
                                case 'general':
@@ -117,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();
@@ -125,9 +121,14 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                $data['dbtype'] = $GLOBALS['wgDBtype'];
                $data['dbversion'] = $this->getDB()->getServerVersion();
 
-               $svn = SpecialVersion::getSvnRevision( $GLOBALS['IP'] );
-               if ( $svn ) {
-                       $data['rev'] = $svn;
+               $git = SpecialVersion::getGitHeadSha1( $GLOBALS['IP'] );
+               if ( $git ) {
+                       $data['git-hash'] = $git;
+               } else {
+                       $svn = SpecialVersion::getSvnRevision( $GLOBALS['IP'] );
+                       if ( $svn ) {
+                               $data['rev'] = $svn;
+                       }
                }
 
                // 'case-insensitive' option is reserved for future
@@ -139,15 +140,22 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                $data['rights'] = $GLOBALS['wgRightsText'];
                $data['lang'] = $GLOBALS['wgLanguageCode'];
 
-               $fallbackLang = $wgContLang->getFallbackLanguageCode();
-               $fallbackLangArray = array();
-               while( $fallbackLang ) {
-                       $fallbackLangArray[] = array( 'code' => $fallbackLang );
-                       $fallbackLang = Language::getFallbackFor( $fallbackLang );
+               $fallbacks = array();
+               foreach( $wgContLang->getFallbackLanguages() as $code ) {
+                       $fallbacks[] = array( 'code' => $code );
                }
-               $data['fallback'] = $fallbackLangArray;
+               $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'] = '';
                }
@@ -183,6 +191,8 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                        $data['misermode'] = '';
                }
 
+               $data['maxuploadsize'] = UploadBase::getMaxUploadSize();
+
                wfRunHooks( 'APIQuerySiteInfoGeneralInfo', array( $this, &$data ) );
 
                return $this->getResult()->addValue( 'query', $property, $data );
@@ -210,6 +220,10 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                        if ( MWNamespace::isContent( $ns ) ) {
                                $data[$ns]['content'] = '';
                        }
+
+                       if ( MWNamespace::isNonincludable( $ns ) ) {
+                               $data[$ns]['nonincludable'] = '';
+                       }
                }
 
                $this->getResult()->setIndexedTagName( $data, 'ns' );
@@ -276,13 +290,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();
@@ -298,7 +307,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'];
                        }
@@ -466,7 +475,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();
@@ -482,13 +491,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();
 
@@ -589,7 +593,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                        ),
                        'showalldb' => false,
                        'numberingroup' => false,
-                       'inlanguagecode ' => null,
+                       'inlanguagecode' => null,
                );
        }
 
@@ -619,7 +623,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)',
                );
        }
 
@@ -642,7 +646,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() {