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
30 class MonoBookTemplate
extends BaseTemplate
{
33 * Template filter callback for MonoBook skin.
34 * Takes an associative array of data set from a SkinTemplate-based
35 * class, and a wrapper for MediaWiki's localization database, and
36 * outputs a formatted page.
41 // Suppress warnings to prevent notices about missing indexes in $this->data
44 $this->html( 'headelement' );
45 ?
><div id
="globalWrapper">
46 <div id
="column-content">
47 <div id
="content" class="mw-body-primary" role
="main">
50 if ( $this->data
['sitenotice'] ) {
52 <div id
="siteNotice"><?php
53 $this->html( 'sitenotice' )
58 <h1 id
="firstHeading" class="firstHeading" lang
="<?php
59 $this->data['pageLanguage'] =
60 $this->getSkin()->getTitle()->getPageViewLanguage()->getHtmlCode();
61 $this->text( 'pageLanguage' );
62 ?>"><span dir
="auto"><?php
$this->html( 'title' ) ?
></span
></h1
>
64 <div id
="bodyContent" class="mw-body">
65 <div id
="siteSub"><?php
$this->msg( 'tagline' ) ?
></div
>
66 <div id
="contentSub"<?php
67 $this->html( 'userlangattributes' ) ?
>><?php
$this->html( 'subtitle' )
69 <?php
if ( $this->data
['undelete'] ) { ?
>
70 <div id
="contentSub2"><?php
$this->html( 'undelete' ) ?
></div
>
74 if ( $this->data
['newtalk'] ) {
76 <div
class="usermessage"><?php
$this->html( 'newtalk' ) ?
></div
>
80 <div id
="jump-to-nav" class="mw-jump"><?php
81 $this->msg( 'jumpto' )
82 ?
> <a href
="#column-one"><?php
83 $this->msg( 'jumptonavigation' )
85 $this->msg( 'comma-separator' )
86 ?
><a href
="#searchInput"><?php
87 $this->msg( 'jumptosearch' )
90 <!-- start content
-->
91 <?php
$this->html( 'bodytext' ) ?
>
93 if ( $this->data
['catlinks'] ) {
94 $this->html( 'catlinks' );
99 if ( $this->data
['dataAfterContent'] ) {
100 $this->html( 'dataAfterContent'
104 <div
class="visualClear"></div
>
108 <div id
="column-one"<?php
$this->html( 'userlangattributes' ) ?
>>
109 <h2
><?php
$this->msg( 'navigation-heading' ) ?
></h2
>
110 <?php
$this->cactions(); ?
>
111 <div
class="portlet" id
="p-personal" role
="navigation">
112 <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 ); ?
>
125 <div
class="portlet" id
="p-logo" role
="banner">
127 echo Html
::element( 'a', array(
128 'href' => $this->data
['nav_urls']['mainpage']['href'],
129 'style' => "background-image: url({$this->data['logopath']});" )
130 + Linker
::tooltipAndAccesskeyAttribs( 'p-logo' ) ); ?
>
134 $this->renderPortals( $this->data
['sidebar'] );
136 </div
><!-- end of the
left (by
default at least
) column
-->
137 <div
class="visualClear"></div
>
139 $validFooterIcons = $this->getFooterIcons( "icononly" );
140 $validFooterLinks = $this->getFooterLinks( "flat" ); // Additional footer links
142 if ( count( $validFooterIcons ) +
count( $validFooterLinks ) > 0 ) {
144 <div id
="footer" role
="contentinfo"<?php
$this->html( 'userlangattributes' ) ?
>>
146 $footerEnd = '</div>';
151 foreach ( $validFooterIcons as $blockName => $footerIcons ) {
153 <div id
="f-<?php echo htmlspecialchars( $blockName ); ?>ico">
154 <?php
foreach ( $footerIcons as $icon ) { ?
>
155 <?php
echo $this->getSkin()->makeFooterIcon( $icon ); ?
>
164 if ( count( $validFooterLinks ) > 0 ) {
168 foreach ( $validFooterLinks as $aLink ) {
170 <li id
="<?php echo $aLink ?>"><?php
$this->html( $aLink ) ?
></li
>
184 echo Html
::closeElement( 'body' );
185 echo Html
::closeElement( 'html' );
187 } // end of execute() method
189 /*************************************************************************************************/
192 * @param array $sidebar
194 protected function renderPortals( $sidebar ) {
195 if ( !isset( $sidebar['SEARCH'] ) ) {
196 $sidebar['SEARCH'] = true;
198 if ( !isset( $sidebar['TOOLBOX'] ) ) {
199 $sidebar['TOOLBOX'] = true;
201 if ( !isset( $sidebar['LANGUAGES'] ) ) {
202 $sidebar['LANGUAGES'] = true;
205 foreach ( $sidebar as $boxName => $content ) {
206 if ( $content === false ) {
210 if ( $boxName == 'SEARCH' ) {
212 } elseif ( $boxName == 'TOOLBOX' ) {
214 } elseif ( $boxName == 'LANGUAGES' ) {
215 $this->languageBox();
217 $this->customBox( $boxName, $content );
222 function searchBox() {
223 global $wgUseTwoButtonsSearchForm;
225 <div id
="p-search" class="portlet" role
="search">
226 <h3
><label
for="searchInput"><?php
$this->msg( 'search' ) ?
></label
></h3
>
228 <div id
="searchBody" class="pBody">
229 <form action
="<?php $this->text( 'wgScript' ) ?>" id
="searchform">
230 <input type
='hidden' name
="title" value
="<?php $this->text( 'searchtitle' ) ?>"/>
231 <?php
echo $this->makeSearchInput( array( "id" => "searchInput" ) ); ?
>
234 echo $this->makeSearchButton(
236 array( "id" => "searchGoButton", "class" => "searchButton" )
239 if ( $wgUseTwoButtonsSearchForm ) {
241 <?php
echo $this->makeSearchButton(
243 array( "id" => "mw-searchButton", "class" => "searchButton" )
249 $this->text( 'searchaction' )
250 ?>" rel
="search"><?php
$this->msg( 'powersearch-legend' ) ?
></a
></div
><?php
255 <?php
$this->renderAfterPortlet( 'search' ); ?
>
262 * Prints the cactions bar.
263 * Shared between MonoBook and Modern
265 function cactions() {
267 <div id
="p-cactions" class="portlet" role
="navigation">
268 <h3
><?php
$this->msg( 'views' ) ?
></h3
>
272 foreach ( $this->data
['content_actions'] as $key => $tab ) {
274 ' . $this->makeListItem( $key, $tab );
278 <?php
$this->renderAfterPortlet( 'cactions' ); ?
>
284 /*************************************************************************************************/
287 <div
class="portlet" id
="p-tb" role
="navigation">
288 <h3
><?php
$this->msg( 'toolbox' ) ?
></h3
>
293 foreach ( $this->getToolbox() as $key => $tbitem ) {
295 <?php
echo $this->makeListItem( $key, $tbitem ); ?
>
299 wfRunHooks( 'MonoBookTemplateToolboxEnd', array( &$this ) );
300 wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this, true ) );
303 <?php
$this->renderAfterPortlet( 'tb' ); ?
>
309 /*************************************************************************************************/
310 function languageBox() {
311 if ( $this->data
['language_urls'] !== false ) {
313 <div id
="p-lang" class="portlet" role
="navigation">
314 <h3
<?php
$this->html( 'userlangattributes' ) ?
>><?php
$this->msg( 'otherlanguages' ) ?
></h3
>
318 <?php
foreach ( $this->data
['language_urls'] as $key => $langlink ) { ?
>
319 <?php
echo $this->makeListItem( $key, $langlink ); ?
>
326 <?php
$this->renderAfterPortlet( 'lang' ); ?
>
333 /*************************************************************************************************/
336 * @param array|string $cont
338 function customBox( $bar, $cont ) {
339 $portletAttribs = array(
340 'class' => 'generated-sidebar portlet',
341 'id' => Sanitizer
::escapeId( "p-$bar" ),
342 'role' => 'navigation'
345 $tooltip = Linker
::titleAttrib( "p-$bar" );
346 if ( $tooltip !== false ) {
347 $portletAttribs['title'] = $tooltip;
349 echo ' ' . Html
::openElement( 'div', $portletAttribs );
350 $msgObj = wfMessage( $bar );
353 <h3
><?php
echo htmlspecialchars( $msgObj->exists() ?
$msgObj->text() : $bar ); ?
></h3
>
356 if ( is_array( $cont ) ) {
360 foreach ( $cont as $key => $val ) {
362 <?php
echo $this->makeListItem( $key, $val ); ?
>
370 # allow raw HTML block to be defined by extensions
374 $this->renderAfterPortlet( $bar );