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