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