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() {
50 $dbr =& wfGetDB( DB_SLAVE
);
54 This wiki is powered by '''[http://www.mediawiki.org/ MediaWiki]''',
55 copyright (C) 2001-2006 Magnus Manske, Brion Vibber, Lee Daniel Crocker,
56 Tim Starling, Erik Möller, Gabriel Wicke, Ævar Arnfjörð Bjarmason,
57 Niklas Laxström and others.
59 MediaWiki is free software; you can redistribute it and/or modify
60 it under the terms of the GNU General Public License as published by
61 the Free Software Foundation; either version 2 of the License, or
62 (at your option) any later version.
64 MediaWiki is distributed in the hope that it will be useful,
65 but WITHOUT ANY WARRANTY; without even the implied warranty of
66 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
67 GNU General Public License for more details.
69 You should have received [{{SERVER}}{{SCRIPTPATH}}/COPYING a copy of the GNU General Public License]
70 along with this program; if not, write to the Free Software
71 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
72 or [http://www.gnu.org/copyleft/gpl.html read it online]
74 * [http://www.mediawiki.org/ MediaWiki]: $wgVersion
75 * [http://www.php.net/ PHP]: " . phpversion() . " (" . php_sapi_name() . ")
76 * " . $dbr->getSoftwareLink() . ": " . $dbr->getServerVersion();
78 return str_replace( "\t\t", '', $ret );
81 function extensionCredits() {
82 global $wgExtensionCredits, $wgExtensionFunctions, $wgParser, $wgSkinExtensionFunction;
84 if ( ! count( $wgExtensionCredits ) && ! count( $wgExtensionFunctions ) && ! count( $wgSkinExtensionFunction ) )
87 $extensionTypes = array(
88 'specialpage' => 'Special pages',
89 'parserhook' => 'Parser hooks',
90 'variable' => 'Variables',
93 wfRunHooks( 'SpecialVersionExtensionTypes', array( &$this, &$extensionTypes ) );
95 $out = "\n* Extensions:\n";
96 foreach ( $extensionTypes as $type => $text ) {
97 if ( count( @$wgExtensionCredits[$type] ) ) {
98 $out .= "** $text:\n";
100 usort( $wgExtensionCredits[$type], array( $this, 'compare' ) );
102 foreach ( $wgExtensionCredits[$type] as $extension ) {
103 wfSuppressWarnings();
104 $out .= $this->formatCredits(
106 $extension['version'],
107 $extension['author'],
109 $extension['description']
116 if ( count( $wgExtensionFunctions ) ) {
117 $out .= "** Extension functions:\n";
118 $out .= '***' . $this->listToText( $wgExtensionFunctions ) . "\n";
121 if ( $cnt = count( $tags = $wgParser->getTags() ) ) {
122 for ( $i = 0; $i < $cnt; ++
$i )
123 $tags[$i] = "<{$tags[$i]}>";
124 $out .= "** Parser extension tags:\n";
125 $out .= '***' . $this->listToText( $tags ). "\n";
128 if ( count( $wgSkinExtensionFunction ) ) {
129 $out .= "** Skin extension functions:\n";
130 $out .= '***' . $this->listToText( $wgSkinExtensionFunction ) . "\n";
136 function compare( $a, $b ) {
137 if ( $a['name'] === $b['name'] )
140 return LanguageUtf8
::lc( $a['name'] ) > LanguageUtf8
::lc( $b['name'] ) ?
1 : -1;
143 function formatCredits( $name, $version = null, $author = null, $url = null, $description = null) {
148 if ( isset( $version ) )
149 $ret .= " (version $version)";
153 if ( isset( $description ) )
154 $ret .= ', ' . $description;
155 if ( isset( $description ) && isset( $author ) )
157 if ( isset( $author ) )
158 $ret .= ' by ' . $this->listToText( (array)$author );
169 if ( count( $wgHooks ) ) {
170 $myWgHooks = $wgHooks;
174 foreach ($myWgHooks as $hook => $hooks)
175 $ret .= "** $hook: " . $this->listToText( $hooks ) . "\n";
188 $ip = str_replace( '--', ' - ', htmlspecialchars( wfGetIP() ) );
189 return "<!-- visited from $ip -->\n" .
190 "<span style='display:none'>visited from $ip</span>";
197 function listToText( $list ) {
198 $cnt = count( $list );
201 // Enforce always returning a string
202 return (string)$this->arrayToString( $list[0] );
204 $t = array_slice( $list, 0, $cnt - 1 );
205 $one = array_map( array( &$this, 'arrayToString' ), $t );
206 $two = $this->arrayToString( $list[$cnt - 1] );
208 return implode( ', ', $one ) . " and $two";
215 * @param mixed $list Will convert an array to string if given and return
216 * the paramater unaltered otherwise
219 function arrayToString( $list ) {
220 if ( ! is_array( $list ) )
223 $class = get_class( $list[0] );
224 return "($class, {$list[1]})";