Oops, forgot a line. Now this works in Modern too. Yay for code duplication . . .
[lhc/web/wiklou.git] / skins / Modern.php
1 <?php
2 /**
3 * Modern skin, derived from monobook template.
4 *
5 * @todo document
6 * @file
7 * @ingroup Skins
8 */
9
10 if( !defined( 'MEDIAWIKI' ) )
11 die( -1 );
12
13 /**
14 * Inherit main code from SkinTemplate, set the CSS and template filter.
15 * @todo document
16 * @ingroup Skins
17 */
18 class SkinModern extends SkinTemplate {
19 /*
20 * We don't like the default getPoweredBy, the icon clashes with the
21 * skin L&F.
22 */
23 function getPoweredBy() {
24 global $wgVersion;
25 return "<div class='mw_poweredby'>Powered by MediaWiki $wgVersion</div>";
26 }
27
28 function initPage( &$out ) {
29 SkinTemplate::initPage( $out );
30 $this->skinname = 'modern';
31 $this->stylename = 'modern';
32 $this->template = 'ModernTemplate';
33 }
34 }
35
36 /**
37 * @todo document
38 * @ingroup Skins
39 */
40 class ModernTemplate extends QuickTemplate {
41 var $skin;
42 /**
43 * Template filter callback for Modern skin.
44 * Takes an associative array of data set from a SkinTemplate-based
45 * class, and a wrapper for MediaWiki's localization database, and
46 * outputs a formatted page.
47 *
48 * @access private
49 */
50 function execute() {
51 global $wgUser, $wgRequest;
52 $this->skin = $skin = $wgUser->getSkin();
53 $action = $wgRequest->getText( 'action' );
54
55 // Suppress warnings to prevent notices about missing indexes in $this->data
56 wfSuppressWarnings();
57
58 ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
59 <html xmlns="<?php $this->text('xhtmldefaultnamespace') ?>" <?php
60 foreach($this->data['xhtmlnamespaces'] as $tag => $ns) {
61 ?>xmlns:<?php echo "{$tag}=\"{$ns}\" ";
62 } ?>xml:lang="<?php $this->text('lang') ?>" lang="<?php $this->text('lang') ?>" dir="<?php $this->text('dir') ?>">
63 <head>
64 <meta http-equiv="Content-Type" content="<?php $this->text('mimetype') ?>; charset=<?php $this->text('charset') ?>" />
65 <?php $this->html('headlinks') ?>
66 <title><?php $this->text('pagetitle') ?></title>
67 <?php if(empty($this->data['printable']) ) { ?>
68 <style type="text/css" media="screen, projection">/*<![CDATA[*/
69 @import "<?php $this->text('stylepath') ?>/common/shared.css?<?php echo $GLOBALS['wgStyleVersion'] ?>";
70 @import "<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/main.css?<?php echo $GLOBALS['wgStyleVersion'] ?>";
71 /*]]>*/</style>
72 <?php } ?>
73 <link rel="stylesheet" type="text/css" <?php if(empty($this->data['printable']) ) { ?>media="print"<?php } ?> href="<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/print.css?<?php echo $GLOBALS['wgStyleVersion'] ?>" />
74 <!--[if lt IE 7]><meta http-equiv="imagetoolbar" content="no" /><![endif]-->
75
76 <?php print Skin::makeGlobalVariablesScript( $this->data ); ?>
77
78 <script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('stylepath' ) ?>/common/wikibits.js?<?php echo $GLOBALS['wgStyleVersion'] ?>"><!-- wikibits js --></script>
79 <!-- Head Scripts -->
80 <?php $this->html('headscripts') ?>
81 <?php if($this->data['jsvarurl' ]) { ?>
82 <script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('jsvarurl' ) ?>"><!-- site js --></script>
83 <?php } ?>
84 <?php if($this->data['pagecss' ]) { ?>
85 <style type="text/css"><?php $this->html('pagecss' ) ?></style>
86 <?php }
87 if($this->data['usercss' ]) { ?>
88 <style type="text/css"><?php $this->html('usercss' ) ?></style>
89 <?php }
90 if($this->data['userjs' ]) { ?>
91 <script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('userjs' ) ?>"></script>
92 <?php }
93 if($this->data['userjsprev']) { ?>
94 <script type="<?php $this->text('jsmimetype') ?>"><?php $this->html('userjsprev') ?></script>
95 <?php }
96 if($this->data['trackbackhtml']) print $this->data['trackbackhtml']; ?>
97 </head>
98 <body<?php if($this->data['body_ondblclick']) { ?> ondblclick="<?php $this->text('body_ondblclick') ?>"<?php } ?>
99 <?php if($this->data['body_onload' ]) { ?> onload="<?php $this->text('body_onload') ?>"<?php } ?>
100 class="mediawiki <?php $this->text('nsclass') ?> <?php $this->text('dir') ?> <?php $this->text('pageclass') ?>">
101
102 <!-- heading -->
103 <div id="mw_header">
104 <h1 id="firstHeading"><?php $this->data['displaytitle']!=""?$this->html('title'):$this->text('title') ?></h1>
105 </div>
106
107 <div id="mw_main">
108 <div id="mw_contentwrapper">
109 <!-- navigation portlet -->
110 <div id="p-cactions" class="portlet">
111 <h5><?php $this->msg('views') ?></h5>
112 <div class="pBody">
113 <ul>
114 <?php foreach($this->data['content_actions'] as $key => $tab) {
115 echo '
116 <li id="ca-' . Sanitizer::escapeId($key).'"';
117 if( $tab['class'] ) {
118 echo ' class="'.htmlspecialchars($tab['class']).'"';
119 }
120 echo'><a href="'.htmlspecialchars($tab['href']).'"';
121 # We don't want to give the watch tab an accesskey if the
122 # page is being edited, because that conflicts with the
123 # accesskey on the watch checkbox. We also don't want to
124 # give the edit tab an accesskey, because that's fairly su-
125 # perfluous and conflicts with an accesskey (Ctrl-E) often
126 # used for editing in Safari.
127 if( in_array( $action, array( 'edit', 'submit' ) )
128 && in_array( $key, array( 'edit', 'watch', 'unwatch' ))) {
129 echo $skin->tooltip( "ca-$key" );
130 } else {
131 echo $skin->tooltipAndAccesskey( "ca-$key" );
132 }
133 echo '>'.htmlspecialchars($tab['text']).'</a></li>';
134 } ?>
135 </ul>
136 </div>
137 </div>
138
139 <!-- content -->
140 <div id="mw_content">
141 <!-- contentholder does nothing by default, but it allows users to style the text inside
142 the content area without affecting the meaning of 'em' in #mw_content, which is used
143 for the margins -->
144 <div id="mw_contentholder">
145 <div class='mw-topboxes'>
146 <div class="mw-topbox" id="siteSub"><?php $this->msg('tagline') ?></div>
147 <?php if($this->data['newtalk'] ) {
148 ?><div class="usermessage mw-topbox"><?php $this->html('newtalk') ?></div>
149 <?php } ?>
150 <?php if($this->data['sitenotice']) {
151 ?><div class="mw-topbox" id="siteNotice"><?php $this->html('sitenotice') ?></div>
152 <?php } ?>
153 </div>
154
155 <div id="contentSub"><?php $this->html('subtitle') ?></div>
156
157 <?php if($this->data['undelete']) { ?><div id="contentSub2"><?php $this->html('undelete') ?></div><?php } ?>
158 <?php if($this->data['showjumplinks']) { ?><div id="jump-to-nav"><?php $this->msg('jumpto') ?> <a href="#mw_portlets"><?php $this->msg('jumptonavigation') ?></a>, <a href="#searchInput"><?php $this->msg('jumptosearch') ?></a></div><?php } ?>
159
160 <?php $this->html('bodytext') ?>
161 <div class='mw_clear'></div>
162 <?php if($this->data['catlinks']) { $this->html('catlinks'); } ?>
163 </div><!-- mw_contentholder -->
164 </div><!-- mw_content -->
165 </div><!-- mw_contentwrapper -->
166
167 <div id="mw_portlets">
168
169 <!-- portlets -->
170 <?php
171 $sidebar = $this->data['sidebar'];
172 if ( !isset( $sidebar['SEARCH'] ) ) $sidebar['SEARCH'] = true;
173 if ( !isset( $sidebar['TOOLBOX'] ) ) $sidebar['TOOLBOX'] = true;
174 if ( !isset( $sidebar['LANGUAGES'] ) ) $sidebar['LANGUAGES'] = true;
175
176 foreach ($sidebar as $boxName => $cont) {
177 if ( $boxName == 'SEARCH' ) {
178 $this->searchBox();
179 } elseif ( $boxName == 'TOOLBOX' ) {
180 $this->toolbox();
181 } elseif ( $boxName == 'LANGUAGES' ) {
182 $this->languageBox();
183 } else {
184 $this->customBox( $boxName, $cont );
185 }
186 }
187 ?>
188
189 </div><!-- mw_portlets -->
190
191
192 </div><!-- main -->
193
194 <div class="mw_clear"></div>
195
196 <!-- personal portlet -->
197 <div class="portlet" id="p-personal">
198 <h5><?php $this->msg('personaltools') ?></h5>
199 <div class="pBody">
200 <ul>
201 <?php foreach($this->data['personal_urls'] as $key => $item) { ?>
202 <li id="pt-<?php echo Sanitizer::escapeId($key) ?>"<?php
203 if ($item['active']) { ?> class="active"<?php } ?>><a href="<?php
204 echo htmlspecialchars($item['href']) ?>"<?php echo $skin->tooltipAndAccesskey('pt-'.$key) ?><?php
205 if(!empty($item['class'])) { ?> class="<?php
206 echo htmlspecialchars($item['class']) ?>"<?php } ?>><?php
207 echo htmlspecialchars($item['text']) ?></a></li>
208 <?php } ?>
209 </ul>
210 </div>
211 </div>
212
213
214 <!-- footer -->
215 <div id="footer">
216 <ul id="f-list">
217 <?php
218 $footerlinks = array(
219 'lastmod', 'viewcount', 'numberofwatchingusers', 'credits', 'copyright',
220 'privacy', 'about', 'disclaimer', 'tagline',
221 );
222 foreach( $footerlinks as $aLink ) {
223 if( isset( $this->data[$aLink] ) && $this->data[$aLink] ) {
224 ?> <li id="<?php echo$aLink?>"><?php $this->html($aLink) ?></li>
225 <?php }
226 }
227 ?>
228 </ul>
229 <?php echo $this->html("poweredbyico"); ?>
230 </div>
231
232 <?php $this->html('bottomscripts'); /* JS call to runBodyOnloadHook */ ?>
233 <?php $this->html('reporttime') ?>
234 <?php if ( $this->data['debug'] ): ?>
235 <!-- Debug output:
236 <?php $this->text( 'debug' ); ?>
237 -->
238 <?php endif; ?>
239 </body></html>
240 <?php
241 wfRestoreWarnings();
242 } // end of execute() method
243
244 /*************************************************************************************************/
245 function searchBox() {
246 ?>
247 <!-- search -->
248 <div id="p-search" class="portlet">
249 <h5><label for="searchInput"><?php $this->msg('search') ?></label></h5>
250 <div id="searchBody" class="pBody">
251 <form action="<?php $this->text('searchaction') ?>" id="searchform"><div>
252 <input id="searchInput" name="search" type="text"<?php echo $this->skin->tooltipAndAccesskey('search');
253 if( isset( $this->data['search'] ) ) {
254 ?> value="<?php $this->text('search') ?>"<?php } ?> />
255 <input type='submit' name="go" class="searchButton" id="searchGoButton" value="<?php $this->msg('searcharticle') ?>"<?php echo $this->skin->tooltipAndAccesskey( 'search-go' ); ?> />&nbsp;
256 <input type='submit' name="fulltext" class="searchButton" id="mw-searchButton" value="<?php $this->msg('searchbutton') ?>"<?php echo $this->skin->tooltipAndAccesskey( 'search-fulltext' ); ?> />
257 </div></form>
258 </div><!-- pBody -->
259 </div><!-- portlet -->
260 <?php
261 }
262
263 /*************************************************************************************************/
264 function toolbox() {
265 ?>
266 <!-- toolbox -->
267 <div class="portlet" id="p-tb">
268 <h5><?php $this->msg('toolbox') ?></h5>
269 <div class="pBody">
270 <ul>
271 <?php
272 if($this->data['notspecialpage']) { ?>
273 <li id="t-whatlinkshere"><a href="<?php
274 echo htmlspecialchars($this->data['nav_urls']['whatlinkshere']['href'])
275 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-whatlinkshere') ?>><?php $this->msg('whatlinkshere') ?></a></li>
276 <?php
277 if( $this->data['nav_urls']['recentchangeslinked'] ) { ?>
278 <li id="t-recentchangeslinked"><a href="<?php
279 echo htmlspecialchars($this->data['nav_urls']['recentchangeslinked']['href'])
280 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-recentchangeslinked') ?>><?php $this->msg('recentchangeslinked') ?></a></li>
281 <?php }
282 }
283 if(isset($this->data['nav_urls']['trackbacklink'])) { ?>
284 <li id="t-trackbacklink"><a href="<?php
285 echo htmlspecialchars($this->data['nav_urls']['trackbacklink']['href'])
286 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-trackbacklink') ?>><?php $this->msg('trackbacklink') ?></a></li>
287 <?php }
288 if($this->data['feeds']) { ?>
289 <li id="feedlinks"><?php foreach($this->data['feeds'] as $key => $feed) {
290 ?><span id="feed-<?php echo Sanitizer::escapeId($key) ?>"><a href="<?php
291 echo htmlspecialchars($feed['href']) ?>"<?php echo $this->skin->tooltipAndAccesskey('feed-'.$key) ?>><?php echo htmlspecialchars($feed['text'])?></a>&nbsp;</span>
292 <?php } ?></li><?php
293 }
294
295 foreach( array('contributions', 'log', 'blockip', 'emailuser', 'upload', 'specialpages') as $special ) {
296
297 if($this->data['nav_urls'][$special]) {
298 ?><li id="t-<?php echo $special ?>"><a href="<?php echo htmlspecialchars($this->data['nav_urls'][$special]['href'])
299 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-'.$special) ?>><?php $this->msg($special) ?></a></li>
300 <?php }
301 }
302
303 if(!empty($this->data['nav_urls']['print']['href'])) { ?>
304 <li id="t-print"><a href="<?php echo htmlspecialchars($this->data['nav_urls']['print']['href'])
305 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-print') ?>><?php $this->msg('printableversion') ?></a></li><?php
306 }
307
308 if(!empty($this->data['nav_urls']['permalink']['href'])) { ?>
309 <li id="t-permalink"><a href="<?php echo htmlspecialchars($this->data['nav_urls']['permalink']['href'])
310 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-permalink') ?>><?php $this->msg('permalink') ?></a></li><?php
311 } elseif ($this->data['nav_urls']['permalink']['href'] === '') { ?>
312 <li id="t-ispermalink"<?php echo $this->skin->tooltip('t-ispermalink') ?>><?php $this->msg('permalink') ?></li><?php
313 }
314
315 wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this ) );
316 ?> </ul>
317 </div><!-- pBody -->
318 </div><!-- portlet -->
319 <?php
320 }
321
322 /*************************************************************************************************/
323 function languageBox() {
324 ?>
325 <!-- languages -->
326 <?php
327 if( $this->data['language_urls'] ) { ?>
328 <div id="p-lang" class="portlet">
329 <h5><?php $this->msg('otherlanguages') ?></h5>
330 <div class="pBody">
331 <ul>
332 <?php foreach($this->data['language_urls'] as $langlink) { ?>
333 <li class="<?php echo htmlspecialchars($langlink['class'])?>"><?php
334 ?><a href="<?php echo htmlspecialchars($langlink['href']) ?>"><?php echo $langlink['text'] ?></a></li>
335 <?php } ?>
336 </ul>
337 </div><!-- pBody -->
338 </div><!-- portlet -->
339 <?php
340 }
341 }
342
343 /*************************************************************************************************/
344 function customBox( $bar, $cont ) {
345 ?>
346 <div class='generated-sidebar portlet' id='p-<?php echo Sanitizer::escapeId($bar) ?>'<?php echo $this->skin->tooltip('p-'.$bar) ?>>
347 <h5><?php $out = wfMsg( $bar ); if (wfEmptyMsg($bar, $out)) echo $bar; else echo $out; ?></h5>
348 <div class='pBody'>
349 <?php if ( is_array( $cont ) ) { ?>
350 <ul>
351 <?php foreach($cont as $key => $val) { ?>
352 <li id="<?php echo Sanitizer::escapeId($val['id']) ?>"<?php
353 if ( $val['active'] ) { ?> class="active" <?php }
354 ?>><a href="<?php echo htmlspecialchars($val['href']) ?>"<?php echo $this->skin->tooltipAndAccesskey($val['id']) ?>><?php echo htmlspecialchars($val['text']) ?></a></li>
355 <?php } ?>
356 </ul>
357 <?php } else {
358 # allow raw HTML block to be defined by extensions
359 print $cont;
360 }
361 ?>
362 </div><!-- pBody -->
363 </div><!-- portlet -->
364 <?php
365 }
366
367 } // end of class
368 ?>