Partial revert of r53320:
[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 function setupSkinUserCss( OutputPage $out ) {
31 global $wgHandheldStyle;
32
33 parent::setupSkinUserCss( $out );
34
35 // Append to the default screen common & print styles...
36 $out->addStyle( 'monobook/main.css', 'screen' );
37 if( $wgHandheldStyle ) {
38 // Currently in testing... try 'chick/main.css'
39 $out->addStyle( $wgHandheldStyle, 'handheld' );
40 }
41
42 $out->addStyle( 'monobook/IE50Fixes.css', 'screen', 'lt IE 5.5000' );
43 $out->addStyle( 'monobook/IE55Fixes.css', 'screen', 'IE 5.5000' );
44 $out->addStyle( 'monobook/IE60Fixes.css', 'screen', 'IE 6' );
45 $out->addStyle( 'monobook/IE70Fixes.css', 'screen', 'IE 7' );
46
47 $out->addStyle( 'monobook/rtl.css', 'screen', '', 'rtl' );
48
49
50 //@@todo we can move this to the parent once we update all skins
51 if( isset( $this->pagecss ) )
52 $out->addInlineStyle( $this->pagecss );
53
54 if( isset( $this->usercss) )
55 $out->addInlineStyle( $this->usercss );
56
57 }
58 function setupSkinUserJs( OutputPage $out ) {
59 parent::setupSkinUserJs( $out );
60 $out->addScriptFile( 'wikibits.js' );
61
62 //@@todo can move to parent once we update all skins (to not include things twice
63 if( isset( $this->jsvarurl ) )
64 $out->addScriptFile( $this->jsvarurl );
65
66 if( isset( $this->userjs ) )
67 $out->addScriptFile( $this->userjs );
68
69 if( isset( $this->userjsprev ) )
70 $out->addInlineScript( $this->userjsprev );
71 }
72 }
73
74 /**
75 * @todo document
76 * @ingroup Skins
77 */
78 class MonoBookTemplate extends QuickTemplate {
79 var $skin;
80 /**
81 * Template filter callback for MonoBook skin.
82 * Takes an associative array of data set from a SkinTemplate-based
83 * class, and a wrapper for MediaWiki's localization database, and
84 * outputs a formatted page.
85 *
86 * @access private
87 */
88 function execute() {
89 global $wgRequest, $wgOut, $wgStyleVersion, $wgJsMimeType, $wgStylePath;
90 $this->skin = $skin = $this->data['skin'];
91 $action = $wgRequest->getText( 'action' );
92
93 // Suppress warnings to prevent notices about missing indexes in $this->data
94 wfSuppressWarnings();
95 # FIXME: What is this? Should it apply to all skins?
96 $path = htmlspecialchars( $wgStylePath );
97 $wgOut->addScript( <<<HTML
98 <!--[if lt IE 7]><script type="$wgJsMimeType" src="$path/common/IEFixes.js?$wgStyleVersion"></script>
99 <meta http-equiv="imagetoolbar" content="no" /><![endif]-->
100 HTML
101 );
102
103 echo $wgOut->headElement( $this->skin );
104
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'); $this->text('capitalizeallnouns') ?> <?php $this->text('pageclass') ?> <?php $this->text('skinnameclass') ?>">
108 <div id="globalWrapper">
109 <div id="column-content">
110 <div id="content">
111 <a id="top"></a>
112 <?php if($this->data['sitenotice']) { ?><div id="siteNotice"><?php $this->html('sitenotice') ?></div><?php } ?>
113 <h1 id="firstHeading" class="firstHeading"><?php $this->html('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 <?php $this->html('userlangattributes') ?>>
134 <?php foreach($this->data['content_actions'] as $key => $tab) {
135 echo '
136 <li id="' . Sanitizer::escapeId( "ca-$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 <?php $this->html('userlangattributes') ?>>
162 <?php foreach($this->data['personal_urls'] as $key => $item) { ?>
163 <li id="<?php echo Sanitizer::escapeId( "pt-$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('p-logo') ?>></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 $footerlinks = array(
209 'lastmod', 'viewcount', 'numberofwatchingusers', 'credits', 'copyright',
210 'privacy', 'about', 'disclaimer', 'tagline',
211 );
212 $validFooterLinks = array();
213 foreach( $footerlinks as $aLink ) {
214 if( isset( $this->data[$aLink] ) && $this->data[$aLink] ) {
215 $validFooterLinks[] = $aLink;
216 }
217 }
218 if ( count( $validFooterLinks ) > 0 ) {
219 ?> <ul id="f-list">
220 <?php
221 foreach( $validFooterLinks as $aLink ) {
222 if( isset( $this->data[$aLink] ) && $this->data[$aLink] ) {
223 ?> <li id="<?php echo $aLink ?>"><?php $this->html($aLink) ?></li>
224 <?php }
225 }
226 ?>
227 </ul>
228 <?php }
229 ?>
230 </div>
231 </div>
232 <?php $this->html('bottomscripts'); /* JS call to runBodyOnloadHook */ ?>
233 <?php $this->html('reporttime') ?>
234 <?php if ( $this->data['debug'] ): ?>
235 <!-- Debug output:
236 <?php $this->text( 'debug' ); ?>
237
238 -->
239 <?php endif; ?>
240 </body></html>
241 <?php
242 wfRestoreWarnings();
243 } // end of execute() method
244
245 /*************************************************************************************************/
246 function searchBox() {
247 global $wgUseTwoButtonsSearchForm;
248 ?>
249 <div id="p-search" class="portlet">
250 <h5 <?php $this->html('userlangattributes') ?>><label for="searchInput"><?php $this->msg('search') ?></label></h5>
251 <div id="searchBody" class="pBody">
252 <form action="<?php $this->text('wgScript') ?>" id="searchform"><div>
253 <input type='hidden' name="title" value="<?php $this->text('searchtitle') ?>"/>
254 <input id="searchInput" name="search" type="text"<?php echo $this->skin->tooltipAndAccesskey('search');
255 if( isset( $this->data['search'] ) ) {
256 ?> value="<?php $this->text('search') ?>"<?php } ?> />
257 <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;
258 <input type='submit' name="fulltext" class="searchButton" id="mw-searchButton" value="<?php $this->msg('searchbutton') ?>"<?php echo $this->skin->tooltipAndAccesskey( 'search-fulltext' ); ?> /><?php } else { ?>
259
260 <div><a href="<?php $this->text('searchaction') ?>" rel="search"><?php $this->msg('powersearch-legend') ?></a></div><?php } ?>
261
262 </div></form>
263 </div>
264 </div>
265 <?php
266 }
267
268 /*************************************************************************************************/
269 function toolbox() {
270 ?>
271 <div class="portlet" id="p-tb">
272 <h5 <?php $this->html('userlangattributes')?>><?php $this->msg('toolbox') ?></h5>
273 <div class="pBody">
274 <ul>
275 <?php
276 if($this->data['notspecialpage']) { ?>
277 <li id="t-whatlinkshere"><a href="<?php
278 echo htmlspecialchars($this->data['nav_urls']['whatlinkshere']['href'])
279 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-whatlinkshere') ?>><?php $this->msg('whatlinkshere') ?></a></li>
280 <?php
281 if( $this->data['nav_urls']['recentchangeslinked'] ) { ?>
282 <li id="t-recentchangeslinked"><a href="<?php
283 echo htmlspecialchars($this->data['nav_urls']['recentchangeslinked']['href'])
284 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-recentchangeslinked') ?>><?php $this->msg('recentchangeslinked-toolbox') ?></a></li>
285 <?php }
286 }
287 if(isset($this->data['nav_urls']['trackbacklink'])) { ?>
288 <li id="t-trackbacklink"><a href="<?php
289 echo htmlspecialchars($this->data['nav_urls']['trackbacklink']['href'])
290 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-trackbacklink') ?>><?php $this->msg('trackbacklink') ?></a></li>
291 <?php }
292 if($this->data['feeds']) { ?>
293 <li id="feedlinks"><?php foreach($this->data['feeds'] as $key => $feed) {
294 ?><a id="<?php echo Sanitizer::escapeId( "feed-$key" ) ?>" href="<?php
295 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;
296 <?php } ?></li><?php
297 }
298
299 foreach( array('contributions', 'log', 'blockip', 'emailuser', 'upload', 'specialpages') as $special ) {
300
301 if($this->data['nav_urls'][$special]) {
302 ?><li id="t-<?php echo $special ?>"><a href="<?php echo htmlspecialchars($this->data['nav_urls'][$special]['href'])
303 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-'.$special) ?>><?php $this->msg($special) ?></a></li>
304 <?php }
305 }
306
307 if(!empty($this->data['nav_urls']['print']['href'])) { ?>
308 <li id="t-print"><a href="<?php echo htmlspecialchars($this->data['nav_urls']['print']['href'])
309 ?>" rel="alternate"<?php echo $this->skin->tooltipAndAccesskey('t-print') ?>><?php $this->msg('printableversion') ?></a></li><?php
310 }
311
312 if(!empty($this->data['nav_urls']['permalink']['href'])) { ?>
313 <li id="t-permalink"><a href="<?php echo htmlspecialchars($this->data['nav_urls']['permalink']['href'])
314 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-permalink') ?>><?php $this->msg('permalink') ?></a></li><?php
315 } elseif ($this->data['nav_urls']['permalink']['href'] === '') { ?>
316 <li id="t-ispermalink"<?php echo $this->skin->tooltip('t-ispermalink') ?>><?php $this->msg('permalink') ?></li><?php
317 }
318
319 wfRunHooks( 'MonoBookTemplateToolboxEnd', array( &$this ) );
320 wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this ) );
321 ?>
322 </ul>
323 </div>
324 </div>
325 <?php
326 }
327
328 /*************************************************************************************************/
329 function languageBox() {
330 if( $this->data['language_urls'] ) {
331 ?>
332 <div id="p-lang" class="portlet">
333 <h5 <?php $this->html('userlangattributes') ?>><?php $this->msg('otherlanguages') ?></h5>
334 <div class="pBody">
335 <ul>
336 <?php foreach($this->data['language_urls'] as $langlink) { ?>
337 <li class="<?php echo htmlspecialchars($langlink['class'])?>"><?php
338 ?><a href="<?php echo htmlspecialchars($langlink['href']) ?>"><?php echo $langlink['text'] ?></a></li>
339 <?php } ?>
340 </ul>
341 </div>
342 </div>
343 <?php
344 }
345 }
346
347 /*************************************************************************************************/
348 function customBox( $bar, $cont ) {
349 ?>
350 <div class='generated-sidebar portlet' id='<?php echo Sanitizer::escapeId( "p-$bar" ) ?>'<?php echo $this->skin->tooltip('p-'.$bar) ?>>
351 <h5 <?php $this->html('userlangattributes') ?>><?php $out = wfMsg( $bar ); if (wfEmptyMsg($bar, $out)) echo htmlspecialchars($bar); else echo htmlspecialchars($out); ?></h5>
352 <div class='pBody'>
353 <?php if ( is_array( $cont ) ) { ?>
354 <ul>
355 <?php foreach($cont as $key => $val) { ?>
356 <li id="<?php echo Sanitizer::escapeId($val['id']) ?>"<?php
357 if ( $val['active'] ) { ?> class="active" <?php }
358 ?>><a href="<?php echo htmlspecialchars($val['href']) ?>"<?php echo $this->skin->tooltipAndAccesskey($val['id']) ?>><?php echo htmlspecialchars($val['text']) ?></a></li>
359 <?php } ?>
360 </ul>
361 <?php } else {
362 # allow raw HTML block to be defined by extensions
363 print $cont;
364 }
365 ?>
366 </div>
367 </div>
368 <?php
369 }
370 } // end of class
371
372