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/IE60Fixes.css', 'screen', 'IE 6' );
39 $out->addStyle( 'monobook/IE70Fixes.css', 'screen', 'IE 7' );
40 $out->addStyle( 'monobook/rtl.css', 'screen', '', 'rtl' );
48 class MonoBookTemplate
extends QuickTemplate
{
51 * Template filter callback for MonoBook skin.
52 * Takes an associative array of data set from a SkinTemplate-based
53 * class, and a wrapper for MediaWiki's localization database, and
54 * outputs a formatted page.
61 $this->skin
= $skin = $this->data
['skin'];
62 $action = $wgRequest->getText( 'action' );
64 // Suppress warnings to prevent notices about missing indexes in $this->data
67 $this->html( 'headelement' );
68 ?
><div id
="globalWrapper">
69 <div id
="column-content"><div id
="content" <?php
$this->html("specialpageattributes") ?
>>
71 <?php
if($this->data
['sitenotice']) { ?
><div id
="siteNotice"><?php
$this->html('sitenotice') ?
></div
><?php
} ?
>
73 <h1 id
="firstHeading" class="firstHeading"><?php
$this->html('title') ?
></h1
>
74 <div id
="bodyContent">
75 <h3 id
="siteSub"><?php
$this->msg('tagline') ?
></h3
>
76 <div id
="contentSub"<?php
$this->html('userlangattributes') ?
>><?php
$this->html('subtitle') ?
></div
>
77 <?php
if($this->data
['undelete']) { ?
>
78 <div id
="contentSub2"><?php
$this->html('undelete') ?
></div
>
79 <?php
} ?
><?php
if($this->data
['newtalk'] ) { ?
>
80 <div
class="usermessage"><?php
$this->html('newtalk') ?
></div
>
81 <?php
} ?
><?php
if($this->data
['showjumplinks']) { ?
>
82 <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
>
84 <!-- start content
-->
85 <?php
$this->html('bodytext') ?
>
86 <?php
if($this->data
['catlinks']) { $this->html('catlinks'); } ?
>
88 <?php
if($this->data
['dataAfterContent']) { $this->html ('dataAfterContent'); } ?
>
89 <div
class="visualClear"></div
>
92 <div id
="column-one"<?php
$this->html('userlangattributes') ?
>>
93 <div id
="p-cactions" class="portlet">
94 <h5
><?php
$this->msg('views') ?
></h5
>
97 foreach($this->data
['content_actions'] as $key => $tab) {
99 <li id="' . Sanitizer
::escapeId( "ca-$key" ) . '"';
100 if( $tab['class'] ) {
101 echo ' class="'.htmlspecialchars($tab['class']).'"';
103 echo '><a href="'.htmlspecialchars($tab['href']).'"';
104 # We don't want to give the watch tab an accesskey if the
105 # page is being edited, because that conflicts with the
106 # accesskey on the watch checkbox. We also don't want to
107 # give the edit tab an accesskey, because that's fairly su-
108 # perfluous and conflicts with an accesskey (Ctrl-E) often
109 # used for editing in Safari.
110 if( in_array( $action, array( 'edit', 'submit' ) )
111 && in_array( $key, array( 'edit', 'watch', 'unwatch' ))) {
112 echo $skin->tooltip( "ca-$key" );
114 echo $skin->tooltipAndAccesskey( "ca-$key" );
116 echo '>'.htmlspecialchars($tab['text']).'</a></li>';
122 <div
class="portlet" id
="p-personal">
123 <h5
><?php
$this->msg('personaltools') ?
></h5
>
125 <ul
<?php
$this->html('userlangattributes') ?
>>
126 <?php
foreach($this->data
['personal_urls'] as $key => $item) { ?
>
127 <li id
="<?php echo Sanitizer::escapeId( "pt
-$key" ) ?>"<?php
128 if ($item['active']) { ?
> class="active"<?php
} ?
>><a href
="<?php
129 echo htmlspecialchars($item['href']) ?>"<?php
echo $skin->tooltipAndAccesskey('pt-'.$key) ?
><?php
130 if(!empty($item['class'])) { ?
> class="<?php
131 echo htmlspecialchars($item['class']) ?>"<?php
} ?
>><?php
132 echo htmlspecialchars($item['text']) ?
></a
></li
>
137 <div
class="portlet" id
="p-logo">
138 <a style
="background-image: url(<?php $this->text('logopath') ?>);" <?php
139 ?
>href
="<?php echo htmlspecialchars($this->data['nav_urls']['mainpage']['href'])?>"<?php
140 echo $skin->tooltipAndAccesskey('p-logo') ?
>></a
>
142 <script type
="<?php $this->text('jsmimetype') ?>"> if (window
.isMSIE55
) fixalpha(); </script
>
144 $sidebar = $this->data
['sidebar'];
145 if ( !isset( $sidebar['SEARCH'] ) ) $sidebar['SEARCH'] = true;
146 if ( !isset( $sidebar['TOOLBOX'] ) ) $sidebar['TOOLBOX'] = true;
147 if ( !isset( $sidebar['LANGUAGES'] ) ) $sidebar['LANGUAGES'] = true;
148 foreach ($sidebar as $boxName => $cont) {
149 if ( $boxName == 'SEARCH' ) {
151 } elseif ( $boxName == 'TOOLBOX' ) {
153 } elseif ( $boxName == 'LANGUAGES' ) {
154 $this->languageBox();
156 $this->customBox( $boxName, $cont );
160 </div
><!-- end of the
left (by
default at least
) column
-->
161 <div
class="visualClear"></div
>
162 <div id
="footer"<?php
$this->html('userlangattributes') ?
>>
164 if($this->data
['poweredbyico']) { ?
>
165 <div id
="f-poweredbyico"><?php
$this->html('poweredbyico') ?
></div
>
167 if($this->data
['copyrightico']) { ?
>
168 <div id
="f-copyrightico"><?php
$this->html('copyrightico') ?
></div
>
171 // Generate additional footer links
172 $footerlinks = array(
173 'lastmod', 'viewcount', 'numberofwatchingusers', 'credits', 'copyright',
174 'privacy', 'about', 'disclaimer', 'tagline',
176 $validFooterLinks = array();
177 foreach( $footerlinks as $aLink ) {
178 if( isset( $this->data
[$aLink] ) && $this->data
[$aLink] ) {
179 $validFooterLinks[] = $aLink;
182 if ( count( $validFooterLinks ) > 0 ) {
185 foreach( $validFooterLinks as $aLink ) {
186 if( isset( $this->data
[$aLink] ) && $this->data
[$aLink] ) {
187 ?
> <li id
="<?php echo $aLink ?>"><?php
$this->html($aLink) ?
></li
>
196 <?php
$this->html('bottomscripts'); /* JS call to runBodyOnloadHook */ ?
>
197 <?php
$this->html('reporttime') ?
>
198 <?php
if ( $this->data
['debug'] ): ?
>
200 <?php
$this->text( 'debug' ); ?
>
207 } // end of execute() method
209 /*************************************************************************************************/
210 function searchBox() {
211 global $wgUseTwoButtonsSearchForm;
213 <div id
="p-search" class="portlet">
214 <h5
><label
for="searchInput"><?php
$this->msg('search') ?
></label
></h5
>
215 <div id
="searchBody" class="pBody">
216 <form action
="<?php $this->text('wgScript') ?>" id
="searchform">
217 <input type
='hidden' name
="title" value
="<?php $this->text('searchtitle') ?>"/>
219 echo Html
::input( 'search',
220 isset( $this->data
['search'] ) ?
$this->data
['search'] : '', 'search',
222 'id' => 'searchInput',
223 'title' => $this->skin
->titleAttrib( 'search' ),
224 'accesskey' => $this->skin
->accesskey( 'search' )
227 <input type
='submit' name
="go" class="searchButton" id
="searchGoButton" value
="<?php $this->msg('searcharticle') ?>"<?php
echo $this->skin
->tooltipAndAccesskey( 'search-go' ); ?
> /><?php
if ($wgUseTwoButtonsSearchForm) { ?
> 
;
228 <input type
='submit' name
="fulltext" class="searchButton" id
="mw-searchButton" value
="<?php $this->msg('searchbutton') ?>"<?php
echo $this->skin
->tooltipAndAccesskey( 'search-fulltext' ); ?
> /><?php
} else { ?
>
230 <div
><a href
="<?php $this->text('searchaction') ?>" rel
="search"><?php
$this->msg('powersearch-legend') ?
></a
></div
><?php
} ?
>
238 /*************************************************************************************************/
241 <div
class="portlet" id
="p-tb">
242 <h5
><?php
$this->msg('toolbox') ?
></h5
>
246 if($this->data
['notspecialpage']) { ?
>
247 <li id
="t-whatlinkshere"><a href
="<?php
248 echo htmlspecialchars($this->data['nav_urls']['whatlinkshere']['href'])
249 ?>"<?php
echo $this->skin
->tooltipAndAccesskey('t-whatlinkshere') ?
>><?php
$this->msg('whatlinkshere') ?
></a
></li
>
251 if( $this->data
['nav_urls']['recentchangeslinked'] ) { ?
>
252 <li id
="t-recentchangeslinked"><a href
="<?php
253 echo htmlspecialchars($this->data['nav_urls']['recentchangeslinked']['href'])
254 ?>"<?php
echo $this->skin
->tooltipAndAccesskey('t-recentchangeslinked') ?
>><?php
$this->msg('recentchangeslinked-toolbox') ?
></a
></li
>
257 if( isset( $this->data
['nav_urls']['trackbacklink'] ) && $this->data
['nav_urls']['trackbacklink'] ) { ?
>
258 <li id
="t-trackbacklink"><a href
="<?php
259 echo htmlspecialchars($this->data['nav_urls']['trackbacklink']['href'])
260 ?>"<?php
echo $this->skin
->tooltipAndAccesskey('t-trackbacklink') ?
>><?php
$this->msg('trackbacklink') ?
></a
></li
>
262 if($this->data
['feeds']) { ?
>
263 <li id
="feedlinks"><?php
foreach($this->data
['feeds'] as $key => $feed) {
264 ?
><a id
="<?php echo Sanitizer::escapeId( "feed
-$key" ) ?>" href
="<?php
265 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
> 
;
269 foreach( array('contributions', 'log', 'blockip', 'emailuser', 'upload', 'specialpages') as $special ) {
271 if($this->data
['nav_urls'][$special]) {
272 ?
><li id
="t-<?php echo $special ?>"><a href
="<?php echo htmlspecialchars($this->data['nav_urls'][$special]['href'])
273 ?>"<?php
echo $this->skin
->tooltipAndAccesskey('t-'.$special) ?
>><?php
$this->msg($special) ?
></a
></li
>
277 if(!empty($this->data
['nav_urls']['print']['href'])) { ?
>
278 <li id
="t-print"><a href
="<?php echo htmlspecialchars($this->data['nav_urls']['print']['href'])
279 ?>" rel
="alternate"<?php
echo $this->skin
->tooltipAndAccesskey('t-print') ?
>><?php
$this->msg('printableversion') ?
></a
></li
><?php
282 if(!empty($this->data
['nav_urls']['permalink']['href'])) { ?
>
283 <li id
="t-permalink"><a href
="<?php echo htmlspecialchars($this->data['nav_urls']['permalink']['href'])
284 ?>"<?php
echo $this->skin
->tooltipAndAccesskey('t-permalink') ?
>><?php
$this->msg('permalink') ?
></a
></li
><?php
285 } elseif ($this->data
['nav_urls']['permalink']['href'] === '') { ?
>
286 <li id
="t-ispermalink"<?php
echo $this->skin
->tooltip('t-ispermalink') ?
>><?php
$this->msg('permalink') ?
></li
><?php
289 wfRunHooks( 'MonoBookTemplateToolboxEnd', array( &$this ) );
290 wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this ) );
298 /*************************************************************************************************/
299 function languageBox() {
300 if( $this->data
['language_urls'] ) {
302 <div id
="p-lang" class="portlet">
303 <h5
<?php
$this->html('userlangattributes') ?
>><?php
$this->msg('otherlanguages') ?
></h5
>
306 <?php
foreach($this->data
['language_urls'] as $langlink) { ?
>
307 <li
class="<?php echo htmlspecialchars($langlink['class'])?>"><?php
308 ?
><a href
="<?php echo htmlspecialchars($langlink['href']) ?>"><?php
echo $langlink['text'] ?
></a
></li
>
317 /*************************************************************************************************/
318 function customBox( $bar, $cont ) {
320 <div
class='generated-sidebar portlet' id
='<?php echo Sanitizer::escapeId( "p-$bar" ) ?>'<?php
echo $this->skin
->tooltip('p-'.$bar) ?
>>
321 <h5
><?php
$out = wfMsg( $bar ); if (wfEmptyMsg($bar, $out)) echo htmlspecialchars($bar); else echo htmlspecialchars($out); ?
></h5
>
323 <?php
if ( is_array( $cont ) ) { ?
>
325 <?php
foreach($cont as $key => $val) { ?
>
326 <li id
="<?php echo Sanitizer::escapeId($val['id']) ?>"<?php
327 if ( $val['active'] ) { ?
> class="active" <?php
}
328 ?
>><a href
="<?php echo htmlspecialchars($val['href']) ?>"<?php
echo $this->skin
->tooltipAndAccesskey($val['id']) ?
>><?php
echo htmlspecialchars($val['text']) ?
></a
></li
>
332 # allow raw HTML block to be defined by extensions