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;
27 * @param $out OutputPage
29 function setupSkinUserCss( OutputPage
$out ) {
30 global $wgHandheldStyle;
31 parent
::setupSkinUserCss( $out );
33 $out->addModuleStyles( 'skins.monobook' );
35 // Ugh. Can't do this properly because $wgHandheldStyle may be a URL
36 if( $wgHandheldStyle ) {
37 // Currently in testing... try 'chick/main.css'
38 $out->addStyle( $wgHandheldStyle, 'handheld' );
41 // TODO: Migrate all of these
42 //$out->addStyle( 'monobook/IE50Fixes.css', 'screen', 'lt IE 5.5000' );
43 //$out->addStyle( 'monobook/IE55Fixes.css', 'screen', 'IE 5.5000' );
44 //$out->addStyle( 'monobook/IE60Fixes.css', 'screen', 'IE 6' );
45 //$out->addStyle( 'monobook/IE70Fixes.css', 'screen', 'IE 7' );
54 class MonoBookTemplate
extends BaseTemplate
{
62 * Template filter callback for MonoBook skin.
63 * Takes an associative array of data set from a SkinTemplate-based
64 * class, and a wrapper for MediaWiki's localization database, and
65 * outputs a formatted page.
70 $this->skin
= $this->data
['skin'];
72 // Suppress warnings to prevent notices about missing indexes in $this->data
75 $this->html( 'headelement' );
76 ?
><div id
="globalWrapper">
77 <div id
="column-content"><div id
="content">
79 <?php
if($this->data
['sitenotice']) { ?
><div id
="siteNotice"><?php
$this->html('sitenotice') ?
></div
><?php
} ?
>
81 <h1 id
="firstHeading" class="firstHeading"><?php
$this->html('title') ?
></h1
>
82 <div id
="bodyContent">
83 <div id
="siteSub"><?php
$this->msg('tagline') ?
></div
>
84 <div id
="contentSub"<?php
$this->html('userlangattributes') ?
>><?php
$this->html('subtitle') ?
></div
>
85 <?php
if($this->data
['undelete']) { ?
>
86 <div id
="contentSub2"><?php
$this->html('undelete') ?
></div
>
87 <?php
} ?
><?php
if($this->data
['newtalk'] ) { ?
>
88 <div
class="usermessage"><?php
$this->html('newtalk') ?
></div
>
89 <?php
} ?
><?php
if($this->data
['showjumplinks']) { ?
>
90 <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
>
92 <!-- start content
-->
93 <?php
$this->html('bodytext') ?
>
94 <?php
if($this->data
['printfooter']) { ?
><div
class="printfooter"><?php
$this->html('printfooter'); ?
></div
><?php
} ?
>
95 <?php
$this->html('debughtml'); ?
>
96 <?php
if($this->data
['catlinks']) { $this->html('catlinks'); } ?
>
98 <?php
if($this->data
['dataAfterContent']) { $this->html ('dataAfterContent'); } ?
>
99 <div
class="visualClear"></div
>
102 <div id
="column-one"<?php
$this->html('userlangattributes') ?
>>
103 <?php
$this->cactions(); ?
>
104 <div
class="portlet" id
="p-personal">
105 <h5
><?php
$this->msg('personaltools') ?
></h5
>
107 <ul
<?php
$this->html('userlangattributes') ?
>>
108 <?php
foreach($this->getPersonalTools() as $key => $item) { ?
>
109 <?php
echo $this->makeListItem($key, $item); ?
>
115 <div
class="portlet" id
="p-logo">
117 $logoAttribs = array() + Linker
::tooltipAndAccesskeyAttribs('p-logo');
118 $logoAttribs['style'] = "background-image: url({$this->data['logopath']});";
119 $logoAttribs['href'] = $this->data
['nav_urls']['mainpage']['href'];
120 echo Html
::element( 'a', $logoAttribs );
124 <script type
="<?php $this->text('jsmimetype') ?>"> if (window
.isMSIE55
) fixalpha(); </script
>
126 $this->renderPortals( $this->data
['sidebar'] );
128 </div
><!-- end of the
left (by
default at least
) column
-->
129 <div
class="visualClear"></div
>
131 $validFooterIcons = $this->getFooterIcons( "icononly" );
132 $validFooterLinks = $this->getFooterLinks( "flat" ); // Additional footer links
134 if ( count( $validFooterIcons ) +
count( $validFooterLinks ) > 0 ) { ?
>
135 <div id
="footer"<?php
$this->html('userlangattributes') ?
>>
137 $footerEnd = '</div>';
141 foreach ( $validFooterIcons as $blockName => $footerIcons ) { ?
>
142 <div id
="f-<?php echo htmlspecialchars($blockName); ?>ico">
143 <?php
foreach ( $footerIcons as $icon ) { ?
>
144 <?php
echo $this->skin
->makeFooterIcon( $icon ); ?
>
151 if ( count( $validFooterLinks ) > 0 ) {
154 foreach( $validFooterLinks as $aLink ) { ?
>
155 <li id
="<?php echo $aLink ?>"><?php
$this->html($aLink) ?
></li
>
167 echo Html
::closeElement( 'body' );
168 echo Html
::closeElement( 'html' );
170 } // end of execute() method
172 /*************************************************************************************************/
174 protected function renderPortals( $sidebar ) {
175 if ( !isset( $sidebar['SEARCH'] ) ) $sidebar['SEARCH'] = true;
176 if ( !isset( $sidebar['TOOLBOX'] ) ) $sidebar['TOOLBOX'] = true;
177 if ( !isset( $sidebar['LANGUAGES'] ) ) $sidebar['LANGUAGES'] = true;
179 foreach( $sidebar as $boxName => $content ) {
180 if ( $content === false )
183 if ( $boxName == 'SEARCH' ) {
185 } elseif ( $boxName == 'TOOLBOX' ) {
187 } elseif ( $boxName == 'LANGUAGES' ) {
188 $this->languageBox();
190 $this->customBox( $boxName, $content );
195 function searchBox() {
196 global $wgUseTwoButtonsSearchForm;
198 <div id
="p-search" class="portlet">
199 <h5
><label
for="searchInput"><?php
$this->msg('search') ?
></label
></h5
>
200 <div id
="searchBody" class="pBody">
201 <form action
="<?php $this->text('wgScript') ?>" id
="searchform">
202 <input type
='hidden' name
="title" value
="<?php $this->text('searchtitle') ?>"/>
203 <?php
echo $this->makeSearchInput(array( "id" => "searchInput" )); ?
>
205 <?php
echo $this->makeSearchButton("go", array( "id" => "searchGoButton", "class" => "searchButton" ));
206 if ($wgUseTwoButtonsSearchForm): ?
> 
207 <?php
echo $this->makeSearchButton("fulltext", array( "id" => "mw-searchButton", "class" => "searchButton" ));
210 <div
><a href
="<?php $this->text('searchaction') ?>" rel
="search"><?php
$this->msg('powersearch-legend') ?
></a
></div
><?php
220 * Prints the cactions bar.
221 * Shared between MonoBook and Modern
225 function cactions() {
227 <div id
="p-cactions" class="portlet">
228 <h5
><?php
$this->msg('views') ?
></h5
>
231 foreach($this->data
['content_actions'] as $key => $tab) {
232 $linkAttribs = array( 'href' => $tab['href'] );
234 if( isset( $tab["tooltiponly"] ) && $tab["tooltiponly"] ) {
235 $title = Linker
::titleAttrib( "ca-$key" );
236 if ( $title !== false ) {
237 $linkAttribs['title'] = $title;
240 $linkAttribs +
= Linker
::tooltipAndAccesskeyAttribs( "ca-$key" );
242 $linkHtml = Html
::element( 'a', $linkAttribs, $tab['text'] );
244 /* Surround with a <li> */
245 $liAttribs = array( 'id' => Sanitizer
::escapeId( "ca-$key" ) );
246 if( $tab['class'] ) {
247 $liAttribs['class'] = $tab['class'];
250 ' . Html
::rawElement( 'li', $liAttribs, $linkHtml );
258 /*************************************************************************************************/
261 <div
class="portlet" id
="p-tb">
262 <h5
><?php
$this->msg('toolbox') ?
></h5
>
266 foreach ( $this->getToolbox() as $key => $tbitem ) { ?
>
267 <?php
echo $this->makeListItem($key, $tbitem); ?
>
271 wfRunHooks( 'MonoBookTemplateToolboxEnd', array( &$this ) );
272 wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this ) );
280 /*************************************************************************************************/
281 function languageBox() {
282 if( $this->data
['language_urls'] ) {
284 <div id
="p-lang" class="portlet">
285 <h5
<?php
$this->html('userlangattributes') ?
>><?php
$this->msg('otherlanguages') ?
></h5
>
288 <?php
foreach($this->data
['language_urls'] as $key => $langlink) { ?
>
289 <?php
echo $this->makeListItem($key, $langlink); ?
>
299 /*************************************************************************************************/
300 function customBox( $bar, $cont ) {
301 $portletAttribs = array( 'class' => 'generated-sidebar portlet', 'id' => Sanitizer
::escapeId( "p-$bar" ) );
302 $tooltip = Linker
::titleAttrib( "p-$bar" );
303 if ( $tooltip !== false ) {
304 $portletAttribs['title'] = $tooltip;
306 echo ' ' . Html
::openElement( 'div', $portletAttribs );
309 <h5
><?php
$msg = wfMessage( $bar ); echo htmlspecialchars( $msg->exists() ?
$msg->text() : $bar ); ?
></h5
>
311 <?php
if ( is_array( $cont ) ) { ?
>
313 <?php
foreach($cont as $key => $val) { ?
>
314 <?php
echo $this->makeListItem($key, $val); ?
>
319 # allow raw HTML block to be defined by extensions