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