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