X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fspecials%2FSpecialVersion.php;h=ec34db861133982f64a1ab9bf50b7f2594605b8d;hp=2632092cd91c9913784a281a014418e8ad92f823;hb=e73328601d51674e8fef89c3db12b30ceafd702f;hpb=6497541c9c089966ce7d3b0e0abd6b68192d30d8 diff --git a/includes/specials/SpecialVersion.php b/includes/specials/SpecialVersion.php index 2632092cd9..ec34db8611 100644 --- a/includes/specials/SpecialVersion.php +++ b/includes/specials/SpecialVersion.php @@ -23,6 +23,8 @@ * @ingroup SpecialPage */ +use MediaWiki\MediaWikiServices; + /** * Give information about the version of MediaWiki, PHP, the DB and extensions * @@ -47,7 +49,9 @@ class SpecialVersion extends SpecialPage { * @param string|null $par */ public function execute( $par ) { - global $IP, $wgExtensionCredits; + global $IP; + $config = $this->getConfig(); + $extensionCredits = $config->get( 'ExtensionCredits' ); $this->setHeaders(); $this->outputHeader(); @@ -60,7 +64,7 @@ class SpecialVersion extends SpecialPage { if ( isset( $parts[1] ) ) { $extName = str_replace( '_', ' ', $parts[1] ); // Find it! - foreach ( $wgExtensionCredits as $group => $extensions ) { + foreach ( $extensionCredits as $group => $extensions ) { foreach ( $extensions as $ext ) { if ( isset( $ext['name'] ) && ( $ext['name'] === $extName ) ) { $extNode = &$ext; @@ -215,23 +219,26 @@ class SpecialVersion extends SpecialPage { } /** - * Returns wiki text showing the third party software versions (apache, php, mysql). + * @since 1.34 * - * @return string + * @return array */ - public static function softwareInformation() { + public static function getSoftwareInformation() { $dbr = wfGetDB( DB_REPLICA ); // Put the software in an array of form 'name' => 'version'. All messages should // be loaded here, so feel free to use wfMessage in the 'name'. Raw HTML or // wikimarkup can be used. - $software = []; - $software['[https://www.mediawiki.org/ MediaWiki]'] = self::getVersionLinked(); + $software = [ + '[https://www.mediawiki.org/ MediaWiki]' => self::getVersionLinked() + ]; + if ( wfIsHHVM() ) { $software['[https://hhvm.com/ HHVM]'] = HHVM_VERSION . " (" . PHP_SAPI . ")"; } else { $software['[https://php.net/ PHP]'] = PHP_VERSION . " (" . PHP_SAPI . ")"; } + $software[$dbr->getSoftwareLink()] = $dbr->getServerInfo(); if ( defined( 'INTL_ICU_VERSION' ) ) { @@ -241,18 +248,27 @@ class SpecialVersion extends SpecialPage { // Allow a hook to add/remove items. Hooks::run( 'SoftwareInfo', [ &$software ] ); + return $software; + } + + /** + * Returns HTML showing the third party software versions (apache, php, mysql). + * + * @return string HTML table + */ + public static function softwareInformation() { $out = Xml::element( 'h2', [ 'id' => 'mw-version-software' ], wfMessage( 'version-software' )->text() ) . - Xml::openElement( 'table', [ 'class' => 'wikitable plainlinks', 'id' => 'sv-software' ] ) . - " - " . wfMessage( 'version-software-product' )->text() . " - " . wfMessage( 'version-software-version' )->text() . " - \n"; + Xml::openElement( 'table', [ 'class' => 'wikitable plainlinks', 'id' => 'sv-software' ] ) . + " + " . wfMessage( 'version-software-product' )->text() . " + " . wfMessage( 'version-software-version' )->text() . " + \n"; - foreach ( $software as $name => $version ) { + foreach ( self::getSoftwareInformation() as $name => $version ) { $out .= " " . $name . " " . $version . " @@ -406,12 +422,13 @@ class SpecialVersion extends SpecialPage { * @return string Wikitext */ public function getExtensionCredits() { - global $wgExtensionCredits; + $config = $this->getConfig(); + $extensionCredits = $config->get( 'ExtensionCredits' ); if ( - count( $wgExtensionCredits ) === 0 || + count( $extensionCredits ) === 0 || // Skins are displayed separately, see getSkinCredits() - ( count( $wgExtensionCredits ) === 1 && isset( $wgExtensionCredits['skin'] ) ) + ( count( $extensionCredits ) === 1 && isset( $extensionCredits['skin'] ) ) ) { return ''; } @@ -426,14 +443,14 @@ class SpecialVersion extends SpecialPage { Xml::openElement( 'table', [ 'class' => 'wikitable plainlinks', 'id' => 'sv-ext' ] ); // Make sure the 'other' type is set to an array. - if ( !array_key_exists( 'other', $wgExtensionCredits ) ) { - $wgExtensionCredits['other'] = []; + if ( !array_key_exists( 'other', $extensionCredits ) ) { + $extensionCredits['other'] = []; } // Find all extensions that do not have a valid type and give them the type 'other'. - foreach ( $wgExtensionCredits as $type => $extensions ) { + foreach ( $extensionCredits as $type => $extensions ) { if ( !array_key_exists( $type, $extensionTypes ) ) { - $wgExtensionCredits['other'] = array_merge( $wgExtensionCredits['other'], $extensions ); + $extensionCredits['other'] = array_merge( $extensionCredits['other'], $extensions ); } } @@ -555,9 +572,7 @@ class SpecialVersion extends SpecialPage { * @return string HTML output */ protected function getParserTags() { - global $wgParser; - - $tags = $wgParser->getTags(); + $tags = MediaWikiServices::getInstance()->getParser()->getTags(); if ( count( $tags ) ) { $out = Html::rawElement( @@ -599,9 +614,7 @@ class SpecialVersion extends SpecialPage { * @return string HTML output */ protected function getParserFunctionHooks() { - global $wgParser; - - $fhooks = $wgParser->getFunctionHooks(); + $fhooks = MediaWikiServices::getInstance()->getParser()->getFunctionHooks(); if ( count( $fhooks ) ) { $out = Html::rawElement( 'h2', @@ -635,16 +648,17 @@ class SpecialVersion extends SpecialPage { * @return string */ protected function getExtensionCategory( $type, $message ) { - global $wgExtensionCredits; + $config = $this->getConfig(); + $extensionCredits = $config->get( 'ExtensionCredits' ); $out = ''; - if ( array_key_exists( $type, $wgExtensionCredits ) && count( $wgExtensionCredits[$type] ) > 0 ) { + if ( array_key_exists( $type, $extensionCredits ) && count( $extensionCredits[$type] ) > 0 ) { $out .= $this->openExtType( $message, 'credits-' . $type ); - usort( $wgExtensionCredits[$type], [ $this, 'compare' ] ); + usort( $extensionCredits[$type], [ $this, 'compare' ] ); - foreach ( $wgExtensionCredits[$type] as $extension ) { + foreach ( $extensionCredits[$type] as $extension ) { $out .= $this->getCreditsForExtension( $type, $extension ); } } @@ -810,7 +824,7 @@ class SpecialVersion extends SpecialPage { } // ... and generate the description; which can be a parameterized l10n message - // in the form array( , , ... ) or just a straight + // in the form [ , , ... ] or just a straight // up string if ( isset( $extension['descriptionmsg'] ) ) { // Localized description of extension @@ -884,9 +898,9 @@ class SpecialVersion extends SpecialPage { $ret[] = Html::closeElement( 'table' ); return implode( "\n", $ret ); - } else { - return ''; } + + return ''; } private function openExtType( $text = null, $name = null ) { @@ -1134,10 +1148,11 @@ class SpecialVersion extends SpecialPage { * @return string Wikitext */ public function getEntryPointInfo() { - global $wgArticlePath, $wgScriptPath; - $scriptPath = $wgScriptPath ?: "/"; + $config = $this->getConfig(); + $scriptPath = $config->get( 'ScriptPath' ) ?: '/'; + $entryPoints = [ - 'version-entrypoints-articlepath' => $wgArticlePath, + 'version-entrypoints-articlepath' => $config->get( 'ArticlePath' ), 'version-entrypoints-scriptpath' => $scriptPath, 'version-entrypoints-index-php' => wfScript( 'index' ), 'version-entrypoints-api-php' => wfScript( 'api' ),