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