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.
38 public function execute() {
39 $this->html( 'headelement' );
40 ?><div id="globalWrapper">
41 <div id="column-content">
42 <div id="content" class="mw-body" role="main">
45 if ( $this->data['sitenotice'] ) {
47 <div id="siteNotice" class="mw-body-content"><?php
48 $this->html( 'sitenotice' )
54 echo $this->getIndicators();
55 // Loose comparison with '!=' is intentional, to catch null and false too, but not '0'
56 if ( $this->data['title'] != '' ) {
58 <h1 id="firstHeading" class="firstHeading" lang="<?php
59 $this->data['pageLanguage'] =
60 $this->getSkin()->getTitle()->getPageViewLanguage()->getHtmlCode();
61 $this->text( 'pageLanguage' );
62 ?>"><?php $this->html( 'title' ) ?></h1>
67 <div id="bodyContent" class="mw-body-content">
68 <div id="siteSub"><?php $this->msg( 'tagline' ) ?></div>
69 <div id="contentSub"<?php
70 $this->html( 'userlangattributes' ) ?>><?php $this->html( 'subtitle' )
72 <?php if ( $this->data['undelete'] ) { ?>
73 <div id="contentSub2"><?php $this->html( 'undelete' ) ?></div>
77 if ( $this->data['newtalk'] ) {
79 <div class="usermessage"><?php $this->html( 'newtalk' ) ?></div>
83 <div id="jump-to-nav" class="mw-jump"><?php
84 $this->msg( 'jumpto' )
85 ?> <a href="#column-one"><?php
86 $this->msg( 'jumptonavigation' )
88 $this->msg( 'comma-separator' )
89 ?><a href="#searchInput"><?php
90 $this->msg( 'jumptosearch' )
93 <!-- start content -->
94 <?php $this->html( 'bodytext' ) ?>
96 if ( $this->data['catlinks'] ) {
97 $this->html( 'catlinks' );
102 if ( $this->data['dataAfterContent'] ) {
103 $this->html( 'dataAfterContent' );
106 <div class="visualClear"></div>
109 <?php Hooks::run( 'MonoBookAfterContent' ); ?>
111 <div id="column-one"<?php $this->html( 'userlangattributes' ) ?>>
112 <h2><?php $this->msg( 'navigation-heading' ) ?></h2>
113 <?php $this->cactions(); ?>
114 <div class="portlet" id="p-personal" role="navigation">
115 <h3><?php $this->msg( 'personaltools' ) ?></h3>
118 <ul<?php $this->html( 'userlangattributes' ) ?>>
120 $personalTools = $this->getPersonalTools();
122 if ( array_key_exists( 'uls', $personalTools ) ) {
123 echo $this->makeListItem( 'uls', $personalTools['uls'] );
124 unset( $personalTools['uls'] );
127 if ( !$this->getSkin()->getUser()->isLoggedIn() &&
128 User::groupHasPermission( '*', 'edit' )
130 echo Html::rawElement( 'li', [
131 'id' => 'pt-anonuserpage'
132 ], $this->getMsg( 'notloggedin' )->escaped() );
135 foreach ( $personalTools as $key => $item ) { ?>
136 <?php echo $this->makeListItem( $key, $item ); ?>
144 <div class="portlet" id="p-logo" role="banner">
146 echo Html::element( 'a', [
147 'href' => $this->data['nav_urls']['mainpage']['href'],
148 'class' => 'mw-wiki-logo',
150 + Linker::tooltipAndAccesskeyAttribs( 'p-logo' )
155 $this->renderPortals( $this->data['sidebar'] );
157 </div><!-- end of the left (by default at least) column -->
158 <div class="visualClear"></div>
160 $validFooterIcons = $this->getFooterIcons( 'icononly' );
161 // Additional footer links
162 $validFooterLinks = $this->getFooterLinks( 'flat' );
164 if ( count( $validFooterIcons ) + count( $validFooterLinks ) > 0 ) {
166 <div id="footer" role="contentinfo"<?php $this->html( 'userlangattributes' ) ?>>
168 $footerEnd = '</div>';
173 foreach ( $validFooterIcons as $blockName => $footerIcons ) {
175 <div id="f-<?php echo htmlspecialchars( $blockName ); ?>ico">
176 <?php foreach ( $footerIcons as $icon ) { ?>
177 <?php echo $this->getSkin()->makeFooterIcon( $icon ); ?>
186 if ( count( $validFooterLinks ) > 0 ) {
190 foreach ( $validFooterLinks as $aLink ) {
192 <li id="<?php echo $aLink ?>"><?php $this->html( $aLink ) ?></li>
206 echo Html::closeElement( 'body' );
207 echo Html::closeElement( 'html' );
212 * @param array $sidebar
214 protected function renderPortals( $sidebar ) {
215 if ( !isset( $sidebar['SEARCH'] ) ) {
216 $sidebar['SEARCH'] = true;
218 if ( !isset( $sidebar['TOOLBOX'] ) ) {
219 $sidebar['TOOLBOX'] = true;
221 if ( !isset( $sidebar['LANGUAGES'] ) ) {
222 $sidebar['LANGUAGES'] = true;
225 foreach ( $sidebar as $boxName => $content ) {
226 if ( $content === false ) {
230 // Numeric strings gets an integer when set as key, cast back - T73639
231 $boxName = (string)$boxName;
233 if ( $boxName == 'SEARCH' ) {
235 } elseif ( $boxName == 'TOOLBOX' ) {
237 } elseif ( $boxName == 'LANGUAGES' ) {
238 $this->languageBox();
240 $this->customBox( $boxName, $content );
245 function searchBox() {
247 <div id="p-search" class="portlet" role="search">
248 <h3><label for="searchInput"><?php $this->msg( 'search' ) ?></label></h3>
250 <div id="searchBody" class="pBody">
251 <form action="<?php $this->text( 'wgScript' ) ?>" id="searchform">
252 <input type="hidden" name="title" value="<?php $this->text( 'searchtitle' ) ?>"/>
253 <?php echo $this->makeSearchInput( [ 'id' => 'searchInput' ] ); ?>
256 echo $this->makeSearchButton(
258 [ 'id' => 'searchGoButton', 'class' => 'searchButton' ]
261 if ( $this->config->get( 'UseTwoButtonsSearchForm' ) ) {
263 <?php echo $this->makeSearchButton(
265 [ 'id' => 'mw-searchButton', 'class' => 'searchButton' ]
271 $this->text( 'searchaction' )
272 ?>" rel="search"><?php $this->msg( 'powersearch-legend' ) ?></a></div><?php
277 <?php $this->renderAfterPortlet( 'search' ); ?>
284 * Prints the content actions (cactions) bar.
285 * Shared between MonoBook and Modern
287 function cactions() {
289 <div id="p-cactions" class="portlet" role="navigation">
290 <h3><?php $this->msg( 'views' ) ?></h3>
294 foreach ( $this->data['content_actions'] as $key => $tab ) {
296 ' . $this->makeListItem( $key, $tab );
300 <?php $this->renderAfterPortlet( 'cactions' ); ?>
308 <div class="portlet" id="p-tb" role="navigation">
309 <h3><?php $this->msg( 'toolbox' ) ?></h3>
314 foreach ( $this->getToolbox() as $key => $tbitem ) {
316 <?php echo $this->makeListItem( $key, $tbitem ); ?>
320 // Avoid PHP 7.1 warnings
322 Hooks::run( 'MonoBookTemplateToolboxEnd', [ &$skin ] );
323 Hooks::run( 'SkinTemplateToolboxEnd', [ &$skin, true ] );
326 <?php $this->renderAfterPortlet( 'tb' ); ?>
330 Hooks::run( 'MonoBookAfterToolbox' );
333 function languageBox() {
334 if ( $this->data['language_urls'] !== false ) {
336 <div id="p-lang" class="portlet" role="navigation">
337 <h3<?php $this->html( 'userlangattributes' ) ?>><?php $this->msg( 'otherlanguages' ) ?></h3>
341 <?php foreach ( $this->data['language_urls'] as $key => $langLink ) { ?>
342 <?php echo $this->makeListItem( $key, $langLink ); ?>
349 <?php $this->renderAfterPortlet( 'lang' ); ?>
358 * @param array|string $cont
360 function customBox( $bar, $cont ) {
362 'class' => 'generated-sidebar portlet',
363 'id' => Sanitizer::escapeId( "p-$bar" ),
364 'role' => 'navigation'
367 $tooltip = Linker::titleAttrib( "p-$bar" );
368 if ( $tooltip !== false ) {
369 $portletAttribs['title'] = $tooltip;
371 echo ' ' . Html::openElement( 'div', $portletAttribs );
372 $msgObj = wfMessage( $bar );
375 <h3><?php echo htmlspecialchars( $msgObj->exists() ? $msgObj->text() : $bar ); ?></h3>
378 if ( is_array( $cont ) ) {
382 foreach ( $cont as $key => $val ) {
384 <?php echo $this->makeListItem( $key, $val ); ?>
392 # allow raw HTML block to be defined by extensions
396 $this->renderAfterPortlet( $bar );