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;
28 parent
::setupSkinUserCss( $out );
30 $out->addModuleStyles( 'skins.monobook' );
32 // Ugh. Can't do this properly because $wgHandheldStyle may be a URL
33 if( $wgHandheldStyle ) {
34 // Currently in testing... try 'chick/main.css'
35 $out->addStyle( $wgHandheldStyle, 'handheld' );
38 // TODO: Migrate all of these
39 //$out->addStyle( 'monobook/IE50Fixes.css', 'screen', 'lt IE 5.5000' );
40 //$out->addStyle( 'monobook/IE55Fixes.css', 'screen', 'IE 5.5000' );
41 //$out->addStyle( 'monobook/IE60Fixes.css', 'screen', 'IE 6' );
42 //$out->addStyle( 'monobook/IE70Fixes.css', 'screen', 'IE 7' );
45 //$out->addStyle( 'monobook/rtl.css', 'screen', '', 'rtl' );
54 class MonoBookTemplate
extends QuickTemplate
{
57 * Template filter callback for MonoBook skin.
58 * Takes an associative array of data set from a SkinTemplate-based
59 * class, and a wrapper for MediaWiki's localization database, and
60 * outputs a formatted page.
67 $this->skin
= $skin = $this->data
['skin'];
68 $action = $wgRequest->getText( 'action' );
70 // Suppress warnings to prevent notices about missing indexes in $this->data
73 // Generate additional footer links
74 $footerlinks = $this->data
["footerlinks"];
75 // fold footerlinks into a single array using a bit of trickery
76 $footerlinks = call_user_func_array('array_merge', array_values($footerlinks));
78 $this->html( 'headelement' );
79 ?
><div id
="globalWrapper">
80 <div id
="column-content"><div id
="content"<?php
$this->html("specialpageattributes") ?
>>
82 <?php
if($this->data
['sitenotice']) { ?
><div id
="siteNotice"><?php
$this->html('sitenotice') ?
></div
><?php
} ?
>
84 <h1 id
="firstHeading" class="firstHeading"><?php
$this->html('title') ?
></h1
>
85 <div id
="bodyContent">
86 <div id
="siteSub"><?php
$this->msg('tagline') ?
></div
>
87 <div id
="contentSub"<?php
$this->html('userlangattributes') ?
>><?php
$this->html('subtitle') ?
></div
>
88 <?php
if($this->data
['undelete']) { ?
>
89 <div id
="contentSub2"><?php
$this->html('undelete') ?
></div
>
90 <?php
} ?
><?php
if($this->data
['newtalk'] ) { ?
>
91 <div
class="usermessage"><?php
$this->html('newtalk') ?
></div
>
92 <?php
} ?
><?php
if($this->data
['showjumplinks']) { ?
>
93 <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
>
95 <!-- start content
-->
96 <?php
$this->html('bodytext') ?
>
97 <?php
if($this->data
['catlinks']) { $this->html('catlinks'); } ?
>
99 <?php
if($this->data
['dataAfterContent']) { $this->html ('dataAfterContent'); } ?
>
100 <div
class="visualClear"></div
>
103 <div id
="column-one"<?php
$this->html('userlangattributes') ?
>>
104 <div id
="p-cactions" class="portlet">
105 <h5
><?php
$this->msg('views') ?
></h5
>
108 foreach($this->data
['content_actions'] as $key => $tab) {
110 <li id="' . Sanitizer
::escapeId( "ca-$key" ) . '"';
111 if( $tab['class'] ) {
112 echo ' class="'.htmlspecialchars($tab['class']).'"';
114 echo '><a href="'.htmlspecialchars($tab['href']).'"';
115 # We don't want to give the watch tab an accesskey if the
116 # page is being edited, because that conflicts with the
117 # accesskey on the watch checkbox. We also don't want to
118 # give the edit tab an accesskey, because that's fairly su-
119 # perfluous and conflicts with an accesskey (Ctrl-E) often
120 # used for editing in Safari.
121 if( in_array( $action, array( 'edit', 'submit' ) )
122 && in_array( $key, array( 'edit', 'watch', 'unwatch' ))) {
123 echo $skin->tooltip( "ca-$key" );
125 echo $skin->tooltipAndAccesskey( "ca-$key" );
127 echo '>'.htmlspecialchars($tab['text']).'</a></li>';
133 <div
class="portlet" id
="p-personal">
134 <h5
><?php
$this->msg('personaltools') ?
></h5
>
136 <ul
<?php
$this->html('userlangattributes') ?
>>
137 <?php
foreach($this->data
['personal_urls'] as $key => $item) { ?
>
138 <li id
="<?php echo Sanitizer::escapeId( "pt
-$key" ) ?>"<?php
139 if ($item['active']) { ?
> class="active"<?php
} ?
>><a href
="<?php
140 echo htmlspecialchars($item['href']) ?>"<?php
echo $skin->tooltipAndAccesskey('pt-'.$key) ?
><?php
141 if(!empty($item['class'])) { ?
> class="<?php
142 echo htmlspecialchars($item['class']) ?>"<?php
} ?
>><?php
143 echo htmlspecialchars($item['text']) ?
></a
></li
>
148 <div
class="portlet" id
="p-logo">
149 <a style
="background-image: url(<?php $this->text('logopath') ?>);" <?php
150 ?
>href
="<?php echo htmlspecialchars($this->data['nav_urls']['mainpage']['href'])?>"<?php
151 echo $skin->tooltipAndAccesskey('p-logo') ?
>></a
>
153 <script type
="<?php $this->text('jsmimetype') ?>"> if (window
.isMSIE55
) fixalpha(); </script
>
155 $sidebar = $this->data
['sidebar'];
156 if ( !isset( $sidebar['SEARCH'] ) ) $sidebar['SEARCH'] = true;
157 if ( !isset( $sidebar['TOOLBOX'] ) ) $sidebar['TOOLBOX'] = true;
158 if ( !isset( $sidebar['LANGUAGES'] ) ) $sidebar['LANGUAGES'] = true;
159 foreach ($sidebar as $boxName => $cont) {
160 if ( $boxName == 'SEARCH' ) {
162 } elseif ( $boxName == 'TOOLBOX' ) {
164 } elseif ( $boxName == 'LANGUAGES' ) {
165 $this->languageBox();
167 $this->customBox( $boxName, $cont );
171 </div
><!-- end of the
left (by
default at least
) column
-->
172 <div
class="visualClear"></div
>
173 <div id
="footer"<?php
$this->html('userlangattributes') ?
>>
175 if($this->data
['poweredbyico']) { ?
>
176 <div id
="f-poweredbyico"><?php
$this->html('poweredbyico') ?
></div
>
178 if($this->data
['copyrightico']) { ?
>
179 <div id
="f-copyrightico"><?php
$this->html('copyrightico') ?
></div
>
182 // Generate additional footer links
183 $validFooterLinks = array();
184 foreach( $footerlinks as $aLink ) {
185 if( isset( $this->data
[$aLink] ) && $this->data
[$aLink] ) {
186 $validFooterLinks[] = $aLink;
189 if ( count( $validFooterLinks ) > 0 ) {
192 foreach( $validFooterLinks as $aLink ) {
193 if( isset( $this->data
[$aLink] ) && $this->data
[$aLink] ) {
194 ?
> <li id
="<?php echo $aLink ?>"><?php
$this->html($aLink) ?
></li
>
203 <?php
$this->html('bottomscripts'); /* JS call to runBodyOnloadHook */ ?
>
204 <?php
$this->html('reporttime') ?
>
205 <?php
if ( $this->data
['debug'] ): ?
>
207 <?php
$this->text( 'debug' ); ?
>
212 echo Html
::closeElement( 'body' );
213 echo Html
::closeElement( 'html' );
215 } // end of execute() method
217 /*************************************************************************************************/
218 function searchBox() {
219 global $wgUseTwoButtonsSearchForm;
221 <div id
="p-search" class="portlet">
222 <h5
><label
for="searchInput"><?php
$this->msg('search') ?
></label
></h5
>
223 <div id
="searchBody" class="pBody">
224 <form action
="<?php $this->text('wgScript') ?>" id
="searchform">
225 <input type
='hidden' name
="title" value
="<?php $this->text('searchtitle') ?>"/>
227 echo Html
::input( 'search',
228 isset( $this->data
['search'] ) ?
$this->data
['search'] : '', 'search',
230 'id' => 'searchInput',
231 'title' => $this->skin
->titleAttrib( 'search' ),
232 'accesskey' => $this->skin
->accesskey( 'search' )
235 <input type
='submit' name
="go" class="searchButton" id
="searchGoButton" value
="<?php $this->msg('searcharticle') ?>"<?php
echo $this->skin
->tooltipAndAccesskey( 'search-go' ); ?
> /><?php
if ($wgUseTwoButtonsSearchForm) { ?
> 
236 <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 <div
><a href
="<?php $this->text('searchaction') ?>" rel
="search"><?php
$this->msg('powersearch-legend') ?
></a
></div
><?php
} ?
>
246 /*************************************************************************************************/
249 <div
class="portlet" id
="p-tb">
250 <h5
><?php
$this->msg('toolbox') ?
></h5
>
254 if($this->data
['notspecialpage']) { ?
>
255 <li id
="t-whatlinkshere"><a href
="<?php
256 echo htmlspecialchars($this->data['nav_urls']['whatlinkshere']['href'])
257 ?>"<?php
echo $this->skin
->tooltipAndAccesskey('t-whatlinkshere') ?
>><?php
$this->msg('whatlinkshere') ?
></a
></li
>
259 if( $this->data
['nav_urls']['recentchangeslinked'] ) { ?
>
260 <li id
="t-recentchangeslinked"><a href
="<?php
261 echo htmlspecialchars($this->data['nav_urls']['recentchangeslinked']['href'])
262 ?>"<?php
echo $this->skin
->tooltipAndAccesskey('t-recentchangeslinked') ?
>><?php
$this->msg('recentchangeslinked-toolbox') ?
></a
></li
>
265 if( isset( $this->data
['nav_urls']['trackbacklink'] ) && $this->data
['nav_urls']['trackbacklink'] ) { ?
>
266 <li id
="t-trackbacklink"><a href
="<?php
267 echo htmlspecialchars($this->data['nav_urls']['trackbacklink']['href'])
268 ?>"<?php
echo $this->skin
->tooltipAndAccesskey('t-trackbacklink') ?
>><?php
$this->msg('trackbacklink') ?
></a
></li
>
270 if($this->data
['feeds']) { ?
>
271 <li id
="feedlinks"><?php
foreach($this->data
['feeds'] as $key => $feed) {
272 ?
><a id
="<?php echo Sanitizer::escapeId( "feed
-$key" ) ?>" href
="<?php
273 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
> 
277 foreach( array('contributions', 'log', 'blockip', 'emailuser', 'upload', 'specialpages') as $special ) {
279 if($this->data
['nav_urls'][$special]) {
280 ?
><li id
="t-<?php echo $special ?>"><a href
="<?php echo htmlspecialchars($this->data['nav_urls'][$special]['href'])
281 ?>"<?php
echo $this->skin
->tooltipAndAccesskey('t-'.$special) ?
>><?php
$this->msg($special) ?
></a
></li
>
285 if(!empty($this->data
['nav_urls']['print']['href'])) { ?
>
286 <li id
="t-print"><a href
="<?php echo htmlspecialchars($this->data['nav_urls']['print']['href'])
287 ?>" rel
="alternate"<?php
echo $this->skin
->tooltipAndAccesskey('t-print') ?
>><?php
$this->msg('printableversion') ?
></a
></li
><?php
290 if(!empty($this->data
['nav_urls']['permalink']['href'])) { ?
>
291 <li id
="t-permalink"><a href
="<?php echo htmlspecialchars($this->data['nav_urls']['permalink']['href'])
292 ?>"<?php
echo $this->skin
->tooltipAndAccesskey('t-permalink') ?
>><?php
$this->msg('permalink') ?
></a
></li
><?php
293 } elseif ($this->data
['nav_urls']['permalink']['href'] === '') { ?
>
294 <li id
="t-ispermalink"<?php
echo $this->skin
->tooltip('t-ispermalink') ?
>><?php
$this->msg('permalink') ?
></li
><?php
297 wfRunHooks( 'MonoBookTemplateToolboxEnd', array( &$this ) );
298 wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this ) );
306 /*************************************************************************************************/
307 function languageBox() {
308 if( $this->data
['language_urls'] ) {
310 <div id
="p-lang" class="portlet">
311 <h5
<?php
$this->html('userlangattributes') ?
>><?php
$this->msg('otherlanguages') ?
></h5
>
314 <?php
foreach($this->data
['language_urls'] as $langlink) { ?
>
315 <li
class="<?php echo htmlspecialchars($langlink['class'])?>"><?php
316 ?
><a href
="<?php echo htmlspecialchars($langlink['href']) ?>" title
="<?php
317 echo htmlspecialchars($langlink['title']) ?>"><?php
echo $langlink['text'] ?
></a
></li
>
326 /*************************************************************************************************/
327 function customBox( $bar, $cont ) {
329 <div
class='generated-sidebar portlet' id
='<?php echo Sanitizer::escapeId( "p-$bar" ) ?>'<?php
echo $this->skin
->tooltip('p-'.$bar) ?
>>
330 <h5
><?php
$out = wfMsg( $bar ); if (wfEmptyMsg($bar, $out)) echo htmlspecialchars($bar); else echo htmlspecialchars($out); ?
></h5
>
332 <?php
if ( is_array( $cont ) ) { ?
>
334 <?php
foreach($cont as $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
>
341 # allow raw HTML block to be defined by extensions