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