Merge "Whitelist the <wbr> element."
[mediawiki.git] / skins / MonoBook.php
blobf905587ab9fed236b141758e0a7248b5c8ebec46
1 <?php
2 /**
3 * MonoBook nouveau.
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
23 * @todo document
24 * @file
25 * @ingroup Skins
28 if ( !defined( 'MEDIAWIKI' ) ) {
29 die( -1 );
32 /**
33 * Inherit main code from SkinTemplate, set the CSS and template filter.
34 * @todo document
35 * @ingroup Skins
37 class SkinMonoBook extends SkinTemplate {
38 /** Using monobook. */
39 var $skinname = 'monobook', $stylename = 'monobook',
40 $template = 'MonoBookTemplate', $useHeadElement = true;
42 /**
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' );
57 /**
58 * @todo document
59 * @ingroup Skins
61 class MonoBookTemplate extends BaseTemplate {
63 /**
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.
69 * @access private
71 function execute() {
72 // Suppress warnings to prevent notices about missing indexes in $this->data
73 wfSuppressWarnings();
75 $this->html( 'headelement' );
76 ?><div id="globalWrapper">
77 <div id="column-content"><div id="content" class="mw-body-primary" role="main">
78 <a id="top"></a>
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>
92 <?php } ?>
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' ); } ?>
98 <!-- end content -->
99 <?php if ( $this->data['dataAfterContent'] ) { $this->html( 'dataAfterContent' ); } ?>
100 <div class="visualClear"></div>
101 </div>
102 </div></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>
108 <div class="pBody">
109 <ul<?php $this->html( 'userlangattributes' ) ?>>
110 <?php foreach ( $this->getPersonalTools() as $key => $item ) { ?>
111 <?php echo $this->makeListItem( $key, $item ); ?>
113 <?php } ?>
114 </ul>
115 </div>
116 </div>
117 <div class="portlet" id="p-logo" role="banner">
118 <?php
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' ) ); ?>
124 </div>
125 <?php
126 $this->renderPortals( $this->data['sidebar'] );
128 </div><!-- end of the left (by default at least) column -->
129 <div class="visualClear"></div>
130 <?php
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' ) ?>>
136 <?php
137 $footerEnd = '</div>';
138 } else {
139 $footerEnd = '';
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 ); ?>
146 <?php }
148 </div>
149 <?php }
151 if ( count( $validFooterLinks ) > 0 ) {
152 ?> <ul id="f-list">
153 <?php
154 foreach ( $validFooterLinks as $aLink ) { ?>
155 <li id="<?php echo $aLink ?>"><?php $this->html( $aLink ) ?></li>
156 <?php
159 </ul>
160 <?php }
161 echo $footerEnd;
164 </div>
165 <?php
166 $this->printTrail();
167 echo Html::closeElement( 'body' );
168 echo Html::closeElement( 'html' );
169 wfRestoreWarnings();
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 ) {
190 continue;
193 if ( $boxName == 'SEARCH' ) {
194 $this->searchBox();
195 } elseif ( $boxName == 'TOOLBOX' ) {
196 $this->toolbox();
197 } elseif ( $boxName == 'LANGUAGES' ) {
198 $this->languageBox();
199 } else {
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 ) { ?>&#160;
217 <?php echo $this->makeSearchButton( "fulltext", array( "id" => "mw-searchButton", "class" => "searchButton" ) );
218 } else { ?>
220 <div><a href="<?php $this->text( 'searchaction' ) ?>" rel="search"><?php $this->msg( 'powersearch-legend' ) ?></a></div><?php
221 } ?>
223 </form>
224 </div>
225 </div>
226 <?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>
237 <div class="pBody">
238 <ul><?php
239 foreach ( $this->data['content_actions'] as $key => $tab ) {
240 echo '
241 ' . $this->makeListItem( $key, $tab );
242 } ?>
244 </ul>
245 </div>
246 </div>
247 <?php
249 /*************************************************************************************************/
250 function toolbox() {
252 <div class="portlet" id="p-tb" role="navigation">
253 <h3><?php $this->msg( 'toolbox' ) ?></h3>
254 <div class="pBody">
255 <ul>
256 <?php
257 foreach ( $this->getToolbox() as $key => $tbitem ) { ?>
258 <?php echo $this->makeListItem( $key, $tbitem ); ?>
260 <?php
262 wfRunHooks( 'MonoBookTemplateToolboxEnd', array( &$this ) );
263 wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this, true ) );
265 </ul>
266 </div>
267 </div>
268 <?php
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>
277 <div class="pBody">
278 <ul>
279 <?php foreach ( $this->data['language_urls'] as $key => $langlink ) { ?>
280 <?php echo $this->makeListItem( $key, $langlink ); ?>
282 <?php } ?>
283 </ul>
284 </div>
285 </div>
286 <?php
290 /*************************************************************************************************/
292 * @param $bar string
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>
306 <div class='pBody'>
307 <?php if ( is_array( $cont ) ) { ?>
308 <ul>
309 <?php foreach ( $cont as $key => $val ) { ?>
310 <?php echo $this->makeListItem( $key, $val ); ?>
312 <?php } ?>
313 </ul>
314 <?php } else {
315 # allow raw HTML block to be defined by extensions
316 print $cont;
319 </div>
320 </div>
321 <?php
323 } // end of class