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 parent
::setupSkinUserCss( $out );
48 $out->addModuleStyles( 'skins.monobook' );
50 // TODO: Migrate all of these
51 $out->addStyle( 'monobook/IE60Fixes.css', 'screen', 'IE 6' );
52 $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"><div id
="content" class="mw-body-primary" role
="main">
79 <?php
if ( $this->data
['sitenotice'] ) { ?
><div id
="siteNotice"><?php
$this->html( 'sitenotice' ) ?
></div
><?php
} ?
>
81 <h1 id
="firstHeading" class="firstHeading" lang
="<?php
82 $this->data['pageLanguage'] = $this->getSkin()->getTitle()->getPageViewLanguage()->getHtmlCode();
83 $this->text( 'pageLanguage' );
84 ?>"><span dir
="auto"><?php
$this->html( 'title' ) ?
></span
></h1
>
85 <div id
="bodyContent" class="mw-body">
86 <div id
="siteSub"><?php
$this->msg( 'tagline' ) ?
></div
>
87 <div id
="contentSub"<?php
$this->html( 'userlangattributes' ) ?
>><?php
$this->html( 'subtitle' ) ?
></div
>
88 <?php
if ( $this->data
['undelete'] ) { ?
>
89 <div id
="contentSub2"><?php
$this->html( 'undelete' ) ?
></div
>
90 <?php
} ?
><?php
if ( $this->data
['newtalk'] ) { ?
>
91 <div
class="usermessage"><?php
$this->html( 'newtalk' ) ?
></div
>
93 <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
>
95 <!-- start content
-->
96 <?php
$this->html( 'bodytext' ) ?
>
97 <?php
if ( $this->data
['catlinks'] ) { $this->html( 'catlinks' ); } ?
>
99 <?php
if ( $this->data
['dataAfterContent'] ) { $this->html( 'dataAfterContent' ); } ?
>
100 <div
class="visualClear"></div
>
103 <div id
="column-one"<?php
$this->html( 'userlangattributes' ) ?
>>
104 <h2
><?php
$this->msg( 'navigation-heading' ) ?
></h2
>
105 <?php
$this->cactions(); ?
>
106 <div
class="portlet" id
="p-personal" role
="navigation">
107 <h3
><?php
$this->msg( 'personaltools' ) ?
></h3
>
109 <ul
<?php
$this->html( 'userlangattributes' ) ?
>>
110 <?php
foreach ( $this->getPersonalTools() as $key => $item ) { ?
>
111 <?php
echo $this->makeListItem( $key, $item ); ?
>
117 <div
class="portlet" id
="p-logo" role
="banner">
119 echo Html
::element( 'a', array(
120 'href' => $this->data
['nav_urls']['mainpage']['href'],
121 'style' => "background-image: url({$this->data['logopath']});" )
122 + Linker
::tooltipAndAccesskeyAttribs( 'p-logo' ) ); ?
>
126 $this->renderPortals( $this->data
['sidebar'] );
128 </div
><!-- end of the
left (by
default at least
) column
-->
129 <div
class="visualClear"></div
>
131 $validFooterIcons = $this->getFooterIcons( "icononly" );
132 $validFooterLinks = $this->getFooterLinks( "flat" ); // Additional footer links
134 if ( count( $validFooterIcons ) +
count( $validFooterLinks ) > 0 ) { ?
>
135 <div id
="footer" role
="contentinfo"<?php
$this->html( 'userlangattributes' ) ?
>>
137 $footerEnd = '</div>';
141 foreach ( $validFooterIcons as $blockName => $footerIcons ) { ?
>
142 <div id
="f-<?php echo htmlspecialchars( $blockName ); ?>ico">
143 <?php
foreach ( $footerIcons as $icon ) { ?
>
144 <?php
echo $this->getSkin()->makeFooterIcon( $icon ); ?
>
151 if ( count( $validFooterLinks ) > 0 ) {
154 foreach ( $validFooterLinks as $aLink ) { ?
>
155 <li id
="<?php echo $aLink ?>"><?php
$this->html( $aLink ) ?
></li
>
167 echo Html
::closeElement( 'body' );
168 echo Html
::closeElement( 'html' );
170 } // end of execute() method
172 /*************************************************************************************************/
175 * @param $sidebar array
177 protected function renderPortals( $sidebar ) {
178 if ( !isset( $sidebar['SEARCH'] ) ) {
179 $sidebar['SEARCH'] = true;
181 if ( !isset( $sidebar['TOOLBOX'] ) ) {
182 $sidebar['TOOLBOX'] = true;
184 if ( !isset( $sidebar['LANGUAGES'] ) ) {
185 $sidebar['LANGUAGES'] = true;
188 foreach ( $sidebar as $boxName => $content ) {
189 if ( $content === false ) {
193 if ( $boxName == 'SEARCH' ) {
195 } elseif ( $boxName == 'TOOLBOX' ) {
197 } elseif ( $boxName == 'LANGUAGES' ) {
198 $this->languageBox();
200 $this->customBox( $boxName, $content );
205 function searchBox() {
206 global $wgUseTwoButtonsSearchForm;
208 <div id
="p-search" class="portlet" role
="search">
209 <h3
><label
for="searchInput"><?php
$this->msg( 'search' ) ?
></label
></h3
>
210 <div id
="searchBody" class="pBody">
211 <form action
="<?php $this->text( 'wgScript' ) ?>" id
="searchform">
212 <input type
='hidden' name
="title" value
="<?php $this->text( 'searchtitle' ) ?>"/>
213 <?php
echo $this->makeSearchInput( array( "id" => "searchInput" ) ); ?
>
215 <?php
echo $this->makeSearchButton( "go", array( "id" => "searchGoButton", "class" => "searchButton" ) );
216 if ( $wgUseTwoButtonsSearchForm ) { ?
> 
217 <?php
echo $this->makeSearchButton( "fulltext", array( "id" => "mw-searchButton", "class" => "searchButton" ) );
220 <div
><a href
="<?php $this->text( 'searchaction' ) ?>" rel
="search"><?php
$this->msg( 'powersearch-legend' ) ?
></a
></div
><?php
230 * Prints the cactions bar.
231 * Shared between MonoBook and Modern
233 function cactions() {
235 <div id
="p-cactions" class="portlet" role
="navigation">
236 <h3
><?php
$this->msg( 'views' ) ?
></h3
>
239 foreach ( $this->data
['content_actions'] as $key => $tab ) {
241 ' . $this->makeListItem( $key, $tab );
249 /*************************************************************************************************/
252 <div
class="portlet" id
="p-tb" role
="navigation">
253 <h3
><?php
$this->msg( 'toolbox' ) ?
></h3
>
257 foreach ( $this->getToolbox() as $key => $tbitem ) { ?
>
258 <?php
echo $this->makeListItem( $key, $tbitem ); ?
>
262 wfRunHooks( 'MonoBookTemplateToolboxEnd', array( &$this ) );
263 wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this, true ) );
271 /*************************************************************************************************/
272 function languageBox() {
273 if ( $this->data
['language_urls'] ) {
275 <div id
="p-lang" class="portlet" role
="navigation">
276 <h3
<?php
$this->html( 'userlangattributes' ) ?
>><?php
$this->msg( 'otherlanguages' ) ?
></h3
>
279 <?php
foreach ( $this->data
['language_urls'] as $key => $langlink ) { ?
>
280 <?php
echo $this->makeListItem( $key, $langlink ); ?
>
290 /*************************************************************************************************/
293 * @param $cont array|string
295 function customBox( $bar, $cont ) {
296 $portletAttribs = array( 'class' => 'generated-sidebar portlet', 'id' => Sanitizer
::escapeId( "p-$bar" ), 'role' => 'navigation' );
297 $tooltip = Linker
::titleAttrib( "p-$bar" );
298 if ( $tooltip !== false ) {
299 $portletAttribs['title'] = $tooltip;
301 echo ' ' . Html
::openElement( 'div', $portletAttribs );
302 $msgObj = wfMessage( $bar );
305 <h3
><?php
echo htmlspecialchars( $msgObj->exists() ?
$msgObj->text() : $bar ); ?
></h3
>
307 <?php
if ( is_array( $cont ) ) { ?
>
309 <?php
foreach ( $cont as $key => $val ) { ?
>
310 <?php
echo $this->makeListItem( $key, $val ); ?
>
315 # allow raw HTML block to be defined by extensions