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