Revert r58246. Committed a lot of half done stuff by accident. wtf??
[lhc/web/wiklou.git] / skins / MonoBook.php
1 <?php
2 /**
3 * MonoBook nouveau
4 *
5 * Translated from gwicke's previous TAL template version to remove
6 * dependency on PHPTAL.
7 *
8 * @todo document
9 * @file
10 * @ingroup Skins
11 */
12
13 if( !defined( 'MEDIAWIKI' ) )
14 die( -1 );
15
16 /**
17 * Inherit main code from SkinTemplate, set the CSS and template filter.
18 * @todo document
19 * @ingroup Skins
20 */
21 class SkinMonoBook extends SkinTemplate {
22 /** Using monobook. */
23 var $skinname = 'monobook', $stylename = 'monobook',
24 $template = 'MonoBookTemplate', $useHeadElement = true;
25
26 function setupSkinUserCss( OutputPage $out ) {
27 global $wgHandheldStyle, $wgStyleVersion, $wgJsMimeType, $wgStylePath;
28
29 parent::setupSkinUserCss( $out );
30
31 // Append to the default screen common & print styles...
32 $out->addStyle( 'monobook/main.css', 'screen' );
33 if( $wgHandheldStyle ) {
34 // Currently in testing... try 'chick/main.css'
35 $out->addStyle( $wgHandheldStyle, 'handheld' );
36 }
37
38 $out->addStyle( 'monobook/IE50Fixes.css', 'screen', 'lt IE 5.5000' );
39 $out->addStyle( 'monobook/IE55Fixes.css', 'screen', 'IE 5.5000' );
40 $out->addStyle( 'monobook/IE60Fixes.css', 'screen', 'IE 6' );
41 $out->addStyle( 'monobook/IE70Fixes.css', 'screen', 'IE 7' );
42
43 $out->addStyle( 'monobook/rtl.css', 'screen', '', 'rtl' );
44
45 # FIXME: What is this? Should it apply to all skins?
46 $path = htmlspecialchars( $wgStylePath );
47 $out->addScript( <<<HTML
48 <!--[if lt IE 7]><script type="$wgJsMimeType" src="$path/common/IEFixes.js?$wgStyleVersion"></script>
49 <meta http-equiv="imagetoolbar" content="no" /><![endif]-->
50 HTML
51 );
52 }
53 }
54
55 /**
56 * @todo document
57 * @ingroup Skins
58 */
59 class MonoBookTemplate extends QuickTemplate {
60 var $skin;
61 /**
62 * Template filter callback for MonoBook skin.
63 * Takes an associative array of data set from a SkinTemplate-based
64 * class, and a wrapper for MediaWiki's localization database, and
65 * outputs a formatted page.
66 *
67 * @access private
68 */
69 function execute() {
70 global $wgRequest;
71
72 $this->skin = $skin = $this->data['skin'];
73 $action = $wgRequest->getText( 'action' );
74
75 // Suppress warnings to prevent notices about missing indexes in $this->data
76 wfSuppressWarnings();
77
78 $this->html( 'headelement' );
79 ?><body<?php if($this->data['body_ondblclick']) { ?> ondblclick="<?php $this->text('body_ondblclick') ?>"<?php } ?>
80 <?php if($this->data['body_onload']) { ?> onload="<?php $this->text('body_onload') ?>"<?php } ?>
81 class="mediawiki <?php $this->text('dir'); $this->text('capitalizeallnouns') ?> <?php $this->text('pageclass') ?> <?php $this->text('skinnameclass') ?>">
82 <div id="globalWrapper">
83 <div id="column-content">
84 <div id="content">
85 <a id="top"></a>
86 <?php if($this->data['sitenotice']) { ?><div id="siteNotice"><?php $this->html('sitenotice') ?></div><?php } ?>
87 <h1 id="firstHeading" class="firstHeading"><?php $this->html('title') ?></h1>
88 <div id="bodyContent">
89 <h3 id="siteSub"><?php $this->msg('tagline') ?></h3>
90 <div id="contentSub"><?php $this->html('subtitle') ?></div>
91 <?php if($this->data['undelete']) { ?><div id="contentSub2"><?php $this->html('undelete') ?></div><?php } ?>
92 <?php if($this->data['newtalk'] ) { ?><div class="usermessage"><?php $this->html('newtalk') ?></div><?php } ?>
93 <?php if($this->data['showjumplinks']) { ?><div id="jump-to-nav"><?php $this->msg('jumpto') ?> <a href="#column-one"><?php $this->msg('jumptonavigation') ?></a>, <a href="#searchInput"><?php $this->msg('jumptosearch') ?></a></div><?php } ?>
94 <!-- start content -->
95 <?php $this->html('bodytext') ?>
96 <?php if($this->data['catlinks']) { $this->html('catlinks'); } ?>
97 <!-- end content -->
98 <?php if($this->data['dataAfterContent']) { $this->html ('dataAfterContent'); } ?>
99 <div class="visualClear"></div>
100 </div>
101 </div>
102 </div>
103 <div id="column-one">
104 <div id="p-cactions" class="portlet">
105 <h5><?php $this->msg('views') ?></h5>
106 <div class="pBody">
107 <ul <?php $this->html('userlangattributes') ?>>
108 <?php foreach($this->data['content_actions'] as $key => $tab) {
109 echo '
110 <li id="' . Sanitizer::escapeId( "ca-$key" ) . '"';
111 if( $tab['class'] ) {
112 echo ' class="'.htmlspecialchars($tab['class']).'"';
113 }
114 echo '><a href="'.htmlspecialchars($tab['href']).'"';
115 # We don't want to give the watch tab an accesskey if the
116 # page is being edited, because that conflicts with the
117 # accesskey on the watch checkbox. We also don't want to
118 # give the edit tab an accesskey, because that's fairly su-
119 # perfluous and conflicts with an accesskey (Ctrl-E) often
120 # used for editing in Safari.
121 if( in_array( $action, array( 'edit', 'submit' ) )
122 && in_array( $key, array( 'edit', 'watch', 'unwatch' ))) {
123 echo $skin->tooltip( "ca-$key" );
124 } else {
125 echo $skin->tooltipAndAccesskey( "ca-$key" );
126 }
127 echo '>'.htmlspecialchars($tab['text']).'</a></li>';
128 } ?>
129 </ul>
130 </div>
131 </div>
132 <div class="portlet" id="p-personal">
133 <h5><?php $this->msg('personaltools') ?></h5>
134 <div class="pBody">
135 <ul <?php $this->html('userlangattributes') ?>>
136 <?php foreach($this->data['personal_urls'] as $key => $item) { ?>
137 <li id="<?php echo Sanitizer::escapeId( "pt-$key" ) ?>"<?php
138 if ($item['active']) { ?> class="active"<?php } ?>><a href="<?php
139 echo htmlspecialchars($item['href']) ?>"<?php echo $skin->tooltipAndAccesskey('pt-'.$key) ?><?php
140 if(!empty($item['class'])) { ?> class="<?php
141 echo htmlspecialchars($item['class']) ?>"<?php } ?>><?php
142 echo htmlspecialchars($item['text']) ?></a></li>
143 <?php } ?>
144 </ul>
145 </div>
146 </div>
147 <div class="portlet" id="p-logo">
148 <a style="background-image: url(<?php $this->text('logopath') ?>);" <?php
149 ?>href="<?php echo htmlspecialchars($this->data['nav_urls']['mainpage']['href'])?>"<?php
150 echo $skin->tooltipAndAccesskey('p-logo') ?>></a>
151 </div>
152 <script type="<?php $this->text('jsmimetype') ?>"> if (window.isMSIE55) fixalpha(); </script>
153 <?php
154 $sidebar = $this->data['sidebar'];
155 if ( !isset( $sidebar['SEARCH'] ) ) $sidebar['SEARCH'] = true;
156 if ( !isset( $sidebar['TOOLBOX'] ) ) $sidebar['TOOLBOX'] = true;
157 if ( !isset( $sidebar['LANGUAGES'] ) ) $sidebar['LANGUAGES'] = true;
158 foreach ($sidebar as $boxName => $cont) {
159 if ( $boxName == 'SEARCH' ) {
160 $this->searchBox();
161 } elseif ( $boxName == 'TOOLBOX' ) {
162 $this->toolbox();
163 } elseif ( $boxName == 'LANGUAGES' ) {
164 $this->languageBox();
165 } else {
166 $this->customBox( $boxName, $cont );
167 }
168 }
169 ?>
170 </div><!-- end of the left (by default at least) column -->
171 <div class="visualClear"></div>
172 <div id="footer">
173 <?php
174 if($this->data['poweredbyico']) { ?>
175 <div id="f-poweredbyico"><?php $this->html('poweredbyico') ?></div>
176 <?php }
177 if($this->data['copyrightico']) { ?>
178 <div id="f-copyrightico"><?php $this->html('copyrightico') ?></div>
179 <?php }
180
181 // Generate additional footer links
182 $footerlinks = array(
183 'lastmod', 'viewcount', 'numberofwatchingusers', 'credits', 'copyright',
184 'privacy', 'about', 'disclaimer', 'tagline',
185 );
186 $validFooterLinks = array();
187 foreach( $footerlinks as $aLink ) {
188 if( isset( $this->data[$aLink] ) && $this->data[$aLink] ) {
189 $validFooterLinks[] = $aLink;
190 }
191 }
192 if ( count( $validFooterLinks ) > 0 ) {
193 ?> <ul id="f-list">
194 <?php
195 foreach( $validFooterLinks as $aLink ) {
196 if( isset( $this->data[$aLink] ) && $this->data[$aLink] ) {
197 ?> <li id="<?php echo $aLink ?>"><?php $this->html($aLink) ?></li>
198 <?php }
199 }
200 ?>
201 </ul>
202 <?php }
203 ?>
204 </div>
205 </div>
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 -->
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 <div id="p-search" class="portlet">
224 <h5 <?php $this->html('userlangattributes') ?>><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 <?php
229 echo Html::input( 'search',
230 isset( $this->data['search'] ) ? $this->data['search'] : '', 'search',
231 array(
232 'id' => 'searchInput',
233 'title' => $this->skin->titleAttrib( 'search' ),
234 'accesskey' => $this->skin->accesskey( 'search' )
235 ) ); ?>
236
237 <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;
238 <input type='submit' name="fulltext" class="searchButton" id="mw-searchButton" value="<?php $this->msg('searchbutton') ?>"<?php echo $this->skin->tooltipAndAccesskey( 'search-fulltext' ); ?> /><?php } else { ?>
239
240 <div><a href="<?php $this->text('searchaction') ?>" rel="search"><?php $this->msg('powersearch-legend') ?></a></div><?php } ?>
241
242 </form>
243 </div>
244 </div>
245 <?php
246 }
247
248 /*************************************************************************************************/
249 function toolbox() {
250 ?>
251 <div class="portlet" id="p-tb">
252 <h5 <?php $this->html('userlangattributes')?>><?php $this->msg('toolbox') ?></h5>
253 <div class="pBody">
254 <ul>
255 <?php
256 if($this->data['notspecialpage']) { ?>
257 <li id="t-whatlinkshere"><a href="<?php
258 echo htmlspecialchars($this->data['nav_urls']['whatlinkshere']['href'])
259 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-whatlinkshere') ?>><?php $this->msg('whatlinkshere') ?></a></li>
260 <?php
261 if( $this->data['nav_urls']['recentchangeslinked'] ) { ?>
262 <li id="t-recentchangeslinked"><a href="<?php
263 echo htmlspecialchars($this->data['nav_urls']['recentchangeslinked']['href'])
264 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-recentchangeslinked') ?>><?php $this->msg('recentchangeslinked-toolbox') ?></a></li>
265 <?php }
266 }
267 if( isset( $this->data['nav_urls']['trackbacklink'] ) && $this->data['nav_urls']['trackbacklink'] ) { ?>
268 <li id="t-trackbacklink"><a href="<?php
269 echo htmlspecialchars($this->data['nav_urls']['trackbacklink']['href'])
270 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-trackbacklink') ?>><?php $this->msg('trackbacklink') ?></a></li>
271 <?php }
272 if($this->data['feeds']) { ?>
273 <li id="feedlinks"><?php foreach($this->data['feeds'] as $key => $feed) {
274 ?><a id="<?php echo Sanitizer::escapeId( "feed-$key" ) ?>" href="<?php
275 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;
276 <?php } ?></li><?php
277 }
278
279 foreach( array('contributions', 'log', 'blockip', 'emailuser', 'upload', 'specialpages') as $special ) {
280
281 if($this->data['nav_urls'][$special]) {
282 ?><li id="t-<?php echo $special ?>"><a href="<?php echo htmlspecialchars($this->data['nav_urls'][$special]['href'])
283 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-'.$special) ?>><?php $this->msg($special) ?></a></li>
284 <?php }
285 }
286
287 if(!empty($this->data['nav_urls']['print']['href'])) { ?>
288 <li id="t-print"><a href="<?php echo htmlspecialchars($this->data['nav_urls']['print']['href'])
289 ?>" rel="alternate"<?php echo $this->skin->tooltipAndAccesskey('t-print') ?>><?php $this->msg('printableversion') ?></a></li><?php
290 }
291
292 if(!empty($this->data['nav_urls']['permalink']['href'])) { ?>
293 <li id="t-permalink"><a href="<?php echo htmlspecialchars($this->data['nav_urls']['permalink']['href'])
294 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-permalink') ?>><?php $this->msg('permalink') ?></a></li><?php
295 } elseif ($this->data['nav_urls']['permalink']['href'] === '') { ?>
296 <li id="t-ispermalink"<?php echo $this->skin->tooltip('t-ispermalink') ?>><?php $this->msg('permalink') ?></li><?php
297 }
298
299 wfRunHooks( 'MonoBookTemplateToolboxEnd', array( &$this ) );
300 wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this ) );
301 ?>
302 </ul>
303 </div>
304 </div>
305 <?php
306 }
307
308 /*************************************************************************************************/
309 function languageBox() {
310 if( $this->data['language_urls'] ) {
311 ?>
312 <div id="p-lang" class="portlet">
313 <h5 <?php $this->html('userlangattributes') ?>><?php $this->msg('otherlanguages') ?></h5>
314 <div class="pBody">
315 <ul>
316 <?php foreach($this->data['language_urls'] as $langlink) { ?>
317 <li class="<?php echo htmlspecialchars($langlink['class'])?>"><?php
318 ?><a href="<?php echo htmlspecialchars($langlink['href']) ?>"><?php echo $langlink['text'] ?></a></li>
319 <?php } ?>
320 </ul>
321 </div>
322 </div>
323 <?php
324 }
325 }
326
327 /*************************************************************************************************/
328 function customBox( $bar, $cont ) {
329 ?>
330 <div class='generated-sidebar portlet' id='<?php echo Sanitizer::escapeId( "p-$bar" ) ?>'<?php echo $this->skin->tooltip('p-'.$bar) ?>>
331 <h5 <?php $this->html('userlangattributes') ?>><?php $out = wfMsg( $bar ); if (wfEmptyMsg($bar, $out)) echo htmlspecialchars($bar); else echo htmlspecialchars($out); ?></h5>
332 <div class='pBody'>
333 <?php if ( is_array( $cont ) ) { ?>
334 <ul>
335 <?php foreach($cont as $key => $val) { ?>
336 <li id="<?php echo Sanitizer::escapeId($val['id']) ?>"<?php
337 if ( $val['active'] ) { ?> class="active" <?php }
338 ?>><a href="<?php echo htmlspecialchars($val['href']) ?>"<?php echo $this->skin->tooltipAndAccesskey($val['id']) ?>><?php echo htmlspecialchars($val['text']) ?></a></li>
339 <?php } ?>
340 </ul>
341 <?php } else {
342 # allow raw HTML block to be defined by extensions
343 print $cont;
344 }
345 ?>
346 </div>
347 </div>
348 <?php
349 }
350 } // end of class
351
352