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' ) ) {
33 * Inherit main code from SkinTemplate, set the CSS and template filter.
37 class SkinMonoBook
extends SkinTemplate
{
38 /** Using monobook. */
39 var $skinname = 'monobook', $stylename = 'monobook',
40 $template = 'MonoBookTemplate', $useHeadElement = true;
43 * @param $out OutputPage
45 function setupSkinUserCss( OutputPage
$out ) {
46 global $wgHandheldStyle;
47 parent
::setupSkinUserCss( $out );
49 $out->addModuleStyles( 'skins.monobook' );
51 // Ugh. Can't do this properly because $wgHandheldStyle may be a URL
52 if ( $wgHandheldStyle ) {
53 // Currently in testing... try 'chick/main.css'
54 $out->addStyle( $wgHandheldStyle, 'handheld' );
57 // TODO: Migrate all of these
58 $out->addStyle( 'monobook/IE60Fixes.css', 'screen', 'IE 6' );
59 $out->addStyle( 'monobook/IE70Fixes.css', 'screen', 'IE 7' );
68 class MonoBookTemplate
extends BaseTemplate
{
71 * Template filter callback for MonoBook skin.
72 * Takes an associative array of data set from a SkinTemplate-based
73 * class, and a wrapper for MediaWiki's localization database, and
74 * outputs a formatted page.
79 // Suppress warnings to prevent notices about missing indexes in $this->data
82 $this->html( 'headelement' );
83 ?
><div id
="globalWrapper">
84 <div id
="column-content"><div id
="content" class="mw-body-primary" role
="main">
86 <?php
if ( $this->data
['sitenotice'] ) { ?
><div id
="siteNotice"><?php
$this->html( 'sitenotice' ) ?
></div
><?php
} ?
>
88 <h1 id
="firstHeading" class="firstHeading" lang
="<?php
89 $this->data['pageLanguage'] = $this->getSkin()->getTitle()->getPageViewLanguage()->getCode();
90 $this->html( 'pageLanguage' );
91 ?>"><span dir
="auto"><?php
$this->html( 'title' ) ?
></span
></h1
>
92 <div id
="bodyContent" class="mw-body">
93 <div id
="siteSub"><?php
$this->msg( 'tagline' ) ?
></div
>
94 <div id
="contentSub"<?php
$this->html( 'userlangattributes' ) ?
>><?php
$this->html( 'subtitle' ) ?
></div
>
95 <?php
if ( $this->data
['undelete'] ) { ?
>
96 <div id
="contentSub2"><?php
$this->html( 'undelete' ) ?
></div
>
97 <?php
} ?
><?php
if ( $this->data
['newtalk'] ) { ?
>
98 <div
class="usermessage"><?php
$this->html( 'newtalk' ) ?
></div
>
99 <?php
} ?
><?php
if ( $this->data
['showjumplinks'] ) { ?
>
100 <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
>
102 <!-- start content
-->
103 <?php
$this->html( 'bodytext' ) ?
>
104 <?php
if ( $this->data
['catlinks'] ) { $this->html( 'catlinks' ); } ?
>
106 <?php
if ( $this->data
['dataAfterContent'] ) { $this->html( 'dataAfterContent' ); } ?
>
107 <div
class="visualClear"></div
>
110 <div id
="column-one"<?php
$this->html( 'userlangattributes' ) ?
>>
111 <h2
><?php
$this->msg( 'navigation-heading' ) ?
></h2
>
112 <?php
$this->cactions(); ?
>
113 <div
class="portlet" id
="p-personal" role
="navigation">
114 <h3
><?php
$this->msg( 'personaltools' ) ?
></h3
>
116 <ul
<?php
$this->html( 'userlangattributes' ) ?
>>
117 <?php
foreach ( $this->getPersonalTools() as $key => $item ) { ?
>
118 <?php
echo $this->makeListItem( $key, $item ); ?
>
124 <div
class="portlet" id
="p-logo" role
="banner">
126 echo Html
::element( 'a', array(
127 'href' => $this->data
['nav_urls']['mainpage']['href'],
128 'style' => "background-image: url({$this->data['logopath']});" )
129 + Linker
::tooltipAndAccesskeyAttribs( 'p-logo' ) ); ?
>
133 $this->renderPortals( $this->data
['sidebar'] );
135 </div
><!-- end of the
left (by
default at least
) column
-->
136 <div
class="visualClear"></div
>
138 $validFooterIcons = $this->getFooterIcons( "icononly" );
139 $validFooterLinks = $this->getFooterLinks( "flat" ); // Additional footer links
141 if ( count( $validFooterIcons ) +
count( $validFooterLinks ) > 0 ) { ?
>
142 <div id
="footer" role
="contentinfo"<?php
$this->html( 'userlangattributes' ) ?
>>
144 $footerEnd = '</div>';
148 foreach ( $validFooterIcons as $blockName => $footerIcons ) { ?
>
149 <div id
="f-<?php echo htmlspecialchars( $blockName ); ?>ico">
150 <?php
foreach ( $footerIcons as $icon ) { ?
>
151 <?php
echo $this->getSkin()->makeFooterIcon( $icon ); ?
>
158 if ( count( $validFooterLinks ) > 0 ) {
161 foreach ( $validFooterLinks as $aLink ) { ?
>
162 <li id
="<?php echo $aLink ?>"><?php
$this->html( $aLink ) ?
></li
>
174 echo Html
::closeElement( 'body' );
175 echo Html
::closeElement( 'html' );
177 } // end of execute() method
179 /*************************************************************************************************/
182 * @param $sidebar array
184 protected function renderPortals( $sidebar ) {
185 if ( !isset( $sidebar['SEARCH'] ) ) {
186 $sidebar['SEARCH'] = true;
188 if ( !isset( $sidebar['TOOLBOX'] ) ) {
189 $sidebar['TOOLBOX'] = true;
191 if ( !isset( $sidebar['LANGUAGES'] ) ) {
192 $sidebar['LANGUAGES'] = true;
195 foreach ( $sidebar as $boxName => $content ) {
196 if ( $content === false ) {
200 if ( $boxName == 'SEARCH' ) {
202 } elseif ( $boxName == 'TOOLBOX' ) {
204 } elseif ( $boxName == 'LANGUAGES' ) {
205 $this->languageBox();
207 $this->customBox( $boxName, $content );
212 function searchBox() {
213 global $wgUseTwoButtonsSearchForm;
215 <div id
="p-search" class="portlet" role
="search">
216 <h3
><label
for="searchInput"><?php
$this->msg( 'search' ) ?
></label
></h3
>
217 <div id
="searchBody" class="pBody">
218 <form action
="<?php $this->text( 'wgScript' ) ?>" id
="searchform">
219 <input type
='hidden' name
="title" value
="<?php $this->text( 'searchtitle' ) ?>"/>
220 <?php
echo $this->makeSearchInput( array( "id" => "searchInput" ) ); ?
>
222 <?php
echo $this->makeSearchButton( "go", array( "id" => "searchGoButton", "class" => "searchButton" ) );
223 if ( $wgUseTwoButtonsSearchForm ) { ?
> 
224 <?php
echo $this->makeSearchButton( "fulltext", array( "id" => "mw-searchButton", "class" => "searchButton" ) );
227 <div
><a href
="<?php $this->text( 'searchaction' ) ?>" rel
="search"><?php
$this->msg( 'powersearch-legend' ) ?
></a
></div
><?php
237 * Prints the cactions bar.
238 * Shared between MonoBook and Modern
240 function cactions() {
242 <div id
="p-cactions" class="portlet" role
="navigation">
243 <h3
><?php
$this->msg( 'views' ) ?
></h3
>
246 foreach ( $this->data
['content_actions'] as $key => $tab ) {
248 ' . $this->makeListItem( $key, $tab );
256 /*************************************************************************************************/
259 <div
class="portlet" id
="p-tb" role
="navigation">
260 <h3
><?php
$this->msg( 'toolbox' ) ?
></h3
>
264 foreach ( $this->getToolbox() as $key => $tbitem ) { ?
>
265 <?php
echo $this->makeListItem( $key, $tbitem ); ?
>
269 wfRunHooks( 'MonoBookTemplateToolboxEnd', array( &$this ) );
270 wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this, true ) );
278 /*************************************************************************************************/
279 function languageBox() {
280 if ( $this->data
['language_urls'] ) {
282 <div id
="p-lang" class="portlet" role
="navigation">
283 <h3
<?php
$this->html( 'userlangattributes' ) ?
>><?php
$this->msg( 'otherlanguages' ) ?
></h3
>
286 <?php
foreach ( $this->data
['language_urls'] as $key => $langlink ) { ?
>
287 <?php
echo $this->makeListItem( $key, $langlink ); ?
>
297 /*************************************************************************************************/
300 * @param $cont array|string
302 function customBox( $bar, $cont ) {
303 $portletAttribs = array( 'class' => 'generated-sidebar portlet', 'id' => Sanitizer
::escapeId( "p-$bar" ), 'role' => 'navigation' );
304 $tooltip = Linker
::titleAttrib( "p-$bar" );
305 if ( $tooltip !== false ) {
306 $portletAttribs['title'] = $tooltip;
308 echo ' ' . Html
::openElement( 'div', $portletAttribs );
309 $msgObj = wfMessage( $bar );
312 <h3
><?php
echo htmlspecialchars( $msgObj->exists() ?
$msgObj->text() : $bar ); ?
></h3
>
314 <?php
if ( is_array( $cont ) ) { ?
>
316 <?php
foreach ( $cont as $key => $val ) { ?
>
317 <?php
echo $this->makeListItem( $key, $val ); ?
>
322 # allow raw HTML block to be defined by extensions