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