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