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 parent
::setupSkinUserCss( $out );
29 $out->addModuleStyles( 'skins.monobook' );
31 // Ugh. Can't do this properly because $wgHandheldStyle may be a URL
32 if( $wgHandheldStyle ) {
33 // Currently in testing... try 'chick/main.css'
34 $out->addStyle( $wgHandheldStyle, 'handheld' );
37 // TODO: Migrate all of these
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' );
44 //$out->addStyle( 'monobook/rtl.css', 'screen', '', 'rtl' );
53 class MonoBookTemplate
extends QuickTemplate
{
56 * Template filter callback for MonoBook skin.
57 * Takes an associative array of data set from a SkinTemplate-based
58 * class, and a wrapper for MediaWiki's localization database, and
59 * outputs a formatted page.
66 $this->skin
= $skin = $this->data
['skin'];
67 $action = $wgRequest->getText( 'action' );
69 // Suppress warnings to prevent notices about missing indexes in $this->data
72 $this->html( 'headelement' );
73 ?
><div id
="globalWrapper">
74 <div id
="column-content"><div id
="content"<?php
$this->html("specialpageattributes") ?
>>
76 <?php
if($this->data
['sitenotice']) { ?
><div id
="siteNotice"><?php
$this->html('sitenotice') ?
></div
><?php
} ?
>
78 <h1 id
="firstHeading" class="firstHeading"><?php
$this->html('title') ?
></h1
>
79 <div id
="bodyContent">
80 <div id
="siteSub"><?php
$this->msg('tagline') ?
></div
>
81 <div id
="contentSub"<?php
$this->html('userlangattributes') ?
>><?php
$this->html('subtitle') ?
></div
>
82 <?php
if($this->data
['undelete']) { ?
>
83 <div id
="contentSub2"><?php
$this->html('undelete') ?
></div
>
84 <?php
} ?
><?php
if($this->data
['newtalk'] ) { ?
>
85 <div
class="usermessage"><?php
$this->html('newtalk') ?
></div
>
86 <?php
} ?
><?php
if($this->data
['showjumplinks']) { ?
>
87 <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
>
89 <!-- start content
-->
90 <?php
$this->html('bodytext') ?
>
91 <?php
if($this->data
['catlinks']) { $this->html('catlinks'); } ?
>
93 <?php
if($this->data
['dataAfterContent']) { $this->html ('dataAfterContent'); } ?
>
94 <div
class="visualClear"></div
>
97 <div id
="column-one"<?php
$this->html('userlangattributes') ?
>>
98 <div id
="p-cactions" class="portlet">
99 <h5
><?php
$this->msg('views') ?
></h5
>
102 foreach($this->data
['content_actions'] as $key => $tab) {
104 <li id="' . Sanitizer
::escapeId( "ca-$key" ) . '"';
105 if( $tab['class'] ) {
106 echo ' class="'.htmlspecialchars($tab['class']).'"';
108 echo '><a href="'.htmlspecialchars($tab['href']).'"';
109 # We don't want to give the watch tab an accesskey if the
110 # page is being edited, because that conflicts with the
111 # accesskey on the watch checkbox. We also don't want to
112 # give the edit tab an accesskey, because that's fairly su-
113 # perfluous and conflicts with an accesskey (Ctrl-E) often
114 # used for editing in Safari.
115 if( in_array( $action, array( 'edit', 'submit' ) )
116 && in_array( $key, array( 'edit', 'watch', 'unwatch' ))) {
117 echo $skin->tooltip( "ca-$key" );
119 echo $skin->tooltipAndAccesskey( "ca-$key" );
121 echo '>'.htmlspecialchars($tab['text']).'</a></li>';
127 <div
class="portlet" id
="p-personal">
128 <h5
><?php
$this->msg('personaltools') ?
></h5
>
130 <ul
<?php
$this->html('userlangattributes') ?
>>
131 <?php
foreach($this->data
['personal_urls'] as $key => $item) { ?
>
132 <li id
="<?php echo Sanitizer::escapeId( "pt
-$key" ) ?>"<?php
133 if ($item['active']) { ?
> class="active"<?php
} ?
>><a href
="<?php
134 echo htmlspecialchars($item['href']) ?>"<?php
echo $skin->tooltipAndAccesskey('pt-'.$key) ?
><?php
135 if(!empty($item['class'])) { ?
> class="<?php
136 echo htmlspecialchars($item['class']) ?>"<?php
} ?
>><?php
137 echo htmlspecialchars($item['text']) ?
></a
></li
>
142 <div
class="portlet" id
="p-logo">
143 <a style
="background-image: url(<?php $this->text('logopath') ?>);" <?php
144 ?
>href
="<?php echo htmlspecialchars($this->data['nav_urls']['mainpage']['href'])?>"<?php
145 echo $skin->tooltipAndAccesskey('p-logo') ?
>></a
>
147 <script type
="<?php $this->text('jsmimetype') ?>"> if (window
.isMSIE55
) fixalpha(); </script
>
149 $sidebar = $this->data
['sidebar'];
150 if ( !isset( $sidebar['SEARCH'] ) ) $sidebar['SEARCH'] = true;
151 if ( !isset( $sidebar['TOOLBOX'] ) ) $sidebar['TOOLBOX'] = true;
152 if ( !isset( $sidebar['LANGUAGES'] ) ) $sidebar['LANGUAGES'] = true;
153 foreach ($sidebar as $boxName => $cont) {
154 if ( $boxName == 'SEARCH' ) {
156 } elseif ( $boxName == 'TOOLBOX' ) {
158 } elseif ( $boxName == 'LANGUAGES' ) {
159 $this->languageBox();
161 $this->customBox( $boxName, $cont );
165 </div
><!-- end of the
left (by
default at least
) column
-->
166 <div
class="visualClear"></div
>
167 <div id
="footer"<?php
$this->html('userlangattributes') ?
>>
169 if($this->data
['poweredbyico']) { ?
>
170 <div id
="f-poweredbyico"><?php
$this->html('poweredbyico') ?
></div
>
172 if($this->data
['copyrightico']) { ?
>
173 <div id
="f-copyrightico"><?php
$this->html('copyrightico') ?
></div
>
176 // Generate additional footer links
177 $footerlinks = array(
178 'lastmod', 'viewcount', 'numberofwatchingusers', 'credits', 'copyright',
179 'privacy', 'about', 'disclaimer', 'tagline',
181 $validFooterLinks = array();
182 foreach( $footerlinks as $aLink ) {
183 if( isset( $this->data
[$aLink] ) && $this->data
[$aLink] ) {
184 $validFooterLinks[] = $aLink;
187 if ( count( $validFooterLinks ) > 0 ) {
190 foreach( $validFooterLinks as $aLink ) {
191 if( isset( $this->data
[$aLink] ) && $this->data
[$aLink] ) {
192 ?
> <li id
="<?php echo $aLink ?>"><?php
$this->html($aLink) ?
></li
>
201 <?php
$this->html('bottomscripts'); /* JS call to runBodyOnloadHook */ ?
>
202 <?php
$this->html('reporttime') ?
>
203 <?php
if ( $this->data
['debug'] ): ?
>
205 <?php
$this->text( 'debug' ); ?
>
210 echo Html
::closeElement( 'body' );
211 echo Html
::closeElement( 'html' );
213 } // end of execute() method
215 /*************************************************************************************************/
216 function searchBox() {
217 global $wgUseTwoButtonsSearchForm;
219 <div id
="p-search" class="portlet">
220 <h5
><label
for="searchInput"><?php
$this->msg('search') ?
></label
></h5
>
221 <div id
="searchBody" class="pBody">
222 <form action
="<?php $this->text('wgScript') ?>" id
="searchform">
223 <input type
='hidden' name
="title" value
="<?php $this->text('searchtitle') ?>"/>
225 echo Html
::input( 'search',
226 isset( $this->data
['search'] ) ?
$this->data
['search'] : '', 'search',
228 'id' => 'searchInput',
229 'title' => $this->skin
->titleAttrib( 'search' ),
230 'accesskey' => $this->skin
->accesskey( 'search' )
233 <input type
='submit' name
="go" class="searchButton" id
="searchGoButton" value
="<?php $this->msg('searcharticle') ?>"<?php
echo $this->skin
->tooltipAndAccesskey( 'search-go' ); ?
> /><?php
if ($wgUseTwoButtonsSearchForm) { ?
> 
234 <input type
='submit' name
="fulltext" class="searchButton" id
="mw-searchButton" value
="<?php $this->msg('searchbutton') ?>"<?php
echo $this->skin
->tooltipAndAccesskey( 'search-fulltext' ); ?
> /><?php
} else { ?
>
236 <div
><a href
="<?php $this->text('searchaction') ?>" rel
="search"><?php
$this->msg('powersearch-legend') ?
></a
></div
><?php
} ?
>
244 /*************************************************************************************************/
247 <div
class="portlet" id
="p-tb">
248 <h5
><?php
$this->msg('toolbox') ?
></h5
>
252 if($this->data
['notspecialpage']) { ?
>
253 <li id
="t-whatlinkshere"><a href
="<?php
254 echo htmlspecialchars($this->data['nav_urls']['whatlinkshere']['href'])
255 ?>"<?php
echo $this->skin
->tooltipAndAccesskey('t-whatlinkshere') ?
>><?php
$this->msg('whatlinkshere') ?
></a
></li
>
257 if( $this->data
['nav_urls']['recentchangeslinked'] ) { ?
>
258 <li id
="t-recentchangeslinked"><a href
="<?php
259 echo htmlspecialchars($this->data['nav_urls']['recentchangeslinked']['href'])
260 ?>"<?php
echo $this->skin
->tooltipAndAccesskey('t-recentchangeslinked') ?
>><?php
$this->msg('recentchangeslinked-toolbox') ?
></a
></li
>
263 if( isset( $this->data
['nav_urls']['trackbacklink'] ) && $this->data
['nav_urls']['trackbacklink'] ) { ?
>
264 <li id
="t-trackbacklink"><a href
="<?php
265 echo htmlspecialchars($this->data['nav_urls']['trackbacklink']['href'])
266 ?>"<?php
echo $this->skin
->tooltipAndAccesskey('t-trackbacklink') ?
>><?php
$this->msg('trackbacklink') ?
></a
></li
>
268 if($this->data
['feeds']) { ?
>
269 <li id
="feedlinks"><?php
foreach($this->data
['feeds'] as $key => $feed) {
270 ?
><a id
="<?php echo Sanitizer::escapeId( "feed
-$key" ) ?>" href
="<?php
271 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
> 
275 foreach( array('contributions', 'log', 'blockip', 'emailuser', 'upload', 'specialpages') as $special ) {
277 if($this->data
['nav_urls'][$special]) {
278 ?
><li id
="t-<?php echo $special ?>"><a href
="<?php echo htmlspecialchars($this->data['nav_urls'][$special]['href'])
279 ?>"<?php
echo $this->skin
->tooltipAndAccesskey('t-'.$special) ?
>><?php
$this->msg($special) ?
></a
></li
>
283 if(!empty($this->data
['nav_urls']['print']['href'])) { ?
>
284 <li id
="t-print"><a href
="<?php echo htmlspecialchars($this->data['nav_urls']['print']['href'])
285 ?>" rel
="alternate"<?php
echo $this->skin
->tooltipAndAccesskey('t-print') ?
>><?php
$this->msg('printableversion') ?
></a
></li
><?php
288 if(!empty($this->data
['nav_urls']['permalink']['href'])) { ?
>
289 <li id
="t-permalink"><a href
="<?php echo htmlspecialchars($this->data['nav_urls']['permalink']['href'])
290 ?>"<?php
echo $this->skin
->tooltipAndAccesskey('t-permalink') ?
>><?php
$this->msg('permalink') ?
></a
></li
><?php
291 } elseif ($this->data
['nav_urls']['permalink']['href'] === '') { ?
>
292 <li id
="t-ispermalink"<?php
echo $this->skin
->tooltip('t-ispermalink') ?
>><?php
$this->msg('permalink') ?
></li
><?php
295 wfRunHooks( 'MonoBookTemplateToolboxEnd', array( &$this ) );
296 wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this ) );
304 /*************************************************************************************************/
305 function languageBox() {
306 if( $this->data
['language_urls'] ) {
308 <div id
="p-lang" class="portlet">
309 <h5
<?php
$this->html('userlangattributes') ?
>><?php
$this->msg('otherlanguages') ?
></h5
>
312 <?php
foreach($this->data
['language_urls'] as $langlink) { ?
>
313 <li
class="<?php echo htmlspecialchars($langlink['class'])?>"><?php
314 ?
><a href
="<?php echo htmlspecialchars($langlink['href']) ?>" title
="<?php
315 echo htmlspecialchars($langlink['title']) ?>"><?php
echo $langlink['text'] ?
></a
></li
>
324 /*************************************************************************************************/
325 function customBox( $bar, $cont ) {
327 <div
class='generated-sidebar portlet' id
='<?php echo Sanitizer::escapeId( "p-$bar" ) ?>'<?php
echo $this->skin
->tooltip('p-'.$bar) ?
>>
328 <h5
><?php
$out = wfMsg( $bar ); if (wfEmptyMsg($bar, $out)) echo htmlspecialchars($bar); else echo htmlspecialchars($out); ?
></h5
>
330 <?php
if ( is_array( $cont ) ) { ?
>
332 <?php
foreach($cont as $val) { ?
>
333 <li id
="<?php echo Sanitizer::escapeId($val['id']) ?>"<?php
334 if ( $val['active'] ) { ?
> class="active" <?php
}
335 ?
>><a href
="<?php echo htmlspecialchars($val['href']) ?>"<?php
echo $this->skin
->tooltipAndAccesskey($val['id']) ?
>><?php
echo htmlspecialchars($val['text']) ?
></a
></li
>
339 # allow raw HTML block to be defined by extensions