Finish cross-skin unification of <head>
[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, $wgOut;
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 $wgOut->addScript( <<<HTML
67 <!--[if lt IE 7]><script type="$wgJsMimeType" src="$path/common/IEFixes.js?$wgStyleVersion"></script>
68 <meta http-equiv="imagetoolbar" content="no" /><![endif]-->
69 HTML
70 );
71
72 echo $wgOut->headElement( $this->skin );
73 ?><body<?php if($this->data['body_ondblclick']) { ?> ondblclick="<?php $this->text('body_ondblclick') ?>"<?php } ?>
74 <?php if($this->data['body_onload' ]) { ?> onload="<?php $this->text('body_onload') ?>"<?php } ?>
75 class="mediawiki <?php $this->text('dir') ?> <?php $this->text('pageclass') ?> <?php $this->text('skinnameclass') ?>">
76
77 <!-- heading -->
78 <div id="mw_header"><h1 id="firstHeading"><?php $this->html('title') ?></h1></div>
79
80 <div id="mw_main">
81 <div id="mw_contentwrapper">
82 <!-- navigation portlet -->
83 <div id="p-cactions" class="portlet">
84 <h5><?php $this->msg('views') ?></h5>
85 <div class="pBody">
86 <ul>
87 <?php foreach($this->data['content_actions'] as $key => $tab) {
88 echo '
89 <li id="' . Sanitizer::escapeId( "ca-$key" ) . '"';
90 if( $tab['class'] ) {
91 echo ' class="'.htmlspecialchars($tab['class']).'"';
92 }
93 echo'><a href="'.htmlspecialchars($tab['href']).'"';
94 # We don't want to give the watch tab an accesskey if the
95 # page is being edited, because that conflicts with the
96 # accesskey on the watch checkbox. We also don't want to
97 # give the edit tab an accesskey, because that's fairly su-
98 # perfluous and conflicts with an accesskey (Ctrl-E) often
99 # used for editing in Safari.
100 if( in_array( $action, array( 'edit', 'submit' ) )
101 && in_array( $key, array( 'edit', 'watch', 'unwatch' ))) {
102 echo $skin->tooltip( "ca-$key" );
103 } else {
104 echo $skin->tooltipAndAccesskey( "ca-$key" );
105 }
106 echo '>'.htmlspecialchars($tab['text']).'</a></li>';
107 } ?>
108 </ul>
109 </div>
110 </div>
111
112 <!-- content -->
113 <div id="mw_content">
114 <!-- contentholder does nothing by default, but it allows users to style the text inside
115 the content area without affecting the meaning of 'em' in #mw_content, which is used
116 for the margins -->
117 <div id="mw_contentholder">
118 <div class='mw-topboxes'>
119 <div id="mw-js-message" style="display:none;"></div>
120 <div class="mw-topbox" id="siteSub"><?php $this->msg('tagline') ?></div>
121 <?php if($this->data['newtalk'] ) {
122 ?><div class="usermessage mw-topbox"><?php $this->html('newtalk') ?></div>
123 <?php } ?>
124 <?php if($this->data['sitenotice']) {
125 ?><div class="mw-topbox" id="siteNotice"><?php $this->html('sitenotice') ?></div>
126 <?php } ?>
127 </div>
128
129 <div id="contentSub"><?php $this->html('subtitle') ?></div>
130
131 <?php if($this->data['undelete']) { ?><div id="contentSub2"><?php $this->html('undelete') ?></div><?php } ?>
132 <?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 } ?>
133
134 <?php $this->html('bodytext') ?>
135 <div class='mw_clear'></div>
136 <?php if($this->data['catlinks']) { $this->html('catlinks'); } ?>
137 <?php $this->html ('dataAfterContent') ?>
138 </div><!-- mw_contentholder -->
139 </div><!-- mw_content -->
140 </div><!-- mw_contentwrapper -->
141
142 <div id="mw_portlets">
143
144 <!-- portlets -->
145 <?php
146 $sidebar = $this->data['sidebar'];
147 if ( !isset( $sidebar['SEARCH'] ) ) $sidebar['SEARCH'] = true;
148 if ( !isset( $sidebar['TOOLBOX'] ) ) $sidebar['TOOLBOX'] = true;
149 if ( !isset( $sidebar['LANGUAGES'] ) ) $sidebar['LANGUAGES'] = true;
150
151 foreach ($sidebar as $boxName => $cont) {
152 if ( $boxName == 'SEARCH' ) {
153 $this->searchBox();
154 } elseif ( $boxName == 'TOOLBOX' ) {
155 $this->toolbox();
156 } elseif ( $boxName == 'LANGUAGES' ) {
157 $this->languageBox();
158 } else {
159 $this->customBox( $boxName, $cont );
160 }
161 }
162 ?>
163
164 </div><!-- mw_portlets -->
165
166
167 </div><!-- main -->
168
169 <div class="mw_clear"></div>
170
171 <!-- personal portlet -->
172 <div class="portlet" id="p-personal">
173 <h5><?php $this->msg('personaltools') ?></h5>
174 <div class="pBody">
175 <ul>
176 <?php foreach($this->data['personal_urls'] as $key => $item) { ?>
177 <li id="<?php echo Sanitizer::escapeId( "pt-$key" ) ?>"<?php
178 if ($item['active']) { ?> class="active"<?php } ?>><a href="<?php
179 echo htmlspecialchars($item['href']) ?>"<?php echo $skin->tooltipAndAccesskey('pt-'.$key) ?><?php
180 if(!empty($item['class'])) { ?> class="<?php
181 echo htmlspecialchars($item['class']) ?>"<?php } ?>><?php
182 echo htmlspecialchars($item['text']) ?></a></li>
183 <?php } ?>
184 </ul>
185 </div>
186 </div>
187
188
189 <!-- footer -->
190 <div id="footer">
191 <ul id="f-list">
192 <?php
193 $footerlinks = array(
194 'lastmod', 'viewcount', 'numberofwatchingusers', 'credits', 'copyright',
195 'privacy', 'about', 'disclaimer', 'tagline',
196 );
197 foreach( $footerlinks as $aLink ) {
198 if( isset( $this->data[$aLink] ) && $this->data[$aLink] ) {
199 ?> <li id="<?php echo$aLink?>"><?php $this->html($aLink) ?></li>
200 <?php }
201 }
202 ?>
203 </ul>
204 <?php echo $this->html("poweredbyico"); ?>
205 </div>
206
207 <?php $this->html('bottomscripts'); /* JS call to runBodyOnloadHook */ ?>
208 <?php $this->html('reporttime') ?>
209 <?php if ( $this->data['debug'] ): ?>
210 <!-- Debug output:
211 <?php $this->text( 'debug' ); ?>
212 -->
213 <?php endif; ?>
214 </body></html>
215 <?php
216 wfRestoreWarnings();
217 } // end of execute() method
218
219 /*************************************************************************************************/
220 function searchBox() {
221 global $wgUseTwoButtonsSearchForm;
222 ?>
223 <!-- search -->
224 <div id="p-search" class="portlet">
225 <h5><label for="searchInput"><?php $this->msg('search') ?></label></h5>
226 <div id="searchBody" class="pBody">
227 <form action="<?php $this->text('wgScript') ?>" id="searchform"><div>
228 <input type='hidden' name="title" value="<?php $this->text('searchtitle') ?>"/>
229 <input id="searchInput" name="search" type="text"<?php echo $this->skin->tooltipAndAccesskey('search');
230 if( isset( $this->data['search'] ) ) {
231 ?> value="<?php $this->text('search') ?>"<?php } ?> />
232 <input type='submit' name="go" class="searchButton" id="searchGoButton" value="<?php $this->msg('searcharticle') ?>"<?php echo $this->skin->tooltipAndAccesskey( 'search-go' ); ?> /><?php if ($wgUseTwoButtonsSearchForm) { ?>&nbsp;
233 <input type='submit' name="fulltext" class="searchButton" id="mw-searchButton" value="<?php $this->msg('searchbutton') ?>"<?php echo $this->skin->tooltipAndAccesskey( 'search-fulltext' ); ?> /><?php } else { ?>
234
235 <div><a href="<?php $this->text('searchaction') ?>" rel="search"><?php $this->msg('powersearch-legend') ?></a></div><?php } ?>
236
237 </div></form>
238 </div><!-- pBody -->
239 </div><!-- portlet -->
240 <?php
241 }
242
243 /*************************************************************************************************/
244 function toolbox() {
245 ?>
246 <!-- toolbox -->
247 <div class="portlet" id="p-tb">
248 <h5><?php $this->msg('toolbox') ?></h5>
249 <div class="pBody">
250 <ul>
251 <?php
252 if($this->data['notspecialpage']) { ?>
253 <li id="t-whatlinkshere"><a href="<?php
254 echo htmlspecialchars($this->data['nav_urls']['whatlinkshere']['href'])
255 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-whatlinkshere') ?>><?php $this->msg('whatlinkshere') ?></a></li>
256 <?php
257 if( $this->data['nav_urls']['recentchangeslinked'] ) { ?>
258 <li id="t-recentchangeslinked"><a href="<?php
259 echo htmlspecialchars($this->data['nav_urls']['recentchangeslinked']['href'])
260 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-recentchangeslinked') ?>><?php $this->msg('recentchangeslinked-toolbox') ?></a></li>
261 <?php }
262 }
263 if(isset($this->data['nav_urls']['trackbacklink'])) { ?>
264 <li id="t-trackbacklink"><a href="<?php
265 echo htmlspecialchars($this->data['nav_urls']['trackbacklink']['href'])
266 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-trackbacklink') ?>><?php $this->msg('trackbacklink') ?></a></li>
267 <?php }
268 if($this->data['feeds']) { ?>
269 <li id="feedlinks"><?php foreach($this->data['feeds'] as $key => $feed) {
270 ?><a id="<?php echo Sanitizer::escapeId( "feed-$key" ) ?>" href="<?php
271 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>&nbsp;
272 <?php } ?></li><?php
273 }
274
275 foreach( array('contributions', 'log', 'blockip', 'emailuser', 'upload', 'specialpages') as $special ) {
276
277 if($this->data['nav_urls'][$special]) {
278 ?><li id="t-<?php echo $special ?>"><a href="<?php echo htmlspecialchars($this->data['nav_urls'][$special]['href'])
279 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-'.$special) ?>><?php $this->msg($special) ?></a></li>
280 <?php }
281 }
282
283 if(!empty($this->data['nav_urls']['print']['href'])) { ?>
284 <li id="t-print"><a href="<?php echo htmlspecialchars($this->data['nav_urls']['print']['href'])
285 ?>" rel="alternate"<?php echo $this->skin->tooltipAndAccesskey('t-print') ?>><?php $this->msg('printableversion') ?></a></li><?php
286 }
287
288 if(!empty($this->data['nav_urls']['permalink']['href'])) { ?>
289 <li id="t-permalink"><a href="<?php echo htmlspecialchars($this->data['nav_urls']['permalink']['href'])
290 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-permalink') ?>><?php $this->msg('permalink') ?></a></li><?php
291 } elseif ($this->data['nav_urls']['permalink']['href'] === '') { ?>
292 <li id="t-ispermalink"<?php echo $this->skin->tooltip('t-ispermalink') ?>><?php $this->msg('permalink') ?></li><?php
293 }
294
295 wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this ) );
296 ?> </ul>
297 </div><!-- pBody -->
298 </div><!-- portlet -->
299 <?php
300 }
301
302 /*************************************************************************************************/
303 function languageBox() {
304 ?>
305 <!-- languages -->
306 <?php
307 if( $this->data['language_urls'] ) { ?>
308 <div id="p-lang" class="portlet">
309 <h5><?php $this->msg('otherlanguages') ?></h5>
310 <div class="pBody">
311 <ul>
312 <?php foreach($this->data['language_urls'] as $langlink) { ?>
313 <li class="<?php echo htmlspecialchars($langlink['class'])?>"><?php
314 ?><a href="<?php echo htmlspecialchars($langlink['href']) ?>"><?php echo $langlink['text'] ?></a></li>
315 <?php } ?>
316 </ul>
317 </div><!-- pBody -->
318 </div><!-- portlet -->
319 <?php
320 }
321 }
322
323 /*************************************************************************************************/
324 function customBox( $bar, $cont ) {
325 ?>
326 <div class='generated-sidebar portlet' id='<?php echo Sanitizer::escapeId( "p-$bar" ) ?>'<?php echo $this->skin->tooltip('p-'.$bar) ?>>
327 <h5><?php $out = wfMsg( $bar ); if (wfEmptyMsg($bar, $out)) echo $bar; else echo $out; ?></h5>
328 <div class='pBody'>
329 <?php if ( is_array( $cont ) ) { ?>
330 <ul>
331 <?php foreach($cont as $key => $val) { ?>
332 <li id="<?php echo Sanitizer::escapeId($val['id']) ?>"<?php
333 if ( $val['active'] ) { ?> class="active" <?php }
334 ?>><a href="<?php echo htmlspecialchars($val['href']) ?>"<?php echo $this->skin->tooltipAndAccesskey($val['id']) ?>><?php echo htmlspecialchars($val['text']) ?></a></li>
335 <?php } ?>
336 </ul>
337 <?php } else {
338 # allow raw HTML block to be defined by extensions
339 print $cont;
340 }
341 ?>
342 </div><!-- pBody -->
343 </div><!-- portlet -->
344 <?php
345 }
346
347 } // end of class
348 ?>