Merge "Fix Ifb93e49b"
[lhc/web/wiklou.git] / includes / api / ApiQuerySiteinfo.php
index 3ed0113..810e1d6 100644 (file)
@@ -96,6 +96,9 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                                case 'variables':
                                        $fit = $this->appendVariables( $p );
                                        break;
+                               case 'protocols':
+                                       $fit = $this->appendProtocols( $p );
+                                       break;
                                default:
                                        ApiBase::dieDebug( __METHOD__, "Unknown prop=$p" );
                        }
@@ -111,7 +114,9 @@ class ApiQuerySiteinfo extends ApiQueryBase {
        }
 
        protected function appendGeneralInfo( $property ) {
-               global $wgContLang;
+               global $wgContLang,
+                       $wgDisableLangConversion,
+                       $wgDisableTitleConversion;
 
                $data = array();
                $mainPage = Title::newMainPage();
@@ -124,6 +129,27 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                $data['dbtype'] = $GLOBALS['wgDBtype'];
                $data['dbversion'] = $this->getDB()->getServerVersion();
 
+               if ( !$wgDisableLangConversion ) {
+                       $data['langconversion'] = '';
+               }
+
+               if ( !$wgDisableTitleConversion ) {
+                       $data['titleconversion'] = '';
+               }
+
+               if ( $wgContLang->linkPrefixExtension() ) {
+                       $data['linkprefix'] = wfMessage( 'linkprefix' )->inContentLanguage()->text();
+               } else {
+                       $data['linkprefix'] = '';
+               }
+
+               $linktrail = $wgContLang->linkTrail();
+               if ( $linktrail ) {
+                       $data['linktrail'] = $linktrail;
+               } else {
+                       $data['linktrail'] = '';
+               }
+
                $git = SpecialVersion::getGitHeadSha1( $GLOBALS['IP'] );
                if ( $git ) {
                        $data['git-hash'] = $git;
@@ -350,7 +376,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                                );
                        }
                } else {
-                       list( $host, $lag, $index ) = $lb->getMaxLag();
+                       list( , $lag, $index ) = $lb->getMaxLag();
                        $data[] = array(
                                'host' => $wgShowHostnames
                                                ? $lb->getServerName( $index )
@@ -549,6 +575,14 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                return $this->getResult()->addValue( 'query', $property, $variables );
        }
 
+       public function appendProtocols( $property ) {
+               global $wgUrlProtocols;
+               // Make a copy of the global so we don't try to set the _element key of it - bug 45130
+               $protocols = array_values( $wgUrlProtocols );
+               $this->getResult()->setIndexedTagName( $protocols, 'p' );
+               return $this->getResult()->addValue( 'query', $property, $protocols );
+       }
+
        private function formatParserTags( $item ) {
                return "<{$item}>";
        }
@@ -601,6 +635,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                                        'functionhooks',
                                        'showhooks',
                                        'variables',
+                                       'protocols',
                                )
                        ),
                        'filteriw' => array(
@@ -638,6 +673,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                                ' functionhooks         - Returns a list of parser function hooks',
                                ' showhooks             - Returns a list of all subscribed hooks (contents of $wgHooks)',
                                ' variables             - Returns a list of variable IDs',
+                               ' protocols             - Returns a list of protocols that are allowed in external links.',
                        ),
                        'filteriw' =>  'Return only local or only nonlocal entries of the interwiki map',
                        'showalldb' => 'List all database servers, not just the one lagging the most',