86248eebdd68a9ee570421255aa05e8d8abb8f46
[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('nsclass') ?> <?php $this->text('dir') ?> <?php $this->text('pageclass') ?> <?php $this->text('skinclass') ?>">
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 <div class="visualClear"></div>
125 </div>
126 </div>
127 </div>
128 <div id="column-one">
129 <div id="p-cactions" class="portlet">
130 <h5><?php $this->msg('views') ?></h5>
131 <div class="pBody">
132 <ul>
133 <?php foreach($this->data['content_actions'] as $key => $tab) {
134 echo '
135 <li id="ca-' . Sanitizer::escapeId($key).'"';
136 if( $tab['class'] ) {
137 echo ' class="'.htmlspecialchars($tab['class']).'"';
138 }
139 echo'><a href="'.htmlspecialchars($tab['href']).'"';
140 # We don't want to give the watch tab an accesskey if the
141 # page is being edited, because that conflicts with the
142 # accesskey on the watch checkbox. We also don't want to
143 # give the edit tab an accesskey, because that's fairly su-
144 # perfluous and conflicts with an accesskey (Ctrl-E) often
145 # used for editing in Safari.
146 if( in_array( $action, array( 'edit', 'submit' ) )
147 && in_array( $key, array( 'edit', 'watch', 'unwatch' ))) {
148 echo $skin->tooltip( "ca-$key" );
149 } else {
150 echo $skin->tooltipAndAccesskey( "ca-$key" );
151 }
152 echo '>'.htmlspecialchars($tab['text']).'</a></li>';
153 } ?>
154 </ul>
155 </div>
156 </div>
157 <div class="portlet" id="p-personal">
158 <h5><?php $this->msg('personaltools') ?></h5>
159 <div class="pBody">
160 <ul>
161 <?php foreach($this->data['personal_urls'] as $key => $item) { ?>
162 <li id="pt-<?php echo Sanitizer::escapeId($key) ?>"<?php
163 if ($item['active']) { ?> class="active"<?php } ?>><a href="<?php
164 echo htmlspecialchars($item['href']) ?>"<?php echo $skin->tooltipAndAccesskey('pt-'.$key) ?><?php
165 if(!empty($item['class'])) { ?> class="<?php
166 echo htmlspecialchars($item['class']) ?>"<?php } ?>><?php
167 echo htmlspecialchars($item['text']) ?></a></li>
168 <?php } ?>
169 </ul>
170 </div>
171 </div>
172 <div class="portlet" id="p-logo">
173 <a style="background-image: url(<?php $this->text('logopath') ?>);" <?php
174 ?>href="<?php echo htmlspecialchars($this->data['nav_urls']['mainpage']['href'])?>"<?php
175 echo $skin->tooltipAndAccesskey('n-mainpage') ?>></a>
176 </div>
177 <script type="<?php $this->text('jsmimetype') ?>"> if (window.isMSIE55) fixalpha(); </script>
178 <?php
179 $sidebar = $this->data['sidebar'];
180 if ( !isset( $sidebar['SEARCH'] ) ) $sidebar['SEARCH'] = true;
181 if ( !isset( $sidebar['TOOLBOX'] ) ) $sidebar['TOOLBOX'] = true;
182 if ( !isset( $sidebar['LANGUAGES'] ) ) $sidebar['LANGUAGES'] = true;
183 foreach ($sidebar as $boxName => $cont) {
184 if ( $boxName == 'SEARCH' ) {
185 $this->searchBox();
186 } elseif ( $boxName == 'TOOLBOX' ) {
187 $this->toolbox();
188 } elseif ( $boxName == 'LANGUAGES' ) {
189 $this->languageBox();
190 } else {
191 $this->customBox( $boxName, $cont );
192 }
193 }
194 ?>
195 </div><!-- end of the left (by default at least) column -->
196 <div class="visualClear"></div>
197 <div id="footer">
198 <?php
199 if($this->data['poweredbyico']) { ?>
200 <div id="f-poweredbyico"><?php $this->html('poweredbyico') ?></div>
201 <?php }
202 if($this->data['copyrightico']) { ?>
203 <div id="f-copyrightico"><?php $this->html('copyrightico') ?></div>
204 <?php }
205
206 // Generate additional footer links
207 ?>
208 <ul id="f-list">
209 <?php
210 $footerlinks = array(
211 'lastmod', 'viewcount', 'numberofwatchingusers', 'credits', 'copyright',
212 'privacy', 'about', 'disclaimer', 'tagline',
213 );
214 foreach( $footerlinks as $aLink ) {
215 if( isset( $this->data[$aLink] ) && $this->data[$aLink] ) {
216 ?> <li id="<?php echo$aLink?>"><?php $this->html($aLink) ?></li>
217 <?php }
218 }
219 ?>
220 </ul>
221 </div>
222 </div>
223 <?php $this->html('bottomscripts'); /* JS call to runBodyOnloadHook */ ?>
224 <?php $this->html('reporttime') ?>
225 <?php if ( $this->data['debug'] ): ?>
226 <!-- Debug output:
227 <?php $this->text( 'debug' ); ?>
228
229 -->
230 <?php endif; ?>
231 </body></html>
232 <?php
233 wfRestoreWarnings();
234 } // end of execute() method
235
236 /*************************************************************************************************/
237 function searchBox() {
238 ?>
239 <div id="p-search" class="portlet">
240 <h5><label for="searchInput"><?php $this->msg('search') ?></label></h5>
241 <div id="searchBody" class="pBody">
242 <form action="<?php $this->text('searchaction') ?>" id="searchform"><div>
243 <input id="searchInput" name="search" type="text"<?php echo $this->skin->tooltipAndAccesskey('search');
244 if( isset( $this->data['search'] ) ) {
245 ?> value="<?php $this->text('search') ?>"<?php } ?> />
246 <input type='submit' name="go" class="searchButton" id="searchGoButton" value="<?php $this->msg('searcharticle') ?>"<?php echo $this->skin->tooltipAndAccesskey( 'search-go' ); ?> />&nbsp;
247 <input type='submit' name="fulltext" class="searchButton" id="mw-searchButton" value="<?php $this->msg('searchbutton') ?>"<?php echo $this->skin->tooltipAndAccesskey( 'search-fulltext' ); ?> />
248 </div></form>
249 </div>
250 </div>
251 <?php
252 }
253
254 /*************************************************************************************************/
255 function toolbox() {
256 ?>
257 <div class="portlet" id="p-tb">
258 <h5><?php $this->msg('toolbox') ?></h5>
259 <div class="pBody">
260 <ul>
261 <?php
262 if($this->data['notspecialpage']) { ?>
263 <li id="t-whatlinkshere"><a href="<?php
264 echo htmlspecialchars($this->data['nav_urls']['whatlinkshere']['href'])
265 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-whatlinkshere') ?>><?php $this->msg('whatlinkshere') ?></a></li>
266 <?php
267 if( $this->data['nav_urls']['recentchangeslinked'] ) { ?>
268 <li id="t-recentchangeslinked"><a href="<?php
269 echo htmlspecialchars($this->data['nav_urls']['recentchangeslinked']['href'])
270 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-recentchangeslinked') ?>><?php $this->msg('recentchangeslinked') ?></a></li>
271 <?php }
272 }
273 if(isset($this->data['nav_urls']['trackbacklink'])) { ?>
274 <li id="t-trackbacklink"><a href="<?php
275 echo htmlspecialchars($this->data['nav_urls']['trackbacklink']['href'])
276 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-trackbacklink') ?>><?php $this->msg('trackbacklink') ?></a></li>
277 <?php }
278 if($this->data['feeds']) { ?>
279 <li id="feedlinks"><?php foreach($this->data['feeds'] as $key => $feed) {
280 ?><span id="feed-<?php echo Sanitizer::escapeId($key) ?>"><a href="<?php
281 echo htmlspecialchars($feed['href']) ?>"<?php echo $this->skin->tooltipAndAccesskey('feed-'.$key) ?>><?php echo htmlspecialchars($feed['text'])?></a>&nbsp;</span>
282 <?php } ?></li><?php
283 }
284
285 foreach( array('contributions', 'log', 'blockip', 'emailuser', 'upload', 'specialpages') as $special ) {
286
287 if($this->data['nav_urls'][$special]) {
288 ?><li id="t-<?php echo $special ?>"><a href="<?php echo htmlspecialchars($this->data['nav_urls'][$special]['href'])
289 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-'.$special) ?>><?php $this->msg($special) ?></a></li>
290 <?php }
291 }
292
293 if(!empty($this->data['nav_urls']['print']['href'])) { ?>
294 <li id="t-print"><a href="<?php echo htmlspecialchars($this->data['nav_urls']['print']['href'])
295 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-print') ?>><?php $this->msg('printableversion') ?></a></li><?php
296 }
297
298 if(!empty($this->data['nav_urls']['permalink']['href'])) { ?>
299 <li id="t-permalink"><a href="<?php echo htmlspecialchars($this->data['nav_urls']['permalink']['href'])
300 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-permalink') ?>><?php $this->msg('permalink') ?></a></li><?php
301 } elseif ($this->data['nav_urls']['permalink']['href'] === '') { ?>
302 <li id="t-ispermalink"<?php echo $this->skin->tooltip('t-ispermalink') ?>><?php $this->msg('permalink') ?></li><?php
303 }
304
305 wfRunHooks( 'MonoBookTemplateToolboxEnd', array( &$this ) );
306 wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this ) );
307 ?>
308 </ul>
309 </div>
310 </div>
311 <?php
312 }
313
314 /*************************************************************************************************/
315 function languageBox() {
316 if( $this->data['language_urls'] ) {
317 ?>
318 <div id="p-lang" class="portlet">
319 <h5><?php $this->msg('otherlanguages') ?></h5>
320 <div class="pBody">
321 <ul>
322 <?php foreach($this->data['language_urls'] as $langlink) { ?>
323 <li class="<?php echo htmlspecialchars($langlink['class'])?>"><?php
324 ?><a href="<?php echo htmlspecialchars($langlink['href']) ?>"><?php echo $langlink['text'] ?></a></li>
325 <?php } ?>
326 </ul>
327 </div>
328 </div>
329 <?php
330 }
331 }
332
333 /*************************************************************************************************/
334 function customBox( $bar, $cont ) {
335 ?>
336 <div class='generated-sidebar portlet' id='p-<?php echo Sanitizer::escapeId($bar) ?>'<?php echo $this->skin->tooltip('p-'.$bar) ?>>
337 <h5><?php $out = wfMsg( $bar ); if (wfEmptyMsg($bar, $out)) echo $bar; else echo $out; ?></h5>
338 <div class='pBody'>
339 <?php if ( is_array( $cont ) ) { ?>
340 <ul>
341 <?php foreach($cont as $key => $val) { ?>
342 <li id="<?php echo Sanitizer::escapeId($val['id']) ?>"<?php
343 if ( $val['active'] ) { ?> class="active" <?php }
344 ?>><a href="<?php echo htmlspecialchars($val['href']) ?>"<?php echo $this->skin->tooltipAndAccesskey($val['id']) ?>><?php echo htmlspecialchars($val['text']) ?></a></li>
345 <?php } ?>
346 </ul>
347 <?php } else {
348 # allow raw HTML block to be defined by extensions
349 print $cont;
350 }
351 ?>
352 </div>
353 </div>
354 <?php
355 }
356
357 } // end of class
358
359