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