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 function initPage( OutputPage
$out ) {
24 parent
::initPage( $out );
25 $this->skinname
= 'monobook';
26 $this->stylename
= 'monobook';
27 $this->template
= 'MonoBookTemplate';
30 function setupSkinUserCss( OutputPage
$out ) {
31 global $wgHandheldStyle;
33 parent
::setupSkinUserCss( $out );
35 // Append to the default screen common & print styles...
36 $out->addStyle( 'monobook/main.css', 'screen' );
37 if( $wgHandheldStyle ) {
38 // Currently in testing... try 'chick/main.css'
39 $out->addStyle( $wgHandheldStyle, 'handheld' );
42 $out->addStyle( 'monobook/IE50Fixes.css', 'screen', 'lt IE 5.5000' );
43 $out->addStyle( 'monobook/IE55Fixes.css', 'screen', 'IE 5.5000' );
44 $out->addStyle( 'monobook/IE60Fixes.css', 'screen', 'IE 6' );
45 $out->addStyle( 'monobook/IE70Fixes.css', 'screen', 'IE 7' );
47 $out->addStyle( 'monobook/rtl.css', 'screen', '', 'rtl' );
50 //@@todo we can move this to the parent once we update all skins
51 if( isset( $this->pagecss
) && $this->pagecss
)
52 $out->addInlineStyle( $this->pagecss
);
54 if( isset( $this->usercss
) && $this->usercss
)
55 $out->addInlineStyle( $this->usercss
);
58 function setupSkinUserJs( OutputPage
$out ) {
59 parent
::setupSkinUserJs( $out );
60 $out->addScriptFile( 'wikibits.js' );
62 //@@todo can move to parent once we update all skins (to not include things twice
63 if( isset( $this->jsvarurl
) && $this->jsvarurl
)
64 $out->addScriptFile( $this->jsvarurl
);
66 if( isset( $this->userjs
) && $this->userjs
)
67 $out->addScriptFile( $this->userjs
);
69 if( isset( $this->userjsprev
) && $this->userjsprev
)
70 $out->addInlineScript( $this->userjsprev
);
78 class MonoBookTemplate
extends QuickTemplate
{
81 * Template filter callback for MonoBook skin.
82 * Takes an associative array of data set from a SkinTemplate-based
83 * class, and a wrapper for MediaWiki's localization database, and
84 * outputs a formatted page.
89 global $wgRequest, $wgOut, $wgStyleVersion, $wgJsMimeType, $wgStylePath;
90 $this->skin
= $skin = $this->data
['skin'];
91 $action = $wgRequest->getText( 'action' );
93 // Suppress warnings to prevent notices about missing indexes in $this->data
95 # FIXME: What is this? Should it apply to all skins?
96 $path = htmlspecialchars( $wgStylePath );
97 $wgOut->addScript( <<<HTML
98 <!--[if lt IE 7]><script type="$wgJsMimeType" src="$path/common/IEFixes.js?$wgStyleVersion"></script>
99 <meta http-equiv="imagetoolbar" content="no" /><![endif]-->
103 echo $wgOut->headElement( $this->skin
);
105 ?
><body
<?php
if($this->data
['body_ondblclick']) { ?
> ondblclick
="<?php $this->text('body_ondblclick') ?>"<?php
} ?
>
106 <?php
if($this->data
['body_onload']) { ?
> onload
="<?php $this->text('body_onload') ?>"<?php
} ?
>
107 class="mediawiki <?php $this->text('dir'); $this->text('capitalizeallnouns') ?> <?php $this->text('pageclass') ?> <?php $this->text('skinnameclass') ?>">
108 <div id
="globalWrapper">
109 <div id
="column-content">
112 <?php
if($this->data
['sitenotice']) { ?
><div id
="siteNotice"><?php
$this->html('sitenotice') ?
></div
><?php
} ?
>
113 <h1 id
="firstHeading" class="firstHeading"><?php
$this->html('title') ?
></h1
>
114 <div id
="bodyContent">
115 <h3 id
="siteSub"><?php
$this->msg('tagline') ?
></h3
>
116 <div id
="contentSub"><?php
$this->html('subtitle') ?
></div
>
117 <?php
if($this->data
['undelete']) { ?
><div id
="contentSub2"><?php
$this->html('undelete') ?
></div
><?php
} ?
>
118 <?php
if($this->data
['newtalk'] ) { ?
><div
class="usermessage"><?php
$this->html('newtalk') ?
></div
><?php
} ?
>
119 <?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
} ?
>
120 <!-- start content
-->
121 <?php
$this->html('bodytext') ?
>
122 <?php
if($this->data
['catlinks']) { $this->html('catlinks'); } ?
>
124 <?php
if($this->data
['dataAfterContent']) { $this->html ('dataAfterContent'); } ?
>
125 <div
class="visualClear"></div
>
129 <div id
="column-one">
130 <div id
="p-cactions" class="portlet">
131 <h5
><?php
$this->msg('views') ?
></h5
>
133 <ul
<?php
$this->html('userlangattributes') ?
>>
134 <?php
foreach($this->data
['content_actions'] as $key => $tab) {
136 <li id="' . Sanitizer
::escapeId( "ca-$key" ) . '"';
137 if( $tab['class'] ) {
138 echo ' class="'.htmlspecialchars($tab['class']).'"';
140 echo '><a href="'.htmlspecialchars($tab['href']).'"';
141 # We don't want to give the watch tab an accesskey if the
142 # page is being edited, because that conflicts with the
143 # accesskey on the watch checkbox. We also don't want to
144 # give the edit tab an accesskey, because that's fairly su-
145 # perfluous and conflicts with an accesskey (Ctrl-E) often
146 # used for editing in Safari.
147 if( in_array( $action, array( 'edit', 'submit' ) )
148 && in_array( $key, array( 'edit', 'watch', 'unwatch' ))) {
149 echo $skin->tooltip( "ca-$key" );
151 echo $skin->tooltipAndAccesskey( "ca-$key" );
153 echo '>'.htmlspecialchars($tab['text']).'</a></li>';
158 <div
class="portlet" id
="p-personal">
159 <h5
><?php
$this->msg('personaltools') ?
></h5
>
161 <ul
<?php
$this->html('userlangattributes') ?
>>
162 <?php
foreach($this->data
['personal_urls'] as $key => $item) { ?
>
163 <li id
="<?php echo Sanitizer::escapeId( "pt
-$key" ) ?>"<?php
164 if ($item['active']) { ?
> class="active"<?php
} ?
>><a href
="<?php
165 echo htmlspecialchars($item['href']) ?>"<?php
echo $skin->tooltipAndAccesskey('pt-'.$key) ?
><?php
166 if(!empty($item['class'])) { ?
> class="<?php
167 echo htmlspecialchars($item['class']) ?>"<?php
} ?
>><?php
168 echo htmlspecialchars($item['text']) ?
></a
></li
>
173 <div
class="portlet" id
="p-logo">
174 <a style
="background-image: url(<?php $this->text('logopath') ?>);" <?php
175 ?
>href
="<?php echo htmlspecialchars($this->data['nav_urls']['mainpage']['href'])?>"<?php
176 echo $skin->tooltipAndAccesskey('p-logo') ?
>></a
>
178 <script type
="<?php $this->text('jsmimetype') ?>"> if (window
.isMSIE55
) fixalpha(); </script
>
180 $sidebar = $this->data
['sidebar'];
181 if ( !isset( $sidebar['SEARCH'] ) ) $sidebar['SEARCH'] = true;
182 if ( !isset( $sidebar['TOOLBOX'] ) ) $sidebar['TOOLBOX'] = true;
183 if ( !isset( $sidebar['LANGUAGES'] ) ) $sidebar['LANGUAGES'] = true;
184 foreach ($sidebar as $boxName => $cont) {
185 if ( $boxName == 'SEARCH' ) {
187 } elseif ( $boxName == 'TOOLBOX' ) {
189 } elseif ( $boxName == 'LANGUAGES' ) {
190 $this->languageBox();
192 $this->customBox( $boxName, $cont );
196 </div
><!-- end of the
left (by
default at least
) column
-->
197 <div
class="visualClear"></div
>
200 if($this->data
['poweredbyico']) { ?
>
201 <div id
="f-poweredbyico"><?php
$this->html('poweredbyico') ?
></div
>
203 if($this->data
['copyrightico']) { ?
>
204 <div id
="f-copyrightico"><?php
$this->html('copyrightico') ?
></div
>
207 // Generate additional footer links
208 $footerlinks = array(
209 'lastmod', 'viewcount', 'numberofwatchingusers', 'credits', 'copyright',
210 'privacy', 'about', 'disclaimer', 'tagline',
212 $validFooterLinks = array();
213 foreach( $footerlinks as $aLink ) {
214 if( isset( $this->data
[$aLink] ) && $this->data
[$aLink] ) {
215 $validFooterLinks[] = $aLink;
218 if ( count( $validFooterLinks ) > 0 ) {
221 foreach( $validFooterLinks as $aLink ) {
222 if( isset( $this->data
[$aLink] ) && $this->data
[$aLink] ) {
223 ?
> <li id
="<?php echo $aLink ?>"><?php
$this->html($aLink) ?
></li
>
232 <?php
$this->html('bottomscripts'); /* JS call to runBodyOnloadHook */ ?
>
233 <?php
$this->html('reporttime') ?
>
234 <?php
if ( $this->data
['debug'] ): ?
>
236 <?php
$this->text( 'debug' ); ?
>
243 } // end of execute() method
245 /*************************************************************************************************/
246 function searchBox() {
247 global $wgUseTwoButtonsSearchForm;
249 <div id
="p-search" class="portlet">
250 <h5
<?php
$this->html('userlangattributes') ?
>><label
for="searchInput"><?php
$this->msg('search') ?
></label
></h5
>
251 <div id
="searchBody" class="pBody">
252 <form action
="<?php $this->text('wgScript') ?>" id
="searchform"><div
>
253 <input type
='hidden' name
="title" value
="<?php $this->text('searchtitle') ?>"/>
254 <input id
="searchInput" name
="search" type
="text"<?php
echo $this->skin
->tooltipAndAccesskey('search');
255 if( isset( $this->data
['search'] ) && $this->data
['search'] ) {
256 ?
> value
="<?php $this->text('search') ?>"<?php
} ?
> />
257 <input type
='submit' name
="go" class="searchButton" id
="searchGoButton" value
="<?php $this->msg('searcharticle') ?>"<?php
echo $this->skin
->tooltipAndAccesskey( 'search-go' ); ?
> /><?php
if ($wgUseTwoButtonsSearchForm) { ?
> 
;
258 <input type
='submit' name
="fulltext" class="searchButton" id
="mw-searchButton" value
="<?php $this->msg('searchbutton') ?>"<?php
echo $this->skin
->tooltipAndAccesskey( 'search-fulltext' ); ?
> /><?php
} else { ?
>
260 <div
><a href
="<?php $this->text('searchaction') ?>" rel
="search"><?php
$this->msg('powersearch-legend') ?
></a
></div
><?php
} ?
>
268 /*************************************************************************************************/
271 <div
class="portlet" id
="p-tb">
272 <h5
<?php
$this->html('userlangattributes')?
>><?php
$this->msg('toolbox') ?
></h5
>
276 if($this->data
['notspecialpage']) { ?
>
277 <li id
="t-whatlinkshere"><a href
="<?php
278 echo htmlspecialchars($this->data['nav_urls']['whatlinkshere']['href'])
279 ?>"<?php
echo $this->skin
->tooltipAndAccesskey('t-whatlinkshere') ?
>><?php
$this->msg('whatlinkshere') ?
></a
></li
>
281 if( $this->data
['nav_urls']['recentchangeslinked'] ) { ?
>
282 <li id
="t-recentchangeslinked"><a href
="<?php
283 echo htmlspecialchars($this->data['nav_urls']['recentchangeslinked']['href'])
284 ?>"<?php
echo $this->skin
->tooltipAndAccesskey('t-recentchangeslinked') ?
>><?php
$this->msg('recentchangeslinked-toolbox') ?
></a
></li
>
287 if( isset( $this->data
['nav_urls']['trackbacklink'] ) && $this->data
['nav_urls']['trackbacklink'] ) { ?
>
288 <li id
="t-trackbacklink"><a href
="<?php
289 echo htmlspecialchars($this->data['nav_urls']['trackbacklink']['href'])
290 ?>"<?php
echo $this->skin
->tooltipAndAccesskey('t-trackbacklink') ?
>><?php
$this->msg('trackbacklink') ?
></a
></li
>
292 if($this->data
['feeds']) { ?
>
293 <li id
="feedlinks"><?php
foreach($this->data
['feeds'] as $key => $feed) {
294 ?
><a id
="<?php echo Sanitizer::escapeId( "feed
-$key" ) ?>" href
="<?php
295 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
> 
;
299 foreach( array('contributions', 'log', 'blockip', 'emailuser', 'upload', 'specialpages') as $special ) {
301 if($this->data
['nav_urls'][$special]) {
302 ?
><li id
="t-<?php echo $special ?>"><a href
="<?php echo htmlspecialchars($this->data['nav_urls'][$special]['href'])
303 ?>"<?php
echo $this->skin
->tooltipAndAccesskey('t-'.$special) ?
>><?php
$this->msg($special) ?
></a
></li
>
307 if(!empty($this->data
['nav_urls']['print']['href'])) { ?
>
308 <li id
="t-print"><a href
="<?php echo htmlspecialchars($this->data['nav_urls']['print']['href'])
309 ?>" rel
="alternate"<?php
echo $this->skin
->tooltipAndAccesskey('t-print') ?
>><?php
$this->msg('printableversion') ?
></a
></li
><?php
312 if(!empty($this->data
['nav_urls']['permalink']['href'])) { ?
>
313 <li id
="t-permalink"><a href
="<?php echo htmlspecialchars($this->data['nav_urls']['permalink']['href'])
314 ?>"<?php
echo $this->skin
->tooltipAndAccesskey('t-permalink') ?
>><?php
$this->msg('permalink') ?
></a
></li
><?php
315 } elseif ($this->data
['nav_urls']['permalink']['href'] === '') { ?
>
316 <li id
="t-ispermalink"<?php
echo $this->skin
->tooltip('t-ispermalink') ?
>><?php
$this->msg('permalink') ?
></li
><?php
319 wfRunHooks( 'MonoBookTemplateToolboxEnd', array( &$this ) );
320 wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this ) );
328 /*************************************************************************************************/
329 function languageBox() {
330 if( $this->data
['language_urls'] ) {
332 <div id
="p-lang" class="portlet">
333 <h5
<?php
$this->html('userlangattributes') ?
>><?php
$this->msg('otherlanguages') ?
></h5
>
336 <?php
foreach($this->data
['language_urls'] as $langlink) { ?
>
337 <li
class="<?php echo htmlspecialchars($langlink['class'])?>"><?php
338 ?
><a href
="<?php echo htmlspecialchars($langlink['href']) ?>"><?php
echo $langlink['text'] ?
></a
></li
>
347 /*************************************************************************************************/
348 function customBox( $bar, $cont ) {
350 <div
class='generated-sidebar portlet' id
='<?php echo Sanitizer::escapeId( "p-$bar" ) ?>'<?php
echo $this->skin
->tooltip('p-'.$bar) ?
>>
351 <h5
<?php
$this->html('userlangattributes') ?
>><?php
$out = wfMsg( $bar ); if (wfEmptyMsg($bar, $out)) echo htmlspecialchars($bar); else echo htmlspecialchars($out); ?
></h5
>
353 <?php
if ( is_array( $cont ) ) { ?
>
355 <?php
foreach($cont as $key => $val) { ?
>
356 <li id
="<?php echo Sanitizer::escapeId($val['id']) ?>"<?php
357 if ( $val['active'] ) { ?
> class="active" <?php
}
358 ?
>><a href
="<?php echo htmlspecialchars($val['href']) ?>"<?php
echo $this->skin
->tooltipAndAccesskey($val['id']) ?
>><?php
echo htmlspecialchars($val['text']) ?
></a
></li
>
362 # allow raw HTML block to be defined by extensions