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