summaryrefslogtreecommitdiff
path: root/includes/specials/SpecialVersion.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/specials/SpecialVersion.php')
-rw-r--r--includes/specials/SpecialVersion.php256
1 files changed, 181 insertions, 75 deletions
diff --git a/includes/specials/SpecialVersion.php b/includes/specials/SpecialVersion.php
index 8185fe88..4e5b6bf5 100644
--- a/includes/specials/SpecialVersion.php
+++ b/includes/specials/SpecialVersion.php
@@ -37,7 +37,7 @@ class SpecialVersion extends SpecialPage {
protected static $viewvcUrls = array(
'svn+ssh://svn.wikimedia.org/svnroot/mediawiki' => 'http://svn.wikimedia.org/viewvc/mediawiki',
'http://svn.wikimedia.org/svnroot/mediawiki' => 'http://svn.wikimedia.org/viewvc/mediawiki',
- 'https://svn.wikimedia.org/viewvc/mediawiki' => 'https://svn.wikimedia.org/viewvc/mediawiki',
+ 'https://svn.wikimedia.org/svnroot/mediawiki' => 'https://svn.wikimedia.org/viewvc/mediawiki',
);
public function __construct(){
@@ -58,6 +58,7 @@ class SpecialVersion extends SpecialPage {
$text =
$this->getMediaWikiCredits() .
$this->softwareInformation() .
+ $this->getEntryPointInfo() .
$this->getExtensionCredits();
if ( $wgSpecialVersionShowHooks ) {
$text .= $this->getWgHooks();
@@ -79,13 +80,13 @@ class SpecialVersion extends SpecialPage {
* @return string
*/
private static function getMediaWikiCredits() {
- $ret = Xml::element( 'h2', array( 'id' => 'mw-version-license' ), wfMsg( 'version-license' ) );
+ $ret = Xml::element( 'h2', array( 'id' => 'mw-version-license' ), wfMessage( 'version-license' )->text() );
// This text is always left-to-right.
- $ret .= '<div>';
+ $ret .= '<div class="plainlinks">';
$ret .= "__NOTOC__
" . self::getCopyrightAndAuthorList() . "\n
- " . wfMsg( 'version-license-info' );
+ " . wfMessage( 'version-license-info' )->text();
$ret .= '</div>';
return str_replace( "\t\t", '', $ret ) . "\n";
@@ -107,11 +108,14 @@ 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',
- wfMsg( 'version-poweredby-others' )
+ 'Timo Tijhof',
+ '[{{SERVER}}{{SCRIPTPATH}}/CREDITS ' .
+ wfMessage( 'version-poweredby-others' )->text() .
+ ']'
);
- return wfMsg( 'version-poweredby-credits', date( 'Y' ),
- $wgLang->listToText( $authorList ) );
+ return wfMessage( 'version-poweredby-credits', date( 'Y' ),
+ $wgLang->listToText( $authorList ) )->text();
}
/**
@@ -123,8 +127,8 @@ class SpecialVersion extends SpecialPage {
$dbr = wfGetDB( DB_SLAVE );
// Put the software in an array of form 'name' => 'version'. All messages should
- // be loaded here, so feel free to use wfMsg*() in the 'name'. Raw HTML or wikimarkup
- // can be used.
+ // be loaded here, so feel free to use wfMessage in the 'name'. Raw HTML or
+ // wikimarkup can be used.
$software = array();
$software['[https://www.mediawiki.org/ MediaWiki]'] = self::getVersionLinked();
$software['[http://www.php.net/ PHP]'] = phpversion() . " (" . php_sapi_name() . ")";
@@ -133,11 +137,11 @@ class SpecialVersion extends SpecialPage {
// Allow a hook to add/remove items.
wfRunHooks( 'SoftwareInfo', array( &$software ) );
- $out = Xml::element( 'h2', array( 'id' => 'mw-version-software' ), wfMsg( 'version-software' ) ) .
- Xml::openElement( 'table', array( 'class' => 'wikitable', 'id' => 'sv-software' ) ) .
+ $out = Xml::element( 'h2', array( 'id' => 'mw-version-software' ), wfMessage( 'version-software' )->text() ) .
+ Xml::openElement( 'table', array( 'class' => 'wikitable plainlinks', 'id' => 'sv-software' ) ) .
"<tr>
- <th>" . wfMsg( 'version-software-product' ) . "</th>
- <th>" . wfMsg( 'version-software-version' ) . "</th>
+ <th>" . wfMessage( 'version-software-product' )->text() . "</th>
+ <th>" . wfMessage( 'version-software-version' )->text() . "</th>
</tr>\n";
foreach( $software as $name => $version ) {
@@ -160,18 +164,26 @@ class SpecialVersion extends SpecialPage {
global $wgVersion, $IP;
wfProfileIn( __METHOD__ );
- $info = self::getSvnInfo( $IP );
- if ( !$info ) {
+ $gitInfo = self::getGitHeadSha1( $IP );
+ $svnInfo = self::getSvnInfo( $IP );
+ if ( !$svnInfo && !$gitInfo ) {
$version = $wgVersion;
- } elseif( $flags === 'nodb' ) {
- $version = "$wgVersion (r{$info['checkout-rev']})";
+ } elseif ( $gitInfo && $flags === 'nodb' ) {
+ $shortSha1 = substr( $gitInfo, 0, 7 );
+ $version = "$wgVersion ($shortSha1)";
+ } elseif ( $gitInfo ) {
+ $shortSha1 = substr( $gitInfo, 0, 7 );
+ $shortSha1 = wfMessage( 'parentheses' )->params( $shortSha1 )->escaped();
+ $version = "$wgVersion $shortSha1";
+ } elseif ( $flags === 'nodb' ) {
+ $version = "$wgVersion (r{$svnInfo['checkout-rev']})";
} else {
$version = $wgVersion . ' ' .
- wfMsg(
+ wfMessage(
'version-svn-revision',
isset( $info['directory-rev'] ) ? $info['directory-rev'] : '',
$info['checkout-rev']
- );
+ )->text();
}
wfProfileOut( __METHOD__ );
@@ -180,37 +192,79 @@ class SpecialVersion extends SpecialPage {
/**
* Return a wikitext-formatted string of the MediaWiki version with a link to
- * the SVN revision if available.
+ * the SVN revision or the git SHA1 of head if available.
+ * Git is prefered over Svn
+ * The fallback is just $wgVersion
*
* @return mixed
*/
public static function getVersionLinked() {
- global $wgVersion, $IP;
+ global $wgVersion;
wfProfileIn( __METHOD__ );
+ $gitVersion = self::getVersionLinkedGit();
+ if( $gitVersion ) {
+ $v = $gitVersion;
+ } else {
+ $svnVersion = self::getVersionLinkedSvn();
+ if( $svnVersion ) {
+ $v = $svnVersion;
+ } else {
+ $v = $wgVersion; // fallback
+ }
+ }
+
+ wfProfileOut( __METHOD__ );
+ return $v;
+ }
+
+ /**
+ * @return string wgVersion + a link to subversion revision of svn BASE
+ */
+ private static function getVersionLinkedSvn() {
+ global $wgVersion, $IP;
+
$info = self::getSvnInfo( $IP );
+ if( !isset( $info['checkout-rev'] ) ) {
+ return false;
+ }
- if ( isset( $info['checkout-rev'] ) ) {
- $linkText = wfMsg(
- 'version-svn-revision',
- isset( $info['directory-rev'] ) ? $info['directory-rev'] : '',
- $info['checkout-rev']
- );
+ $linkText = wfMessage(
+ 'version-svn-revision',
+ isset( $info['directory-rev'] ) ? $info['directory-rev'] : '',
+ $info['checkout-rev']
+ )->text();
- if ( isset( $info['viewvc-url'] ) ) {
- $version = "$wgVersion [{$info['viewvc-url']} $linkText]";
- } else {
- $version = "$wgVersion $linkText";
- }
+ if ( isset( $info['viewvc-url'] ) ) {
+ $version = "$wgVersion [{$info['viewvc-url']} $linkText]";
} else {
- $version = $wgVersion;
+ $version = "$wgVersion $linkText";
}
- wfProfileOut( __METHOD__ );
return $version;
}
/**
+ * @return bool|string wgVersion + HEAD sha1 stripped to the first 7 chars. False on failure
+ */
+ private static function getVersionLinkedGit() {
+ global $wgVersion, $IP;
+
+ $gitInfo = new GitInfo( $IP );
+ $headSHA1 = $gitInfo->getHeadSHA1();
+ if( !$headSHA1 ) {
+ return false;
+ }
+
+ $shortSHA1 = '(' . substr( $headSHA1, 0, 7 ) . ')';
+ $viewerUrl = $gitInfo->getHeadViewUrl();
+ if ( $viewerUrl !== false ) {
+ $shortSHA1 = "[$viewerUrl $shortSHA1]";
+ }
+ return "$wgVersion $shortSHA1";
+ }
+
+ /**
* Returns an array with the base extension types.
* Type is stored as array key, the message as array value.
*
@@ -225,14 +279,14 @@ class SpecialVersion extends SpecialPage {
public static function getExtensionTypes() {
if ( self::$extensionTypes === false ) {
self::$extensionTypes = array(
- 'specialpage' => wfMsg( 'version-specialpages' ),
- 'parserhook' => wfMsg( 'version-parserhooks' ),
- 'variable' => wfMsg( 'version-variables' ),
- 'media' => wfMsg( 'version-mediahandlers' ),
- 'antispam' => wfMsg( 'version-antispam' ),
- 'skin' => wfMsg( 'version-skins' ),
- 'api' => wfMsg( 'version-api' ),
- 'other' => wfMsg( 'version-other' ),
+ 'specialpage' => wfMessage( 'version-specialpages' )->text(),
+ 'parserhook' => wfMessage( 'version-parserhooks' )->text(),
+ 'variable' => wfMessage( 'version-variables' )->text(),
+ 'media' => wfMessage( 'version-mediahandlers' )->text(),
+ 'antispam' => wfMessage( 'version-antispam' )->text(),
+ 'skin' => wfMessage( 'version-skins' )->text(),
+ 'api' => wfMessage( 'version-api' )->text(),
+ 'other' => wfMessage( 'version-other' )->text(),
);
wfRunHooks( 'ExtensionTypes', array( &self::$extensionTypes ) );
@@ -274,8 +328,8 @@ class SpecialVersion extends SpecialPage {
*/
wfRunHooks( 'SpecialVersionExtensionTypes', array( &$this, &$extensionTypes ) );
- $out = Xml::element( 'h2', array( 'id' => 'mw-version-ext' ), wfMsg( 'version-extensions' ) ) .
- Xml::openElement( 'table', array( 'class' => 'wikitable', 'id' => 'sv-ext' ) );
+ $out = Xml::element( 'h2', array( 'id' => 'mw-version-ext' ), $this->msg( 'version-extensions' )->text() ) .
+ Xml::openElement( 'table', array( 'class' => 'wikitable plainlinks', 'id' => 'sv-ext' ) );
// Make sure the 'other' type is set to an array.
if ( !array_key_exists( 'other', $wgExtensionCredits ) ) {
@@ -300,7 +354,7 @@ class SpecialVersion extends SpecialPage {
$out .= $this->getExtensionCategory( 'other', $extensionTypes['other'] );
if ( count( $wgExtensionFunctions ) ) {
- $out .= $this->openExtType( wfMsg( 'version-extension-functions' ), 'extension-functions' );
+ $out .= $this->openExtType( $this->msg( 'version-extension-functions' )->text(), 'extension-functions' );
$out .= '<tr><td colspan="4">' . $this->listToText( $wgExtensionFunctions ) . "</td></tr>\n";
}
@@ -311,13 +365,13 @@ class SpecialVersion extends SpecialPage {
for ( $i = 0; $i < $cnt; ++$i ) {
$tags[$i] = "&lt;{$tags[$i]}&gt;";
}
- $out .= $this->openExtType( wfMsg( 'version-parser-extensiontags' ), 'parser-tags' );
+ $out .= $this->openExtType( $this->msg( 'version-parser-extensiontags' )->text(), 'parser-tags' );
$out .= '<tr><td colspan="4">' . $this->listToText( $tags ). "</td></tr>\n";
}
$fhooks = $wgParser->getFunctionHooks();
if( count( $fhooks ) ) {
- $out .= $this->openExtType( wfMsg( 'version-parser-function-hooks' ), 'parser-function-hooks' );
+ $out .= $this->openExtType( $this->msg( 'version-parser-function-hooks' )->text(), 'parser-function-hooks' );
$out .= '<tr><td colspan="4">' . $this->listToText( $fhooks ) . "</td></tr>\n";
}
@@ -356,6 +410,9 @@ class SpecialVersion extends SpecialPage {
/**
* Callback to sort extensions by type.
+ * @param $a array
+ * @param $b array
+ * @return int
*/
function compare( $a, $b ) {
if( $a['name'] === $b['name'] ) {
@@ -377,15 +434,26 @@ class SpecialVersion extends SpecialPage {
function getCreditsForExtension( array $extension ) {
$name = isset( $extension['name'] ) ? $extension['name'] : '[no name]';
+ $vcsText = false;
+
if ( isset( $extension['path'] ) ) {
- $svnInfo = self::getSvnInfo( dirname($extension['path']) );
- $directoryRev = isset( $svnInfo['directory-rev'] ) ? $svnInfo['directory-rev'] : null;
- $checkoutRev = isset( $svnInfo['checkout-rev'] ) ? $svnInfo['checkout-rev'] : null;
- $viewvcUrl = isset( $svnInfo['viewvc-url'] ) ? $svnInfo['viewvc-url'] : null;
- } else {
- $directoryRev = null;
- $checkoutRev = null;
- $viewvcUrl = null;
+ $gitInfo = new GitInfo( dirname( $extension['path'] ) );
+ $gitHeadSHA1 = $gitInfo->getHeadSHA1();
+ if ( $gitHeadSHA1 !== false ) {
+ $vcsText = '(' . substr( $gitHeadSHA1, 0, 7 ) . ')';
+ $gitViewerUrl = $gitInfo->getHeadViewUrl();
+ if ( $gitViewerUrl !== false ) {
+ $vcsText = "[$gitViewerUrl $vcsText]";
+ }
+ } else {
+ $svnInfo = self::getSvnInfo( dirname( $extension['path'] ) );
+ # Make subversion text/link.
+ if ( $svnInfo !== false ) {
+ $directoryRev = isset( $svnInfo['directory-rev'] ) ? $svnInfo['directory-rev'] : null;
+ $vcsText = $this->msg( 'version-svn-revision', $directoryRev, $svnInfo['checkout-rev'] )->text();
+ $vcsText = isset( $svnInfo['viewvc-url'] ) ? '[' . $svnInfo['viewvc-url'] . " $vcsText]" : $vcsText;
+ }
+ }
}
# Make main link (or just the name if there is no URL).
@@ -397,20 +465,12 @@ class SpecialVersion extends SpecialPage {
if ( isset( $extension['version'] ) ) {
$versionText = '<span class="mw-version-ext-version">' .
- wfMsg( 'version-version', $extension['version'] ) .
+ $this->msg( 'version-version', $extension['version'] )->text() .
'</span>';
} else {
$versionText = '';
}
- # Make subversion text/link.
- if ( $checkoutRev ) {
- $svnText = wfMsg( 'version-svn-revision', $directoryRev, $checkoutRev );
- $svnText = isset( $viewvcUrl ) ? "[$viewvcUrl $svnText]" : $svnText;
- } else {
- $svnText = false;
- }
-
# Make description text.
$description = isset ( $extension['description'] ) ? $extension['description'] : '';
@@ -422,16 +482,16 @@ class SpecialVersion extends SpecialPage {
$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
- $description = wfMsg( $descriptionMsgKey, $descriptionMsg );
+ $description = $this->msg( $descriptionMsgKey, $descriptionMsg )->text();
} else {
- $description = wfMsg( $descriptionMsg );
+ $description = $this->msg( $descriptionMsg )->text();
}
}
- if ( $svnText !== false ) {
+ if ( $vcsText !== false ) {
$extNameVer = "<tr>
<td><em>$mainLink $versionText</em></td>
- <td><em>$svnText</em></td>";
+ <td><em>$vcsText</em></td>";
} else {
$extNameVer = "<tr>
<td colspan=\"2\"><em>$mainLink $versionText</em></td>";
@@ -457,11 +517,11 @@ class SpecialVersion extends SpecialPage {
$myWgHooks = $wgHooks;
ksort( $myWgHooks );
- $ret = Xml::element( 'h2', array( 'id' => 'mw-version-hooks' ), wfMsg( 'version-hooks' ) ) .
+ $ret = Xml::element( 'h2', array( 'id' => 'mw-version-hooks' ), $this->msg( 'version-hooks' )->text() ) .
Xml::openElement( 'table', array( 'class' => 'wikitable', 'id' => 'sv-hooks' ) ) .
"<tr>
- <th>" . wfMsg( 'version-hook-name' ) . "</th>
- <th>" . wfMsg( 'version-hook-subscribedby' ) . "</th>
+ <th>" . $this->msg( 'version-hook-name' )->text() . "</th>
+ <th>" . $this->msg( 'version-hook-subscribedby' )->text() . "</th>
</tr>\n";
foreach ( $myWgHooks as $hook => $hooks ) {
@@ -517,7 +577,7 @@ class SpecialVersion extends SpecialPage {
$list = array();
foreach( (array)$authors as $item ) {
if( $item == '...' ) {
- $list[] = wfMsg( 'version-poweredby-others' );
+ $list[] = $this->msg( 'version-poweredby-others' )->text();
} else {
$list[] = $item;
}
@@ -562,8 +622,8 @@ class SpecialVersion extends SpecialPage {
$list = $list[0];
}
if( is_object( $list ) ) {
- $class = get_class( $list );
- return "($class)";
+ $class = wfMessage( 'parentheses' )->params( get_class( $list ) )->escaped();
+ return $class;
} elseif ( !is_array( $list ) ) {
return $list;
} else {
@@ -572,7 +632,7 @@ class SpecialVersion extends SpecialPage {
} else {
$class = $list[0];
}
- return "($class, {$list[1]})";
+ return wfMessage( 'parentheses' )->params( "$class, {$list[1]}" )->escaped();
}
}
@@ -589,6 +649,8 @@ class SpecialVersion extends SpecialPage {
* url The subversion URL of the directory
* repo-url The base URL of the repository
* viewvc-url A ViewVC URL pointing to the checked-out revision
+ * @param $dir string
+ * @return array|bool
*/
public static function getSvnInfo( $dir ) {
// http://svnbook.red-bean.com/nightly/en/svn.developer.insidewc.html
@@ -676,6 +738,50 @@ class SpecialVersion extends SpecialPage {
}
}
+ /**
+ * @param $dir String: directory of the git checkout
+ * @return bool|String sha1 of commit HEAD points to
+ */
+ public static function getGitHeadSha1( $dir ) {
+ $repo = new GitInfo( $dir );
+ return $repo->getHeadSHA1();
+ }
+
+ /**
+ * Get the list of entry points and their URLs
+ * @return string Wikitext
+ */
+ public function getEntryPointInfo() {
+ global $wgArticlePath, $wgScriptPath;
+ $entryPoints = array(
+ 'version-entrypoints-articlepath' => $wgArticlePath,
+ 'version-entrypoints-scriptpath' => $wgScriptPath,
+ 'version-entrypoints-index-php' => wfScript( 'index' ),
+ 'version-entrypoints-api-php' => wfScript( 'api' ),
+ 'version-entrypoints-load-php' => wfScript( 'load' ),
+ );
+
+ $out = Html::element( 'h2', array( 'id' => 'mw-version-entrypoints' ), $this->msg( 'version-entrypoints' )->text() ) .
+ Html::openElement( 'table', array( 'class' => 'wikitable plainlinks', 'id' => 'mw-version-entrypoints-table' ) ) .
+ Html::openElement( 'tr' ) .
+ Html::element( 'th', array(), $this->msg( 'version-entrypoints-header-entrypoint' )->text() ) .
+ Html::element( 'th', array(), $this->msg( 'version-entrypoints-header-url' )->text() ) .
+ Html::closeElement( 'tr' );
+
+ foreach ( $entryPoints as $message => $value ) {
+ $url = wfExpandUrl( $value, PROTO_RELATIVE );
+ $out .= Html::openElement( 'tr' ) .
+ // ->text() looks like it should be ->parse(), but this function
+ // returns wikitext, not HTML, boo
+ Html::rawElement( 'td', array(), $this->msg( $message )->text() ) .
+ Html::rawElement( 'td', array(), Html::rawElement( 'code', array(), "[$url $value]" ) ) .
+ Html::closeElement( 'tr' );
+ }
+
+ $out .= Html::closeElement( 'table' );
+ return $out;
+ }
+
function showEasterEgg() {
$rx = $rp = $xe = '';
$alpha = array("", "kbQW", "\$\n()");