Allow the search box, toolbox and languages box in the Monobook sidebar to be moved...
[lhc/web/wiklou.git] / skins / Modern.php
1 <?php
2 /**
3 * Modern skin, derived from monobook template.
4 *
5 * @todo document
6 * @file
7 * @ingroup Skins
8 */
9
10 if( !defined( 'MEDIAWIKI' ) )
11 die( -1 );
12
13 /**
14 * Inherit main code from SkinTemplate, set the CSS and template filter.
15 * @todo document
16 * @ingroup Skins
17 */
18 class SkinModern extends SkinTemplate {
19 /*
20 * We don't like the default getPoweredBy, the icon clashes with the
21 * skin L&F.
22 */
23 function getPoweredBy() {
24 global $wgVersion;
25 return "<div class='mw_poweredby'>Powered by MediaWiki $wgVersion</div>";
26 }
27
28 function initPage( &$out ) {
29 SkinTemplate::initPage( $out );
30 $this->skinname = 'modern';
31 $this->stylename = 'modern';
32 $this->template = 'ModernTemplate';
33 }
34 }
35
36 /**
37 * @todo document
38 * @ingroup Skins
39 */
40 class ModernTemplate extends QuickTemplate {
41 var $skin;
42 /**
43 * Template filter callback for Modern skin.
44 * Takes an associative array of data set from a SkinTemplate-based
45 * class, and a wrapper for MediaWiki's localization database, and
46 * outputs a formatted page.
47 *
48 * @access private
49 */
50 function execute() {
51 global $wgUser;
52 $this->skin = $skin = $wgUser->getSkin();
53
54 // Suppress warnings to prevent notices about missing indexes in $this->data
55 wfSuppressWarnings();
56
57 ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
58 <html xmlns="<?php $this->text('xhtmldefaultnamespace') ?>" <?php
59 foreach($this->data['xhtmlnamespaces'] as $tag => $ns) {
60 ?>xmlns:<?php echo "{$tag}=\"{$ns}\" ";
61 } ?>xml:lang="<?php $this->text('lang') ?>" lang="<?php $this->text('lang') ?>" dir="<?php $this->text('dir') ?>">
62 <head>
63 <meta http-equiv="Content-Type" content="<?php $this->text('mimetype') ?>; charset=<?php $this->text('charset') ?>" />
64 <?php $this->html('headlinks') ?>
65 <title><?php $this->text('pagetitle') ?></title>
66 <?php if(empty($this->data['printable']) ) { ?>
67 <style type="text/css" media="screen, projection">/*<![CDATA[*/
68 @import "<?php $this->text('stylepath') ?>/common/shared.css?<?php echo $GLOBALS['wgStyleVersion'] ?>";
69 @import "<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/main.css?<?php echo $GLOBALS['wgStyleVersion'] ?>";
70 /*]]>*/</style>
71 <?php } ?>
72 <link rel="stylesheet" type="text/css" <?php if(empty($this->data['printable']) ) { ?>media="print"<?php } ?> href="<?php $this->text('stylepath') ?>/<?php $this->text('stylename') ?>/print.css?<?php echo $GLOBALS['wgStyleVersion'] ?>" />
73 <!--[if lt IE 7]><meta http-equiv="imagetoolbar" content="no" /><![endif]-->
74
75 <?php print Skin::makeGlobalVariablesScript( $this->data ); ?>
76
77 <script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('stylepath' ) ?>/common/wikibits.js?<?php echo $GLOBALS['wgStyleVersion'] ?>"><!-- wikibits js --></script>
78 <!-- Head Scripts -->
79 <?php $this->html('headscripts') ?>
80 <?php if($this->data['jsvarurl' ]) { ?>
81 <script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('jsvarurl' ) ?>"><!-- site js --></script>
82 <?php } ?>
83 <?php if($this->data['pagecss' ]) { ?>
84 <style type="text/css"><?php $this->html('pagecss' ) ?></style>
85 <?php }
86 if($this->data['usercss' ]) { ?>
87 <style type="text/css"><?php $this->html('usercss' ) ?></style>
88 <?php }
89 if($this->data['userjs' ]) { ?>
90 <script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('userjs' ) ?>"></script>
91 <?php }
92 if($this->data['userjsprev']) { ?>
93 <script type="<?php $this->text('jsmimetype') ?>"><?php $this->html('userjsprev') ?></script>
94 <?php }
95 if($this->data['trackbackhtml']) print $this->data['trackbackhtml']; ?>
96 </head>
97 <body<?php if($this->data['body_ondblclick']) { ?> ondblclick="<?php $this->text('body_ondblclick') ?>"<?php } ?>
98 <?php if($this->data['body_onload' ]) { ?> onload="<?php $this->text('body_onload') ?>"<?php } ?>
99 class="mediawiki <?php $this->text('nsclass') ?> <?php $this->text('dir') ?> <?php $this->text('pageclass') ?>">
100
101 <!-- heading -->
102 <div id="mw_header">
103 <h1 id="firstHeading"><?php $this->data['displaytitle']!=""?$this->html('title'):$this->text('title') ?></h1>
104 </div>
105
106 <div id="mw_main">
107 <div id="mw_contentwrapper">
108 <!-- navigation portlet -->
109 <div id="p-cactions" class="portlet">
110 <h5><?php $this->msg('views') ?></h5>
111 <div class="pBody">
112 <ul>
113 <?php foreach($this->data['content_actions'] as $key => $tab) { ?>
114 <li id="ca-<?php echo Sanitizer::escapeId($key) ?>"<?php
115 if($tab['class']) { ?> class="<?php echo htmlspecialchars($tab['class']) ?>"<?php }
116 ?>><a href="<?php echo htmlspecialchars($tab['href']) ?>"<?php echo $skin->tooltipAndAccesskey('ca-'.$key) ?>><?php
117 echo htmlspecialchars($tab['text']) ?></a></li>
118 <?php } ?>
119 </ul>
120 </div>
121 </div>
122
123 <!-- content -->
124 <div id="mw_content">
125 <!-- contentholder does nothing by default, but it allows users to style the text inside
126 the content area without affecting the meaning of 'em' in #mw_content, which is used
127 for the margins -->
128 <div id="mw_contentholder">
129 <div class='mw-topboxes'>
130 <div class="mw-topbox" id="siteSub"><?php $this->msg('tagline') ?></div>
131 <?php if($this->data['newtalk'] ) {
132 ?><div class="usermessage mw-topbox"><?php $this->html('newtalk') ?></div>
133 <?php } ?>
134 <?php if($this->data['sitenotice']) {
135 ?><div class="mw-topbox" id="siteNotice"><?php $this->html('sitenotice') ?></div>
136 <?php } ?>
137 </div>
138
139 <div id="contentSub"><?php $this->html('subtitle') ?></div>
140
141 <?php if($this->data['undelete']) { ?><div id="contentSub2"><?php $this->html('undelete') ?></div><?php } ?>
142 <?php if($this->data['showjumplinks']) { ?><div id="jump-to-nav"><?php $this->msg('jumpto') ?> <a href="#mw_portlets"><?php $this->msg('jumptonavigation') ?></a>, <a href="#searchInput"><?php $this->msg('jumptosearch') ?></a></div><?php } ?>
143
144 <?php $this->html('bodytext') ?>
145 <div class='mw_clear'></div>
146 <?php if($this->data['catlinks']) { $this->html('catlinks'); } ?>
147 </div><!-- mw_contentholder -->
148 </div><!-- mw_content -->
149 </div><!-- mw_contentwrapper -->
150
151 <div id="mw_portlets">
152
153 <!-- portlets -->
154 <?php
155 $sidebar = $this->data['sidebar'];
156 if ( !isset( $sidebar['SEARCH'] ) ) $sidebar['SEARCH'] = true;
157 if ( !isset( $sidebar['TOOLBOX'] ) ) $sidebar['TOOLBOX'] = true;
158 if ( !isset( $sidebar['LANGUAGES'] ) ) $sidebar['LANGUAGES'] = true;
159
160 foreach ($sidebar as $boxName => $cont) {
161 if ( $boxName == 'SEARCH' ) {
162 $this->searchBox();
163 } elseif ( $boxName == 'TOOLBOX' ) {
164 $this->toolbox();
165 } elseif ( $boxName == 'LANGUAGES' ) {
166 $this->languageBox();
167 } else {
168 $this->customBox( $boxName, $cont );
169 }
170 }
171 ?>
172
173 </div><!-- mw_portlets -->
174
175
176 </div><!-- main -->
177
178 <div class="mw_clear"></div>
179
180 <!-- personal portlet -->
181 <div class="portlet" id="p-personal">
182 <h5><?php $this->msg('personaltools') ?></h5>
183 <div class="pBody">
184 <ul>
185 <?php foreach($this->data['personal_urls'] as $key => $item) { ?>
186 <li id="pt-<?php echo Sanitizer::escapeId($key) ?>"<?php
187 if ($item['active']) { ?> class="active"<?php } ?>><a href="<?php
188 echo htmlspecialchars($item['href']) ?>"<?php echo $skin->tooltipAndAccesskey('pt-'.$key) ?><?php
189 if(!empty($item['class'])) { ?> class="<?php
190 echo htmlspecialchars($item['class']) ?>"<?php } ?>><?php
191 echo htmlspecialchars($item['text']) ?></a></li>
192 <?php } ?>
193 </ul>
194 </div>
195 </div>
196
197
198 <!-- footer -->
199 <div id="footer">
200 <ul id="f-list">
201 <?php
202 $footerlinks = array(
203 'lastmod', 'viewcount', 'numberofwatchingusers', 'credits', 'copyright',
204 'privacy', 'about', 'disclaimer', 'tagline',
205 );
206 foreach( $footerlinks as $aLink ) {
207 if( isset( $this->data[$aLink] ) && $this->data[$aLink] ) {
208 ?> <li id="<?php echo$aLink?>"><?php $this->html($aLink) ?></li>
209 <?php }
210 }
211 ?>
212 </ul>
213 <?php echo $this->html("poweredbyico"); ?>
214 </div>
215
216 <?php $this->html('bottomscripts'); /* JS call to runBodyOnloadHook */ ?>
217 <?php $this->html('reporttime') ?>
218 <?php if ( $this->data['debug'] ): ?>
219 <!-- Debug output:
220 <?php $this->text( 'debug' ); ?>
221 -->
222 <?php endif; ?>
223 </body></html>
224 <?php
225 wfRestoreWarnings();
226 } // end of execute() method
227
228 /*************************************************************************************************/
229 function searchBox() {
230 ?>
231 <!-- search -->
232 <div id="p-search" class="portlet">
233 <h5><label for="searchInput"><?php $this->msg('search') ?></label></h5>
234 <div id="searchBody" class="pBody">
235 <form action="<?php $this->text('searchaction') ?>" id="searchform"><div>
236 <input id="searchInput" name="search" type="text"<?php echo $this->skin->tooltipAndAccesskey('search');
237 if( isset( $this->data['search'] ) ) {
238 ?> value="<?php $this->text('search') ?>"<?php } ?> />
239 <input type='submit' name="go" class="searchButton" id="searchGoButton" value="<?php $this->msg('searcharticle') ?>"<?php echo $this->skin->tooltipAndAccesskey( 'search-go' ); ?> />&nbsp;
240 <input type='submit' name="fulltext" class="searchButton" id="mw-searchButton" value="<?php $this->msg('searchbutton') ?>"<?php echo $this->skin->tooltipAndAccesskey( 'search-fulltext' ); ?> />
241 </div></form>
242 </div><!-- pBody -->
243 </div><!-- portlet -->
244 <?php
245 }
246
247 /*************************************************************************************************/
248 function toolbox() {
249 ?>
250 <!-- toolbox -->
251 <div class="portlet" id="p-tb">
252 <h5><?php $this->msg('toolbox') ?></h5>
253 <div class="pBody">
254 <ul>
255 <?php
256 if($this->data['notspecialpage']) { ?>
257 <li id="t-whatlinkshere"><a href="<?php
258 echo htmlspecialchars($this->data['nav_urls']['whatlinkshere']['href'])
259 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-whatlinkshere') ?>><?php $this->msg('whatlinkshere') ?></a></li>
260 <?php
261 if( $this->data['nav_urls']['recentchangeslinked'] ) { ?>
262 <li id="t-recentchangeslinked"><a href="<?php
263 echo htmlspecialchars($this->data['nav_urls']['recentchangeslinked']['href'])
264 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-recentchangeslinked') ?>><?php $this->msg('recentchangeslinked') ?></a></li>
265 <?php }
266 }
267 if(isset($this->data['nav_urls']['trackbacklink'])) { ?>
268 <li id="t-trackbacklink"><a href="<?php
269 echo htmlspecialchars($this->data['nav_urls']['trackbacklink']['href'])
270 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-trackbacklink') ?>><?php $this->msg('trackbacklink') ?></a></li>
271 <?php }
272 if($this->data['feeds']) { ?>
273 <li id="feedlinks"><?php foreach($this->data['feeds'] as $key => $feed) {
274 ?><span id="feed-<?php echo Sanitizer::escapeId($key) ?>"><a href="<?php
275 echo htmlspecialchars($feed['href']) ?>"<?php echo $this->skin->tooltipAndAccesskey('feed-'.$key) ?>><?php echo htmlspecialchars($feed['text'])?></a>&nbsp;</span>
276 <?php } ?></li><?php
277 }
278
279 foreach( array('contributions', 'log', 'blockip', 'emailuser', 'upload', 'specialpages') as $special ) {
280
281 if($this->data['nav_urls'][$special]) {
282 ?><li id="t-<?php echo $special ?>"><a href="<?php echo htmlspecialchars($this->data['nav_urls'][$special]['href'])
283 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-'.$special) ?>><?php $this->msg($special) ?></a></li>
284 <?php }
285 }
286
287 if(!empty($this->data['nav_urls']['print']['href'])) { ?>
288 <li id="t-print"><a href="<?php echo htmlspecialchars($this->data['nav_urls']['print']['href'])
289 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-print') ?>><?php $this->msg('printableversion') ?></a></li><?php
290 }
291
292 if(!empty($this->data['nav_urls']['permalink']['href'])) { ?>
293 <li id="t-permalink"><a href="<?php echo htmlspecialchars($this->data['nav_urls']['permalink']['href'])
294 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-permalink') ?>><?php $this->msg('permalink') ?></a></li><?php
295 } elseif ($this->data['nav_urls']['permalink']['href'] === '') { ?>
296 <li id="t-ispermalink"<?php echo $this->skin->tooltip('t-ispermalink') ?>><?php $this->msg('permalink') ?></li><?php
297 }
298
299 wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this ) );
300 ?> </ul>
301 </div><!-- pBody -->
302 </div><!-- portlet -->
303 <?php
304 }
305
306 /*************************************************************************************************/
307 function languageBox() {
308 ?>
309 <!-- languages -->
310 <?php
311 if( $this->data['language_urls'] ) { ?>
312 <div id="p-lang" class="portlet">
313 <h5><?php $this->msg('otherlanguages') ?></h5>
314 <div class="pBody">
315 <ul>
316 <?php foreach($this->data['language_urls'] as $langlink) { ?>
317 <li class="<?php echo htmlspecialchars($langlink['class'])?>"><?php
318 ?><a href="<?php echo htmlspecialchars($langlink['href']) ?>"><?php echo $langlink['text'] ?></a></li>
319 <?php } ?>
320 </ul>
321 </div><!-- pBody -->
322 </div><!-- portlet -->
323 <?php
324 }
325 }
326
327 /*************************************************************************************************/
328 function customBox( $bar, $cont ) {
329 ?>
330 <div class='generated-sidebar portlet' id='p-<?php echo Sanitizer::escapeId($bar) ?>'<?php echo $this->skin->tooltip('p-'.$bar) ?>>
331 <h5><?php $out = wfMsg( $bar ); if (wfEmptyMsg($bar, $out)) echo $bar; else echo $out; ?></h5>
332 <div class='pBody'>
333 <?php if ( is_array( $cont ) ) { ?>
334 <ul>
335 <?php foreach($cont as $key => $val) { ?>
336 <li id="<?php echo Sanitizer::escapeId($val['id']) ?>"<?php
337 if ( $val['active'] ) { ?> class="active" <?php }
338 ?>><a href="<?php echo htmlspecialchars($val['href']) ?>"<?php echo $this->skin->tooltipAndAccesskey($val['id']) ?>><?php echo htmlspecialchars($val['text']) ?></a></li>
339 <?php } ?>
340 </ul>
341 <?php } else {
342 # allow raw HTML block to be defined by extensions
343 print $cont;
344 }
345 ?>
346 </div><!-- pBody -->
347 </div><!-- portlet -->
348 <?php
349 }
350
351 } // end of class
352 ?>