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';
44 * @param OutputPage $out
46 function setupSkinUserCss( OutputPage
$out ) {
47 parent
::setupSkinUserCss( $out );
49 $out->addModuleStyles( array( 'mediawiki.skinning.interface', 'skins.monobook.styles' ) );
51 // TODO: Migrate all of these
52 $out->addStyle( 'monobook/IE60Fixes.css', 'screen', 'IE 6' );
53 $out->addStyle( 'monobook/IE70Fixes.css', 'screen', 'IE 7' );
61 class MonoBookTemplate
extends BaseTemplate
{
64 * Template filter callback for MonoBook skin.
65 * Takes an associative array of data set from a SkinTemplate-based
66 * class, and a wrapper for MediaWiki's localization database, and
67 * outputs a formatted page.
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">
78 <div id
="content" class="mw-body-primary" role
="main">
81 if ( $this->data
['sitenotice'] ) {
83 <div id
="siteNotice"><?php
84 $this->html( 'sitenotice' )
89 <h1 id
="firstHeading" class="firstHeading" lang
="<?php
90 $this->data['pageLanguage'] =
91 $this->getSkin()->getTitle()->getPageViewLanguage()->getHtmlCode();
92 $this->text( 'pageLanguage' );
93 ?>"><span dir
="auto"><?php
$this->html( 'title' ) ?
></span
></h1
>
95 <div id
="bodyContent" class="mw-body">
96 <div id
="siteSub"><?php
$this->msg( 'tagline' ) ?
></div
>
97 <div id
="contentSub"<?php
98 $this->html( 'userlangattributes' ) ?
>><?php
$this->html( 'subtitle' )
100 <?php
if ( $this->data
['undelete'] ) { ?
>
101 <div id
="contentSub2"><?php
$this->html( 'undelete' ) ?
></div
>
105 if ( $this->data
['newtalk'] ) {
107 <div
class="usermessage"><?php
$this->html( 'newtalk' ) ?
></div
>
111 <div id
="jump-to-nav" class="mw-jump"><?php
112 $this->msg( 'jumpto' )
113 ?
> <a href
="#column-one"><?php
114 $this->msg( 'jumptonavigation' )
116 $this->msg( 'comma-separator' )
117 ?
><a href
="#searchInput"><?php
118 $this->msg( 'jumptosearch' )
121 <!-- start content
-->
122 <?php
$this->html( 'bodytext' ) ?
>
124 if ( $this->data
['catlinks'] ) {
125 $this->html( 'catlinks' );
130 if ( $this->data
['dataAfterContent'] ) {
131 $this->html( 'dataAfterContent'
135 <div
class="visualClear"></div
>
139 <div id
="column-one"<?php
$this->html( 'userlangattributes' ) ?
>>
140 <h2
><?php
$this->msg( 'navigation-heading' ) ?
></h2
>
141 <?php
$this->cactions(); ?
>
142 <div
class="portlet" id
="p-personal" role
="navigation">
143 <h3
><?php
$this->msg( 'personaltools' ) ?
></h3
>
146 <ul
<?php
$this->html( 'userlangattributes' ) ?
>>
147 <?php
foreach ( $this->getPersonalTools() as $key => $item ) { ?
>
148 <?php
echo $this->makeListItem( $key, $item ); ?
>
156 <div
class="portlet" id
="p-logo" role
="banner">
158 echo Html
::element( 'a', array(
159 'href' => $this->data
['nav_urls']['mainpage']['href'],
160 'style' => "background-image: url({$this->data['logopath']});" )
161 + Linker
::tooltipAndAccesskeyAttribs( 'p-logo' ) ); ?
>
165 $this->renderPortals( $this->data
['sidebar'] );
167 </div
><!-- end of the
left (by
default at least
) column
-->
168 <div
class="visualClear"></div
>
170 $validFooterIcons = $this->getFooterIcons( "icononly" );
171 $validFooterLinks = $this->getFooterLinks( "flat" ); // Additional footer links
173 if ( count( $validFooterIcons ) +
count( $validFooterLinks ) > 0 ) {
175 <div id
="footer" role
="contentinfo"<?php
$this->html( 'userlangattributes' ) ?
>>
177 $footerEnd = '</div>';
182 foreach ( $validFooterIcons as $blockName => $footerIcons ) {
184 <div id
="f-<?php echo htmlspecialchars( $blockName ); ?>ico">
185 <?php
foreach ( $footerIcons as $icon ) { ?
>
186 <?php
echo $this->getSkin()->makeFooterIcon( $icon ); ?
>
195 if ( count( $validFooterLinks ) > 0 ) {
199 foreach ( $validFooterLinks as $aLink ) {
201 <li id
="<?php echo $aLink ?>"><?php
$this->html( $aLink ) ?
></li
>
215 echo Html
::closeElement( 'body' );
216 echo Html
::closeElement( 'html' );
218 } // end of execute() method
220 /*************************************************************************************************/
223 * @param array $sidebar
225 protected function renderPortals( $sidebar ) {
226 if ( !isset( $sidebar['SEARCH'] ) ) {
227 $sidebar['SEARCH'] = true;
229 if ( !isset( $sidebar['TOOLBOX'] ) ) {
230 $sidebar['TOOLBOX'] = true;
232 if ( !isset( $sidebar['LANGUAGES'] ) ) {
233 $sidebar['LANGUAGES'] = true;
236 foreach ( $sidebar as $boxName => $content ) {
237 if ( $content === false ) {
241 if ( $boxName == 'SEARCH' ) {
243 } elseif ( $boxName == 'TOOLBOX' ) {
245 } elseif ( $boxName == 'LANGUAGES' ) {
246 $this->languageBox();
248 $this->customBox( $boxName, $content );
253 function searchBox() {
254 global $wgUseTwoButtonsSearchForm;
256 <div id
="p-search" class="portlet" role
="search">
257 <h3
><label
for="searchInput"><?php
$this->msg( 'search' ) ?
></label
></h3
>
259 <div id
="searchBody" class="pBody">
260 <form action
="<?php $this->text( 'wgScript' ) ?>" id
="searchform">
261 <input type
='hidden' name
="title" value
="<?php $this->text( 'searchtitle' ) ?>"/>
262 <?php
echo $this->makeSearchInput( array( "id" => "searchInput" ) ); ?
>
265 echo $this->makeSearchButton(
267 array( "id" => "searchGoButton", "class" => "searchButton" )
270 if ( $wgUseTwoButtonsSearchForm ) {
272 <?php
echo $this->makeSearchButton(
274 array( "id" => "mw-searchButton", "class" => "searchButton" )
280 $this->text( 'searchaction' )
281 ?>" rel
="search"><?php
$this->msg( 'powersearch-legend' ) ?
></a
></div
><?php
286 <?php
$this->renderAfterPortlet( 'search' ); ?
>
293 * Prints the cactions bar.
294 * Shared between MonoBook and Modern
296 function cactions() {
298 <div id
="p-cactions" class="portlet" role
="navigation">
299 <h3
><?php
$this->msg( 'views' ) ?
></h3
>
303 foreach ( $this->data
['content_actions'] as $key => $tab ) {
305 ' . $this->makeListItem( $key, $tab );
309 <?php
$this->renderAfterPortlet( 'cactions' ); ?
>
315 /*************************************************************************************************/
318 <div
class="portlet" id
="p-tb" role
="navigation">
319 <h3
><?php
$this->msg( 'toolbox' ) ?
></h3
>
324 foreach ( $this->getToolbox() as $key => $tbitem ) {
326 <?php
echo $this->makeListItem( $key, $tbitem ); ?
>
330 wfRunHooks( 'MonoBookTemplateToolboxEnd', array( &$this ) );
331 wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this, true ) );
334 <?php
$this->renderAfterPortlet( 'tb' ); ?
>
340 /*************************************************************************************************/
341 function languageBox() {
342 if ( $this->data
['language_urls'] !== false ) {
344 <div id
="p-lang" class="portlet" role
="navigation">
345 <h3
<?php
$this->html( 'userlangattributes' ) ?
>><?php
$this->msg( 'otherlanguages' ) ?
></h3
>
349 <?php
foreach ( $this->data
['language_urls'] as $key => $langlink ) { ?
>
350 <?php
echo $this->makeListItem( $key, $langlink ); ?
>
357 <?php
$this->renderAfterPortlet( 'lang' ); ?
>
364 /*************************************************************************************************/
367 * @param array|string $cont
369 function customBox( $bar, $cont ) {
370 $portletAttribs = array(
371 'class' => 'generated-sidebar portlet',
372 'id' => Sanitizer
::escapeId( "p-$bar" ),
373 'role' => 'navigation'
376 $tooltip = Linker
::titleAttrib( "p-$bar" );
377 if ( $tooltip !== false ) {
378 $portletAttribs['title'] = $tooltip;
380 echo ' ' . Html
::openElement( 'div', $portletAttribs );
381 $msgObj = wfMessage( $bar );
384 <h3
><?php
echo htmlspecialchars( $msgObj->exists() ?
$msgObj->text() : $bar ); ?
></h3
>
387 if ( is_array( $cont ) ) {
391 foreach ( $cont as $key => $val ) {
393 <?php
echo $this->makeListItem( $key, $val ); ?
>
401 # allow raw HTML block to be defined by extensions
405 $this->renderAfterPortlet( $bar );