3 * Give information about the version of MediaWiki, PHP, the DB and extensions
6 * @subpackage SpecialPage
10 * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
11 * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
12 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
18 function wfSpecialVersion() {
19 $version = new SpecialVersion
;
23 class SpecialVersion
{
30 $wgOut->addHTML( '<div dir="ltr">' );
32 $this->MediaWikiCredits() .
33 $this->extensionCredits() .
36 $wgOut->addHTML( $this->IPInfo() );
37 $wgOut->addHTML( '</div>' );
47 function MediaWikiCredits() {
48 $version = self
::getVersion();
49 $dbr =& wfGetDB( DB_SLAVE
);
51 global $wgLanguageNames, $wgLanguageCode;
52 $mwlang = $wgLanguageNames[$wgLanguageCode];
56 This wiki is powered by '''[http://www.mediawiki.org/ MediaWiki]''',
57 copyright (C) 2001-2007 Magnus Manske, Brion Vibber, Lee Daniel Crocker,
58 Tim Starling, Erik Möller, Gabriel Wicke, Ævar Arnfjörð Bjarmason,
59 Niklas Laxström, Domas Mituzas, Rob Church and others.
61 MediaWiki is free software; you can redistribute it and/or modify
62 it under the terms of the GNU General Public License as published by
63 the Free Software Foundation; either version 2 of the License, or
64 (at your option) any later version.
66 MediaWiki is distributed in the hope that it will be useful,
67 but WITHOUT ANY WARRANTY; without even the implied warranty of
68 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
69 GNU General Public License for more details.
71 You should have received [{{SERVER}}{{SCRIPTPATH}}/COPYING a copy of the GNU General Public License]
72 along with this program; if not, write to the Free Software
73 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
74 or [http://www.gnu.org/copyleft/gpl.html read it online]
76 * [http://www.mediawiki.org/ MediaWiki]: $version ($wgLanguageCode $mwlang)
77 * [http://www.php.net/ PHP]: " . phpversion() . " (" . php_sapi_name() . ")
78 * " . $dbr->getSoftwareLink() . ": " . $dbr->getServerVersion();
80 return str_replace( "\t\t", '', $ret );
83 public static function getVersion() {
84 global $wgVersion, $IP;
85 $svn = self
::getSvnRevision( $IP );
86 return $svn ?
"$wgVersion (r$svn)" : $wgVersion;
89 function extensionCredits() {
90 global $wgExtensionCredits, $wgExtensionFunctions, $wgParser, $wgSkinExtensionFunction;
92 if ( ! count( $wgExtensionCredits ) && ! count( $wgExtensionFunctions ) && ! count( $wgSkinExtensionFunction ) )
95 $extensionTypes = array(
96 'specialpage' => 'Special pages',
97 'parserhook' => 'Parser hooks',
98 'variable' => 'Variables',
101 wfRunHooks( 'SpecialVersionExtensionTypes', array( &$this, &$extensionTypes ) );
103 $out = "\n* Extensions:\n";
104 foreach ( $extensionTypes as $type => $text ) {
105 if ( count( @$wgExtensionCredits[$type] ) ) {
106 $out .= "** $text:\n";
108 usort( $wgExtensionCredits[$type], array( $this, 'compare' ) );
110 foreach ( $wgExtensionCredits[$type] as $extension ) {
111 wfSuppressWarnings();
112 $out .= $this->formatCredits(
114 $extension['version'],
115 $extension['author'],
117 $extension['description']
124 if ( count( $wgExtensionFunctions ) ) {
125 $out .= "** Extension functions:\n";
126 $out .= '***' . $this->listToText( $wgExtensionFunctions ) . "\n";
129 if ( $cnt = count( $tags = $wgParser->getTags() ) ) {
130 for ( $i = 0; $i < $cnt; ++
$i )
131 $tags[$i] = "<{$tags[$i]}>";
132 $out .= "** Parser extension tags:\n";
133 $out .= '***' . $this->listToText( $tags ). "\n";
136 if( $cnt = count( $fhooks = $wgParser->getFunctionHooks() ) ) {
137 $out .= "** Parser function hooks:\n";
138 $out .= '***' . $this->listToText( $fhooks ) . "\n";
141 if ( count( $wgSkinExtensionFunction ) ) {
142 $out .= "** Skin extension functions:\n";
143 $out .= '***' . $this->listToText( $wgSkinExtensionFunction ) . "\n";
149 function compare( $a, $b ) {
150 if ( $a['name'] === $b['name'] )
153 return Language
::lc( $a['name'] ) > Language
::lc( $b['name'] ) ?
1 : -1;
156 function formatCredits( $name, $version = null, $author = null, $url = null, $description = null) {
161 if ( isset( $version ) )
162 $ret .= " (version $version)";
166 if ( isset( $description ) )
167 $ret .= ', ' . $description;
168 if ( isset( $description ) && isset( $author ) )
170 if ( isset( $author ) )
171 $ret .= ' by ' . $this->listToText( (array)$author );
182 if ( count( $wgHooks ) ) {
183 $myWgHooks = $wgHooks;
187 foreach ($myWgHooks as $hook => $hooks)
188 $ret .= "** $hook: " . $this->listToText( $hooks ) . "\n";
201 $ip = str_replace( '--', ' - ', htmlspecialchars( wfGetIP() ) );
202 return "<!-- visited from $ip -->\n" .
203 "<span style='display:none'>visited from $ip</span>";
210 function listToText( $list ) {
211 $cnt = count( $list );
214 // Enforce always returning a string
215 return (string)$this->arrayToString( $list[0] );
217 $t = array_slice( $list, 0, $cnt - 1 );
218 $one = array_map( array( &$this, 'arrayToString' ), $t );
219 $two = $this->arrayToString( $list[$cnt - 1] );
221 return implode( ', ', $one ) . " and $two";
228 * @param mixed $list Will convert an array to string if given and return
229 * the paramater unaltered otherwise
232 function arrayToString( $list ) {
233 if ( ! is_array( $list ) )
236 $class = get_class( $list[0] );
237 return "($class, {$list[1]})";
242 * Retrieve the revision number of a Subversion working directory.
247 * @return mixed revision number as int, or false if not a SVN checkout
249 public static function getSvnRevision( $dir ) {
250 // http://svnbook.red-bean.com/nightly/en/svn.developer.insidewc.html
251 $entries = $dir . '/.svn/entries';
253 if( !file_exists( $entries ) ) {
257 $content = file( $entries );
259 // check if file is xml (subversion release <= 1.3) or not (subversion release = 1.4)
260 if( preg_match( '/^<\?xml/', $content[0] ) ) {
261 // subversion is release <= 1.3
262 if( !function_exists( 'simplexml_load_file' ) ) {
263 // We could fall back to expat... YUCK
267 // SimpleXml whines about the xmlns...
268 wfSuppressWarnings();
269 $xml = simplexml_load_file( $entries );
273 foreach( $xml->entry
as $entry ) {
274 if( $xml->entry
[0]['name'] == '' ) {
275 // The directory entry should always have a revision marker.
276 if( $entry['revision'] ) {
277 return intval( $entry['revision'] );
284 // subversion is release 1.4
285 return intval( $content[3] );