Remove most named character references from output
[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;
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 }
46 }
47
48 /**
49 * @todo document
50 * @ingroup Skins
51 */
52 class MonoBookTemplate extends QuickTemplate {
53 var $skin;
54 /**
55 * Template filter callback for MonoBook skin.
56 * Takes an associative array of data set from a SkinTemplate-based
57 * class, and a wrapper for MediaWiki's localization database, and
58 * outputs a formatted page.
59 *
60 * @access private
61 */
62 function execute() {
63 global $wgRequest;
64
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 ?><div id="globalWrapper">
73 <div id="column-content"><div id="content"<?php $this->html("specialpageattributes") ?>>
74 <a id="top"></a>
75 <?php if($this->data['sitenotice']) { ?><div id="siteNotice"><?php $this->html('sitenotice') ?></div><?php } ?>
76
77 <h1 id="firstHeading" class="firstHeading"><?php $this->html('title') ?></h1>
78 <div id="bodyContent">
79 <h3 id="siteSub"><?php $this->msg('tagline') ?></h3>
80 <div id="contentSub"<?php $this->html('userlangattributes') ?>><?php $this->html('subtitle') ?></div>
81 <?php if($this->data['undelete']) { ?>
82 <div id="contentSub2"><?php $this->html('undelete') ?></div>
83 <?php } ?><?php if($this->data['newtalk'] ) { ?>
84 <div class="usermessage"><?php $this->html('newtalk') ?></div>
85 <?php } ?><?php if($this->data['showjumplinks']) { ?>
86 <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>
87 <?php } ?>
88 <!-- start content -->
89 <?php $this->html('bodytext') ?>
90 <?php if($this->data['catlinks']) { $this->html('catlinks'); } ?>
91 <!-- end content -->
92 <?php if($this->data['dataAfterContent']) { $this->html ('dataAfterContent'); } ?>
93 <div class="visualClear"></div>
94 </div>
95 </div></div>
96 <div id="column-one"<?php $this->html('userlangattributes') ?>>
97 <div id="p-cactions" class="portlet">
98 <h5><?php $this->msg('views') ?></h5>
99 <div class="pBody">
100 <ul><?php
101 foreach($this->data['content_actions'] as $key => $tab) {
102 echo '
103 <li id="' . Sanitizer::escapeId( "ca-$key" ) . '"';
104 if( $tab['class'] ) {
105 echo ' class="'.htmlspecialchars($tab['class']).'"';
106 }
107 echo '><a href="'.htmlspecialchars($tab['href']).'"';
108 # We don't want to give the watch tab an accesskey if the
109 # page is being edited, because that conflicts with the
110 # accesskey on the watch checkbox. We also don't want to
111 # give the edit tab an accesskey, because that's fairly su-
112 # perfluous and conflicts with an accesskey (Ctrl-E) often
113 # used for editing in Safari.
114 if( in_array( $action, array( 'edit', 'submit' ) )
115 && in_array( $key, array( 'edit', 'watch', 'unwatch' ))) {
116 echo $skin->tooltip( "ca-$key" );
117 } else {
118 echo $skin->tooltipAndAccesskey( "ca-$key" );
119 }
120 echo '>'.htmlspecialchars($tab['text']).'</a></li>';
121 } ?>
122
123 </ul>
124 </div>
125 </div>
126 <div class="portlet" id="p-personal">
127 <h5><?php $this->msg('personaltools') ?></h5>
128 <div class="pBody">
129 <ul<?php $this->html('userlangattributes') ?>>
130 <?php foreach($this->data['personal_urls'] as $key => $item) { ?>
131 <li id="<?php echo Sanitizer::escapeId( "pt-$key" ) ?>"<?php
132 if ($item['active']) { ?> class="active"<?php } ?>><a href="<?php
133 echo htmlspecialchars($item['href']) ?>"<?php echo $skin->tooltipAndAccesskey('pt-'.$key) ?><?php
134 if(!empty($item['class'])) { ?> class="<?php
135 echo htmlspecialchars($item['class']) ?>"<?php } ?>><?php
136 echo htmlspecialchars($item['text']) ?></a></li>
137 <?php } ?>
138 </ul>
139 </div>
140 </div>
141 <div class="portlet" id="p-logo">
142 <a style="background-image: url(<?php $this->text('logopath') ?>);" <?php
143 ?>href="<?php echo htmlspecialchars($this->data['nav_urls']['mainpage']['href'])?>"<?php
144 echo $skin->tooltipAndAccesskey('p-logo') ?>></a>
145 </div>
146 <script type="<?php $this->text('jsmimetype') ?>"> if (window.isMSIE55) fixalpha(); </script>
147 <?php
148 $sidebar = $this->data['sidebar'];
149 if ( !isset( $sidebar['SEARCH'] ) ) $sidebar['SEARCH'] = true;
150 if ( !isset( $sidebar['TOOLBOX'] ) ) $sidebar['TOOLBOX'] = true;
151 if ( !isset( $sidebar['LANGUAGES'] ) ) $sidebar['LANGUAGES'] = true;
152 foreach ($sidebar as $boxName => $cont) {
153 if ( $boxName == 'SEARCH' ) {
154 $this->searchBox();
155 } elseif ( $boxName == 'TOOLBOX' ) {
156 $this->toolbox();
157 } elseif ( $boxName == 'LANGUAGES' ) {
158 $this->languageBox();
159 } else {
160 $this->customBox( $boxName, $cont );
161 }
162 }
163 ?>
164 </div><!-- end of the left (by default at least) column -->
165 <div class="visualClear"></div>
166 <div id="footer"<?php $this->html('userlangattributes') ?>>
167 <?php
168 if($this->data['poweredbyico']) { ?>
169 <div id="f-poweredbyico"><?php $this->html('poweredbyico') ?></div>
170 <?php }
171 if($this->data['copyrightico']) { ?>
172 <div id="f-copyrightico"><?php $this->html('copyrightico') ?></div>
173 <?php }
174
175 // Generate additional footer links
176 $footerlinks = array(
177 'lastmod', 'viewcount', 'numberofwatchingusers', 'credits', 'copyright',
178 'privacy', 'about', 'disclaimer', 'tagline',
179 );
180 $validFooterLinks = array();
181 foreach( $footerlinks as $aLink ) {
182 if( isset( $this->data[$aLink] ) && $this->data[$aLink] ) {
183 $validFooterLinks[] = $aLink;
184 }
185 }
186 if ( count( $validFooterLinks ) > 0 ) {
187 ?> <ul id="f-list">
188 <?php
189 foreach( $validFooterLinks 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 }
197 ?>
198 </div>
199 </div>
200 <?php $this->html('bottomscripts'); /* JS call to runBodyOnloadHook */ ?>
201 <?php $this->html('reporttime') ?>
202 <?php if ( $this->data['debug'] ): ?>
203 <!-- Debug output:
204 <?php $this->text( 'debug' ); ?>
205
206 -->
207 <?php endif;
208
209 echo Html::closeElement( 'body' );
210 echo Html::closeElement( 'html' );
211 wfRestoreWarnings();
212 } // end of execute() method
213
214 /*************************************************************************************************/
215 function searchBox() {
216 global $wgUseTwoButtonsSearchForm;
217 ?>
218 <div id="p-search" class="portlet">
219 <h5><label for="searchInput"><?php $this->msg('search') ?></label></h5>
220 <div id="searchBody" class="pBody">
221 <form action="<?php $this->text('wgScript') ?>" id="searchform">
222 <input type='hidden' name="title" value="<?php $this->text('searchtitle') ?>"/>
223 <?php
224 echo Html::input( 'search',
225 isset( $this->data['search'] ) ? $this->data['search'] : '', 'search',
226 array(
227 'id' => 'searchInput',
228 'title' => $this->skin->titleAttrib( 'search' ),
229 'accesskey' => $this->skin->accesskey( 'search' )
230 ) ); ?>
231
232 <input type='submit' name="go" class="searchButton" id="searchGoButton" value="<?php $this->msg('searcharticle') ?>"<?php echo $this->skin->tooltipAndAccesskey( 'search-go' ); ?> /><?php if ($wgUseTwoButtonsSearchForm) { ?>&#160;
233 <input type='submit' name="fulltext" class="searchButton" id="mw-searchButton" value="<?php $this->msg('searchbutton') ?>"<?php echo $this->skin->tooltipAndAccesskey( 'search-fulltext' ); ?> /><?php } else { ?>
234
235 <div><a href="<?php $this->text('searchaction') ?>" rel="search"><?php $this->msg('powersearch-legend') ?></a></div><?php } ?>
236
237 </form>
238 </div>
239 </div>
240 <?php
241 }
242
243 /*************************************************************************************************/
244 function toolbox() {
245 ?>
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'] ) && $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>&#160;
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( 'MonoBookTemplateToolboxEnd', array( &$this ) );
295 wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this ) );
296 ?>
297 </ul>
298 </div>
299 </div>
300 <?php
301 }
302
303 /*************************************************************************************************/
304 function languageBox() {
305 if( $this->data['language_urls'] ) {
306 ?>
307 <div id="p-lang" class="portlet">
308 <h5<?php $this->html('userlangattributes') ?>><?php $this->msg('otherlanguages') ?></h5>
309 <div class="pBody">
310 <ul>
311 <?php foreach($this->data['language_urls'] as $langlink) { ?>
312 <li class="<?php echo htmlspecialchars($langlink['class'])?>"><?php
313 ?><a href="<?php echo htmlspecialchars($langlink['href']) ?>"><?php echo $langlink['text'] ?></a></li>
314 <?php } ?>
315 </ul>
316 </div>
317 </div>
318 <?php
319 }
320 }
321
322 /*************************************************************************************************/
323 function customBox( $bar, $cont ) {
324 ?>
325 <div class='generated-sidebar portlet' id='<?php echo Sanitizer::escapeId( "p-$bar" ) ?>'<?php echo $this->skin->tooltip('p-'.$bar) ?>>
326 <h5><?php $out = wfMsg( $bar ); if (wfEmptyMsg($bar, $out)) echo htmlspecialchars($bar); else echo htmlspecialchars($out); ?></h5>
327 <div class='pBody'>
328 <?php if ( is_array( $cont ) ) { ?>
329 <ul>
330 <?php foreach($cont as $key => $val) { ?>
331 <li id="<?php echo Sanitizer::escapeId($val['id']) ?>"<?php
332 if ( $val['active'] ) { ?> class="active" <?php }
333 ?>><a href="<?php echo htmlspecialchars($val['href']) ?>"<?php echo $this->skin->tooltipAndAccesskey($val['id']) ?>><?php echo htmlspecialchars($val['text']) ?></a></li>
334 <?php } ?>
335 </ul>
336 <?php } else {
337 # allow raw HTML block to be defined by extensions
338 print $cont;
339 }
340 ?>
341 </div>
342 </div>
343 <?php
344 }
345 } // end of class
346
347