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