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/IE60Fixes.css', 'screen', 'IE 6' );
43 $out->addStyle( 'monobook/IE70Fixes.css', 'screen', 'IE 7' );
52 class MonoBookTemplate
extends BaseTemplate
{
55 * Template filter callback for MonoBook skin.
56 * Takes an associative array of data set from a SkinTemplate-based
57 * class, and a wrapper for MediaWiki's localization database, and
58 * outputs a formatted page.
63 // Suppress warnings to prevent notices about missing indexes in $this->data
66 $this->html( 'headelement' );
67 ?
><div id
="globalWrapper">
68 <div id
="column-content"><div id
="content">
70 <?php
if($this->data
['sitenotice']) { ?
><div id
="siteNotice"><?php
$this->html('sitenotice') ?
></div
><?php
} ?
>
72 <h1 id
="firstHeading" class="firstHeading"><span dir
="auto"><?php
$this->html('title') ?
></span
></h1
>
73 <div id
="bodyContent" class="mw-body">
74 <div id
="siteSub"><?php
$this->msg('tagline') ?
></div
>
75 <div id
="contentSub"<?php
$this->html('userlangattributes') ?
>><?php
$this->html('subtitle') ?
></div
>
76 <?php
if($this->data
['undelete']) { ?
>
77 <div id
="contentSub2"><?php
$this->html('undelete') ?
></div
>
78 <?php
} ?
><?php
if($this->data
['newtalk'] ) { ?
>
79 <div
class="usermessage"><?php
$this->html('newtalk') ?
></div
>
80 <?php
} ?
><?php
if($this->data
['showjumplinks']) { ?
>
81 <div id
="jump-to-nav" class="mw-jump"><?php
$this->msg('jumpto') ?
> <a href
="#column-one"><?php
$this->msg('jumptonavigation') ?
></a
>, <a href
="#searchInput"><?php
$this->msg('jumptosearch') ?
></a
></div
>
83 <!-- start content
-->
84 <?php
$this->html('bodytext') ?
>
85 <?php
if($this->data
['catlinks']) { $this->html('catlinks'); } ?
>
87 <?php
if($this->data
['dataAfterContent']) { $this->html ('dataAfterContent'); } ?
>
88 <div
class="visualClear"></div
>
91 <div id
="column-one"<?php
$this->html('userlangattributes') ?
>>
92 <?php
$this->cactions(); ?
>
93 <div
class="portlet" id
="p-personal">
94 <h5
><?php
$this->msg('personaltools') ?
></h5
>
96 <ul
<?php
$this->html('userlangattributes') ?
>>
97 <?php
foreach($this->getPersonalTools() as $key => $item) { ?
>
98 <?php
echo $this->makeListItem($key, $item); ?
>
104 <div
class="portlet" id
="p-logo">
106 echo Html
::element( 'a', array(
107 'href' => $this->data
['nav_urls']['mainpage']['href'],
108 'style' => "background-image: url({$this->data['logopath']});" )
109 + Linker
::tooltipAndAccesskeyAttribs('p-logo') ); ?
>
113 $this->renderPortals( $this->data
['sidebar'] );
115 </div
><!-- end of the
left (by
default at least
) column
-->
116 <div
class="visualClear"></div
>
118 $validFooterIcons = $this->getFooterIcons( "icononly" );
119 $validFooterLinks = $this->getFooterLinks( "flat" ); // Additional footer links
121 if ( count( $validFooterIcons ) +
count( $validFooterLinks ) > 0 ) { ?
>
122 <div id
="footer"<?php
$this->html('userlangattributes') ?
>>
124 $footerEnd = '</div>';
128 foreach ( $validFooterIcons as $blockName => $footerIcons ) { ?
>
129 <div id
="f-<?php echo htmlspecialchars($blockName); ?>ico">
130 <?php
foreach ( $footerIcons as $icon ) { ?
>
131 <?php
echo $this->getSkin()->makeFooterIcon( $icon ); ?
>
138 if ( count( $validFooterLinks ) > 0 ) {
141 foreach( $validFooterLinks as $aLink ) { ?
>
142 <li id
="<?php echo $aLink ?>"><?php
$this->html($aLink) ?
></li
>
154 echo Html
::closeElement( 'body' );
155 echo Html
::closeElement( 'html' );
157 } // end of execute() method
159 /*************************************************************************************************/
162 * @param $sidebar array
164 protected function renderPortals( $sidebar ) {
165 if ( !isset( $sidebar['SEARCH'] ) ) $sidebar['SEARCH'] = true;
166 if ( !isset( $sidebar['TOOLBOX'] ) ) $sidebar['TOOLBOX'] = true;
167 if ( !isset( $sidebar['LANGUAGES'] ) ) $sidebar['LANGUAGES'] = true;
169 foreach( $sidebar as $boxName => $content ) {
170 if ( $content === false )
173 if ( $boxName == 'SEARCH' ) {
175 } elseif ( $boxName == 'TOOLBOX' ) {
177 } elseif ( $boxName == 'LANGUAGES' ) {
178 $this->languageBox();
180 $this->customBox( $boxName, $content );
185 function searchBox() {
186 global $wgUseTwoButtonsSearchForm;
188 <div id
="p-search" class="portlet">
189 <h5
><label
for="searchInput"><?php
$this->msg('search') ?
></label
></h5
>
190 <div id
="searchBody" class="pBody">
191 <form action
="<?php $this->text('wgScript') ?>" id
="searchform">
192 <input type
='hidden' name
="title" value
="<?php $this->text('searchtitle') ?>"/>
193 <?php
echo $this->makeSearchInput(array( "id" => "searchInput" )); ?
>
195 <?php
echo $this->makeSearchButton("go", array( "id" => "searchGoButton", "class" => "searchButton" ));
196 if ($wgUseTwoButtonsSearchForm): ?
> 
197 <?php
echo $this->makeSearchButton("fulltext", array( "id" => "mw-searchButton", "class" => "searchButton" ));
200 <div
><a href
="<?php $this->text('searchaction') ?>" rel
="search"><?php
$this->msg('powersearch-legend') ?
></a
></div
><?php
210 * Prints the cactions bar.
211 * Shared between MonoBook and Modern
213 function cactions() {
215 <div id
="p-cactions" class="portlet">
216 <h5
><?php
$this->msg('views') ?
></h5
>
219 foreach($this->data
['content_actions'] as $key => $tab) {
221 ' . $this->makeListItem( $key, $tab );
229 /*************************************************************************************************/
232 <div
class="portlet" id
="p-tb">
233 <h5
><?php
$this->msg('toolbox') ?
></h5
>
237 foreach ( $this->getToolbox() as $key => $tbitem ) { ?
>
238 <?php
echo $this->makeListItem($key, $tbitem); ?
>
242 wfRunHooks( 'MonoBookTemplateToolboxEnd', array( &$this ) );
243 wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this, true ) );
251 /*************************************************************************************************/
252 function languageBox() {
253 if( $this->data
['language_urls'] ) {
255 <div id
="p-lang" class="portlet">
256 <h5
<?php
$this->html('userlangattributes') ?
>><?php
$this->msg('otherlanguages') ?
></h5
>
259 <?php
foreach($this->data
['language_urls'] as $key => $langlink) { ?
>
260 <?php
echo $this->makeListItem($key, $langlink); ?
>
270 /*************************************************************************************************/
273 * @param $cont array|string
275 function customBox( $bar, $cont ) {
276 $portletAttribs = array( 'class' => 'generated-sidebar portlet', 'id' => Sanitizer
::escapeId( "p-$bar" ) );
277 $tooltip = Linker
::titleAttrib( "p-$bar" );
278 if ( $tooltip !== false ) {
279 $portletAttribs['title'] = $tooltip;
281 echo ' ' . Html
::openElement( 'div', $portletAttribs );
284 <h5
><?php
$msg = wfMessage( $bar ); echo htmlspecialchars( $msg->exists() ?
$msg->text() : $bar ); ?
></h5
>
286 <?php
if ( is_array( $cont ) ) { ?
>
288 <?php
foreach($cont as $key => $val) { ?
>
289 <?php
echo $this->makeListItem($key, $val); ?
>
294 # allow raw HTML block to be defined by extensions