diff options
Diffstat (limited to 'includes/api/ApiQuerySiteinfo.php')
-rw-r--r-- | includes/api/ApiQuerySiteinfo.php | 57 |
1 files changed, 47 insertions, 10 deletions
diff --git a/includes/api/ApiQuerySiteinfo.php b/includes/api/ApiQuerySiteinfo.php index ec503d64..810e1d6b 100644 --- a/includes/api/ApiQuerySiteinfo.php +++ b/includes/api/ApiQuerySiteinfo.php @@ -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(); @@ -120,10 +125,31 @@ class ApiQuerySiteinfo extends ApiQueryBase { $data['sitename'] = $GLOBALS['wgSitename']; $data['generator'] = "MediaWiki {$GLOBALS['wgVersion']}"; $data['phpversion'] = phpversion(); - $data['phpsapi'] = php_sapi_name(); + $data['phpsapi'] = PHP_SAPI; $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; @@ -227,6 +253,11 @@ class ApiQuerySiteinfo extends ApiQueryBase { if ( MWNamespace::isNonincludable( $ns ) ) { $data[$ns]['nonincludable'] = ''; } + + $contentmodel = MWNamespace::getNamespaceContentModel( $ns ); + if ( $contentmodel ) { + $data[$ns]['defaultcontentmodel'] = $contentmodel; + } } $this->getResult()->setIndexedTagName( $data, 'ns' ); @@ -345,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 ) @@ -457,7 +488,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { } if ( isset( $ext['author'] ) ) { $ret['author'] = is_array( $ext['author'] ) ? - implode( ', ', $ext['author' ] ) : $ext['author']; + implode( ', ', $ext['author'] ) : $ext['author']; } if ( isset( $ext['url'] ) ) { $ret['url'] = $ext['url']; @@ -525,7 +556,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { public function appendExtensionTags( $property ) { global $wgParser; $wgParser->firstCallInit(); - $tags = array_map( array( $this, 'formatParserTags'), $wgParser->getTags() ); + $tags = array_map( array( $this, 'formatParserTags' ), $wgParser->getTags() ); $this->getResult()->setIndexedTagName( $tags, 't' ); return $this->getResult()->addValue( 'query', $property, $tags ); } @@ -544,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}>"; } @@ -554,7 +593,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { ksort( $myWgHooks ); $data = array(); - foreach ( $myWgHooks as $hook => $hooks ) { + foreach ( $myWgHooks as $hook => $hooks ) { $arr = array( 'name' => $hook, 'subscribers' => array_map( array( 'SpecialVersion', 'arrayToString' ), $hooks ), @@ -596,6 +635,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { 'functionhooks', 'showhooks', 'variables', + 'protocols', ) ), 'filteriw' => array( @@ -633,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', @@ -662,8 +703,4 @@ class ApiQuerySiteinfo extends ApiQueryBase { public function getHelpUrls() { return 'https://www.mediawiki.org/wiki/API:Meta#siteinfo_.2F_si'; } - - public function getVersion() { - return __CLASS__ . ': $Id$'; - } } |