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';
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' );
46 //@@todo we can move this to the parent once we update all skins
47 if( isset( $this->pagecss
) && $this->pagecss
)
48 $out->addInlineStyle( $this->pagecss
);
50 if( isset( $this->usercss
) && $this->usercss
)
51 $out->addInlineStyle( $this->usercss
);
54 function setupSkinUserJs( OutputPage
$out ) {
55 parent
::setupSkinUserJs( $out );
56 $out->addScriptFile( 'wikibits.js' );
58 //@@todo can move to parent once we update all skins (to not include things twice
59 if( isset( $this->jsvarurl
) && $this->jsvarurl
)
60 $out->addScriptFile( $this->jsvarurl
);
62 if( isset( $this->userjs
) && $this->userjs
)
63 $out->addScriptFile( $this->userjs
);
65 if( isset( $this->userjsprev
) && $this->userjsprev
)
66 $out->addInlineScript( $this->userjsprev
);
74 class MonoBookTemplate
extends QuickTemplate
{
77 * Template filter callback for MonoBook skin.
78 * Takes an associative array of data set from a SkinTemplate-based
79 * class, and a wrapper for MediaWiki's localization database, and
80 * outputs a formatted page.
85 global $wgRequest, $wgOut, $wgStyleVersion, $wgJsMimeType, $wgStylePath;
86 $this->skin
= $skin = $this->data
['skin'];
87 $action = $wgRequest->getText( 'action' );
89 // Suppress warnings to prevent notices about missing indexes in $this->data
91 # FIXME: What is this? Should it apply to all skins?
92 $path = htmlspecialchars( $wgStylePath );
93 $wgOut->addScript( <<<HTML
94 <!--[if lt IE 7]><script type="$wgJsMimeType" src="$path/common/IEFixes.js?$wgStyleVersion"></script>
95 <meta http-equiv="imagetoolbar" content="no" /><![endif]-->
99 echo $wgOut->headElement( $this->skin
);
101 ?
><body
<?php
if($this->data
['body_ondblclick']) { ?
> ondblclick
="<?php $this->text('body_ondblclick') ?>"<?php
} ?
>
102 <?php
if($this->data
['body_onload']) { ?
> onload
="<?php $this->text('body_onload') ?>"<?php
} ?
>
103 class="mediawiki <?php $this->text('dir'); $this->text('capitalizeallnouns') ?> <?php $this->text('pageclass') ?> <?php $this->text('skinnameclass') ?>">
104 <div id
="globalWrapper">
105 <div id
="column-content">
108 <?php
if($this->data
['sitenotice']) { ?
><div id
="siteNotice"><?php
$this->html('sitenotice') ?
></div
><?php
} ?
>
109 <h1 id
="firstHeading" class="firstHeading"><?php
$this->html('title') ?
></h1
>
110 <div id
="bodyContent">
111 <h3 id
="siteSub"><?php
$this->msg('tagline') ?
></h3
>
112 <div id
="contentSub"><?php
$this->html('subtitle') ?
></div
>
113 <?php
if($this->data
['undelete']) { ?
><div id
="contentSub2"><?php
$this->html('undelete') ?
></div
><?php
} ?
>
114 <?php
if($this->data
['newtalk'] ) { ?
><div
class="usermessage"><?php
$this->html('newtalk') ?
></div
><?php
} ?
>
115 <?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
} ?
>
116 <!-- start content
-->
117 <?php
$this->html('bodytext') ?
>
118 <?php
if($this->data
['catlinks']) { $this->html('catlinks'); } ?
>
120 <?php
if($this->data
['dataAfterContent']) { $this->html ('dataAfterContent'); } ?
>
121 <div
class="visualClear"></div
>
125 <div id
="column-one">
126 <div id
="p-cactions" class="portlet">
127 <h5
><?php
$this->msg('views') ?
></h5
>
129 <ul
<?php
$this->html('userlangattributes') ?
>>
130 <?php
foreach($this->data
['content_actions'] as $key => $tab) {
132 <li id="' . Sanitizer
::escapeId( "ca-$key" ) . '"';
133 if( $tab['class'] ) {
134 echo ' class="'.htmlspecialchars($tab['class']).'"';
136 echo '><a href="'.htmlspecialchars($tab['href']).'"';
137 # We don't want to give the watch tab an accesskey if the
138 # page is being edited, because that conflicts with the
139 # accesskey on the watch checkbox. We also don't want to
140 # give the edit tab an accesskey, because that's fairly su-
141 # perfluous and conflicts with an accesskey (Ctrl-E) often
142 # used for editing in Safari.
143 if( in_array( $action, array( 'edit', 'submit' ) )
144 && in_array( $key, array( 'edit', 'watch', 'unwatch' ))) {
145 echo $skin->tooltip( "ca-$key" );
147 echo $skin->tooltipAndAccesskey( "ca-$key" );
149 echo '>'.htmlspecialchars($tab['text']).'</a></li>';
154 <div
class="portlet" id
="p-personal">
155 <h5
><?php
$this->msg('personaltools') ?
></h5
>
157 <ul
<?php
$this->html('userlangattributes') ?
>>
158 <?php
foreach($this->data
['personal_urls'] as $key => $item) { ?
>
159 <li id
="<?php echo Sanitizer::escapeId( "pt
-$key" ) ?>"<?php
160 if ($item['active']) { ?
> class="active"<?php
} ?
>><a href
="<?php
161 echo htmlspecialchars($item['href']) ?>"<?php
echo $skin->tooltipAndAccesskey('pt-'.$key) ?
><?php
162 if(!empty($item['class'])) { ?
> class="<?php
163 echo htmlspecialchars($item['class']) ?>"<?php
} ?
>><?php
164 echo htmlspecialchars($item['text']) ?
></a
></li
>
169 <div
class="portlet" id
="p-logo">
170 <a style
="background-image: url(<?php $this->text('logopath') ?>);" <?php
171 ?
>href
="<?php echo htmlspecialchars($this->data['nav_urls']['mainpage']['href'])?>"<?php
172 echo $skin->tooltipAndAccesskey('p-logo') ?
>></a
>
174 <script type
="<?php $this->text('jsmimetype') ?>"> if (window
.isMSIE55
) fixalpha(); </script
>
176 $sidebar = $this->data
['sidebar'];
177 if ( !isset( $sidebar['SEARCH'] ) ) $sidebar['SEARCH'] = true;
178 if ( !isset( $sidebar['TOOLBOX'] ) ) $sidebar['TOOLBOX'] = true;
179 if ( !isset( $sidebar['LANGUAGES'] ) ) $sidebar['LANGUAGES'] = true;
180 foreach ($sidebar as $boxName => $cont) {
181 if ( $boxName == 'SEARCH' ) {
183 } elseif ( $boxName == 'TOOLBOX' ) {
185 } elseif ( $boxName == 'LANGUAGES' ) {
186 $this->languageBox();
188 $this->customBox( $boxName, $cont );
192 </div
><!-- end of the
left (by
default at least
) column
-->
193 <div
class="visualClear"></div
>
196 if($this->data
['poweredbyico']) { ?
>
197 <div id
="f-poweredbyico"><?php
$this->html('poweredbyico') ?
></div
>
199 if($this->data
['copyrightico']) { ?
>
200 <div id
="f-copyrightico"><?php
$this->html('copyrightico') ?
></div
>
203 // Generate additional footer links
204 $footerlinks = array(
205 'lastmod', 'viewcount', 'numberofwatchingusers', 'credits', 'copyright',
206 'privacy', 'about', 'disclaimer', 'tagline',
208 $validFooterLinks = array();
209 foreach( $footerlinks as $aLink ) {
210 if( isset( $this->data
[$aLink] ) && $this->data
[$aLink] ) {
211 $validFooterLinks[] = $aLink;
214 if ( count( $validFooterLinks ) > 0 ) {
217 foreach( $validFooterLinks as $aLink ) {
218 if( isset( $this->data
[$aLink] ) && $this->data
[$aLink] ) {
219 ?
> <li id
="<?php echo $aLink ?>"><?php
$this->html($aLink) ?
></li
>
228 <?php
$this->html('bottomscripts'); /* JS call to runBodyOnloadHook */ ?
>
229 <?php
$this->html('reporttime') ?
>
230 <?php
if ( $this->data
['debug'] ): ?
>
232 <?php
$this->text( 'debug' ); ?
>
239 } // end of execute() method
241 /*************************************************************************************************/
242 function searchBox() {
243 global $wgUseTwoButtonsSearchForm;
245 <div id
="p-search" class="portlet">
246 <h5
<?php
$this->html('userlangattributes') ?
>><label
for="searchInput"><?php
$this->msg('search') ?
></label
></h5
>
247 <div id
="searchBody" class="pBody">
248 <form action
="<?php $this->text('wgScript') ?>" id
="searchform">
249 <input type
='hidden' name
="title" value
="<?php $this->text('searchtitle') ?>"/>
251 echo Html
::input( 'search',
252 isset( $this->data
['search'] ) ?
$this->data
['search'] : '', 'search',
254 'id' => 'searchInput',
255 'title' => $this->skin
->titleAttrib( 'search' ),
256 'accesskey' => $this->skin
->accesskey( 'search' )
259 <input type
='submit' name
="go" class="searchButton" id
="searchGoButton" value
="<?php $this->msg('searcharticle') ?>"<?php
echo $this->skin
->tooltipAndAccesskey( 'search-go' ); ?
> /><?php
if ($wgUseTwoButtonsSearchForm) { ?
> 
;
260 <input type
='submit' name
="fulltext" class="searchButton" id
="mw-searchButton" value
="<?php $this->msg('searchbutton') ?>"<?php
echo $this->skin
->tooltipAndAccesskey( 'search-fulltext' ); ?
> /><?php
} else { ?
>
262 <div
><a href
="<?php $this->text('searchaction') ?>" rel
="search"><?php
$this->msg('powersearch-legend') ?
></a
></div
><?php
} ?
>
270 /*************************************************************************************************/
273 <div
class="portlet" id
="p-tb">
274 <h5
<?php
$this->html('userlangattributes')?
>><?php
$this->msg('toolbox') ?
></h5
>
278 if($this->data
['notspecialpage']) { ?
>
279 <li id
="t-whatlinkshere"><a href
="<?php
280 echo htmlspecialchars($this->data['nav_urls']['whatlinkshere']['href'])
281 ?>"<?php
echo $this->skin
->tooltipAndAccesskey('t-whatlinkshere') ?
>><?php
$this->msg('whatlinkshere') ?
></a
></li
>
283 if( $this->data
['nav_urls']['recentchangeslinked'] ) { ?
>
284 <li id
="t-recentchangeslinked"><a href
="<?php
285 echo htmlspecialchars($this->data['nav_urls']['recentchangeslinked']['href'])
286 ?>"<?php
echo $this->skin
->tooltipAndAccesskey('t-recentchangeslinked') ?
>><?php
$this->msg('recentchangeslinked-toolbox') ?
></a
></li
>
289 if( isset( $this->data
['nav_urls']['trackbacklink'] ) && $this->data
['nav_urls']['trackbacklink'] ) { ?
>
290 <li id
="t-trackbacklink"><a href
="<?php
291 echo htmlspecialchars($this->data['nav_urls']['trackbacklink']['href'])
292 ?>"<?php
echo $this->skin
->tooltipAndAccesskey('t-trackbacklink') ?
>><?php
$this->msg('trackbacklink') ?
></a
></li
>
294 if($this->data
['feeds']) { ?
>
295 <li id
="feedlinks"><?php
foreach($this->data
['feeds'] as $key => $feed) {
296 ?
><a id
="<?php echo Sanitizer::escapeId( "feed
-$key" ) ?>" href
="<?php
297 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
> 
;
301 foreach( array('contributions', 'log', 'blockip', 'emailuser', 'upload', 'specialpages') as $special ) {
303 if($this->data
['nav_urls'][$special]) {
304 ?
><li id
="t-<?php echo $special ?>"><a href
="<?php echo htmlspecialchars($this->data['nav_urls'][$special]['href'])
305 ?>"<?php
echo $this->skin
->tooltipAndAccesskey('t-'.$special) ?
>><?php
$this->msg($special) ?
></a
></li
>
309 if(!empty($this->data
['nav_urls']['print']['href'])) { ?
>
310 <li id
="t-print"><a href
="<?php echo htmlspecialchars($this->data['nav_urls']['print']['href'])
311 ?>" rel
="alternate"<?php
echo $this->skin
->tooltipAndAccesskey('t-print') ?
>><?php
$this->msg('printableversion') ?
></a
></li
><?php
314 if(!empty($this->data
['nav_urls']['permalink']['href'])) { ?
>
315 <li id
="t-permalink"><a href
="<?php echo htmlspecialchars($this->data['nav_urls']['permalink']['href'])
316 ?>"<?php
echo $this->skin
->tooltipAndAccesskey('t-permalink') ?
>><?php
$this->msg('permalink') ?
></a
></li
><?php
317 } elseif ($this->data
['nav_urls']['permalink']['href'] === '') { ?
>
318 <li id
="t-ispermalink"<?php
echo $this->skin
->tooltip('t-ispermalink') ?
>><?php
$this->msg('permalink') ?
></li
><?php
321 wfRunHooks( 'MonoBookTemplateToolboxEnd', array( &$this ) );
322 wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this ) );
330 /*************************************************************************************************/
331 function languageBox() {
332 if( $this->data
['language_urls'] ) {
334 <div id
="p-lang" class="portlet">
335 <h5
<?php
$this->html('userlangattributes') ?
>><?php
$this->msg('otherlanguages') ?
></h5
>
338 <?php
foreach($this->data
['language_urls'] as $langlink) { ?
>
339 <li
class="<?php echo htmlspecialchars($langlink['class'])?>"><?php
340 ?
><a href
="<?php echo htmlspecialchars($langlink['href']) ?>"><?php
echo $langlink['text'] ?
></a
></li
>
349 /*************************************************************************************************/
350 function customBox( $bar, $cont ) {
352 <div
class='generated-sidebar portlet' id
='<?php echo Sanitizer::escapeId( "p-$bar" ) ?>'<?php
echo $this->skin
->tooltip('p-'.$bar) ?
>>
353 <h5
<?php
$this->html('userlangattributes') ?
>><?php
$out = wfMsg( $bar ); if (wfEmptyMsg($bar, $out)) echo htmlspecialchars($bar); else echo htmlspecialchars($out); ?
></h5
>
355 <?php
if ( is_array( $cont ) ) { ?
>
357 <?php
foreach($cont as $key => $val) { ?
>
358 <li id
="<?php echo Sanitizer::escapeId($val['id']) ?>"<?php
359 if ( $val['active'] ) { ?
> class="active" <?php
}
360 ?
>><a href
="<?php echo htmlspecialchars($val['href']) ?>"<?php
echo $this->skin
->tooltipAndAccesskey($val['id']) ?
>><?php
echo htmlspecialchars($val['text']) ?
></a
></li
>
364 # allow raw HTML block to be defined by extensions