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