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