Localisation updates from http://translatewiki.net.
[mediawiki.git] / skins / MonoBook.php
blobaeeb0f809127932017ec287a3802431dffc125bd
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 global $wgHandheldStyle;
47 parent::setupSkinUserCss( $out );
49 $out->addModuleStyles( 'skins.monobook' );
51 // Ugh. Can't do this properly because $wgHandheldStyle may be a URL
52 if ( $wgHandheldStyle ) {
53 // Currently in testing... try 'chick/main.css'
54 $out->addStyle( $wgHandheldStyle, 'handheld' );
57 // TODO: Migrate all of these
58 $out->addStyle( 'monobook/IE60Fixes.css', 'screen', 'IE 6' );
59 $out->addStyle( 'monobook/IE70Fixes.css', 'screen', 'IE 7' );
64 /**
65 * @todo document
66 * @ingroup Skins
68 class MonoBookTemplate extends BaseTemplate {
70 /**
71 * Template filter callback for MonoBook skin.
72 * Takes an associative array of data set from a SkinTemplate-based
73 * class, and a wrapper for MediaWiki's localization database, and
74 * outputs a formatted page.
76 * @access private
78 function execute() {
79 // Suppress warnings to prevent notices about missing indexes in $this->data
80 wfSuppressWarnings();
82 $this->html( 'headelement' );
83 ?><div id="globalWrapper">
84 <div id="column-content"><div id="content" class="mw-body-primary" role="main">
85 <a id="top"></a>
86 <?php if ( $this->data['sitenotice'] ) { ?><div id="siteNotice"><?php $this->html( 'sitenotice' ) ?></div><?php } ?>
88 <h1 id="firstHeading" class="firstHeading" lang="<?php
89 $this->data['pageLanguage'] = $this->getSkin()->getTitle()->getPageViewLanguage()->getCode();
90 $this->html( 'pageLanguage' );
91 ?>"><span dir="auto"><?php $this->html( 'title' ) ?></span></h1>
92 <div id="bodyContent" class="mw-body">
93 <div id="siteSub"><?php $this->msg( 'tagline' ) ?></div>
94 <div id="contentSub"<?php $this->html( 'userlangattributes' ) ?>><?php $this->html( 'subtitle' ) ?></div>
95 <?php if ( $this->data['undelete'] ) { ?>
96 <div id="contentSub2"><?php $this->html( 'undelete' ) ?></div>
97 <?php } ?><?php if ( $this->data['newtalk'] ) { ?>
98 <div class="usermessage"><?php $this->html( 'newtalk' ) ?></div>
99 <?php } ?><?php if ( $this->data['showjumplinks'] ) { ?>
100 <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>
101 <?php } ?>
102 <!-- start content -->
103 <?php $this->html( 'bodytext' ) ?>
104 <?php if ( $this->data['catlinks'] ) { $this->html( 'catlinks' ); } ?>
105 <!-- end content -->
106 <?php if ( $this->data['dataAfterContent'] ) { $this->html( 'dataAfterContent' ); } ?>
107 <div class="visualClear"></div>
108 </div>
109 </div></div>
110 <div id="column-one"<?php $this->html( 'userlangattributes' ) ?>>
111 <h2><?php $this->msg( 'navigation-heading' ) ?></h2>
112 <?php $this->cactions(); ?>
113 <div class="portlet" id="p-personal" role="navigation">
114 <h3><?php $this->msg( 'personaltools' ) ?></h3>
115 <div class="pBody">
116 <ul<?php $this->html( 'userlangattributes' ) ?>>
117 <?php foreach ( $this->getPersonalTools() as $key => $item ) { ?>
118 <?php echo $this->makeListItem( $key, $item ); ?>
120 <?php } ?>
121 </ul>
122 </div>
123 </div>
124 <div class="portlet" id="p-logo" role="banner">
125 <?php
126 echo Html::element( 'a', array(
127 'href' => $this->data['nav_urls']['mainpage']['href'],
128 'style' => "background-image: url({$this->data['logopath']});" )
129 + Linker::tooltipAndAccesskeyAttribs( 'p-logo' ) ); ?>
131 </div>
132 <?php
133 $this->renderPortals( $this->data['sidebar'] );
135 </div><!-- end of the left (by default at least) column -->
136 <div class="visualClear"></div>
137 <?php
138 $validFooterIcons = $this->getFooterIcons( "icononly" );
139 $validFooterLinks = $this->getFooterLinks( "flat" ); // Additional footer links
141 if ( count( $validFooterIcons ) + count( $validFooterLinks ) > 0 ) { ?>
142 <div id="footer" role="contentinfo"<?php $this->html( 'userlangattributes' ) ?>>
143 <?php
144 $footerEnd = '</div>';
145 } else {
146 $footerEnd = '';
148 foreach ( $validFooterIcons as $blockName => $footerIcons ) { ?>
149 <div id="f-<?php echo htmlspecialchars( $blockName ); ?>ico">
150 <?php foreach ( $footerIcons as $icon ) { ?>
151 <?php echo $this->getSkin()->makeFooterIcon( $icon ); ?>
153 <?php }
155 </div>
156 <?php }
158 if ( count( $validFooterLinks ) > 0 ) {
159 ?> <ul id="f-list">
160 <?php
161 foreach ( $validFooterLinks as $aLink ) { ?>
162 <li id="<?php echo $aLink ?>"><?php $this->html( $aLink ) ?></li>
163 <?php
166 </ul>
167 <?php }
168 echo $footerEnd;
171 </div>
172 <?php
173 $this->printTrail();
174 echo Html::closeElement( 'body' );
175 echo Html::closeElement( 'html' );
176 wfRestoreWarnings();
177 } // end of execute() method
179 /*************************************************************************************************/
182 * @param $sidebar array
184 protected function renderPortals( $sidebar ) {
185 if ( !isset( $sidebar['SEARCH'] ) ) {
186 $sidebar['SEARCH'] = true;
188 if ( !isset( $sidebar['TOOLBOX'] ) ) {
189 $sidebar['TOOLBOX'] = true;
191 if ( !isset( $sidebar['LANGUAGES'] ) ) {
192 $sidebar['LANGUAGES'] = true;
195 foreach ( $sidebar as $boxName => $content ) {
196 if ( $content === false ) {
197 continue;
200 if ( $boxName == 'SEARCH' ) {
201 $this->searchBox();
202 } elseif ( $boxName == 'TOOLBOX' ) {
203 $this->toolbox();
204 } elseif ( $boxName == 'LANGUAGES' ) {
205 $this->languageBox();
206 } else {
207 $this->customBox( $boxName, $content );
212 function searchBox() {
213 global $wgUseTwoButtonsSearchForm;
215 <div id="p-search" class="portlet" role="search">
216 <h3><label for="searchInput"><?php $this->msg( 'search' ) ?></label></h3>
217 <div id="searchBody" class="pBody">
218 <form action="<?php $this->text( 'wgScript' ) ?>" id="searchform">
219 <input type='hidden' name="title" value="<?php $this->text( 'searchtitle' ) ?>"/>
220 <?php echo $this->makeSearchInput( array( "id" => "searchInput" ) ); ?>
222 <?php echo $this->makeSearchButton( "go", array( "id" => "searchGoButton", "class" => "searchButton" ) );
223 if ( $wgUseTwoButtonsSearchForm ) { ?>&#160;
224 <?php echo $this->makeSearchButton( "fulltext", array( "id" => "mw-searchButton", "class" => "searchButton" ) );
225 } else { ?>
227 <div><a href="<?php $this->text( 'searchaction' ) ?>" rel="search"><?php $this->msg( 'powersearch-legend' ) ?></a></div><?php
228 } ?>
230 </form>
231 </div>
232 </div>
233 <?php
237 * Prints the cactions bar.
238 * Shared between MonoBook and Modern
240 function cactions() {
242 <div id="p-cactions" class="portlet" role="navigation">
243 <h3><?php $this->msg( 'views' ) ?></h3>
244 <div class="pBody">
245 <ul><?php
246 foreach ( $this->data['content_actions'] as $key => $tab ) {
247 echo '
248 ' . $this->makeListItem( $key, $tab );
249 } ?>
251 </ul>
252 </div>
253 </div>
254 <?php
256 /*************************************************************************************************/
257 function toolbox() {
259 <div class="portlet" id="p-tb" role="navigation">
260 <h3><?php $this->msg( 'toolbox' ) ?></h3>
261 <div class="pBody">
262 <ul>
263 <?php
264 foreach ( $this->getToolbox() as $key => $tbitem ) { ?>
265 <?php echo $this->makeListItem( $key, $tbitem ); ?>
267 <?php
269 wfRunHooks( 'MonoBookTemplateToolboxEnd', array( &$this ) );
270 wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this, true ) );
272 </ul>
273 </div>
274 </div>
275 <?php
278 /*************************************************************************************************/
279 function languageBox() {
280 if ( $this->data['language_urls'] ) {
282 <div id="p-lang" class="portlet" role="navigation">
283 <h3<?php $this->html( 'userlangattributes' ) ?>><?php $this->msg( 'otherlanguages' ) ?></h3>
284 <div class="pBody">
285 <ul>
286 <?php foreach ( $this->data['language_urls'] as $key => $langlink ) { ?>
287 <?php echo $this->makeListItem( $key, $langlink ); ?>
289 <?php } ?>
290 </ul>
291 </div>
292 </div>
293 <?php
297 /*************************************************************************************************/
299 * @param $bar string
300 * @param $cont array|string
302 function customBox( $bar, $cont ) {
303 $portletAttribs = array( 'class' => 'generated-sidebar portlet', 'id' => Sanitizer::escapeId( "p-$bar" ), 'role' => 'navigation' );
304 $tooltip = Linker::titleAttrib( "p-$bar" );
305 if ( $tooltip !== false ) {
306 $portletAttribs['title'] = $tooltip;
308 echo ' ' . Html::openElement( 'div', $portletAttribs );
309 $msgObj = wfMessage( $bar );
312 <h3><?php echo htmlspecialchars( $msgObj->exists() ? $msgObj->text() : $bar ); ?></h3>
313 <div class='pBody'>
314 <?php if ( is_array( $cont ) ) { ?>
315 <ul>
316 <?php foreach ( $cont as $key => $val ) { ?>
317 <?php echo $this->makeListItem( $key, $val ); ?>
319 <?php } ?>
320 </ul>
321 <?php } else {
322 # allow raw HTML block to be defined by extensions
323 print $cont;
326 </div>
327 </div>
328 <?php
330 } // end of class