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 public $skinname = 'monobook';
40 public $stylename = 'monobook';
41 public $template = 'MonoBookTemplate';
42 public $useHeadElement = true;
45 * @param OutputPage $out
47 function setupSkinUserCss( OutputPage
$out ) {
48 parent
::setupSkinUserCss( $out );
50 $out->addModuleStyles( array( 'skins.common.interface', 'skins.monobook.styles' ) );
52 // TODO: Migrate all of these
53 $out->addStyle( 'monobook/IE60Fixes.css', 'screen', 'IE 6' );
54 $out->addStyle( 'monobook/IE70Fixes.css', 'screen', 'IE 7' );
62 class MonoBookTemplate
extends BaseTemplate
{
65 * Template filter callback for MonoBook skin.
66 * Takes an associative array of data set from a SkinTemplate-based
67 * class, and a wrapper for MediaWiki's localization database, and
68 * outputs a formatted page.
73 // Suppress warnings to prevent notices about missing indexes in $this->data
76 $this->html( 'headelement' );
77 ?
><div id
="globalWrapper">
78 <div id
="column-content">
79 <div id
="content" class="mw-body-primary" role
="main">
82 if ( $this->data
['sitenotice'] ) {
84 <div id
="siteNotice"><?php
85 $this->html( 'sitenotice' )
90 <h1 id
="firstHeading" class="firstHeading" lang
="<?php
91 $this->data['pageLanguage'] =
92 $this->getSkin()->getTitle()->getPageViewLanguage()->getHtmlCode();
93 $this->text( 'pageLanguage' );
94 ?>"><span dir
="auto"><?php
$this->html( 'title' ) ?
></span
></h1
>
96 <div id
="bodyContent" class="mw-body">
97 <div id
="siteSub"><?php
$this->msg( 'tagline' ) ?
></div
>
98 <div id
="contentSub"<?php
99 $this->html( 'userlangattributes' ) ?
>><?php
$this->html( 'subtitle' )
101 <?php
if ( $this->data
['undelete'] ) { ?
>
102 <div id
="contentSub2"><?php
$this->html( 'undelete' ) ?
></div
>
106 if ( $this->data
['newtalk'] ) {
108 <div
class="usermessage"><?php
$this->html( 'newtalk' ) ?
></div
>
112 <div id
="jump-to-nav" class="mw-jump"><?php
113 $this->msg( 'jumpto' )
114 ?
> <a href
="#column-one"><?php
115 $this->msg( 'jumptonavigation' )
117 $this->msg( 'comma-separator' )
118 ?
><a href
="#searchInput"><?php
119 $this->msg( 'jumptosearch' )
122 <!-- start content
-->
123 <?php
$this->html( 'bodytext' ) ?
>
125 if ( $this->data
['catlinks'] ) {
126 $this->html( 'catlinks' );
131 if ( $this->data
['dataAfterContent'] ) {
132 $this->html( 'dataAfterContent'
136 <div
class="visualClear"></div
>
140 <div id
="column-one"<?php
$this->html( 'userlangattributes' ) ?
>>
141 <h2
><?php
$this->msg( 'navigation-heading' ) ?
></h2
>
142 <?php
$this->cactions(); ?
>
143 <div
class="portlet" id
="p-personal" role
="navigation">
144 <h3
><?php
$this->msg( 'personaltools' ) ?
></h3
>
147 <ul
<?php
$this->html( 'userlangattributes' ) ?
>>
148 <?php
foreach ( $this->getPersonalTools() as $key => $item ) { ?
>
149 <?php
echo $this->makeListItem( $key, $item ); ?
>
157 <div
class="portlet" id
="p-logo" role
="banner">
159 echo Html
::element( 'a', array(
160 'href' => $this->data
['nav_urls']['mainpage']['href'],
161 'style' => "background-image: url({$this->data['logopath']});" )
162 + Linker
::tooltipAndAccesskeyAttribs( 'p-logo' ) ); ?
>
166 $this->renderPortals( $this->data
['sidebar'] );
168 </div
><!-- end of the
left (by
default at least
) column
-->
169 <div
class="visualClear"></div
>
171 $validFooterIcons = $this->getFooterIcons( "icononly" );
172 $validFooterLinks = $this->getFooterLinks( "flat" ); // Additional footer links
174 if ( count( $validFooterIcons ) +
count( $validFooterLinks ) > 0 ) {
176 <div id
="footer" role
="contentinfo"<?php
$this->html( 'userlangattributes' ) ?
>>
178 $footerEnd = '</div>';
183 foreach ( $validFooterIcons as $blockName => $footerIcons ) {
185 <div id
="f-<?php echo htmlspecialchars( $blockName ); ?>ico">
186 <?php
foreach ( $footerIcons as $icon ) { ?
>
187 <?php
echo $this->getSkin()->makeFooterIcon( $icon ); ?
>
196 if ( count( $validFooterLinks ) > 0 ) {
200 foreach ( $validFooterLinks as $aLink ) {
202 <li id
="<?php echo $aLink ?>"><?php
$this->html( $aLink ) ?
></li
>
216 echo Html
::closeElement( 'body' );
217 echo Html
::closeElement( 'html' );
219 } // end of execute() method
221 /*************************************************************************************************/
224 * @param array $sidebar
226 protected function renderPortals( $sidebar ) {
227 if ( !isset( $sidebar['SEARCH'] ) ) {
228 $sidebar['SEARCH'] = true;
230 if ( !isset( $sidebar['TOOLBOX'] ) ) {
231 $sidebar['TOOLBOX'] = true;
233 if ( !isset( $sidebar['LANGUAGES'] ) ) {
234 $sidebar['LANGUAGES'] = true;
237 foreach ( $sidebar as $boxName => $content ) {
238 if ( $content === false ) {
242 if ( $boxName == 'SEARCH' ) {
244 } elseif ( $boxName == 'TOOLBOX' ) {
246 } elseif ( $boxName == 'LANGUAGES' ) {
247 $this->languageBox();
249 $this->customBox( $boxName, $content );
254 function searchBox() {
255 global $wgUseTwoButtonsSearchForm;
257 <div id
="p-search" class="portlet" role
="search">
258 <h3
><label
for="searchInput"><?php
$this->msg( 'search' ) ?
></label
></h3
>
260 <div id
="searchBody" class="pBody">
261 <form action
="<?php $this->text( 'wgScript' ) ?>" id
="searchform">
262 <input type
='hidden' name
="title" value
="<?php $this->text( 'searchtitle' ) ?>"/>
263 <?php
echo $this->makeSearchInput( array( "id" => "searchInput" ) ); ?
>
266 echo $this->makeSearchButton(
268 array( "id" => "searchGoButton", "class" => "searchButton" )
271 if ( $wgUseTwoButtonsSearchForm ) {
273 <?php
echo $this->makeSearchButton(
275 array( "id" => "mw-searchButton", "class" => "searchButton" )
281 $this->text( 'searchaction' )
282 ?>" rel
="search"><?php
$this->msg( 'powersearch-legend' ) ?
></a
></div
><?php
287 <?php
$this->renderAfterPortlet( 'search' ); ?
>
294 * Prints the cactions bar.
295 * Shared between MonoBook and Modern
297 function cactions() {
299 <div id
="p-cactions" class="portlet" role
="navigation">
300 <h3
><?php
$this->msg( 'views' ) ?
></h3
>
304 foreach ( $this->data
['content_actions'] as $key => $tab ) {
306 ' . $this->makeListItem( $key, $tab );
310 <?php
$this->renderAfterPortlet( 'cactions' ); ?
>
316 /*************************************************************************************************/
319 <div
class="portlet" id
="p-tb" role
="navigation">
320 <h3
><?php
$this->msg( 'toolbox' ) ?
></h3
>
325 foreach ( $this->getToolbox() as $key => $tbitem ) {
327 <?php
echo $this->makeListItem( $key, $tbitem ); ?
>
331 wfRunHooks( 'MonoBookTemplateToolboxEnd', array( &$this ) );
332 wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this, true ) );
335 <?php
$this->renderAfterPortlet( 'tb' ); ?
>
341 /*************************************************************************************************/
342 function languageBox() {
343 if ( $this->data
['language_urls'] !== false ) {
345 <div id
="p-lang" class="portlet" role
="navigation">
346 <h3
<?php
$this->html( 'userlangattributes' ) ?
>><?php
$this->msg( 'otherlanguages' ) ?
></h3
>
350 <?php
foreach ( $this->data
['language_urls'] as $key => $langlink ) { ?
>
351 <?php
echo $this->makeListItem( $key, $langlink ); ?
>
358 <?php
$this->renderAfterPortlet( 'lang' ); ?
>
365 /*************************************************************************************************/
368 * @param array|string $cont
370 function customBox( $bar, $cont ) {
371 $portletAttribs = array(
372 'class' => 'generated-sidebar portlet',
373 'id' => Sanitizer
::escapeId( "p-$bar" ),
374 'role' => 'navigation'
377 $tooltip = Linker
::titleAttrib( "p-$bar" );
378 if ( $tooltip !== false ) {
379 $portletAttribs['title'] = $tooltip;
381 echo ' ' . Html
::openElement( 'div', $portletAttribs );
382 $msgObj = wfMessage( $bar );
385 <h3
><?php
echo htmlspecialchars( $msgObj->exists() ?
$msgObj->text() : $bar ); ?
></h3
>
388 if ( is_array( $cont ) ) {
392 foreach ( $cont as $key => $val ) {
394 <?php
echo $this->makeListItem( $key, $val ); ?
>
402 # allow raw HTML block to be defined by extensions
406 $this->renderAfterPortlet( $bar );