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