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