self revert r45512, r45513 and r45515 for now
[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( OutputPage $out ) {
29 parent::initPage( $out );
30 $this->skinname = 'modern';
31 $this->stylename = 'modern';
32 $this->template = 'ModernTemplate';
33 }
34
35 function setupSkinUserCss( OutputPage $out ){
36 // Do not call parent::setupSkinUserCss(), we have our own print style
37 $out->addStyle( 'common/shared.css', 'screen' );
38 $out->addStyle( 'modern/main.css', 'screen' );
39 $out->addStyle( 'modern/print.css', 'print' );
40 $out->addStyle( 'modern/rtl.css', 'screen', '', 'rtl' );
41 }
42 }
43
44 /**
45 * @todo document
46 * @ingroup Skins
47 */
48 class ModernTemplate extends QuickTemplate {
49 var $skin;
50 /**
51 * Template filter callback for Modern skin.
52 * Takes an associative array of data set from a SkinTemplate-based
53 * class, and a wrapper for MediaWiki's localization database, and
54 * outputs a formatted page.
55 *
56 * @access private
57 */
58 function execute() {
59 global $wgRequest;
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 ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
67 <html xmlns="<?php $this->text('xhtmldefaultnamespace') ?>" <?php
68 foreach($this->data['xhtmlnamespaces'] as $tag => $ns) {
69 ?>xmlns:<?php echo "{$tag}=\"{$ns}\" ";
70 } ?>xml:lang="<?php $this->text('lang') ?>" lang="<?php $this->text('lang') ?>" dir="<?php $this->text('dir') ?>">
71 <head>
72 <meta http-equiv="Content-Type" content="<?php $this->text('mimetype') ?>; charset=<?php $this->text('charset') ?>" />
73 <?php $this->html('headlinks') ?>
74 <title><?php $this->text('pagetitle') ?></title>
75 <?php $this->html('csslinks') ?>
76 <!--[if lt IE 7]><meta http-equiv="imagetoolbar" content="no" /><![endif]-->
77
78 <?php print Skin::makeGlobalVariablesScript( $this->data ); ?>
79
80 <script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('stylepath' ) ?>/common/wikibits.js?<?php echo $GLOBALS['wgStyleVersion'] ?>"><!-- wikibits js --></script>
81 <!-- Head Scripts -->
82 <?php $this->html('headscripts') ?>
83 <?php if($this->data['jsvarurl' ]) { ?>
84 <script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('jsvarurl' ) ?>"><!-- site js --></script>
85 <?php } ?>
86 <?php if($this->data['pagecss' ]) { ?>
87 <style type="text/css"><?php $this->html('pagecss' ) ?></style>
88 <?php }
89 if($this->data['usercss' ]) { ?>
90 <style type="text/css"><?php $this->html('usercss' ) ?></style>
91 <?php }
92 if($this->data['userjs' ]) { ?>
93 <script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('userjs' ) ?>"></script>
94 <?php }
95 if($this->data['userjsprev']) { ?>
96 <script type="<?php $this->text('jsmimetype') ?>"><?php $this->html('userjsprev') ?></script>
97 <?php }
98 if($this->data['trackbackhtml']) print $this->data['trackbackhtml']; ?>
99 </head>
100 <body<?php if($this->data['body_ondblclick']) { ?> ondblclick="<?php $this->text('body_ondblclick') ?>"<?php } ?>
101 <?php if($this->data['body_onload' ]) { ?> onload="<?php $this->text('body_onload') ?>"<?php } ?>
102 class="mediawiki <?php $this->text('dir') ?> <?php $this->text('pageclass') ?> <?php $this->text('skinnameclass') ?>">
103
104 <!-- heading -->
105 <div id="mw_header"><h1 id="firstHeading"><?php $this->data['displaytitle']!=""?$this->html('title'):$this->text('title') ?></h1></div>
106
107 <div id="mw_main">
108 <div id="mw_contentwrapper">
109 <!-- navigation portlet -->
110 <div id="p-cactions" class="portlet">
111 <h5><?php $this->msg('views') ?></h5>
112 <div class="pBody">
113 <ul>
114 <?php foreach($this->data['content_actions'] as $key => $tab) {
115 echo '
116 <li id="' . Sanitizer::escapeId( "ca-$key" ) . '"';
117 if( $tab['class'] ) {
118 echo ' class="'.htmlspecialchars($tab['class']).'"';
119 }
120 echo'><a href="'.htmlspecialchars($tab['href']).'"';
121 # We don't want to give the watch tab an accesskey if the
122 # page is being edited, because that conflicts with the
123 # accesskey on the watch checkbox. We also don't want to
124 # give the edit tab an accesskey, because that's fairly su-
125 # perfluous and conflicts with an accesskey (Ctrl-E) often
126 # used for editing in Safari.
127 if( in_array( $action, array( 'edit', 'submit' ) )
128 && in_array( $key, array( 'edit', 'watch', 'unwatch' ))) {
129 echo $skin->tooltip( "ca-$key" );
130 } else {
131 echo $skin->tooltipAndAccesskey( "ca-$key" );
132 }
133 echo '>'.htmlspecialchars($tab['text']).'</a></li>';
134 } ?>
135 </ul>
136 </div>
137 </div>
138
139 <!-- content -->
140 <div id="mw_content">
141 <!-- contentholder does nothing by default, but it allows users to style the text inside
142 the content area without affecting the meaning of 'em' in #mw_content, which is used
143 for the margins -->
144 <div id="mw_contentholder">
145 <div class='mw-topboxes'>
146 <div id="mw-js-message" style="display:none;"></div>
147 <div class="mw-topbox" id="siteSub"><?php $this->msg('tagline') ?></div>
148 <?php if($this->data['newtalk'] ) {
149 ?><div class="usermessage mw-topbox"><?php $this->html('newtalk') ?></div>
150 <?php } ?>
151 <?php if($this->data['sitenotice']) {
152 ?><div class="mw-topbox" id="siteNotice"><?php $this->html('sitenotice') ?></div>
153 <?php } ?>
154 </div>
155
156 <div id="contentSub"><?php $this->html('subtitle') ?></div>
157
158 <?php if($this->data['undelete']) { ?><div id="contentSub2"><?php $this->html('undelete') ?></div><?php } ?>
159 <?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 } ?>
160
161 <?php $this->html('bodytext') ?>
162 <div class='mw_clear'></div>
163 <?php if($this->data['catlinks']) { $this->html('catlinks'); } ?>
164 <?php $this->html ('dataAfterContent') ?>
165 </div><!-- mw_contentholder -->
166 </div><!-- mw_content -->
167 </div><!-- mw_contentwrapper -->
168
169 <div id="mw_portlets">
170
171 <!-- portlets -->
172 <?php
173 $sidebar = $this->data['sidebar'];
174 if ( !isset( $sidebar['SEARCH'] ) ) $sidebar['SEARCH'] = true;
175 if ( !isset( $sidebar['TOOLBOX'] ) ) $sidebar['TOOLBOX'] = true;
176 if ( !isset( $sidebar['LANGUAGES'] ) ) $sidebar['LANGUAGES'] = true;
177
178 foreach ($sidebar as $boxName => $cont) {
179 if ( $boxName == 'SEARCH' ) {
180 $this->searchBox();
181 } elseif ( $boxName == 'TOOLBOX' ) {
182 $this->toolbox();
183 } elseif ( $boxName == 'LANGUAGES' ) {
184 $this->languageBox();
185 } else {
186 $this->customBox( $boxName, $cont );
187 }
188 }
189 ?>
190
191 </div><!-- mw_portlets -->
192
193
194 </div><!-- main -->
195
196 <div class="mw_clear"></div>
197
198 <!-- personal portlet -->
199 <div class="portlet" id="p-personal">
200 <h5><?php $this->msg('personaltools') ?></h5>
201 <div class="pBody">
202 <ul>
203 <?php foreach($this->data['personal_urls'] as $key => $item) { ?>
204 <li id="<?php echo Sanitizer::escapeId( "pt-$key" ) ?>"<?php
205 if ($item['active']) { ?> class="active"<?php } ?>><a href="<?php
206 echo htmlspecialchars($item['href']) ?>"<?php echo $skin->tooltipAndAccesskey('pt-'.$key) ?><?php
207 if(!empty($item['class'])) { ?> class="<?php
208 echo htmlspecialchars($item['class']) ?>"<?php } ?>><?php
209 echo htmlspecialchars($item['text']) ?></a></li>
210 <?php } ?>
211 </ul>
212 </div>
213 </div>
214
215
216 <!-- footer -->
217 <div id="footer">
218 <ul id="f-list">
219 <?php
220 $footerlinks = array(
221 'lastmod', 'viewcount', 'numberofwatchingusers', 'credits', 'copyright',
222 'privacy', 'about', 'disclaimer', 'tagline',
223 );
224 foreach( $footerlinks as $aLink ) {
225 if( isset( $this->data[$aLink] ) && $this->data[$aLink] ) {
226 ?> <li id="<?php echo$aLink?>"><?php $this->html($aLink) ?></li>
227 <?php }
228 }
229 ?>
230 </ul>
231 <?php echo $this->html("poweredbyico"); ?>
232 </div>
233
234 <?php $this->html('bottomscripts'); /* JS call to runBodyOnloadHook */ ?>
235 <?php $this->html('reporttime') ?>
236 <?php if ( $this->data['debug'] ): ?>
237 <!-- Debug output:
238 <?php $this->text( 'debug' ); ?>
239 -->
240 <?php endif; ?>
241 </body></html>
242 <?php
243 wfRestoreWarnings();
244 } // end of execute() method
245
246 /*************************************************************************************************/
247 function searchBox() {
248 ?>
249 <!-- search -->
250 <div id="p-search" class="portlet">
251 <h5><label for="searchInput"><?php $this->msg('search') ?></label></h5>
252 <div id="searchBody" class="pBody">
253 <form action="<?php $this->text('searchaction') ?>" id="searchform"><div>
254 <input id="searchInput" name="search" type="text"<?php echo $this->skin->tooltipAndAccesskey('search');
255 if( isset( $this->data['search'] ) ) {
256 ?> value="<?php $this->text('search') ?>"<?php } ?> />
257 <input type='submit' name="go" class="searchButton" id="searchGoButton" value="<?php $this->msg('searcharticle') ?>"<?php echo $this->skin->tooltipAndAccesskey( 'search-go' ); ?> />&nbsp;
258 <input type='submit' name="fulltext" class="searchButton" id="mw-searchButton" value="<?php $this->msg('searchbutton') ?>"<?php echo $this->skin->tooltipAndAccesskey( 'search-fulltext' ); ?> />
259 <a href="<?php $this->text('searchaction') ?>" rel="search"><?php $this->msg('powersearch-legend') ?></a>
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="<?php echo Sanitizer::escapeId( "feed-$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='<?php echo Sanitizer::escapeId( "p-$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 ?>