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">
101 if ( $this->data
['sitenotice'] ) {
103 <div id
="siteNotice"><?php
$this->html( 'sitenotice' ) ?
></div
>
107 <h1 id
="firstHeading" class="firstHeading" lang
="<?php
108 $this->data['pageLanguage'] =
109 $this->getSkin()->getTitle()->getPageViewLanguage()->getHtmlCode();
110 $this->text( 'pageLanguage' );
111 ?>"><span dir
="auto"><?php
$this->html( 'title' ) ?
></span
></h1
>
112 <?php
$this->html( 'prebodyhtml' ) ?
>
113 <div id
="bodyContent" class="mw-body-content">
115 if ( $this->data
['isarticle'] ) {
117 <div id
="siteSub"><?php
$this->msg( 'tagline' ) ?
></div
>
121 <div id
="contentSub"<?php
122 $this->html( 'userlangattributes' )
123 ?
>><?php
$this->html( 'subtitle' ) ?
></div
>
125 if ( $this->data
['undelete'] ) {
127 <div id
="contentSub2"><?php
$this->html( 'undelete' ) ?
></div
>
132 if ( $this->data
['newtalk'] ) {
134 <div
class="usermessage"><?php
$this->html( 'newtalk' ) ?
></div
>
138 <div id
="jump-to-nav" class="mw-jump">
139 <?php
$this->msg( 'jumpto' ) ?
>
140 <a href
="#mw-navigation"><?php
141 $this->msg( 'jumptonavigation' )
143 $this->msg( 'comma-separator' )
145 <a href
="#p-search"><?php
$this->msg( 'jumptosearch' ) ?
></a
>
147 <?php
$this->html( 'bodycontent' ) ?
>
149 if ( $this->data
['printfooter'] ) {
151 <div
class="printfooter">
152 <?php
$this->html( 'printfooter' ); ?
>
158 if ( $this->data
['catlinks'] ) {
161 $this->html( 'catlinks' );
167 if ( $this->data
['dataAfterContent'] ) {
170 $this->html( 'dataAfterContent' );
175 <div
class="visualClear"></div
>
176 <?php
$this->html( 'debughtml' ); ?
>
179 <div id
="mw-navigation">
180 <h2
><?php
$this->msg( 'navigation-heading' ) ?
></h2
>
183 <?php
$this->renderNavigation( 'PERSONAL' ); ?
>
184 <div id
="left-navigation">
185 <?php
$this->renderNavigation( array( 'NAMESPACES', 'VARIANTS' ) ); ?
>
187 <div id
="right-navigation">
188 <?php
$this->renderNavigation( array( 'VIEWS', 'ACTIONS', 'SEARCH' ) ); ?
>
192 <div id
="p-logo" role
="banner"><a style
="background-image: url(<?php
193 $this->text( 'logopath' )
195 echo htmlspecialchars( $this->data['nav_urls']['mainpage']['href'] )
197 echo Xml
::expandAttributes( Linker
::tooltipAndAccesskeyAttribs( 'p-logo' ) )
199 <?php
$this->renderPortals( $this->data
['sidebar'] ); ?
>
202 <div id
="footer" role
="contentinfo"<?php
$this->html( 'userlangattributes' ) ?
>>
204 foreach ( $this->getFooterLinks() as $category => $links ) {
210 foreach ( $links as $link ) {
226 <?php
$footericons = $this->getFooterIcons( "icononly" );
227 if ( count( $footericons ) > 0 ) {
229 <ul id
="footer-icons" class="noprint">
231 foreach ( $footericons as $blockName => $footerIcons ) {
234 echo htmlspecialchars( $blockName ); ?>ico">
236 foreach ( $footerIcons as $icon ) {
239 echo $this->getSkin()->makeFooterIcon( $icon );
253 <div style
="clear:both"></div
>
255 <?php
$this->printTrail(); ?
>
263 * Render a series of portals
265 * @param array $portals
267 protected function renderPortals( $portals ) {
268 // Force the rendering of the following portals
269 if ( !isset( $portals['SEARCH'] ) ) {
270 $portals['SEARCH'] = true;
272 if ( !isset( $portals['TOOLBOX'] ) ) {
273 $portals['TOOLBOX'] = true;
275 if ( !isset( $portals['LANGUAGES'] ) ) {
276 $portals['LANGUAGES'] = true;
279 foreach ( $portals as $name => $content ) {
280 if ( $content === false ) {
288 $this->renderPortal( 'tb', $this->getToolbox(), 'toolbox', 'SkinTemplateToolboxEnd' );
291 if ( $this->data
['language_urls'] !== false ) {
292 $this->renderPortal( 'lang', $this->data
['language_urls'], 'otherlanguages' );
296 $this->renderPortal( $name, $content );
303 * @param string $name
304 * @param array $content
305 * @param null|string $msg
306 * @param null|string|array $hook
308 protected function renderPortal( $name, $content, $msg = null, $hook = null ) {
309 if ( $msg === null ) {
312 $msgObj = wfMessage( $msg );
314 <div
class="portal" role
="navigation" id
='<?php
315 echo Sanitizer::escapeId( "p-$name" )
317 echo Linker
::tooltip( 'p-' . $name )
318 ?
> aria
-labelledby
='<?php echo Sanitizer::escapeId( "p-$name-label" ) ?>'>
320 $this->html( 'userlangattributes' )
322 echo Sanitizer::escapeId( "p-$name-label" )
324 echo htmlspecialchars( $msgObj->exists() ?
$msgObj->text() : $msg );
329 if ( is_array( $content ) ) {
333 foreach ( $content as $key => $val ) {
335 <?php
echo $this->makeListItem( $key, $val ); ?
>
339 if ( $hook !== null ) {
340 wfRunHooks( $hook, array( &$this, true ) );
348 echo $content; /* Allow raw HTML block to be defined by extensions */
351 $this->renderAfterPortlet( $name );
359 * Render one or more navigations elements by name, automatically reveresed
360 * when UI is in RTL mode
362 * @param array $elements
364 protected function renderNavigation( $elements ) {
365 global $wgVectorUseSimpleSearch;
367 // If only one element was given, wrap it in an array, allowing more
368 // flexible arguments
369 if ( !is_array( $elements ) ) {
370 $elements = array( $elements );
371 // If there's a series of elements, reverse them when in RTL mode
372 } elseif ( $this->data
['rtl'] ) {
373 $elements = array_reverse( $elements );
376 foreach ( $elements as $name => $element ) {
377 switch ( $element ) {
380 <div id
="p-namespaces" role
="navigation" class="vectorTabs<?php
381 if ( count( $this->data['namespace_urls'] ) == 0 ) {
382 echo ' emptyPortlet';
384 ?>" aria
-labelledby
="p-namespaces-label">
385 <h3 id
="p-namespaces-label"><?php
$this->msg( 'namespaces' ) ?
></h3
>
386 <ul
<?php
$this->html( 'userlangattributes' ) ?
>>
388 foreach ( $this->data
['namespace_urls'] as $link ) {
391 echo $link['attributes']
392 ?
>><span
><a href
="<?php
393 echo htmlspecialchars( $link['href'] )
397 echo htmlspecialchars( $link['text'] )
408 <div id
="p-variants" role
="navigation" class="vectorMenu<?php
409 if ( count( $this->data['variant_urls'] ) == 0 ) {
410 echo ' emptyPortlet';
412 ?>" aria
-labelledby
="p-variants-label">
414 // Replace the label with the name of currently chosen variant, if any
415 $variantLabel = $this->getMsg( 'variants' )->text();
416 foreach ( $this->data
['variant_urls'] as $link ) {
417 if ( stripos( $link['attributes'], 'selected' ) !== false ) {
418 $variantLabel = $link['text'];
423 <h3 id
="p-variants-label"><span
424 style
="display: block;" <?php
/* Temporary WMF deployment hack, to be removed before 1.24 release */ ?
>
425 ><?php
echo htmlspecialchars( $variantLabel ) ?
></span
><a href
="#"></a
></h3
>
430 foreach ( $this->data
['variant_urls'] as $link ) {
433 echo $link['attributes']
435 echo htmlspecialchars( $link['href'] )
437 echo htmlspecialchars( $link['lang'] )
439 echo htmlspecialchars( $link['hreflang'] )
443 echo htmlspecialchars( $link['text'] )
455 <div id
="p-views" role
="navigation" class="vectorTabs<?php
456 if ( count( $this->data['view_urls'] ) == 0 ) {
457 echo ' emptyPortlet';
459 ?>" aria
-labelledby
="p-views-label">
460 <h3 id
="p-views-label"><?php
$this->msg( 'views' ) ?
></h3
>
462 $this->html( 'userlangattributes' )
465 foreach ( $this->data
['view_urls'] as $link ) {
468 echo $link['attributes']
469 ?
>><span
><a href
="<?php
470 echo htmlspecialchars( $link['href'] )
474 // $link['text'] can be undefined - bug 27764
475 if ( array_key_exists( 'text', $link ) ) {
476 echo array_key_exists( 'img', $link )
477 ?
'<img src="' . $link['img'] . '" alt="' . $link['text'] . '" />'
478 : htmlspecialchars( $link['text'] );
490 <div id
="p-cactions" role
="navigation" class="vectorMenu<?php
491 if ( count( $this->data['action_urls'] ) == 0 ) {
492 echo ' emptyPortlet';
494 ?>" aria
-labelledby
="p-cactions-label">
495 <h3 id
="p-cactions-label"><span
><?php
$this->msg( 'vector-more-actions' ) ?
></span
><a href
="#"></a
></h3
>
498 <ul
<?php
$this->html( 'userlangattributes' ) ?
>>
500 foreach ( $this->data
['action_urls'] as $link ) {
503 echo $link['attributes']
506 echo htmlspecialchars( $link['href'] )
508 echo $link['key'] ?
>><?php
echo htmlspecialchars( $link['text'] )
521 <div id
="p-personal" role
="navigation" class="<?php
522 if ( count( $this->data['personal_urls'] ) == 0 ) {
523 echo ' emptyPortlet';
525 ?>" aria
-labelledby
="p-personal-label">
526 <h3 id
="p-personal-label"><?php
$this->msg( 'personaltools' ) ?
></h3
>
527 <ul
<?php
$this->html( 'userlangattributes' ) ?
>>
529 $personalTools = $this->getPersonalTools();
530 foreach ( $personalTools as $key => $item ) {
531 echo $this->makeListItem( $key, $item );
540 <div id
="p-search" role
="search">
541 <h3
<?php
$this->html( 'userlangattributes' ) ?
>>
542 <label
for="searchInput"><?php
$this->msg( 'search' ) ?
></label
>
545 <form action
="<?php $this->text( 'wgScript' ) ?>" id
="searchform">
547 if ( $wgVectorUseSimpleSearch ) {
549 <div id
="simpleSearch">
558 echo $this->makeSearchInput( array( 'id' => 'searchInput' ) );
559 echo Html
::hidden( 'title', $this->get( 'searchtitle' ) );
560 // We construct two buttons (for 'go' and 'fulltext' search modes),
561 // but only one will be visible and actionable at a time (they are
562 // overlaid on top of each other in CSS).
563 // * Browsers will use the 'fulltext' one by default (as it's the
564 // first in tree-order), which is desirable when they are unable
565 // to show search suggestions (either due to being broken or
566 // having JavaScript turned off).
567 // * The mediawiki.searchSuggest module, after doing tests for the
568 // broken browsers, removes the 'fulltext' button and handles
569 // 'fulltext' search itself; this will reveal the 'go' button and
570 // cause it to be used.
571 echo $this->makeSearchButton(
573 array( 'id' => 'mw-searchButton', 'class' => 'searchButton mw-fallbackSearchButton' )
575 echo $this->makeSearchButton(
577 array( 'id' => 'searchButton', 'class' => 'searchButton' )