3 * Vector - Modern version of MonoBook with fresh look and many usability
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 * http://www.gnu.org/copyleft/gpl.html
26 * QuickTemplate class for Vector skin
29 class VectorTemplate
extends BaseTemplate
{
33 * Outputs the entire contents of the (X)HTML page
35 public function execute() {
36 global $wgVectorUseIconWatch;
38 // Build additional attributes for navigation urls
39 $nav = $this->data
['content_navigation'];
41 if ( $wgVectorUseIconWatch ) {
42 $mode = $this->getSkin()->getUser()->isWatched( $this->getSkin()->getRelevantTitle() )
46 if ( isset( $nav['actions'][$mode] ) ) {
47 $nav['views'][$mode] = $nav['actions'][$mode];
48 $nav['views'][$mode]['class'] = rtrim( 'icon ' . $nav['views'][$mode]['class'], ' ' );
49 $nav['views'][$mode]['primary'] = true;
50 unset( $nav['actions'][$mode] );
55 foreach ( $nav as $section => $links ) {
56 foreach ( $links as $key => $link ) {
57 if ( $section == 'views' && !( isset( $link['primary'] ) && $link['primary'] ) ) {
58 $link['class'] = rtrim( 'collapsible ' . $link['class'], ' ' );
61 $xmlID = isset( $link['id'] ) ?
$link['id'] : 'ca-' . $xmlID;
62 $nav[$section][$key]['attributes'] =
63 ' id="' . Sanitizer
::escapeId( $xmlID ) . '"';
64 if ( $link['class'] ) {
65 $nav[$section][$key]['attributes'] .=
66 ' class="' . htmlspecialchars( $link['class'] ) . '"';
67 unset( $nav[$section][$key]['class'] );
69 if ( isset( $link['tooltiponly'] ) && $link['tooltiponly'] ) {
70 $nav[$section][$key]['key'] =
71 Linker
::tooltip( $xmlID );
73 $nav[$section][$key]['key'] =
74 Xml
::expandAttributes( Linker
::tooltipAndAccesskeyAttribs( $xmlID ) );
78 $this->data
['namespace_urls'] = $nav['namespaces'];
79 $this->data
['view_urls'] = $nav['views'];
80 $this->data
['action_urls'] = $nav['actions'];
81 $this->data
['variant_urls'] = $nav['variants'];
83 // Reverse horizontally rendered navigation elements
84 if ( $this->data
['rtl'] ) {
85 $this->data
['view_urls'] =
86 array_reverse( $this->data
['view_urls'] );
87 $this->data
['namespace_urls'] =
88 array_reverse( $this->data
['namespace_urls'] );
89 $this->data
['personal_urls'] =
90 array_reverse( $this->data
['personal_urls'] );
93 $this->html( 'headelement' );
95 <div id
="mw-page-base" class="noprint"></div
>
96 <div id
="mw-head-base" class="noprint"></div
>
97 <div id
="content" class="mw-body" role
="main">
100 <div id
="mw-js-message" style
="display:none;"<?php
$this->html( 'userlangattributes' ) ?
>></div
>
102 if ( $this->data
['sitenotice'] ) {
104 <div id
="siteNotice"><?php
$this->html( 'sitenotice' ) ?
></div
>
108 <h1 id
="firstHeading" class="firstHeading" lang
="<?php
109 $this->data['pageLanguage'] =
110 $this->getSkin()->getTitle()->getPageViewLanguage()->getHtmlCode();
111 $this->text( 'pageLanguage' );
112 ?>"><span dir
="auto"><?php
$this->html( 'title' ) ?
></span
></h1
>
113 <?php
$this->html( 'prebodyhtml' ) ?
>
114 <div id
="bodyContent" class="mw-body-content">
116 if ( $this->data
['isarticle'] ) {
118 <div id
="siteSub"><?php
$this->msg( 'tagline' ) ?
></div
>
122 <div id
="contentSub"<?php
123 $this->html( 'userlangattributes' )
124 ?
>><?php
$this->html( 'subtitle' ) ?
></div
>
126 if ( $this->data
['undelete'] ) {
128 <div id
="contentSub2"><?php
$this->html( 'undelete' ) ?
></div
>
133 if ( $this->data
['newtalk'] ) {
135 <div
class="usermessage"><?php
$this->html( 'newtalk' ) ?
></div
>
139 <div id
="jump-to-nav" class="mw-jump">
140 <?php
$this->msg( 'jumpto' ) ?
>
141 <a href
="#mw-navigation"><?php
142 $this->msg( 'jumptonavigation' )
144 $this->msg( 'comma-separator' )
146 <a href
="#p-search"><?php
$this->msg( 'jumptosearch' ) ?
></a
>
148 <?php
$this->html( 'bodycontent' ) ?
>
150 if ( $this->data
['printfooter'] ) {
152 <div
class="printfooter">
153 <?php
$this->html( 'printfooter' ); ?
>
159 if ( $this->data
['catlinks'] ) {
162 $this->html( 'catlinks' );
168 if ( $this->data
['dataAfterContent'] ) {
171 $this->html( 'dataAfterContent' );
176 <div
class="visualClear"></div
>
177 <?php
$this->html( 'debughtml' ); ?
>
180 <div id
="mw-navigation">
181 <h2
><?php
$this->msg( 'navigation-heading' ) ?
></h2
>
184 <?php
$this->renderNavigation( 'PERSONAL' ); ?
>
185 <div id
="left-navigation">
186 <?php
$this->renderNavigation( array( 'NAMESPACES', 'VARIANTS' ) ); ?
>
188 <div id
="right-navigation">
189 <?php
$this->renderNavigation( array( 'VIEWS', 'ACTIONS', 'SEARCH' ) ); ?
>
193 <div id
="p-logo" role
="banner"><a style
="background-image: url(<?php
194 $this->text( 'logopath' )
196 echo htmlspecialchars( $this->data['nav_urls']['mainpage']['href'] )
198 echo Xml
::expandAttributes( Linker
::tooltipAndAccesskeyAttribs( 'p-logo' ) )
200 <?php
$this->renderPortals( $this->data
['sidebar'] ); ?
>
203 <div id
="footer" role
="contentinfo"<?php
$this->html( 'userlangattributes' ) ?
>>
205 foreach ( $this->getFooterLinks() as $category => $links ) {
211 foreach ( $links as $link ) {
227 <?php
$footericons = $this->getFooterIcons( "icononly" );
228 if ( count( $footericons ) > 0 ) {
230 <ul id
="footer-icons" class="noprint">
232 foreach ( $footericons as $blockName => $footerIcons ) {
235 echo htmlspecialchars( $blockName ); ?>ico">
237 foreach ( $footerIcons as $icon ) {
240 echo $this->getSkin()->makeFooterIcon( $icon );
254 <div style
="clear:both"></div
>
256 <?php
$this->printTrail(); ?
>
264 * Render a series of portals
266 * @param array $portals
268 protected function renderPortals( $portals ) {
269 // Force the rendering of the following portals
270 if ( !isset( $portals['SEARCH'] ) ) {
271 $portals['SEARCH'] = true;
273 if ( !isset( $portals['TOOLBOX'] ) ) {
274 $portals['TOOLBOX'] = true;
276 if ( !isset( $portals['LANGUAGES'] ) ) {
277 $portals['LANGUAGES'] = true;
280 foreach ( $portals as $name => $content ) {
281 if ( $content === false ) {
289 $this->renderPortal( 'tb', $this->getToolbox(), 'toolbox', 'SkinTemplateToolboxEnd' );
292 if ( $this->data
['language_urls'] !== false ) {
293 $this->renderPortal( 'lang', $this->data
['language_urls'], 'otherlanguages' );
297 $this->renderPortal( $name, $content );
304 * @param string $name
305 * @param array $content
306 * @param null|string $msg
307 * @param null|string|array $hook
309 protected function renderPortal( $name, $content, $msg = null, $hook = null ) {
310 if ( $msg === null ) {
313 $msgObj = wfMessage( $msg );
315 <div
class="portal" role
="navigation" id
='<?php
316 echo Sanitizer::escapeId( "p-$name" )
318 echo Linker
::tooltip( 'p-' . $name )
319 ?
> aria
-labelledby
='<?php echo Sanitizer::escapeId( "p-$name-label" ) ?>'>
321 $this->html( 'userlangattributes' )
323 echo Sanitizer::escapeId( "p-$name-label" )
325 echo htmlspecialchars( $msgObj->exists() ?
$msgObj->text() : $msg );
330 if ( is_array( $content ) ) {
334 foreach ( $content as $key => $val ) {
336 <?php
echo $this->makeListItem( $key, $val ); ?
>
340 if ( $hook !== null ) {
341 wfRunHooks( $hook, array( &$this, true ) );
349 echo $content; /* Allow raw HTML block to be defined by extensions */
352 $this->renderAfterPortlet( $name );
360 * Render one or more navigations elements by name, automatically reveresed
361 * when UI is in RTL mode
363 * @param array $elements
365 protected function renderNavigation( $elements ) {
366 global $wgVectorUseSimpleSearch;
368 // If only one element was given, wrap it in an array, allowing more
369 // flexible arguments
370 if ( !is_array( $elements ) ) {
371 $elements = array( $elements );
372 // If there's a series of elements, reverse them when in RTL mode
373 } elseif ( $this->data
['rtl'] ) {
374 $elements = array_reverse( $elements );
377 foreach ( $elements as $name => $element ) {
378 switch ( $element ) {
381 <div id
="p-namespaces" role
="navigation" class="vectorTabs<?php
382 if ( count( $this->data['namespace_urls'] ) == 0 ) {
383 echo ' emptyPortlet';
385 ?>" aria
-labelledby
="p-namespaces-label">
386 <h3 id
="p-namespaces-label"><?php
$this->msg( 'namespaces' ) ?
></h3
>
387 <ul
<?php
$this->html( 'userlangattributes' ) ?
>>
389 foreach ( $this->data
['namespace_urls'] as $link ) {
392 echo $link['attributes']
393 ?
>><span
><a href
="<?php
394 echo htmlspecialchars( $link['href'] )
398 echo htmlspecialchars( $link['text'] )
409 <div id
="p-variants" role
="navigation" class="vectorMenu<?php
410 if ( count( $this->data['variant_urls'] ) == 0 ) {
411 echo ' emptyPortlet';
413 ?>" aria
-labelledby
="p-variants-label">
414 <h3 id
="mw-vector-current-variant">
416 foreach ( $this->data
['variant_urls'] as $link ) {
419 if ( stripos( $link['attributes'], 'selected' ) !== false ) {
422 echo htmlspecialchars( $link['text'] )
432 <h3 id
="p-variants-label"><span
><?php
$this->msg( 'variants' ) ?
></span
><a href
="#"></a
></h3
>
437 foreach ( $this->data
['variant_urls'] as $link ) {
440 echo $link['attributes']
442 echo htmlspecialchars( $link['href'] )
444 echo htmlspecialchars( $link['lang'] )
446 echo htmlspecialchars( $link['hreflang'] )
450 echo htmlspecialchars( $link['text'] )
462 <div id
="p-views" role
="navigation" class="vectorTabs<?php
463 if ( count( $this->data['view_urls'] ) == 0 ) {
464 echo ' emptyPortlet';
466 ?>" aria
-labelledby
="p-views-label">
467 <h3 id
="p-views-label"><?php
$this->msg( 'views' ) ?
></h3
>
469 $this->html( 'userlangattributes' )
472 foreach ( $this->data
['view_urls'] as $link ) {
475 echo $link['attributes']
476 ?
>><span
><a href
="<?php
477 echo htmlspecialchars( $link['href'] )
481 // $link['text'] can be undefined - bug 27764
482 if ( array_key_exists( 'text', $link ) ) {
483 echo array_key_exists( 'img', $link )
484 ?
'<img src="' . $link['img'] . '" alt="' . $link['text'] . '" />'
485 : htmlspecialchars( $link['text'] );
497 <div id
="p-cactions" role
="navigation" class="vectorMenu<?php
498 if ( count( $this->data['action_urls'] ) == 0 ) {
499 echo ' emptyPortlet';
501 ?>" aria
-labelledby
="p-cactions-label">
502 <h3 id
="p-cactions-label"><span
><?php
$this->msg( 'vector-more-actions' ) ?
></span
><a href
="#"></a
></h3
>
505 <ul
<?php
$this->html( 'userlangattributes' ) ?
>>
507 foreach ( $this->data
['action_urls'] as $link ) {
510 echo $link['attributes']
513 echo htmlspecialchars( $link['href'] )
515 echo $link['key'] ?
>><?php
echo htmlspecialchars( $link['text'] )
528 <div id
="p-personal" role
="navigation" class="<?php
529 if ( count( $this->data['personal_urls'] ) == 0 ) {
530 echo ' emptyPortlet';
532 ?>" aria
-labelledby
="p-personal-label">
533 <h3 id
="p-personal-label"><?php
$this->msg( 'personaltools' ) ?
></h3
>
534 <ul
<?php
$this->html( 'userlangattributes' ) ?
>>
536 $personalTools = $this->getPersonalTools();
537 foreach ( $personalTools as $key => $item ) {
538 echo $this->makeListItem( $key, $item );
547 <div id
="p-search" role
="search">
548 <h3
<?php
$this->html( 'userlangattributes' ) ?
>>
549 <label
for="searchInput"><?php
$this->msg( 'search' ) ?
></label
>
552 <form action
="<?php $this->text( 'wgScript' ) ?>" id
="searchform">
554 if ($wgVectorUseSimpleSearch) {
556 <div id
="simpleSearch">
565 echo $this->makeSearchInput( array( 'id' => 'searchInput' ) );
566 echo Html
::hidden( 'title', $this->get( 'searchtitle' ) );
567 // We construct two buttons (for 'go' and 'fulltext' search modes),
568 // but only one will be visible and actionable at a time (they are
569 // overlaid on top of each other in CSS).
570 // * Browsers will use the 'fulltext' one by default (as it's the
571 // first in tree-order), which is desirable when they are unable
572 // to show search suggestions (either due to being broken or
573 // having JavaScript turned off).
574 // * The mediawiki.searchSuggest module, after doing tests for the
575 // broken browsers, removes the 'fulltext' button and handles
576 // 'fulltext' search itself; this will reveal the 'go' button and
577 // cause it to be used.
578 echo $this->makeSearchButton(
580 array( 'id' => 'mw-searchButton', 'class' => 'searchButton mw-fallbackSearchButton' )
582 echo $this->makeSearchButton(
584 array( 'id' => 'searchButton', 'class' => 'searchButton' )