Unused since r74966 $wgHandheldStyle is handled by the resourceloader.
[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 // TODO: Migrate all of these
32 //$out->addStyle( 'monobook/IE50Fixes.css', 'screen', 'lt IE 5.5000' );
33 //$out->addStyle( 'monobook/IE55Fixes.css', 'screen', 'IE 5.5000' );
34 //$out->addStyle( 'monobook/IE60Fixes.css', 'screen', 'IE 6' );
35 //$out->addStyle( 'monobook/IE70Fixes.css', 'screen', 'IE 7' );
36
37 // TODO: migrate
38 //$out->addStyle( 'monobook/rtl.css', 'screen', '', 'rtl' );
39
40 }
41 }
42
43 /**
44 * @todo document
45 * @ingroup Skins
46 */
47 class MonoBookTemplate extends QuickTemplate {
48 var $skin;
49 /**
50 * Template filter callback for MonoBook skin.
51 * Takes an associative array of data set from a SkinTemplate-based
52 * class, and a wrapper for MediaWiki's localization database, and
53 * outputs a formatted page.
54 *
55 * @access private
56 */
57 function execute() {
58 global $wgRequest;
59
60 $this->skin = $skin = $this->data['skin'];
61 $action = $wgRequest->getText( 'action' );
62
63 // Suppress warnings to prevent notices about missing indexes in $this->data
64 wfSuppressWarnings();
65
66 $this->html( 'headelement' );
67 ?><div id="globalWrapper">
68 <div id="column-content"><div id="content"<?php $this->html("specialpageattributes") ?>>
69 <a id="top"></a>
70 <?php if($this->data['sitenotice']) { ?><div id="siteNotice"><?php $this->html('sitenotice') ?></div><?php } ?>
71
72 <h1 id="firstHeading" class="firstHeading"><?php $this->html('title') ?></h1>
73 <div id="bodyContent">
74 <div id="siteSub"><?php $this->msg('tagline') ?></div>
75 <div id="contentSub"<?php $this->html('userlangattributes') ?>><?php $this->html('subtitle') ?></div>
76 <?php if($this->data['undelete']) { ?>
77 <div id="contentSub2"><?php $this->html('undelete') ?></div>
78 <?php } ?><?php if($this->data['newtalk'] ) { ?>
79 <div class="usermessage"><?php $this->html('newtalk') ?></div>
80 <?php } ?><?php if($this->data['showjumplinks']) { ?>
81 <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>
82 <?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></div>
91 <div id="column-one"<?php $this->html('userlangattributes') ?>>
92 <div id="p-cactions" class="portlet">
93 <h5><?php $this->msg('views') ?></h5>
94 <div class="pBody">
95 <ul><?php
96 foreach($this->data['content_actions'] as $key => $tab) {
97 echo '
98 <li id="' . Sanitizer::escapeId( "ca-$key" ) . '"';
99 if( $tab['class'] ) {
100 echo ' class="'.htmlspecialchars($tab['class']).'"';
101 }
102 echo '><a href="'.htmlspecialchars($tab['href']).'"';
103 # We don't want to give the watch tab an accesskey if the
104 # page is being edited, because that conflicts with the
105 # accesskey on the watch checkbox. We also don't want to
106 # give the edit tab an accesskey, because that's fairly su-
107 # perfluous and conflicts with an accesskey (Ctrl-E) often
108 # used for editing in Safari.
109 if( in_array( $action, array( 'edit', 'submit' ) )
110 && in_array( $key, array( 'edit', 'watch', 'unwatch' ))) {
111 echo $skin->tooltip( "ca-$key" );
112 } else {
113 echo $skin->tooltipAndAccesskey( "ca-$key" );
114 }
115 echo '>'.htmlspecialchars($tab['text']).'</a></li>';
116 } ?>
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
204 echo Html::closeElement( 'body' );
205 echo Html::closeElement( 'html' );
206 wfRestoreWarnings();
207 } // end of execute() method
208
209 /*************************************************************************************************/
210 function searchBox() {
211 global $wgUseTwoButtonsSearchForm;
212 ?>
213 <div id="p-search" class="portlet">
214 <h5><label for="searchInput"><?php $this->msg('search') ?></label></h5>
215 <div id="searchBody" class="pBody">
216 <form action="<?php $this->text('wgScript') ?>" id="searchform">
217 <input type='hidden' name="title" value="<?php $this->text('searchtitle') ?>"/>
218 <?php
219 echo Html::input( 'search',
220 isset( $this->data['search'] ) ? $this->data['search'] : '', 'search',
221 array(
222 'id' => 'searchInput',
223 'title' => $this->skin->titleAttrib( 'search' ),
224 'accesskey' => $this->skin->accesskey( 'search' )
225 ) ); ?>
226
227 <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;
228 <input type='submit' name="fulltext" class="searchButton" id="mw-searchButton" value="<?php $this->msg('searchbutton') ?>"<?php echo $this->skin->tooltipAndAccesskey( 'search-fulltext' ); ?> /><?php } else { ?>
229
230 <div><a href="<?php $this->text('searchaction') ?>" rel="search"><?php $this->msg('powersearch-legend') ?></a></div><?php } ?>
231
232 </form>
233 </div>
234 </div>
235 <?php
236 }
237
238 /*************************************************************************************************/
239 function toolbox() {
240 ?>
241 <div class="portlet" id="p-tb">
242 <h5><?php $this->msg('toolbox') ?></h5>
243 <div class="pBody">
244 <ul>
245 <?php
246 if($this->data['notspecialpage']) { ?>
247 <li id="t-whatlinkshere"><a href="<?php
248 echo htmlspecialchars($this->data['nav_urls']['whatlinkshere']['href'])
249 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-whatlinkshere') ?>><?php $this->msg('whatlinkshere') ?></a></li>
250 <?php
251 if( $this->data['nav_urls']['recentchangeslinked'] ) { ?>
252 <li id="t-recentchangeslinked"><a href="<?php
253 echo htmlspecialchars($this->data['nav_urls']['recentchangeslinked']['href'])
254 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-recentchangeslinked') ?>><?php $this->msg('recentchangeslinked-toolbox') ?></a></li>
255 <?php }
256 }
257 if( isset( $this->data['nav_urls']['trackbacklink'] ) && $this->data['nav_urls']['trackbacklink'] ) { ?>
258 <li id="t-trackbacklink"><a href="<?php
259 echo htmlspecialchars($this->data['nav_urls']['trackbacklink']['href'])
260 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-trackbacklink') ?>><?php $this->msg('trackbacklink') ?></a></li>
261 <?php }
262 if($this->data['feeds']) { ?>
263 <li id="feedlinks"><?php foreach($this->data['feeds'] as $key => $feed) {
264 ?><a id="<?php echo Sanitizer::escapeId( "feed-$key" ) ?>" href="<?php
265 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;
266 <?php } ?></li><?php
267 }
268
269 foreach( array('contributions', 'log', 'blockip', 'emailuser', 'upload', 'specialpages') as $special ) {
270
271 if($this->data['nav_urls'][$special]) {
272 ?><li id="t-<?php echo $special ?>"><a href="<?php echo htmlspecialchars($this->data['nav_urls'][$special]['href'])
273 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-'.$special) ?>><?php $this->msg($special) ?></a></li>
274 <?php }
275 }
276
277 if(!empty($this->data['nav_urls']['print']['href'])) { ?>
278 <li id="t-print"><a href="<?php echo htmlspecialchars($this->data['nav_urls']['print']['href'])
279 ?>" rel="alternate"<?php echo $this->skin->tooltipAndAccesskey('t-print') ?>><?php $this->msg('printableversion') ?></a></li><?php
280 }
281
282 if(!empty($this->data['nav_urls']['permalink']['href'])) { ?>
283 <li id="t-permalink"><a href="<?php echo htmlspecialchars($this->data['nav_urls']['permalink']['href'])
284 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-permalink') ?>><?php $this->msg('permalink') ?></a></li><?php
285 } elseif ($this->data['nav_urls']['permalink']['href'] === '') { ?>
286 <li id="t-ispermalink"<?php echo $this->skin->tooltip('t-ispermalink') ?>><?php $this->msg('permalink') ?></li><?php
287 }
288
289 wfRunHooks( 'MonoBookTemplateToolboxEnd', array( &$this ) );
290 wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this ) );
291 ?>
292 </ul>
293 </div>
294 </div>
295 <?php
296 }
297
298 /*************************************************************************************************/
299 function languageBox() {
300 if( $this->data['language_urls'] ) {
301 ?>
302 <div id="p-lang" class="portlet">
303 <h5<?php $this->html('userlangattributes') ?>><?php $this->msg('otherlanguages') ?></h5>
304 <div class="pBody">
305 <ul>
306 <?php foreach($this->data['language_urls'] as $langlink) { ?>
307 <li class="<?php echo htmlspecialchars($langlink['class'])?>"><?php
308 ?><a href="<?php echo htmlspecialchars($langlink['href']) ?>" title="<?php
309 echo htmlspecialchars($langlink['title']) ?>"><?php echo $langlink['text'] ?></a></li>
310 <?php } ?>
311 </ul>
312 </div>
313 </div>
314 <?php
315 }
316 }
317
318 /*************************************************************************************************/
319 function customBox( $bar, $cont ) {
320 ?>
321 <div class='generated-sidebar portlet' id='<?php echo Sanitizer::escapeId( "p-$bar" ) ?>'<?php echo $this->skin->tooltip('p-'.$bar) ?>>
322 <h5><?php $out = wfMsg( $bar ); if (wfEmptyMsg($bar, $out)) echo htmlspecialchars($bar); else echo htmlspecialchars($out); ?></h5>
323 <div class='pBody'>
324 <?php if ( is_array( $cont ) ) { ?>
325 <ul>
326 <?php foreach($cont as $val) { ?>
327 <li id="<?php echo Sanitizer::escapeId($val['id']) ?>"<?php
328 if ( $val['active'] ) { ?> class="active" <?php }
329 ?>><a href="<?php echo htmlspecialchars($val['href']) ?>"<?php echo $this->skin->tooltipAndAccesskey($val['id']) ?>><?php echo htmlspecialchars($val['text']) ?></a></li>
330 <?php } ?>
331 </ul>
332 <?php } else {
333 # allow raw HTML block to be defined by extensions
334 print $cont;
335 }
336 ?>
337 </div>
338 </div>
339 <?php
340 }
341 } // end of class
342
343