From 4ac9fa081a7c045f6a9f1cfc529d82423f485b2e Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 8 Dec 2013 09:55:49 +0100 Subject: Update to MediaWiki 1.22.0 --- includes/specials/SpecialVersion.php | 203 ++++++++++------------------------- 1 file changed, 55 insertions(+), 148 deletions(-) (limited to 'includes/specials/SpecialVersion.php') diff --git a/includes/specials/SpecialVersion.php b/includes/specials/SpecialVersion.php index 81d17817..5ba785f5 100644 --- a/includes/specials/SpecialVersion.php +++ b/includes/specials/SpecialVersion.php @@ -55,7 +55,7 @@ class SpecialVersion extends SpecialPage { $out = $this->getOutput(); $out->allowClickjacking(); - if( $par !== 'Credits' ) { + if ( $par !== 'Credits' ) { $text = $this->getMediaWikiCredits() . $this->softwareInformation() . @@ -69,9 +69,7 @@ class SpecialVersion extends SpecialPage { $out->addHTML( $this->IPInfo() ); if ( $this->getRequest()->getVal( 'easteregg' ) ) { - if ( $this->showEasterEgg() ) { - // TODO: put something interesting here - } + // TODO: put something interesting here } } else { // Credits sub page @@ -115,11 +113,13 @@ class SpecialVersion extends SpecialPage { global $wgLang; if ( defined( 'MEDIAWIKI_INSTALL' ) ) { - $othersLink = '[http://www.mediawiki.org/wiki/Special:Version/Credits ' . wfMessage( 'version-poweredby-others' )->text() . ']'; + $othersLink = '[//www.mediawiki.org/wiki/Special:Version/Credits ' . wfMessage( 'version-poweredby-others' )->text() . ']'; } else { $othersLink = '[[Special:Version/Credits|' . wfMessage( 'version-poweredby-others' )->text() . ']]'; } + $translatorsLink = '[//translatewiki.net/wiki/Translating:MediaWiki/Credits ' . wfMessage( 'version-poweredby-translators' )->text() . ']'; + $authorList = array( 'Magnus Manske', 'Brion Vibber', 'Lee Daniel Crocker', 'Tim Starling', 'Erik Möller', 'Gabriel Wicke', 'Ævar Arnfjörð Bjarmason', @@ -128,10 +128,11 @@ class SpecialVersion extends SpecialPage { 'Alexandre Emsenhuber', 'Siebrand Mazeland', 'Chad Horohoe', 'Roan Kattouw', 'Trevor Parscal', 'Bryan Tong Minh', 'Sam Reed', 'Victor Vasiliev', 'Rotem Liss', 'Platonides', 'Antoine Musso', - 'Timo Tijhof', 'Daniel Kinzler', 'Jeroen De Dauw', $othersLink + 'Timo Tijhof', 'Daniel Kinzler', 'Jeroen De Dauw', $othersLink, + $translatorsLink ); - return wfMessage( 'version-poweredby-credits', date( 'Y' ), + return wfMessage( 'version-poweredby-credits', MWTimestamp::getLocalInstance()->format( 'Y' ), $wgLang->listToText( $authorList ) )->text(); } @@ -161,7 +162,7 @@ class SpecialVersion extends SpecialPage { " . wfMessage( 'version-software-version' )->text() . " \n"; - foreach( $software as $name => $version ) { + foreach ( $software as $name => $version ) { $out .= " " . $name . " " . $version . " @@ -220,11 +221,11 @@ class SpecialVersion extends SpecialPage { wfProfileIn( __METHOD__ ); $gitVersion = self::getVersionLinkedGit(); - if( $gitVersion ) { + if ( $gitVersion ) { $v = $gitVersion; } else { $svnVersion = self::getVersionLinkedSvn(); - if( $svnVersion ) { + if ( $svnVersion ) { $v = $svnVersion; } else { $v = $wgVersion; // fallback @@ -242,7 +243,7 @@ class SpecialVersion extends SpecialPage { global $IP; $info = self::getSvnInfo( $IP ); - if( !isset( $info['checkout-rev'] ) ) { + if ( !isset( $info['checkout-rev'] ) ) { return false; } @@ -267,7 +268,7 @@ class SpecialVersion extends SpecialPage { private static function getwgVersionLinked() { global $wgVersion; $versionUrl = ""; - if( wfRunHooks( 'SpecialVersionVersionUrl', array( $wgVersion, &$versionUrl ) ) ) { + if ( wfRunHooks( 'SpecialVersionVersionUrl', array( $wgVersion, &$versionUrl ) ) ) { $versionParts = array(); preg_match( "/^(\d+\.\d+)/", $wgVersion, $versionParts ); $versionUrl = "https://www.mediawiki.org/wiki/MediaWiki_{$versionParts[1]}"; @@ -276,22 +277,30 @@ class SpecialVersion extends SpecialPage { } /** - * @return bool|string wgVersion + HEAD sha1 stripped to the first 7 chars. False on failure + * @since 1.22 Returns the HEAD date in addition to the sha1 and link + * @return bool|string wgVersion + HEAD sha1 stripped to the first 7 chars with link and date, or false on failure */ private static function getVersionLinkedGit() { - global $IP; + global $IP, $wgLang; $gitInfo = new GitInfo( $IP ); $headSHA1 = $gitInfo->getHeadSHA1(); - if( !$headSHA1 ) { + if ( !$headSHA1 ) { return false; } $shortSHA1 = '(' . substr( $headSHA1, 0, 7 ) . ')'; - $viewerUrl = $gitInfo->getHeadViewUrl(); - if ( $viewerUrl !== false ) { - $shortSHA1 = "[$viewerUrl $shortSHA1]"; + + $gitHeadUrl = $gitInfo->getHeadViewUrl(); + if ( $gitHeadUrl !== false ) { + $shortSHA1 = "[$gitHeadUrl $shortSHA1]"; } + + $gitHeadCommitDate = $gitInfo->getHeadCommitDate(); + if ( $gitHeadCommitDate ) { + $shortSHA1 .= "
" . $wgLang->timeanddate( $gitHeadCommitDate, true ); + } + return self::getwgVersionLinked() . " $shortSHA1"; } @@ -384,11 +393,6 @@ class SpecialVersion extends SpecialPage { // We want the 'other' type to be last in the list. $out .= $this->getExtensionCategory( 'other', $extensionTypes['other'] ); - if ( count( $wgExtensionFunctions ) ) { - $out .= $this->openExtType( $this->msg( 'version-extension-functions' )->text(), 'extension-functions' ); - $out .= '' . $this->listToText( $wgExtensionFunctions ) . "\n"; - } - $tags = $wgParser->getTags(); $cnt = count( $tags ); @@ -397,11 +401,11 @@ class SpecialVersion extends SpecialPage { $tags[$i] = "<{$tags[$i]}>"; } $out .= $this->openExtType( $this->msg( 'version-parser-extensiontags' )->text(), 'parser-tags' ); - $out .= '' . $this->listToText( $tags ). "\n"; + $out .= '' . $this->listToText( $tags ) . "\n"; } $fhooks = $wgParser->getFunctionHooks(); - if( count( $fhooks ) ) { + if ( count( $fhooks ) ) { $out .= $this->openExtType( $this->msg( 'version-parser-function-hooks' )->text(), 'parser-function-hooks' ); $out .= '' . $this->listToText( $fhooks ) . "\n"; } @@ -446,7 +450,7 @@ class SpecialVersion extends SpecialPage { * @return int */ function compare( $a, $b ) { - if( $a['name'] === $b['name'] ) { + if ( $a['name'] === $b['name'] ) { return 0; } else { return $this->getLanguage()->lc( $a['name'] ) > $this->getLanguage()->lc( $b['name'] ) @@ -463,6 +467,8 @@ class SpecialVersion extends SpecialPage { * @return string */ function getCreditsForExtension( array $extension ) { + global $wgLang; + $name = isset( $extension['name'] ) ? $extension['name'] : '[no name]'; $vcsText = false; @@ -476,6 +482,10 @@ class SpecialVersion extends SpecialPage { if ( $gitViewerUrl !== false ) { $vcsText = "[$gitViewerUrl $vcsText]"; } + $gitHeadCommitDate = $gitInfo->getHeadCommitDate(); + if ( $gitHeadCommitDate ) { + $vcsText .= "
" . $wgLang->timeanddate( $gitHeadCommitDate, true ); + } } else { $svnInfo = self::getSvnInfo( dirname( $extension['path'] ) ); # Make subversion text/link. @@ -503,13 +513,13 @@ class SpecialVersion extends SpecialPage { } # Make description text. - $description = isset ( $extension['description'] ) ? $extension['description'] : ''; + $description = isset( $extension['description'] ) ? $extension['description'] : ''; - if( isset ( $extension['descriptionmsg'] ) ) { + if ( isset( $extension['descriptionmsg'] ) ) { # Look for a localized description. $descriptionMsg = $extension['descriptionmsg']; - if( is_array( $descriptionMsg ) ) { + if ( is_array( $descriptionMsg ) ) { $descriptionMsgKey = $descriptionMsg[0]; // Get the message key array_shift( $descriptionMsg ); // Shift out the message key to get the parameters only array_map( "htmlspecialchars", $descriptionMsg ); // For sanity @@ -528,7 +538,7 @@ class SpecialVersion extends SpecialPage { $mainLink $versionText"; } - $author = isset ( $extension['author'] ) ? $extension['author'] : array(); + $author = isset( $extension['author'] ) ? $extension['author'] : array(); $extDescAuthor = "$description " . $this->listAuthors( $author, false ) . " \n"; @@ -564,21 +574,22 @@ class SpecialVersion extends SpecialPage { $ret .= Xml::closeElement( 'table' ); return $ret; - } else + } else { return ''; + } } private function openExtType( $text, $name = null ) { $opt = array( 'colspan' => 4 ); $out = ''; - if( $this->firstExtOpened ) { + if ( $this->firstExtOpened ) { // Insert a spacing line $out .= '' . Html::element( 'td', $opt ) . "\n"; } $this->firstExtOpened = true; - if( $name ) { + if ( $name ) { $opt['id'] = "sv-$name"; } @@ -605,7 +616,7 @@ class SpecialVersion extends SpecialPage { */ function listAuthors( $authors ) { $list = array(); - foreach( (array)$authors as $item ) { + foreach ( (array)$authors as $item ) { if ( $item == '...' ) { $list[] = $this->msg( 'version-poweredby-others' )->text(); } elseif ( substr( $item, -5 ) == ' ...]' ) { @@ -650,16 +661,16 @@ class SpecialVersion extends SpecialPage { * @return Mixed */ public static function arrayToString( $list ) { - if( is_array( $list ) && count( $list ) == 1 ) { + if ( is_array( $list ) && count( $list ) == 1 ) { $list = $list[0]; } - if( is_object( $list ) ) { + if ( is_object( $list ) ) { $class = wfMessage( 'parentheses' )->params( get_class( $list ) )->escaped(); return $class; } elseif ( !is_array( $list ) ) { return $list; } else { - if( is_object( $list[0] ) ) { + if ( is_object( $list[0] ) ) { $class = get_class( $list[0] ); } else { $class = $list[0]; @@ -688,7 +699,7 @@ class SpecialVersion extends SpecialPage { // http://svnbook.red-bean.com/nightly/en/svn.developer.insidewc.html $entries = $dir . '/.svn/entries'; - if( !file_exists( $entries ) ) { + if ( !file_exists( $entries ) ) { return false; } @@ -698,9 +709,9 @@ class SpecialVersion extends SpecialPage { } // check if file is xml (subversion release <= 1.3) or not (subversion release = 1.4) - if( preg_match( '/^<\?xml/', $lines[0] ) ) { + if ( preg_match( '/^<\?xml/', $lines[0] ) ) { // subversion is release <= 1.3 - if( !function_exists( 'simplexml_load_file' ) ) { + if ( !function_exists( 'simplexml_load_file' ) ) { // We could fall back to expat... YUCK return false; } @@ -710,11 +721,11 @@ class SpecialVersion extends SpecialPage { $xml = simplexml_load_file( $entries ); wfRestoreWarnings(); - if( $xml ) { - foreach( $xml->entry as $entry ) { - if( $xml->entry[0]['name'] == '' ) { + if ( $xml ) { + foreach ( $xml->entry as $entry ) { + if ( $xml->entry[0]['name'] == '' ) { // The directory entry should always have a revision marker. - if( $entry['revision'] ) { + if ( $entry['revision'] ) { return array( 'checkout-rev' => intval( $entry['revision'] ) ); } } @@ -831,108 +842,4 @@ class SpecialVersion extends SpecialPage { return 'wiki'; } - function showEasterEgg() { - $rx = $rp = $xe = ''; - $alpha = array( "", "kbQW", "\$\n()" ); - $beta = implode( "', '", $alpha); - $juliet = 'echo $delta + strrev( $foxtrot ) - $alfa + $wgVersion . base64_decode( $bravo ) * $charlie'; - for ( $i = 1; $i <= 4; $i++ ) { - $rx .= '([^j]*)J'; - $rp .= "+(\\$i)"; - } - - $rx = "/$rx/Sei"; - $O = substr( "$alpha')", 1 ); - for ( $i = 1; $i <= strlen( $rx ) / 3; $i++ ) { - $rx[$i-1] = strtolower( $rx[$i-1] ); - } - $ry = ".*?(.((.)(.))).{1,3}(.)(.{1,$i})(\\4.\\3)(.).*"; - $ry = "/$ry/Sei"; - $O = substr( "$beta')", 1 ); - preg_match_all( '/(?<=\$)[[:alnum:]]*/', substr( $juliet, 0, $i<<1 ), $charlie ); - foreach( $charlie[0] as $bravo ) { - $$bravo =& $xe; - } - $xe = 'xe=<<0kssss?zk-0k10000:zk kbe zk=DDzk<<3&0kssssJ|Dzk>>13JJ^3658 kbe zk=pueDzk&0kssJ.pueDzk>>8JJ?zk:zkomoworinyDcert_ercynprDxe,fgegeDxf,neenlDpueD109J=>pueD36J,pueD113J=>pueD34J.pueD92J. 0 .pueD34JJJ,fgegeDxv,neenlDpueD13J=>snyfr,pueD10J=>snyfrJJJJwo'; - - $haystack = preg_replace( $ry, "$1$2$5$1_$7$89$i$5$6$8$O", $juliet ); - return preg_replace( $rx, $rp, $haystack ); - } } -- cgit v1.2.2