5 * Translated from gwicke's previous TAL template version to remove
6 * dependency on PHPTAL.
13 if( !defined( 'MEDIAWIKI' ) )
17 * Inherit main code from SkinTemplate, set the CSS and template filter.
21 class SkinMonoBook extends SkinTemplate {
22 /** Using monobook. */
23 var $skinname = 'monobook', $stylename = 'monobook',
24 $template = 'MonoBookTemplate', $useHeadElement = true;
26 function setupSkinUserCss( OutputPage $out ) {
27 global $wgHandheldStyle;
29 parent::setupSkinUserCss( $out );
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' );
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' );
43 $out->addStyle( 'monobook/rtl.css', 'screen', '', 'rtl' );
52 class MonoBookTemplate extends QuickTemplate {
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.
65 $this->skin = $skin = $this->data['skin'];
66 $action = $wgRequest->getText( 'action' );
68 // Suppress warnings to prevent notices about missing indexes in $this->data
71 // Generate additional footer links
72 $footerlinks = $this->data["footerlinks"];
73 // fold footerlinks into a single array using a bit of trickery
74 $footerlinks = call_user_func_array('array_merge', array_values($footerlinks));
75 // Generate additional footer icons
76 $footericons = $this->data["footericons"];
77 // Unset any icons which don't have an image
78 foreach ( $footericons as $footerIconsKey => &$footerIconsBlock ) {
79 foreach ( $footerIconsBlock as $footerIconKey => $footerIcon ) {
80 if ( !is_string($footerIcon) && !isset($footerIcon["src"]) ) {
81 unset($footerIconsBlock[$footerIconKey]);
85 // Redo removal of any empty blocks
86 foreach ( $footericons as $footerIconsKey => &$footerIconsBlock ) {
87 if ( count($footerIconsBlock) <= 0 ) {
88 unset($footericons[$footerIconsKey]);
92 $this->html( 'headelement' );
93 ?><div id="globalWrapper">
94 <div id="column-content"><div id="content"<?php $this->html("specialpageattributes") ?>>
96 <?php if($this->data['sitenotice']) { ?><div id="siteNotice"><?php $this->html('sitenotice') ?></div><?php } ?>
98 <h1 id="firstHeading" class="firstHeading"><?php $this->html('title') ?></h1>
99 <div id="bodyContent">
100 <div id="siteSub"><?php $this->msg('tagline') ?></div>
101 <div id="contentSub"<?php $this->html('userlangattributes') ?>><?php $this->html('subtitle') ?></div>
102 <?php if($this->data['undelete']) { ?>
103 <div id="contentSub2"><?php $this->html('undelete') ?></div>
104 <?php } ?><?php if($this->data['newtalk'] ) { ?>
105 <div class="usermessage"><?php $this->html('newtalk') ?></div>
106 <?php } ?><?php if($this->data['showjumplinks']) { ?>
107 <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>
109 <!-- start content -->
110 <?php $this->html('bodytext') ?>
111 <?php if($this->data['catlinks']) { $this->html('catlinks'); } ?>
113 <?php if($this->data['dataAfterContent']) { $this->html ('dataAfterContent'); } ?>
114 <div class="visualClear"></div>
117 <div id="column-one"<?php $this->html('userlangattributes') ?>>
118 <div id="p-cactions" class="portlet">
119 <h5><?php $this->msg('views') ?></h5>
122 foreach($this->data['content_actions'] as $key => $tab) {
124 <li id="' . Sanitizer::escapeId( "ca-$key" ) . '"';
125 if( $tab['class'] ) {
126 echo ' class="'.htmlspecialchars($tab['class']).'"';
128 echo '><a href="'.htmlspecialchars($tab['href']).'"';
129 # We don't want to give the watch tab an accesskey if the
130 # page is being edited, because that conflicts with the
131 # accesskey on the watch checkbox. We also don't want to
132 # give the edit tab an accesskey, because that's fairly su-
133 # perfluous and conflicts with an accesskey (Ctrl-E) often
134 # used for editing in Safari.
135 if( in_array( $action, array( 'edit', 'submit' ) )
136 && in_array( $key, array( 'edit', 'watch', 'unwatch' ))) {
137 echo $skin->tooltip( "ca-$key" );
139 echo $skin->tooltipAndAccesskey( "ca-$key" );
141 echo '>'.htmlspecialchars($tab['text']).'</a></li>';
147 <div class="portlet" id="p-personal">
148 <h5><?php $this->msg('personaltools') ?></h5>
150 <ul<?php $this->html('userlangattributes') ?>>
151 <?php foreach($this->data['personal_urls'] as $key => $item) { ?>
152 <li id="<?php echo Sanitizer::escapeId( "pt-$key" ) ?>"<?php
153 if ($item['active']) { ?> class="active"<?php } ?>><a href="<?php
154 echo htmlspecialchars($item['href']) ?>"<?php echo $skin->tooltipAndAccesskey('pt-'.$key) ?><?php
155 if(!empty($item['class'])) { ?> class="<?php
156 echo htmlspecialchars($item['class']) ?>"<?php } ?>><?php
157 echo htmlspecialchars($item['text']) ?></a></li>
162 <div class="portlet" id="p-logo">
163 <a style="background-image: url(<?php $this->text('logopath') ?>);" <?php
164 ?>href="<?php echo htmlspecialchars($this->data['nav_urls']['mainpage']['href'])?>"<?php
165 echo $skin->tooltipAndAccesskey('p-logo') ?>></a>
167 <script type="<?php $this->text('jsmimetype') ?>"> if (window.isMSIE55) fixalpha(); </script>
169 $sidebar = $this->data['sidebar'];
170 if ( !isset( $sidebar['SEARCH'] ) ) $sidebar['SEARCH'] = true;
171 if ( !isset( $sidebar['TOOLBOX'] ) ) $sidebar['TOOLBOX'] = true;
172 if ( !isset( $sidebar['LANGUAGES'] ) ) $sidebar['LANGUAGES'] = true;
173 foreach ($sidebar as $boxName => $cont) {
174 if ( $boxName == 'SEARCH' ) {
176 } elseif ( $boxName == 'TOOLBOX' ) {
178 } elseif ( $boxName == 'LANGUAGES' ) {
179 $this->languageBox();
181 $this->customBox( $boxName, $cont );
185 </div><!-- end of the left (by default at least) column -->
186 <div class="visualClear"></div>
187 <div id="footer"<?php $this->html('userlangattributes') ?>>
188 <?php foreach ( $footericons as $blockName => $footerIcons ) { ?>
189 <div id="f-<?php echo htmlspecialchars($blockName); ?>ico">
190 <?php foreach ( $footerIcons as $icon ) { ?>
191 <?php echo $this->skin->makeFooterIcon( $icon ); ?>
198 // Generate additional footer links
199 $validFooterLinks = array();
200 foreach( $footerlinks as $aLink ) {
201 if( isset( $this->data[$aLink] ) && $this->data[$aLink] ) {
202 $validFooterLinks[] = $aLink;
205 if ( count( $validFooterLinks ) > 0 ) {
208 foreach( $validFooterLinks as $aLink ) {
209 if( isset( $this->data[$aLink] ) && $this->data[$aLink] ) {
210 ?> <li id="<?php echo $aLink ?>"><?php $this->html($aLink) ?></li>
219 <?php $this->html('bottomscripts'); /* JS call to runBodyOnloadHook */ ?>
220 <?php $this->html('reporttime') ?>
221 <?php if ( $this->data['debug'] ): ?>
223 <?php $this->text( 'debug' ); ?>
228 echo Html::closeElement( 'body' );
229 echo Html::closeElement( 'html' );
231 } // end of execute() method
233 /*************************************************************************************************/
234 function searchBox() {
235 global $wgUseTwoButtonsSearchForm;
237 <div id="p-search" class="portlet">
238 <h5><label for="searchInput"><?php $this->msg('search') ?></label></h5>
239 <div id="searchBody" class="pBody">
240 <form action="<?php $this->text('wgScript') ?>" id="searchform">
241 <input type='hidden' name="title" value="<?php $this->text('searchtitle') ?>"/>
243 echo Html::input( 'search',
244 isset( $this->data['search'] ) ? $this->data['search'] : '', 'search',
246 'id' => 'searchInput',
247 'title' => $this->skin->titleAttrib( 'search' ),
248 'accesskey' => $this->skin->accesskey( 'search' )
251 <input type='submit' name="go" class="searchButton" id="searchGoButton" value="<?php $this->msg('searcharticle') ?>"<?php echo $this->skin->tooltipAndAccesskey( 'search-go' ); ?> /><?php if ($wgUseTwoButtonsSearchForm) { ?> 
252 <input type='submit' name="fulltext" class="searchButton" id="mw-searchButton" value="<?php $this->msg('searchbutton') ?>"<?php echo $this->skin->tooltipAndAccesskey( 'search-fulltext' ); ?> /><?php } else { ?>
254 <div><a href="<?php $this->text('searchaction') ?>" rel="search"><?php $this->msg('powersearch-legend') ?></a></div><?php } ?>
262 /*************************************************************************************************/
265 <div class="portlet" id="p-tb">
266 <h5><?php $this->msg('toolbox') ?></h5>
270 if($this->data['notspecialpage']) { ?>
271 <li id="t-whatlinkshere"><a href="<?php
272 echo htmlspecialchars($this->data['nav_urls']['whatlinkshere']['href'])
273 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-whatlinkshere') ?>><?php $this->msg('whatlinkshere') ?></a></li>
275 if( $this->data['nav_urls']['recentchangeslinked'] ) { ?>
276 <li id="t-recentchangeslinked"><a href="<?php
277 echo htmlspecialchars($this->data['nav_urls']['recentchangeslinked']['href'])
278 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-recentchangeslinked') ?>><?php $this->msg('recentchangeslinked-toolbox') ?></a></li>
281 if( isset( $this->data['nav_urls']['trackbacklink'] ) && $this->data['nav_urls']['trackbacklink'] ) { ?>
282 <li id="t-trackbacklink"><a href="<?php
283 echo htmlspecialchars($this->data['nav_urls']['trackbacklink']['href'])
284 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-trackbacklink') ?>><?php $this->msg('trackbacklink') ?></a></li>
286 if($this->data['feeds']) { ?>
287 <li id="feedlinks"><?php foreach($this->data['feeds'] as $key => $feed) {
288 ?><a id="<?php echo Sanitizer::escapeId( "feed-$key" ) ?>" href="<?php
289 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> 
293 foreach( array('contributions', 'log', 'blockip', 'emailuser', 'upload', 'specialpages') as $special ) {
295 if($this->data['nav_urls'][$special]) {
296 ?><li id="t-<?php echo $special ?>"><a href="<?php echo htmlspecialchars($this->data['nav_urls'][$special]['href'])
297 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-'.$special) ?>><?php $this->msg($special) ?></a></li>
301 if(!empty($this->data['nav_urls']['print']['href'])) { ?>
302 <li id="t-print"><a href="<?php echo htmlspecialchars($this->data['nav_urls']['print']['href'])
303 ?>" rel="alternate"<?php echo $this->skin->tooltipAndAccesskey('t-print') ?>><?php $this->msg('printableversion') ?></a></li><?php
306 if(!empty($this->data['nav_urls']['permalink']['href'])) { ?>
307 <li id="t-permalink"><a href="<?php echo htmlspecialchars($this->data['nav_urls']['permalink']['href'])
308 ?>"<?php echo $this->skin->tooltipAndAccesskey('t-permalink') ?>><?php $this->msg('permalink') ?></a></li><?php
309 } elseif ($this->data['nav_urls']['permalink']['href'] === '') { ?>
310 <li id="t-ispermalink"<?php echo $this->skin->tooltip('t-ispermalink') ?>><?php $this->msg('permalink') ?></li><?php
313 wfRunHooks( 'MonoBookTemplateToolboxEnd', array( &$this ) );
314 wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this ) );
322 /*************************************************************************************************/
323 function languageBox() {
324 if( $this->data['language_urls'] ) {
326 <div id="p-lang" class="portlet">
327 <h5<?php $this->html('userlangattributes') ?>><?php $this->msg('otherlanguages') ?></h5>
330 <?php foreach($this->data['language_urls'] as $langlink) { ?>
331 <li class="<?php echo htmlspecialchars($langlink['class'])?>"><?php
332 ?><a href="<?php echo htmlspecialchars($langlink['href']) ?>" title="<?php
333 echo htmlspecialchars($langlink['title']) ?>"><?php echo $langlink['text'] ?></a></li>
342 /*************************************************************************************************/
343 function customBox( $bar, $cont ) {
345 <div class='generated-sidebar portlet' id='<?php echo Sanitizer::escapeId( "p-$bar" ) ?>'<?php echo $this->skin->tooltip('p-'.$bar) ?>>
346 <h5><?php $out = wfMsg( $bar ); if (wfEmptyMsg($bar, $out)) echo htmlspecialchars($bar); else echo htmlspecialchars($out); ?></h5>
348 <?php if ( is_array( $cont ) ) { ?>
350 <?php foreach($cont as $val) { ?>
351 <li id="<?php echo Sanitizer::escapeId($val['id']) ?>"<?php
352 if ( $val['active'] ) { ?> class="active" <?php }
353 ?>><a href="<?php echo htmlspecialchars($val['href']) ?>"<?php echo $this->skin->tooltipAndAccesskey($val['id']) ?>><?php echo htmlspecialchars($val['text']) ?></a></li>
357 # allow raw HTML block to be defined by extensions