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