Localisation updates from http://translatewiki.net.
[mediawiki.git] / skins / MonoBook.php
blobecbcd70a345788e0322f35573d43ff9749ec2df8
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 );
31 /**
32 * Inherit main code from SkinTemplate, set the CSS and template filter.
33 * @todo document
34 * @ingroup Skins
36 class SkinMonoBook extends SkinTemplate {
37 /** Using monobook. */
38 var $skinname = 'monobook', $stylename = 'monobook',
39 $template = 'MonoBookTemplate', $useHeadElement = true;
41 /**
42 * @param $out OutputPage
44 function setupSkinUserCss( OutputPage $out ) {
45 global $wgHandheldStyle;
46 parent::setupSkinUserCss( $out );
48 $out->addModuleStyles( 'skins.monobook' );
50 // Ugh. Can't do this properly because $wgHandheldStyle may be a URL
51 if( $wgHandheldStyle ) {
52 // Currently in testing... try 'chick/main.css'
53 $out->addStyle( $wgHandheldStyle, 'handheld' );
56 // TODO: Migrate all of these
57 $out->addStyle( 'monobook/IE60Fixes.css', 'screen', 'IE 6' );
58 $out->addStyle( 'monobook/IE70Fixes.css', 'screen', 'IE 7' );
63 /**
64 * @todo document
65 * @ingroup Skins
67 class MonoBookTemplate extends BaseTemplate {
69 /**
70 * Template filter callback for MonoBook skin.
71 * Takes an associative array of data set from a SkinTemplate-based
72 * class, and a wrapper for MediaWiki's localization database, and
73 * outputs a formatted page.
75 * @access private
77 function execute() {
78 // Suppress warnings to prevent notices about missing indexes in $this->data
79 wfSuppressWarnings();
81 $this->html( 'headelement' );
82 ?><div id="globalWrapper">
83 <div id="column-content"><div id="content" class="mw-body-primary" role="main">
84 <a id="top"></a>
85 <?php if($this->data['sitenotice']) { ?><div id="siteNotice"><?php $this->html('sitenotice') ?></div><?php } ?>
87 <h1 id="firstHeading" class="firstHeading" lang="<?php
88 $this->data['pageLanguage'] = $this->getSkin()->getTitle()->getPageViewLanguage()->getCode();
89 $this->html( 'pageLanguage' );
90 ?>"><span dir="auto"><?php $this->html('title') ?></span></h1>
91 <div id="bodyContent" class="mw-body">
92 <div id="siteSub"><?php $this->msg('tagline') ?></div>
93 <div id="contentSub"<?php $this->html('userlangattributes') ?>><?php $this->html('subtitle') ?></div>
94 <?php if($this->data['undelete']) { ?>
95 <div id="contentSub2"><?php $this->html('undelete') ?></div>
96 <?php } ?><?php if($this->data['newtalk'] ) { ?>
97 <div class="usermessage"><?php $this->html('newtalk') ?></div>
98 <?php } ?><?php if($this->data['showjumplinks']) { ?>
99 <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>
100 <?php } ?>
101 <!-- start content -->
102 <?php $this->html('bodytext') ?>
103 <?php if($this->data['catlinks']) { $this->html('catlinks'); } ?>
104 <!-- end content -->
105 <?php if($this->data['dataAfterContent']) { $this->html ('dataAfterContent'); } ?>
106 <div class="visualClear"></div>
107 </div>
108 </div></div>
109 <div id="column-one"<?php $this->html('userlangattributes') ?>>
110 <h2><?php $this->msg( 'navigation-heading' ) ?></h2>
111 <?php $this->cactions(); ?>
112 <div class="portlet" id="p-personal" role="navigation">
113 <h3><?php $this->msg('personaltools') ?></h3>
114 <div class="pBody">
115 <ul<?php $this->html('userlangattributes') ?>>
116 <?php foreach($this->getPersonalTools() as $key => $item) { ?>
117 <?php echo $this->makeListItem($key, $item); ?>
119 <?php } ?>
120 </ul>
121 </div>
122 </div>
123 <div class="portlet" id="p-logo" role="banner">
124 <?php
125 echo Html::element( 'a', array(
126 'href' => $this->data['nav_urls']['mainpage']['href'],
127 'style' => "background-image: url({$this->data['logopath']});" )
128 + Linker::tooltipAndAccesskeyAttribs('p-logo') ); ?>
130 </div>
131 <?php
132 $this->renderPortals( $this->data['sidebar'] );
134 </div><!-- end of the left (by default at least) column -->
135 <div class="visualClear"></div>
136 <?php
137 $validFooterIcons = $this->getFooterIcons( "icononly" );
138 $validFooterLinks = $this->getFooterLinks( "flat" ); // Additional footer links
140 if ( count( $validFooterIcons ) + count( $validFooterLinks ) > 0 ) { ?>
141 <div id="footer" role="contentinfo"<?php $this->html('userlangattributes') ?>>
142 <?php
143 $footerEnd = '</div>';
144 } else {
145 $footerEnd = '';
147 foreach ( $validFooterIcons as $blockName => $footerIcons ) { ?>
148 <div id="f-<?php echo htmlspecialchars($blockName); ?>ico">
149 <?php foreach ( $footerIcons as $icon ) { ?>
150 <?php echo $this->getSkin()->makeFooterIcon( $icon ); ?>
152 <?php }
154 </div>
155 <?php }
157 if ( count( $validFooterLinks ) > 0 ) {
158 ?> <ul id="f-list">
159 <?php
160 foreach( $validFooterLinks as $aLink ) { ?>
161 <li id="<?php echo $aLink ?>"><?php $this->html($aLink) ?></li>
162 <?php
165 </ul>
166 <?php }
167 echo $footerEnd;
170 </div>
171 <?php
172 $this->printTrail();
173 echo Html::closeElement( 'body' );
174 echo Html::closeElement( 'html' );
175 wfRestoreWarnings();
176 } // end of execute() method
178 /*************************************************************************************************/
181 * @param $sidebar array
183 protected function renderPortals( $sidebar ) {
184 if ( !isset( $sidebar['SEARCH'] ) ) $sidebar['SEARCH'] = true;
185 if ( !isset( $sidebar['TOOLBOX'] ) ) $sidebar['TOOLBOX'] = true;
186 if ( !isset( $sidebar['LANGUAGES'] ) ) $sidebar['LANGUAGES'] = true;
188 foreach( $sidebar as $boxName => $content ) {
189 if ( $content === false )
190 continue;
192 if ( $boxName == 'SEARCH' ) {
193 $this->searchBox();
194 } elseif ( $boxName == 'TOOLBOX' ) {
195 $this->toolbox();
196 } elseif ( $boxName == 'LANGUAGES' ) {
197 $this->languageBox();
198 } else {
199 $this->customBox( $boxName, $content );
204 function searchBox() {
205 global $wgUseTwoButtonsSearchForm;
207 <div id="p-search" class="portlet" role="search">
208 <h3><label for="searchInput"><?php $this->msg( 'search' ) ?></label></h3>
209 <div id="searchBody" class="pBody">
210 <form action="<?php $this->text( 'wgScript' ) ?>" id="searchform">
211 <input type='hidden' name="title" value="<?php $this->text( 'searchtitle' ) ?>"/>
212 <?php echo $this->makeSearchInput( array( "id" => "searchInput" ) ); ?>
214 <?php echo $this->makeSearchButton( "go", array( "id" => "searchGoButton", "class" => "searchButton" ) );
215 if ( $wgUseTwoButtonsSearchForm ): ?>&#160;
216 <?php echo $this->makeSearchButton( "fulltext", array( "id" => "mw-searchButton", "class" => "searchButton" ) );
217 else: ?>
219 <div><a href="<?php $this->text( 'searchaction' ) ?>" rel="search"><?php $this->msg( 'powersearch-legend' ) ?></a></div><?php
220 endif; ?>
222 </form>
223 </div>
224 </div>
225 <?php
229 * Prints the cactions bar.
230 * Shared between MonoBook and Modern
232 function cactions() {
234 <div id="p-cactions" class="portlet" role="navigation">
235 <h3><?php $this->msg( 'views' ) ?></h3>
236 <div class="pBody">
237 <ul><?php
238 foreach( $this->data['content_actions'] as $key => $tab ) {
239 echo '
240 ' . $this->makeListItem( $key, $tab );
241 } ?>
243 </ul>
244 </div>
245 </div>
246 <?php
248 /*************************************************************************************************/
249 function toolbox() {
251 <div class="portlet" id="p-tb" role="navigation">
252 <h3><?php $this->msg( 'toolbox' ) ?></h3>
253 <div class="pBody">
254 <ul>
255 <?php
256 foreach ( $this->getToolbox() as $key => $tbitem ) { ?>
257 <?php echo $this->makeListItem( $key, $tbitem ); ?>
259 <?php
261 wfRunHooks( 'MonoBookTemplateToolboxEnd', array( &$this ) );
262 wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this, true ) );
264 </ul>
265 </div>
266 </div>
267 <?php
270 /*************************************************************************************************/
271 function languageBox() {
272 if( $this->data['language_urls'] ) {
274 <div id="p-lang" class="portlet" role="navigation">
275 <h3<?php $this->html( 'userlangattributes' ) ?>><?php $this->msg( 'otherlanguages' ) ?></h3>
276 <div class="pBody">
277 <ul>
278 <?php foreach( $this->data['language_urls'] as $key => $langlink ) { ?>
279 <?php echo $this->makeListItem( $key, $langlink ); ?>
281 <?php } ?>
282 </ul>
283 </div>
284 </div>
285 <?php
289 /*************************************************************************************************/
291 * @param $bar string
292 * @param $cont array|string
294 function customBox( $bar, $cont ) {
295 $portletAttribs = array( 'class' => 'generated-sidebar portlet', 'id' => Sanitizer::escapeId( "p-$bar" ), 'role' => 'navigation' );
296 $tooltip = Linker::titleAttrib( "p-$bar" );
297 if ( $tooltip !== false ) {
298 $portletAttribs['title'] = $tooltip;
300 echo ' ' . Html::openElement( 'div', $portletAttribs );
303 <h3><?php $msg = wfMessage( $bar ); echo htmlspecialchars( $msg->exists() ? $msg->text() : $bar ); ?></h3>
304 <div class='pBody'>
305 <?php if ( is_array( $cont ) ) { ?>
306 <ul>
307 <?php foreach( $cont as $key => $val ) { ?>
308 <?php echo $this->makeListItem( $key, $val ); ?>
310 <?php } ?>
311 </ul>
312 <?php } else {
313 # allow raw HTML block to be defined by extensions
314 print $cont;
317 </div>
318 </div>
319 <?php
321 } // end of class