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