Improving extendibility of the sidebar improvements, css adding, and also JS variables.
[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 if( wfRunHooks( 'SkinSidebarOutputSpecialBox', array( &$this, $boxName, $cont ) ) ) {
169 # If no hook returned false, then output a normal box
170 $this->customBox( $boxName, $cont );
171 }
172 }
173 }
174 ?>
175
176 </div><!-- mw_portlets -->
177
178
179 </div><!-- main -->
180
181 <div class="mw_clear"></div>
182
183 <!-- personal portlet -->
184 <div class="portlet" id="p-personal">
185 <h5><?php $this->msg('personaltools') ?></h5>
186 <div class="pBody">
187 <ul>
188 <?php foreach($this->data['personal_urls'] as $key => $item) { ?>
189 <li id="pt-<?php echo Sanitizer::escapeId($key) ?>"<?php
190 if ($item['active']) { ?> class="active"<?php } ?>><a href="<?php
191 echo htmlspecialchars($item['href']) ?>"<?php echo $skin->tooltipAndAccesskey('pt-'.$key) ?><?php
192 if(!empty($item['class'])) { ?> class="<?php
193 echo htmlspecialchars($item['class']) ?>"<?php } ?>><?php
194 echo htmlspecialchars($item['text']) ?></a></li>
195 <?php } ?>
196 </ul>
197 </div>
198 </div>
199
200
201 <!-- footer -->
202 <div id="footer">
203 <ul id="f-list">
204 <?php
205 $footerlinks = array(
206 'lastmod', 'viewcount', 'numberofwatchingusers', 'credits', 'copyright',
207 'privacy', 'about', 'disclaimer', 'tagline',
208 );
209 foreach( $footerlinks as $aLink ) {
210 if( isset( $this->data[$aLink] ) && $this->data[$aLink] ) {
211 ?> <li id="<?php echo$aLink?>"><?php $this->html($aLink) ?></li>
212 <?php }
213 }
214 ?>
215 </ul>
216 <?php echo $this->html("poweredbyico"); ?>
217 </div>
218
219 <?php $this->html('bottomscripts'); /* JS call to runBodyOnloadHook */ ?>
220 <?php $this->html('reporttime') ?>
221 <?php if ( $this->data['debug'] ): ?>
222 <!-- Debug output:
223 <?php $this->text( 'debug' ); ?>
224 -->
225 <?php endif; ?>
226 </body></html>
227 <?php
228 wfRestoreWarnings();
229 } // end of execute() method
230
231 /*************************************************************************************************/
232 function searchBox() {
233 ?>
234 <!-- search -->
235 <div id="p-search" class="portlet">
236 <h5><label for="searchInput"><?php $this->msg('search') ?></label></h5>
237 <div id="searchBody" class="pBody">
238 <form action="<?php $this->text('searchaction') ?>" id="searchform"><div>
239 <input id="searchInput" name="search" type="text"<?php echo $this->skin->tooltipAndAccesskey('search');
240 if( isset( $this->data['search'] ) ) {
241 ?> value="<?php $this->text('search') ?>"<?php } ?> />
242 <input type='submit' name="go" class="searchButton" id="searchGoButton" value="<?php $this->msg('searcharticle') ?>"<?php echo $this->skin->tooltipAndAccesskey( 'search-go' ); ?> />&nbsp;
243 <input type='submit' name="fulltext" class="searchButton" id="mw-searchButton" value="<?php $this->msg('searchbutton') ?>"<?php echo $this->skin->tooltipAndAccesskey( 'search-fulltext' ); ?> />
244 </div></form>
245 </div><!-- pBody -->
246 </div><!-- portlet -->
247 <?php
248 }
249
250 /*************************************************************************************************/
251 function toolbox() {
252 ?>
253 <!-- toolbox -->
254 <div class="portlet" id="p-tb">
255 <h5><?php $this->msg('toolbox') ?></h5>
256 <div class="pBody">
257 <ul>
258 <?php
259 if($this->data['notspecialpage']) { ?>
260 <li id="t-whatlinkshere"><a href="<?php
261 echo htmlspecialchars($this->data['nav_urls']['whatlinkshere']['href'])
262 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-whatlinkshere') ?>><?php $this->msg('whatlinkshere') ?></a></li>
263 <?php
264 if( $this->data['nav_urls']['recentchangeslinked'] ) { ?>
265 <li id="t-recentchangeslinked"><a href="<?php
266 echo htmlspecialchars($this->data['nav_urls']['recentchangeslinked']['href'])
267 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-recentchangeslinked') ?>><?php $this->msg('recentchangeslinked') ?></a></li>
268 <?php }
269 }
270 if(isset($this->data['nav_urls']['trackbacklink'])) { ?>
271 <li id="t-trackbacklink"><a href="<?php
272 echo htmlspecialchars($this->data['nav_urls']['trackbacklink']['href'])
273 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-trackbacklink') ?>><?php $this->msg('trackbacklink') ?></a></li>
274 <?php }
275 if($this->data['feeds']) { ?>
276 <li id="feedlinks"><?php foreach($this->data['feeds'] as $key => $feed) {
277 ?><span id="feed-<?php echo Sanitizer::escapeId($key) ?>"><a href="<?php
278 echo htmlspecialchars($feed['href']) ?>"<?php echo $this->skin->tooltipAndAccesskey('feed-'.$key) ?>><?php echo htmlspecialchars($feed['text'])?></a>&nbsp;</span>
279 <?php } ?></li><?php
280 }
281
282 foreach( array('contributions', 'log', 'blockip', 'emailuser', 'upload', 'specialpages') as $special ) {
283
284 if($this->data['nav_urls'][$special]) {
285 ?><li id="t-<?php echo $special ?>"><a href="<?php echo htmlspecialchars($this->data['nav_urls'][$special]['href'])
286 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-'.$special) ?>><?php $this->msg($special) ?></a></li>
287 <?php }
288 }
289
290 if(!empty($this->data['nav_urls']['print']['href'])) { ?>
291 <li id="t-print"><a href="<?php echo htmlspecialchars($this->data['nav_urls']['print']['href'])
292 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-print') ?>><?php $this->msg('printableversion') ?></a></li><?php
293 }
294
295 if(!empty($this->data['nav_urls']['permalink']['href'])) { ?>
296 <li id="t-permalink"><a href="<?php echo htmlspecialchars($this->data['nav_urls']['permalink']['href'])
297 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-permalink') ?>><?php $this->msg('permalink') ?></a></li><?php
298 } elseif ($this->data['nav_urls']['permalink']['href'] === '') { ?>
299 <li id="t-ispermalink"<?php echo $this->skin->tooltip('t-ispermalink') ?>><?php $this->msg('permalink') ?></li><?php
300 }
301
302 wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this ) );
303 ?> </ul>
304 </div><!-- pBody -->
305 </div><!-- portlet -->
306 <?php
307 }
308
309 /*************************************************************************************************/
310 function languageBox() {
311 ?>
312 <!-- languages -->
313 <?php
314 if( $this->data['language_urls'] ) { ?>
315 <div id="p-lang" class="portlet">
316 <h5><?php $this->msg('otherlanguages') ?></h5>
317 <div class="pBody">
318 <ul>
319 <?php foreach($this->data['language_urls'] as $langlink) { ?>
320 <li class="<?php echo htmlspecialchars($langlink['class'])?>"><?php
321 ?><a href="<?php echo htmlspecialchars($langlink['href']) ?>"><?php echo $langlink['text'] ?></a></li>
322 <?php } ?>
323 </ul>
324 </div><!-- pBody -->
325 </div><!-- portlet -->
326 <?php
327 }
328 }
329
330 /*************************************************************************************************/
331 function customBox( $bar, $cont ) {
332 ?>
333 <div class='generated-sidebar portlet' id='p-<?php echo Sanitizer::escapeId($bar) ?>'<?php echo $this->skin->tooltip('p-'.$bar) ?>>
334 <h5><?php $out = wfMsg( $bar ); if (wfEmptyMsg($bar, $out)) echo $bar; else echo $out; ?></h5>
335 <div class='pBody'>
336 <?php if ( is_array( $cont ) ) { ?>
337 <ul>
338 <?php foreach($cont as $key => $val) { ?>
339 <li id="<?php echo Sanitizer::escapeId($val['id']) ?>"<?php
340 if ( $val['active'] ) { ?> class="active" <?php }
341 ?>><a href="<?php echo htmlspecialchars($val['href']) ?>"<?php echo $this->skin->tooltipAndAccesskey($val['id']) ?>><?php echo htmlspecialchars($val['text']) ?></a></li>
342 <?php } ?>
343 </ul>
344 <?php } else {
345 # allow raw HTML block to be defined by extensions
346 print $cont;
347 }
348 ?>
349 </div><!-- pBody -->
350 </div><!-- portlet -->
351 <?php
352 }
353
354 } // end of class
355
356