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