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