* Special:Import/importDump fixes: report XML parse errors, accept <minor/>
[lhc/web/wiklou.git] / includes / SpecialVersion.php
1 <?php
2 /**
3 * Give information about the version of MediaWiki, PHP, the DB and extensions
4 *
5 * @package MediaWiki
6 * @subpackage SpecialPage
7 *
8 * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
9 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
10 */
11
12 /**
13 * constructor
14 */
15 function wfSpecialVersion() {
16 $version = new SpecialVersion;
17 $version->execute();
18 }
19
20 class SpecialVersion {
21 /**
22 * @var object
23 */
24 var $langObj;
25
26 /**
27 * Constructor
28 */
29 function SpecialVersion() {
30 // English motherfucker, do you speak it?
31 $this->langObj = setupLangObj( 'LanguageEn' );
32 $this->langObj->initEncoding();
33 }
34
35 function execute() {
36 global $wgOut;
37
38 $wgOut->setRobotpolicy( 'index,follow' );
39 $wgOut->addWikiText( $this->MediaWikiCredits() . $this->extensionCredits() );
40 $wgOut->addHTML( $this->IPInfo() );
41 }
42
43 function MediaWikiCredits() {
44 global $wgVersion;
45
46 $dbr =& wfGetDB( DB_SLAVE );
47
48 $ret =
49 "__NOTOC__
50 <div dir='ltr'>
51 This wiki is powered by '''[http://www.mediawiki.org/ MediaWiki]''',
52 copyright (C) 2001-2005 Magnus Manske, Brion Vibber, Lee Daniel Crocker,
53 Tim Starling, Erik Möller, and others.
54
55 MediaWiki is free software; you can redistribute it and/or modify
56 it under the terms of the GNU General Public License as published by
57 the Free Software Foundation; either version 2 of the License, or
58 (at your option) any later version.
59
60 MediaWiki is distributed in the hope that it will be useful,
61 but WITHOUT ANY WARRANTY; without even the implied warranty of
62 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
63 GNU General Public License for more details.
64
65 You should have received [{{SERVER}}{{SCRIPTPATH}}/COPYING a copy of the GNU General Public License]
66 along with this program; if not, write to the Free Software
67 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
68 or [http://www.gnu.org/copyleft/gpl.html read it online]
69
70 * [http://www.mediawiki.org/ MediaWiki]: $wgVersion
71 * [http://www.php.net/ PHP]: " . phpversion() . " (" . php_sapi_name() . ")
72 * " . $dbr->getSoftwareLink() . ": " . $dbr->getServerVersion() . "
73 </div>";
74
75 return str_replace( "\t\t", '', $ret );
76 }
77
78 function extensionCredits() {
79 global $wgExtensionCredits, $wgExtensionFunctions, $wgSkinExtensionFunction;
80
81 if ( ! count( $wgExtensionCredits ) && ! count( $wgExtensionFunctions ) && ! count( $wgSkinExtensionFunction ) )
82 return '';
83
84 $extensionTypes = array(
85 'specialpage' => 'Special pages',
86 'parserhook' => 'Parser hooks',
87 'other' => 'Other',
88 );
89
90 wfRunHooks( 'ExtensionTypes', array( &$extensionTypes ) );
91
92 $out = "\n* Extensions:\n";
93 foreach ( $extensionTypes as $type => $text ) {
94 if ( count( @$wgExtensionCredits[$type] ) ) {
95 $out .= "** $text:\n";
96 foreach ( $wgExtensionCredits[$type] as $extension ) {
97 wfSuppressWarnings();
98 $out .= $this->formatCredits(
99 $extension['name'],
100 $extension['version'],
101 $extension['author'],
102 $extension['url'],
103 $extension['description']
104 );
105 wfRestoreWarnings();
106 }
107 }
108 }
109
110 if ( count( $wgExtensionFunctions ) ) {
111 $out .= "** Extension functions:\n";
112 $out .= '***' . $this->langObj->listToText( $wgExtensionFunctions ) . "\n";
113 }
114
115 if ( count( $wgSkinExtensionFunction ) ) {
116 $out .= "** Skin extension functions:\n";
117 $out .= '***' . $this->langObj->listToText( $wgSkinExtensionFunction ) . "\n";
118 }
119
120 return $out;
121 }
122
123 function formatCredits( $name, $version = null, $author = null, $url = null, $description = null) {
124 $ret = '*** ';
125 if ( isset( $url ) )
126 $ret .= "[$url ";
127 $ret .= "''$name";
128 if ( isset( $version ) )
129 $ret .= " (version $version)";
130 $ret .= "''";
131 if ( isset( $url ) )
132 $ret .= ']';
133 if ( isset( $description ) )
134 $ret .= ', ' . $description;
135 if ( isset( $description ) && isset( $author ) )
136 $ret .= ', ';
137 if ( isset( $author ) )
138 $ret .= ' by ' . $this->langObj->listToText( (array)$author );
139
140 return "$ret\n";
141 }
142
143 function IPInfo() {
144
145 $ip = str_replace( '--', ' - - ', htmlspecialchars( wfGetIP() ) );
146 return "<!-- visited from $ip -->\n";
147 }
148 }
149 ?>