+ Using usort() on the extensnion list with a callback function that sorts by byte...
[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 * @access private
25 */
26 var $langObj;
27
28 /**
29 * Constructor
30 */
31 function SpecialVersion() {
32 // English motherfucker, do you speak it?
33 $this->langObj = setupLangObj( 'LanguageEn' );
34 $this->langObj->initEncoding();
35 }
36
37 /**
38 * main()
39 */
40 function execute() {
41 global $wgOut;
42
43 $wgOut->addWikiText(
44 $this->MediaWikiCredits() .
45 $this->extensionCredits() .
46 $this->wgHooks()
47 );
48 $wgOut->addHTML( $this->IPInfo() );
49 }
50
51 /**#@+
52 * @access private
53 */
54
55 /**
56 * @static
57 */
58 function MediaWikiCredits() {
59 global $wgVersion;
60
61 $dbr =& wfGetDB( DB_SLAVE );
62
63 $ret =
64 "__NOTOC__
65 <div dir='ltr'>
66 This wiki is powered by '''[http://www.mediawiki.org/ MediaWiki]''',
67 copyright (C) 2001-2005 Magnus Manske, Brion Vibber, Lee Daniel Crocker,
68 Tim Starling, Erik Möller, and others.
69
70 MediaWiki is free software; you can redistribute it and/or modify
71 it under the terms of the GNU General Public License as published by
72 the Free Software Foundation; either version 2 of the License, or
73 (at your option) any later version.
74
75 MediaWiki is distributed in the hope that it will be useful,
76 but WITHOUT ANY WARRANTY; without even the implied warranty of
77 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
78 GNU General Public License for more details.
79
80 You should have received [{{SERVER}}{{SCRIPTPATH}}/COPYING a copy of the GNU General Public License]
81 along with this program; if not, write to the Free Software
82 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
83 or [http://www.gnu.org/copyleft/gpl.html read it online]
84
85 * [http://www.mediawiki.org/ MediaWiki]: $wgVersion
86 * [http://www.php.net/ PHP]: " . phpversion() . " (" . php_sapi_name() . ")
87 * " . $dbr->getSoftwareLink() . ": " . $dbr->getServerVersion() . "
88 </div>";
89
90 return str_replace( "\t\t", '', $ret );
91 }
92
93 function extensionCredits() {
94 global $wgExtensionCredits, $wgExtensionFunctions, $wgSkinExtensionFunction;
95
96 if ( ! count( $wgExtensionCredits ) && ! count( $wgExtensionFunctions ) && ! count( $wgSkinExtensionFunction ) )
97 return '';
98
99 $extensionTypes = array(
100 'specialpage' => 'Special pages',
101 'parserhook' => 'Parser hooks',
102 'variable' => 'Variables',
103 'other' => 'Other',
104 );
105 wfRunHooks( 'SpecialVersionExtensionTypes', array( &$this, &$extensionTypes ) );
106
107 $out = "\n* Extensions:\n";
108 foreach ( $extensionTypes as $type => $text ) {
109 if ( count( @$wgExtensionCredits[$type] ) ) {
110 $out .= "** $text:\n";
111
112 usort( $wgExtensionCredits[$type], array( $this, 'compare' ) );
113
114 foreach ( $wgExtensionCredits[$type] as $extension ) {
115 wfSuppressWarnings();
116 $out .= $this->formatCredits(
117 $extension['name'],
118 $extension['version'],
119 $extension['author'],
120 $extension['url'],
121 $extension['description']
122 );
123 wfRestoreWarnings();
124 }
125 }
126 }
127
128 if ( count( $wgExtensionFunctions ) ) {
129 $out .= "** Extension functions:\n";
130 $out .= '***' . $this->langObj->listToText( $wgExtensionFunctions ) . "\n";
131 }
132
133 if ( count( $wgSkinExtensionFunction ) ) {
134 $out .= "** Skin extension functions:\n";
135 $out .= '***' . $this->langObj->listToText( $wgSkinExtensionFunction ) . "\n";
136 }
137
138 return $out;
139 }
140
141 function compare( $a, $b ) {
142 if ( $a['name'] === $b['name'] )
143 return 0;
144 else
145 return $this->langObj->lc( $a['name'] ) > $this->langObj->lc( $b['name'] ) ? 1 : -1;
146 }
147
148 function formatCredits( $name, $version = null, $author = null, $url = null, $description = null) {
149 $ret = '*** ';
150 if ( isset( $url ) )
151 $ret .= "[$url ";
152 $ret .= "''$name";
153 if ( isset( $version ) )
154 $ret .= " (version $version)";
155 $ret .= "''";
156 if ( isset( $url ) )
157 $ret .= ']';
158 if ( isset( $description ) )
159 $ret .= ', ' . $description;
160 if ( isset( $description ) && isset( $author ) )
161 $ret .= ', ';
162 if ( isset( $author ) )
163 $ret .= ' by ' . $this->langObj->listToText( (array)$author );
164
165 return "$ret\n";
166 }
167
168 function wgHooks() {
169 global $wgHooks;
170
171 $myWgHooks = $wgHooks;
172 ksort( $myWgHooks );
173
174 $ret = "* Hooks:\n";
175 foreach ($myWgHooks as $hook => $hooks)
176 $ret .= "** $hook:" . $this->langObj->listToText( $hooks ) . "\n";
177
178 return $ret;
179 }
180
181 /**
182 * @static
183 */
184 function IPInfo() {
185 $ip = str_replace( '--', '-', htmlspecialchars( wfGetIP() ) );
186 return "<!-- visited from $ip -->\n";
187 }
188
189 /**#@-*/
190 }
191
192 /**#@-*/
193 ?>