Vector: Label the more actions menu "More", not "Actions"
[lhc/web/wiklou.git] / skins / MonoBook.php
1 <?php
2 /**
3 * MonoBook nouveau.
4 *
5 * Translated from gwicke's previous TAL template version to remove
6 * dependency on PHPTAL.
7 *
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.
12 *
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.
17 *
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
22 *
23 * @todo document
24 * @file
25 * @ingroup Skins
26 */
27
28 if ( !defined( 'MEDIAWIKI' ) ) {
29 die( -1 );
30 }
31
32 /**
33 * Inherit main code from SkinTemplate, set the CSS and template filter.
34 * @todo document
35 * @ingroup Skins
36 */
37 class SkinMonoBook extends SkinTemplate {
38 /** Using monobook. */
39 public $skinname = 'monobook';
40 public $stylename = 'monobook';
41 public $template = 'MonoBookTemplate';
42
43 /**
44 * @param OutputPage $out
45 */
46 function setupSkinUserCss( OutputPage $out ) {
47 parent::setupSkinUserCss( $out );
48
49 $out->addModuleStyles( array( 'mediawiki.skinning.interface', 'skins.monobook.styles' ) );
50
51 // TODO: Migrate all of these
52 $out->addStyle( 'monobook/IE60Fixes.css', 'screen', 'IE 6' );
53 $out->addStyle( 'monobook/IE70Fixes.css', 'screen', 'IE 7' );
54 }
55 }
56
57 /**
58 * @todo document
59 * @ingroup Skins
60 */
61 class MonoBookTemplate extends BaseTemplate {
62
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.
68 *
69 * @access private
70 */
71 function execute() {
72 // Suppress warnings to prevent notices about missing indexes in $this->data
73 wfSuppressWarnings();
74
75 $this->html( 'headelement' );
76 ?><div id="globalWrapper">
77 <div id="column-content">
78 <div id="content" class="mw-body-primary" role="main">
79 <a id="top"></a>
80 <?php
81 if ( $this->data['sitenotice'] ) {
82 ?>
83 <div id="siteNotice"><?php
84 $this->html( 'sitenotice' )
85 ?></div><?php
86 }
87 ?>
88
89 <h1 id="firstHeading" class="firstHeading" lang="<?php
90 $this->data['pageLanguage'] =
91 $this->getSkin()->getTitle()->getPageViewLanguage()->getHtmlCode();
92 $this->text( 'pageLanguage' );
93 ?>"><span dir="auto"><?php $this->html( 'title' ) ?></span></h1>
94
95 <div id="bodyContent" class="mw-body">
96 <div id="siteSub"><?php $this->msg( 'tagline' ) ?></div>
97 <div id="contentSub"<?php
98 $this->html( 'userlangattributes' ) ?>><?php $this->html( 'subtitle' )
99 ?></div>
100 <?php if ( $this->data['undelete'] ) { ?>
101 <div id="contentSub2"><?php $this->html( 'undelete' ) ?></div>
102 <?php
103 }
104 ?><?php
105 if ( $this->data['newtalk'] ) {
106 ?>
107 <div class="usermessage"><?php $this->html( 'newtalk' ) ?></div>
108 <?php
109 }
110 ?>
111 <div id="jump-to-nav" class="mw-jump"><?php
112 $this->msg( 'jumpto' )
113 ?> <a href="#column-one"><?php
114 $this->msg( 'jumptonavigation' )
115 ?></a><?php
116 $this->msg( 'comma-separator' )
117 ?><a href="#searchInput"><?php
118 $this->msg( 'jumptosearch' )
119 ?></a></div>
120
121 <!-- start content -->
122 <?php $this->html( 'bodytext' ) ?>
123 <?php
124 if ( $this->data['catlinks'] ) {
125 $this->html( 'catlinks' );
126 }
127 ?>
128 <!-- end content -->
129 <?php
130 if ( $this->data['dataAfterContent'] ) {
131 $this->html( 'dataAfterContent'
132 );
133 }
134 ?>
135 <div class="visualClear"></div>
136 </div>
137 </div>
138 </div>
139 <div id="column-one"<?php $this->html( 'userlangattributes' ) ?>>
140 <h2><?php $this->msg( 'navigation-heading' ) ?></h2>
141 <?php $this->cactions(); ?>
142 <div class="portlet" id="p-personal" role="navigation">
143 <h3><?php $this->msg( 'personaltools' ) ?></h3>
144
145 <div class="pBody">
146 <ul<?php $this->html( 'userlangattributes' ) ?>>
147 <?php foreach ( $this->getPersonalTools() as $key => $item ) { ?>
148 <?php echo $this->makeListItem( $key, $item ); ?>
149
150 <?php
151 }
152 ?>
153 </ul>
154 </div>
155 </div>
156 <div class="portlet" id="p-logo" role="banner">
157 <?php
158 echo Html::element( 'a', array(
159 'href' => $this->data['nav_urls']['mainpage']['href'],
160 'style' => "background-image: url({$this->data['logopath']});" )
161 + Linker::tooltipAndAccesskeyAttribs( 'p-logo' ) ); ?>
162
163 </div>
164 <?php
165 $this->renderPortals( $this->data['sidebar'] );
166 ?>
167 </div><!-- end of the left (by default at least) column -->
168 <div class="visualClear"></div>
169 <?php
170 $validFooterIcons = $this->getFooterIcons( "icononly" );
171 $validFooterLinks = $this->getFooterLinks( "flat" ); // Additional footer links
172
173 if ( count( $validFooterIcons ) + count( $validFooterLinks ) > 0 ) {
174 ?>
175 <div id="footer" role="contentinfo"<?php $this->html( 'userlangattributes' ) ?>>
176 <?php
177 $footerEnd = '</div>';
178 } else {
179 $footerEnd = '';
180 }
181
182 foreach ( $validFooterIcons as $blockName => $footerIcons ) {
183 ?>
184 <div id="f-<?php echo htmlspecialchars( $blockName ); ?>ico">
185 <?php foreach ( $footerIcons as $icon ) { ?>
186 <?php echo $this->getSkin()->makeFooterIcon( $icon ); ?>
187
188 <?php
189 }
190 ?>
191 </div>
192 <?php
193 }
194
195 if ( count( $validFooterLinks ) > 0 ) {
196 ?>
197 <ul id="f-list">
198 <?php
199 foreach ( $validFooterLinks as $aLink ) {
200 ?>
201 <li id="<?php echo $aLink ?>"><?php $this->html( $aLink ) ?></li>
202 <?php
203 }
204 ?>
205 </ul>
206 <?php
207 }
208
209 echo $footerEnd;
210 ?>
211
212 </div>
213 <?php
214 $this->printTrail();
215 echo Html::closeElement( 'body' );
216 echo Html::closeElement( 'html' );
217 wfRestoreWarnings();
218 } // end of execute() method
219
220 /*************************************************************************************************/
221
222 /**
223 * @param array $sidebar
224 */
225 protected function renderPortals( $sidebar ) {
226 if ( !isset( $sidebar['SEARCH'] ) ) {
227 $sidebar['SEARCH'] = true;
228 }
229 if ( !isset( $sidebar['TOOLBOX'] ) ) {
230 $sidebar['TOOLBOX'] = true;
231 }
232 if ( !isset( $sidebar['LANGUAGES'] ) ) {
233 $sidebar['LANGUAGES'] = true;
234 }
235
236 foreach ( $sidebar as $boxName => $content ) {
237 if ( $content === false ) {
238 continue;
239 }
240
241 if ( $boxName == 'SEARCH' ) {
242 $this->searchBox();
243 } elseif ( $boxName == 'TOOLBOX' ) {
244 $this->toolbox();
245 } elseif ( $boxName == 'LANGUAGES' ) {
246 $this->languageBox();
247 } else {
248 $this->customBox( $boxName, $content );
249 }
250 }
251 }
252
253 function searchBox() {
254 global $wgUseTwoButtonsSearchForm;
255 ?>
256 <div id="p-search" class="portlet" role="search">
257 <h3><label for="searchInput"><?php $this->msg( 'search' ) ?></label></h3>
258
259 <div id="searchBody" class="pBody">
260 <form action="<?php $this->text( 'wgScript' ) ?>" id="searchform">
261 <input type='hidden' name="title" value="<?php $this->text( 'searchtitle' ) ?>"/>
262 <?php echo $this->makeSearchInput( array( "id" => "searchInput" ) ); ?>
263
264 <?php
265 echo $this->makeSearchButton(
266 "go",
267 array( "id" => "searchGoButton", "class" => "searchButton" )
268 );
269
270 if ( $wgUseTwoButtonsSearchForm ) {
271 ?>&#160;
272 <?php echo $this->makeSearchButton(
273 "fulltext",
274 array( "id" => "mw-searchButton", "class" => "searchButton" )
275 );
276 } else {
277 ?>
278
279 <div><a href="<?php
280 $this->text( 'searchaction' )
281 ?>" rel="search"><?php $this->msg( 'powersearch-legend' ) ?></a></div><?php
282 } ?>
283
284 </form>
285
286 <?php $this->renderAfterPortlet( 'search' ); ?>
287 </div>
288 </div>
289 <?php
290 }
291
292 /**
293 * Prints the cactions bar.
294 * Shared between MonoBook and Modern
295 */
296 function cactions() {
297 ?>
298 <div id="p-cactions" class="portlet" role="navigation">
299 <h3><?php $this->msg( 'views' ) ?></h3>
300
301 <div class="pBody">
302 <ul><?php
303 foreach ( $this->data['content_actions'] as $key => $tab ) {
304 echo '
305 ' . $this->makeListItem( $key, $tab );
306 } ?>
307
308 </ul>
309 <?php $this->renderAfterPortlet( 'cactions' ); ?>
310 </div>
311 </div>
312 <?php
313 }
314
315 /*************************************************************************************************/
316 function toolbox() {
317 ?>
318 <div class="portlet" id="p-tb" role="navigation">
319 <h3><?php $this->msg( 'toolbox' ) ?></h3>
320
321 <div class="pBody">
322 <ul>
323 <?php
324 foreach ( $this->getToolbox() as $key => $tbitem ) {
325 ?>
326 <?php echo $this->makeListItem( $key, $tbitem ); ?>
327
328 <?php
329 }
330 wfRunHooks( 'MonoBookTemplateToolboxEnd', array( &$this ) );
331 wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this, true ) );
332 ?>
333 </ul>
334 <?php $this->renderAfterPortlet( 'tb' ); ?>
335 </div>
336 </div>
337 <?php
338 }
339
340 /*************************************************************************************************/
341 function languageBox() {
342 if ( $this->data['language_urls'] !== false ) {
343 ?>
344 <div id="p-lang" class="portlet" role="navigation">
345 <h3<?php $this->html( 'userlangattributes' ) ?>><?php $this->msg( 'otherlanguages' ) ?></h3>
346
347 <div class="pBody">
348 <ul>
349 <?php foreach ( $this->data['language_urls'] as $key => $langlink ) { ?>
350 <?php echo $this->makeListItem( $key, $langlink ); ?>
351
352 <?php
353 }
354 ?>
355 </ul>
356
357 <?php $this->renderAfterPortlet( 'lang' ); ?>
358 </div>
359 </div>
360 <?php
361 }
362 }
363
364 /*************************************************************************************************/
365 /**
366 * @param string $bar
367 * @param array|string $cont
368 */
369 function customBox( $bar, $cont ) {
370 $portletAttribs = array(
371 'class' => 'generated-sidebar portlet',
372 'id' => Sanitizer::escapeId( "p-$bar" ),
373 'role' => 'navigation'
374 );
375
376 $tooltip = Linker::titleAttrib( "p-$bar" );
377 if ( $tooltip !== false ) {
378 $portletAttribs['title'] = $tooltip;
379 }
380 echo ' ' . Html::openElement( 'div', $portletAttribs );
381 $msgObj = wfMessage( $bar );
382 ?>
383
384 <h3><?php echo htmlspecialchars( $msgObj->exists() ? $msgObj->text() : $bar ); ?></h3>
385 <div class='pBody'>
386 <?php
387 if ( is_array( $cont ) ) {
388 ?>
389 <ul>
390 <?php
391 foreach ( $cont as $key => $val ) {
392 ?>
393 <?php echo $this->makeListItem( $key, $val ); ?>
394
395 <?php
396 }
397 ?>
398 </ul>
399 <?php
400 } else {
401 # allow raw HTML block to be defined by extensions
402 print $cont;
403 }
404
405 $this->renderAfterPortlet( $bar );
406 ?>
407 </div>
408 </div>
409 <?php
410 }
411 } // end of class