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' );
51 class MonoBookTemplate
extends BaseTemplate
{
59 * Template filter callback for MonoBook skin.
60 * Takes an associative array of data set from a SkinTemplate-based
61 * class, and a wrapper for MediaWiki's localization database, and
62 * outputs a formatted page.
67 $this->skin
= $this->data
['skin'];
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">
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
['printfooter']) { ?
><div
class="printfooter"><?php
$this->html('printfooter'); ?
></div
><?php
} ?
>
92 <?php
$this->html('debughtml'); ?
>
93 <?php
if($this->data
['catlinks']) { $this->html('catlinks'); } ?
>
95 <?php
if($this->data
['dataAfterContent']) { $this->html ('dataAfterContent'); } ?
>
96 <div
class="visualClear"></div
>
99 <div id
="column-one"<?php
$this->html('userlangattributes') ?
>>
100 <?php
$this->cactions(); ?
>
101 <div
class="portlet" id
="p-personal">
102 <h5
><?php
$this->msg('personaltools') ?
></h5
>
104 <ul
<?php
$this->html('userlangattributes') ?
>>
105 <?php
foreach($this->getPersonalTools() as $key => $item) { ?
>
106 <?php
echo $this->makeListItem($key, $item); ?
>
112 <div
class="portlet" id
="p-logo">
114 $logoAttribs = array() + Linker
::tooltipAndAccesskeyAttribs('p-logo');
115 $logoAttribs['style'] = "background-image: url({$this->data['logopath']});";
116 $logoAttribs['href'] = $this->data
['nav_urls']['mainpage']['href'];
117 echo Html
::element( 'a', $logoAttribs );
121 <script type
="<?php $this->text('jsmimetype') ?>"> if (window
.isMSIE55
) fixalpha(); </script
>
123 $this->renderPortals( $this->data
['sidebar'] );
125 </div
><!-- end of the
left (by
default at least
) column
-->
126 <div
class="visualClear"></div
>
128 $validFooterIcons = $this->getFooterIcons( "icononly" );
129 $validFooterLinks = $this->getFooterLinks( "flat" ); // Additional footer links
131 if ( count( $validFooterIcons ) +
count( $validFooterLinks ) > 0 ) { ?
>
132 <div id
="footer"<?php
$this->html('userlangattributes') ?
>>
134 $footerEnd = '</div>';
138 foreach ( $validFooterIcons as $blockName => $footerIcons ) { ?
>
139 <div id
="f-<?php echo htmlspecialchars($blockName); ?>ico">
140 <?php
foreach ( $footerIcons as $icon ) { ?
>
141 <?php
echo $this->skin
->makeFooterIcon( $icon ); ?
>
148 if ( count( $validFooterLinks ) > 0 ) {
151 foreach( $validFooterLinks as $aLink ) { ?
>
152 <li id
="<?php echo $aLink ?>"><?php
$this->html($aLink) ?
></li
>
164 echo Html
::closeElement( 'body' );
165 echo Html
::closeElement( 'html' );
167 } // end of execute() method
169 /*************************************************************************************************/
171 protected function renderPortals( $sidebar ) {
172 if ( !isset( $sidebar['SEARCH'] ) ) $sidebar['SEARCH'] = true;
173 if ( !isset( $sidebar['TOOLBOX'] ) ) $sidebar['TOOLBOX'] = true;
174 if ( !isset( $sidebar['LANGUAGES'] ) ) $sidebar['LANGUAGES'] = true;
176 foreach( $sidebar as $boxName => $content ) {
177 if ( $content === false )
180 if ( $boxName == 'SEARCH' ) {
182 } elseif ( $boxName == 'TOOLBOX' ) {
184 } elseif ( $boxName == 'LANGUAGES' ) {
185 $this->languageBox();
187 $this->customBox( $boxName, $content );
192 function searchBox() {
193 global $wgUseTwoButtonsSearchForm;
195 <div id
="p-search" class="portlet">
196 <h5
><label
for="searchInput"><?php
$this->msg('search') ?
></label
></h5
>
197 <div id
="searchBody" class="pBody">
198 <form action
="<?php $this->text('wgScript') ?>" id
="searchform">
199 <input type
='hidden' name
="title" value
="<?php $this->text('searchtitle') ?>"/>
200 <?php
echo $this->makeSearchInput(array( "id" => "searchInput" )); ?
>
202 <?php
echo $this->makeSearchButton("go", array( "id" => "searchGoButton", "class" => "searchButton" ));
203 if ($wgUseTwoButtonsSearchForm): ?
> 
204 <?php
echo $this->makeSearchButton("fulltext", array( "id" => "mw-searchButton", "class" => "searchButton" ));
207 <div
><a href
="<?php $this->text('searchaction') ?>" rel
="search"><?php
$this->msg('powersearch-legend') ?
></a
></div
><?php
217 * Prints the cactions bar.
218 * Shared between MonoBook and Modern
220 function cactions() {
222 <div id
="p-cactions" class="portlet">
223 <h5
><?php
$this->msg('views') ?
></h5
>
226 foreach($this->data
['content_actions'] as $key => $tab) {
227 $linkAttribs = array( 'href' => $tab['href'] );
229 if( isset( $tab["tooltiponly"] ) && $tab["tooltiponly"] ) {
230 $title = Linker
::titleAttrib( "ca-$key" );
231 if ( $title !== false ) {
232 $linkAttribs['title'] = $title;
235 $linkAttribs +
= Linker
::tooltipAndAccesskeyAttribs( "ca-$key" );
237 $linkHtml = Html
::element( 'a', $linkAttribs, $tab['text'] );
239 /* Surround with a <li> */
240 $liAttribs = array( 'id' => Sanitizer
::escapeId( "ca-$key" ) );
241 if( $tab['class'] ) {
242 $liAttribs['class'] = $tab['class'];
245 ' . Html
::rawElement( 'li', $liAttribs, $linkHtml );
253 /*************************************************************************************************/
256 <div
class="portlet" id
="p-tb">
257 <h5
><?php
$this->msg('toolbox') ?
></h5
>
261 foreach ( $this->getToolbox() as $key => $tbitem ) { ?
>
262 <?php
echo $this->makeListItem($key, $tbitem); ?
>
266 wfRunHooks( 'MonoBookTemplateToolboxEnd', array( &$this ) );
267 wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this ) );
275 /*************************************************************************************************/
276 function languageBox() {
277 if( $this->data
['language_urls'] ) {
279 <div id
="p-lang" class="portlet">
280 <h5
<?php
$this->html('userlangattributes') ?
>><?php
$this->msg('otherlanguages') ?
></h5
>
283 <?php
foreach($this->data
['language_urls'] as $key => $langlink) { ?
>
284 <?php
echo $this->makeListItem($key, $langlink); ?
>
294 /*************************************************************************************************/
295 function customBox( $bar, $cont ) {
296 $portletAttribs = array( 'class' => 'generated-sidebar portlet', 'id' => Sanitizer
::escapeId( "p-$bar" ) );
297 $tooltip = Linker
::titleAttrib( "p-$bar" );
298 if ( $tooltip !== false ) {
299 $portletAttribs['title'] = $tooltip;
301 echo ' ' . Html
::openElement( 'div', $portletAttribs );
304 <h5
><?php
$msg = wfMessage( $bar ); echo htmlspecialchars( $msg->exists() ?
$msg->text() : $bar ); ?
></h5
>
306 <?php
if ( is_array( $cont ) ) { ?
>
308 <?php
foreach($cont as $key => $val) { ?
>
309 <?php
echo $this->makeListItem($key, $val); ?
>
314 # allow raw HTML block to be defined by extensions