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