5 * Translated from gwicke's previous TAL template version to remove
6 * dependency on PHPTAL.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 * http://www.gnu.org/copyleft/gpl.html
28 if( !defined( 'MEDIAWIKI' ) )
32 * Inherit main code from SkinTemplate, set the CSS and template filter.
36 class SkinMonoBook
extends SkinTemplate
{
37 /** Using monobook. */
38 var $skinname = 'monobook', $stylename = 'monobook',
39 $template = 'MonoBookTemplate', $useHeadElement = true;
42 * @param $out OutputPage
44 function setupSkinUserCss( OutputPage
$out ) {
45 global $wgHandheldStyle;
46 parent
::setupSkinUserCss( $out );
48 $out->addModuleStyles( 'skins.monobook' );
50 // Ugh. Can't do this properly because $wgHandheldStyle may be a URL
51 if( $wgHandheldStyle ) {
52 // Currently in testing... try 'chick/main.css'
53 $out->addStyle( $wgHandheldStyle, 'handheld' );
56 // TODO: Migrate all of these
57 $out->addStyle( 'monobook/IE60Fixes.css', 'screen', 'IE 6' );
58 $out->addStyle( 'monobook/IE70Fixes.css', 'screen', 'IE 7' );
67 class MonoBookTemplate
extends BaseTemplate
{
70 * Template filter callback for MonoBook skin.
71 * Takes an associative array of data set from a SkinTemplate-based
72 * class, and a wrapper for MediaWiki's localization database, and
73 * outputs a formatted page.
78 // Suppress warnings to prevent notices about missing indexes in $this->data
81 $this->html( 'headelement' );
82 ?
><div id
="globalWrapper">
83 <div id
="column-content"><div id
="content" class="mw-body-primary" role
="main">
85 <?php
if($this->data
['sitenotice']) { ?
><div id
="siteNotice"><?php
$this->html('sitenotice') ?
></div
><?php
} ?
>
87 <h1 id
="firstHeading" class="firstHeading" lang
="<?php
88 $this->data['pageLanguage'] = $this->getSkin()->getTitle()->getPageViewLanguage()->getCode();
89 $this->html( 'pageLanguage' );
90 ?>"><span dir
="auto"><?php
$this->html('title') ?
></span
></h1
>
91 <div id
="bodyContent" class="mw-body">
92 <div id
="siteSub"><?php
$this->msg('tagline') ?
></div
>
93 <div id
="contentSub"<?php
$this->html('userlangattributes') ?
>><?php
$this->html('subtitle') ?
></div
>
94 <?php
if($this->data
['undelete']) { ?
>
95 <div id
="contentSub2"><?php
$this->html('undelete') ?
></div
>
96 <?php
} ?
><?php
if($this->data
['newtalk'] ) { ?
>
97 <div
class="usermessage"><?php
$this->html('newtalk') ?
></div
>
98 <?php
} ?
><?php
if($this->data
['showjumplinks']) { ?
>
99 <div id
="jump-to-nav" class="mw-jump"><?php
$this->msg('jumpto') ?
> <a href
="#column-one"><?php
$this->msg('jumptonavigation') ?
></a
><?php
$this->msg( 'comma-separator' ) ?
><a href
="#searchInput"><?php
$this->msg('jumptosearch') ?
></a
></div
>
101 <!-- start content
-->
102 <?php
$this->html('bodytext') ?
>
103 <?php
if($this->data
['catlinks']) { $this->html('catlinks'); } ?
>
105 <?php
if($this->data
['dataAfterContent']) { $this->html ('dataAfterContent'); } ?
>
106 <div
class="visualClear"></div
>
109 <div id
="column-one"<?php
$this->html('userlangattributes') ?
>>
110 <h2
><?php
$this->msg( 'navigation-heading' ) ?
></h2
>
111 <?php
$this->cactions(); ?
>
112 <div
class="portlet" id
="p-personal" role
="navigation">
113 <h3
><?php
$this->msg('personaltools') ?
></h3
>
115 <ul
<?php
$this->html('userlangattributes') ?
>>
116 <?php
foreach($this->getPersonalTools() as $key => $item) { ?
>
117 <?php
echo $this->makeListItem($key, $item); ?
>
123 <div
class="portlet" id
="p-logo" role
="banner">
125 echo Html
::element( 'a', array(
126 'href' => $this->data
['nav_urls']['mainpage']['href'],
127 'style' => "background-image: url({$this->data['logopath']});" )
128 + Linker
::tooltipAndAccesskeyAttribs('p-logo') ); ?
>
132 $this->renderPortals( $this->data
['sidebar'] );
134 </div
><!-- end of the
left (by
default at least
) column
-->
135 <div
class="visualClear"></div
>
137 $validFooterIcons = $this->getFooterIcons( "icononly" );
138 $validFooterLinks = $this->getFooterLinks( "flat" ); // Additional footer links
140 if ( count( $validFooterIcons ) +
count( $validFooterLinks ) > 0 ) { ?
>
141 <div id
="footer" role
="contentinfo"<?php
$this->html('userlangattributes') ?
>>
143 $footerEnd = '</div>';
147 foreach ( $validFooterIcons as $blockName => $footerIcons ) { ?
>
148 <div id
="f-<?php echo htmlspecialchars($blockName); ?>ico">
149 <?php
foreach ( $footerIcons as $icon ) { ?
>
150 <?php
echo $this->getSkin()->makeFooterIcon( $icon ); ?
>
157 if ( count( $validFooterLinks ) > 0 ) {
160 foreach( $validFooterLinks as $aLink ) { ?
>
161 <li id
="<?php echo $aLink ?>"><?php
$this->html($aLink) ?
></li
>
173 echo Html
::closeElement( 'body' );
174 echo Html
::closeElement( 'html' );
176 } // end of execute() method
178 /*************************************************************************************************/
181 * @param $sidebar array
183 protected function renderPortals( $sidebar ) {
184 if ( !isset( $sidebar['SEARCH'] ) ) $sidebar['SEARCH'] = true;
185 if ( !isset( $sidebar['TOOLBOX'] ) ) $sidebar['TOOLBOX'] = true;
186 if ( !isset( $sidebar['LANGUAGES'] ) ) $sidebar['LANGUAGES'] = true;
188 foreach( $sidebar as $boxName => $content ) {
189 if ( $content === false )
192 if ( $boxName == 'SEARCH' ) {
194 } elseif ( $boxName == 'TOOLBOX' ) {
196 } elseif ( $boxName == 'LANGUAGES' ) {
197 $this->languageBox();
199 $this->customBox( $boxName, $content );
204 function searchBox() {
205 global $wgUseTwoButtonsSearchForm;
207 <div id
="p-search" class="portlet" role
="search">
208 <h3
><label
for="searchInput"><?php
$this->msg( 'search' ) ?
></label
></h3
>
209 <div id
="searchBody" class="pBody">
210 <form action
="<?php $this->text( 'wgScript' ) ?>" id
="searchform">
211 <input type
='hidden' name
="title" value
="<?php $this->text( 'searchtitle' ) ?>"/>
212 <?php
echo $this->makeSearchInput( array( "id" => "searchInput" ) ); ?
>
214 <?php
echo $this->makeSearchButton( "go", array( "id" => "searchGoButton", "class" => "searchButton" ) );
215 if ( $wgUseTwoButtonsSearchForm ): ?
> 
216 <?php
echo $this->makeSearchButton( "fulltext", array( "id" => "mw-searchButton", "class" => "searchButton" ) );
219 <div
><a href
="<?php $this->text( 'searchaction' ) ?>" rel
="search"><?php
$this->msg( 'powersearch-legend' ) ?
></a
></div
><?php
229 * Prints the cactions bar.
230 * Shared between MonoBook and Modern
232 function cactions() {
234 <div id
="p-cactions" class="portlet" role
="navigation">
235 <h3
><?php
$this->msg( 'views' ) ?
></h3
>
238 foreach( $this->data
['content_actions'] as $key => $tab ) {
240 ' . $this->makeListItem( $key, $tab );
248 /*************************************************************************************************/
251 <div
class="portlet" id
="p-tb" role
="navigation">
252 <h3
><?php
$this->msg( 'toolbox' ) ?
></h3
>
256 foreach ( $this->getToolbox() as $key => $tbitem ) { ?
>
257 <?php
echo $this->makeListItem( $key, $tbitem ); ?
>
261 wfRunHooks( 'MonoBookTemplateToolboxEnd', array( &$this ) );
262 wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this, true ) );
270 /*************************************************************************************************/
271 function languageBox() {
272 if( $this->data
['language_urls'] ) {
274 <div id
="p-lang" class="portlet" role
="navigation">
275 <h3
<?php
$this->html( 'userlangattributes' ) ?
>><?php
$this->msg( 'otherlanguages' ) ?
></h3
>
278 <?php
foreach( $this->data
['language_urls'] as $key => $langlink ) { ?
>
279 <?php
echo $this->makeListItem( $key, $langlink ); ?
>
289 /*************************************************************************************************/
292 * @param $cont array|string
294 function customBox( $bar, $cont ) {
295 $portletAttribs = array( 'class' => 'generated-sidebar portlet', 'id' => Sanitizer
::escapeId( "p-$bar" ), 'role' => 'navigation' );
296 $tooltip = Linker
::titleAttrib( "p-$bar" );
297 if ( $tooltip !== false ) {
298 $portletAttribs['title'] = $tooltip;
300 echo ' ' . Html
::openElement( 'div', $portletAttribs );
303 <h3
><?php
$msg = wfMessage( $bar ); echo htmlspecialchars( $msg->exists() ?
$msg->text() : $bar ); ?
></h3
>
305 <?php
if ( is_array( $cont ) ) { ?
>
307 <?php
foreach( $cont as $key => $val ) { ?
>
308 <?php
echo $this->makeListItem( $key, $val ); ?
>
313 # allow raw HTML block to be defined by extensions