From c1f9b1f7b1b77776192048005dcc66dcf3df2bfb Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 27 Dec 2014 15:41:37 +0100 Subject: Update to MediaWiki 1.24.1 --- includes/specials/SpecialVersion.php | 738 +++++++++++++++++++++++++++-------- 1 file changed, 565 insertions(+), 173 deletions(-) (limited to 'includes/specials/SpecialVersion.php') diff --git a/includes/specials/SpecialVersion.php b/includes/specials/SpecialVersion.php index 5ba785f5..cb3fc118 100644 --- a/includes/specials/SpecialVersion.php +++ b/includes/specials/SpecialVersion.php @@ -29,9 +29,13 @@ * @ingroup SpecialPage */ class SpecialVersion extends SpecialPage { - protected $firstExtOpened = false; + /** + * Stores the current rev id/SHA hash of MediaWiki core + */ + protected $coreId = ''; + protected static $extensionTypes = false; protected static $viewvcUrls = array( @@ -46,43 +50,95 @@ class SpecialVersion extends SpecialPage { /** * main() + * @param string|null $par */ public function execute( $par ) { - global $wgSpecialVersionShowHooks, $IP; + global $IP, $wgExtensionCredits; $this->setHeaders(); $this->outputHeader(); $out = $this->getOutput(); $out->allowClickjacking(); - if ( $par !== 'Credits' ) { - $text = - $this->getMediaWikiCredits() . - $this->softwareInformation() . - $this->getEntryPointInfo() . - $this->getExtensionCredits(); - if ( $wgSpecialVersionShowHooks ) { - $text .= $this->getWgHooks(); + // Explode the sub page information into useful bits + $parts = explode( '/', (string)$par ); + $extNode = null; + if ( isset( $parts[1] ) ) { + $extName = str_replace( '_', ' ', $parts[1] ); + // Find it! + foreach ( $wgExtensionCredits as $group => $extensions ) { + foreach ( $extensions as $ext ) { + if ( isset( $ext['name'] ) && ( $ext['name'] === $extName ) ) { + $extNode = &$ext; + break 2; + } + } } - - $out->addWikiText( $text ); - $out->addHTML( $this->IPInfo() ); - - if ( $this->getRequest()->getVal( 'easteregg' ) ) { - // TODO: put something interesting here + if ( !$extNode ) { + $out->setStatusCode( 404 ); } } else { - // Credits sub page - - // Header - $out->addHTML( wfMessage( 'version-credits-summary' )->parseAsBlock() ); + $extName = 'MediaWiki'; + } - $wikiText = file_get_contents( $IP . '/CREDITS' ); + // Now figure out what to do + switch ( strtolower( $parts[0] ) ) { + case 'credits': + $wikiText = '{{int:version-credits-not-found}}'; + if ( $extName === 'MediaWiki' ) { + $wikiText = file_get_contents( $IP . '/CREDITS' ); + } elseif ( ( $extNode !== null ) && isset( $extNode['path'] ) ) { + $file = $this->getExtAuthorsFileName( dirname( $extNode['path'] ) ); + if ( $file ) { + $wikiText = file_get_contents( $file ); + if ( substr( $file, -4 ) === '.txt' ) { + $wikiText = Html::element( 'pre', array(), $wikiText ); + } + } + } - // Take everything from the first section onwards, to remove the (not localized) header - $wikiText = substr( $wikiText, strpos( $wikiText, '==' ) ); + $out->setPageTitle( $this->msg( 'version-credits-title', $extName ) ); + $out->addWikiText( $wikiText ); + break; + + case 'license': + $wikiText = '{{int:version-license-not-found}}'; + if ( $extName === 'MediaWiki' ) { + $wikiText = file_get_contents( $IP . '/COPYING' ); + } elseif ( ( $extNode !== null ) && isset( $extNode['path'] ) ) { + $file = $this->getExtLicenseFileName( dirname( $extNode['path'] ) ); + if ( $file ) { + $wikiText = file_get_contents( $file ); + if ( !isset( $extNode['license-name'] ) ) { + // If the developer did not explicitly set license-name they probably + // are unaware that we're now sucking this file in and thus it's probably + // not wikitext friendly. + $wikiText = "
$wikiText
"; + } + } + } - $out->addWikiText( $wikiText ); + $out->setPageTitle( $this->msg( 'version-license-title', $extName ) ); + $out->addWikiText( $wikiText ); + break; + + default: + $out->addModules( 'mediawiki.special.version' ); + $out->addWikiText( + $this->getMediaWikiCredits() . + $this->softwareInformation() . + $this->getEntryPointInfo() + ); + $out->addHtml( + $this->getSkinCredits() . + $this->getExtensionCredits() . + $this->getParserTags() . + $this->getParserFunctionHooks() + ); + $out->addWikiText( $this->getWgHooks() ); + $out->addHTML( $this->IPInfo() ); + + break; } } @@ -92,7 +148,11 @@ class SpecialVersion extends SpecialPage { * @return string */ private static function getMediaWikiCredits() { - $ret = Xml::element( 'h2', array( 'id' => 'mw-version-license' ), wfMessage( 'version-license' )->text() ); + $ret = Xml::element( + 'h2', + array( 'id' => 'mw-version-license' ), + wfMessage( 'version-license' )->text() + ); // This text is always left-to-right. $ret .= '