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