e412c9ce59c33b43f7598d0c2d5b7efb5db04705
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 if ( !defined( 'MEDIAWIKI' ) ) {
31 * SkinTemplate class for Vector skin
34 class SkinVector
extends SkinTemplate
{
35 public $useHeadElement = true;
36 public $skinname = 'vector';
37 public $stylename = 'vector';
38 public $template = 'VectorTemplate';
40 protected static $bodyClasses = array( 'vector-animateLayout' );
43 * Initializes output page and sets up skin-specific parameters
44 * @param OutputPage $out Object to initialize
46 public function initPage( OutputPage
$out ) {
47 global $wgLocalStylePath;
49 parent
::initPage( $out );
51 // Append CSS which includes IE only behavior fixes for hover support -
52 // this is better than including this in a CSS file since it doesn't
53 // wait for the CSS file to load before fetching the HTC file.
54 $min = $this->getRequest()->getFuzzyBool( 'debug' ) ?
'' : '.min';
55 $out->addHeadItem( 'csshover',
56 '<!--[if lt IE 7]><style type="text/css">body{behavior:url("' .
57 htmlspecialchars( $wgLocalStylePath ) .
58 "/{$this->stylename}/csshover{$min}.htc\")}</style><![endif]-->"
61 $out->addModules( array( 'skins.vector.js', 'skins.vector.collapsibleNav' ) );
65 * Loads skin and user CSS files.
66 * @param OutputPage $out
68 function setupSkinUserCss( OutputPage
$out ) {
69 parent
::setupSkinUserCss( $out );
71 $styles = array( 'skins.common.interface', 'skins.vector.styles' );
72 wfRunHooks( 'SkinVectorStyleModules', array( $this, &$styles ) );
73 $out->addModuleStyles( $styles );
77 * Adds classes to the body element.
79 * @param OutputPage $out
80 * @param array &$bodyAttrs Array of attributes that will be set on the body element
82 function addToBodyAttributes( $out, &$bodyAttrs ) {
83 if ( isset( $bodyAttrs['class'] ) && strlen( $bodyAttrs['class'] ) > 0 ) {
84 $bodyAttrs['class'] .= ' ' . implode( ' ', static::$bodyClasses );
86 $bodyAttrs['class'] = implode( ' ', static::$bodyClasses );
92 * QuickTemplate class for Vector skin
95 class VectorTemplate
extends BaseTemplate
{
99 * Outputs the entire contents of the (X)HTML page
101 public function execute() {
102 global $wgVectorUseIconWatch;
104 // Build additional attributes for navigation urls
105 $nav = $this->data
['content_navigation'];
107 if ( $wgVectorUseIconWatch ) {
108 $mode = $this->getSkin()->getUser()->isWatched( $this->getSkin()->getRelevantTitle() )
112 if ( isset( $nav['actions'][$mode] ) ) {
113 $nav['views'][$mode] = $nav['actions'][$mode];
114 $nav['views'][$mode]['class'] = rtrim( 'icon ' . $nav['views'][$mode]['class'], ' ' );
115 $nav['views'][$mode]['primary'] = true;
116 unset( $nav['actions'][$mode] );
121 foreach ( $nav as $section => $links ) {
122 foreach ( $links as $key => $link ) {
123 if ( $section == 'views' && !( isset( $link['primary'] ) && $link['primary'] ) ) {
124 $link['class'] = rtrim( 'collapsible ' . $link['class'], ' ' );
127 $xmlID = isset( $link['id'] ) ?
$link['id'] : 'ca-' . $xmlID;
128 $nav[$section][$key]['attributes'] =
129 ' id="' . Sanitizer
::escapeId( $xmlID ) . '"';
130 if ( $link['class'] ) {
131 $nav[$section][$key]['attributes'] .=
132 ' class="' . htmlspecialchars( $link['class'] ) . '"';
133 unset( $nav[$section][$key]['class'] );
135 if ( isset( $link['tooltiponly'] ) && $link['tooltiponly'] ) {
136 $nav[$section][$key]['key'] =
137 Linker
::tooltip( $xmlID );
139 $nav[$section][$key]['key'] =
140 Xml
::expandAttributes( Linker
::tooltipAndAccesskeyAttribs( $xmlID ) );
144 $this->data
['namespace_urls'] = $nav['namespaces'];
145 $this->data
['view_urls'] = $nav['views'];
146 $this->data
['action_urls'] = $nav['actions'];
147 $this->data
['variant_urls'] = $nav['variants'];
149 // Reverse horizontally rendered navigation elements
150 if ( $this->data
['rtl'] ) {
151 $this->data
['view_urls'] =
152 array_reverse( $this->data
['view_urls'] );
153 $this->data
['namespace_urls'] =
154 array_reverse( $this->data
['namespace_urls'] );
155 $this->data
['personal_urls'] =
156 array_reverse( $this->data
['personal_urls'] );
159 $this->html( 'headelement' );
161 <div id
="mw-page-base" class="noprint"></div
>
162 <div id
="mw-head-base" class="noprint"></div
>
163 <div id
="content" class="mw-body" role
="main">
165 <div id
="mw-js-message" style
="display:none;"<?php
$this->html( 'userlangattributes' ) ?
>></div
>
167 if ( $this->data
['sitenotice'] ) {
169 <div id
="siteNotice"><?php
$this->html( 'sitenotice' ) ?
></div
>
173 <h1 id
="firstHeading" class="firstHeading" lang
="<?php
174 $this->data['pageLanguage'] =
175 $this->getSkin()->getTitle()->getPageViewLanguage()->getHtmlCode();
176 $this->text( 'pageLanguage' );
177 ?>"><span dir
="auto"><?php
$this->html( 'title' ) ?
></span
></h1
>
178 <?php
$this->html( 'prebodyhtml' ) ?
>
179 <div id
="bodyContent">
181 if ( $this->data
['isarticle'] ) {
183 <div id
="siteSub"><?php
$this->msg( 'tagline' ) ?
></div
>
187 <div id
="contentSub"<?php
188 $this->html( 'userlangattributes' )
189 ?
>><?php
$this->html( 'subtitle' ) ?
></div
>
191 if ( $this->data
['undelete'] ) {
193 <div id
="contentSub2"><?php
$this->html( 'undelete' ) ?
></div
>
198 if ( $this->data
['newtalk'] ) {
200 <div
class="usermessage"><?php
$this->html( 'newtalk' ) ?
></div
>
204 <div id
="jump-to-nav" class="mw-jump">
205 <?php
$this->msg( 'jumpto' ) ?
>
206 <a href
="#mw-navigation"><?php
207 $this->msg( 'jumptonavigation' )
209 $this->msg( 'comma-separator' )
211 <a href
="#p-search"><?php
$this->msg( 'jumptosearch' ) ?
></a
>
213 <?php
$this->html( 'bodycontent' ) ?
>
215 if ( $this->data
['printfooter'] ) {
217 <div
class="printfooter">
218 <?php
$this->html( 'printfooter' ); ?
>
224 if ( $this->data
['catlinks'] ) {
227 $this->html( 'catlinks' );
233 if ( $this->data
['dataAfterContent'] ) {
236 $this->html( 'dataAfterContent' );
241 <div
class="visualClear"></div
>
242 <?php
$this->html( 'debughtml' ); ?
>
245 <div id
="mw-navigation">
246 <h2
><?php
$this->msg( 'navigation-heading' ) ?
></h2
>
248 <?php
$this->renderNavigation( 'PERSONAL' ); ?
>
249 <div id
="left-navigation">
250 <?php
$this->renderNavigation( array( 'NAMESPACES', 'VARIANTS' ) ); ?
>
252 <div id
="right-navigation">
253 <?php
$this->renderNavigation( array( 'VIEWS', 'ACTIONS', 'SEARCH' ) ); ?
>
257 <div id
="p-logo" role
="banner"><a style
="background-image: url(<?php
258 $this->text( 'logopath' )
260 echo htmlspecialchars( $this->data['nav_urls']['mainpage']['href'] )
262 echo Xml
::expandAttributes( Linker
::tooltipAndAccesskeyAttribs( 'p-logo' ) )
264 <?php
$this->renderPortals( $this->data
['sidebar'] ); ?
>
267 <div id
="footer" role
="contentinfo"<?php
$this->html( 'userlangattributes' ) ?
>>
269 foreach ( $this->getFooterLinks() as $category => $links ) {
275 foreach ( $links as $link ) {
291 <?php
$footericons = $this->getFooterIcons( "icononly" );
292 if ( count( $footericons ) > 0 ) { ?
>
293 <ul id
="footer-icons" class="noprint">
295 foreach ( $footericons as $blockName => $footerIcons ) {
298 echo htmlspecialchars( $blockName ); ?>ico">
300 foreach ( $footerIcons as $icon ) {
303 echo $this->getSkin()->makeFooterIcon( $icon );
317 <div style
="clear:both"></div
>
319 <?php
$this->printTrail(); ?
>
327 * Render a series of portals
329 * @param array $portals
331 protected function renderPortals( $portals ) {
332 // Force the rendering of the following portals
333 if ( !isset( $portals['SEARCH'] ) ) {
334 $portals['SEARCH'] = true;
336 if ( !isset( $portals['TOOLBOX'] ) ) {
337 $portals['TOOLBOX'] = true;
339 if ( !isset( $portals['LANGUAGES'] ) ) {
340 $portals['LANGUAGES'] = true;
343 foreach ( $portals as $name => $content ) {
344 if ( $content === false ) {
352 $this->renderPortal( 'tb', $this->getToolbox(), 'toolbox', 'SkinTemplateToolboxEnd' );
355 if ( $this->data
['language_urls'] !== false ) {
356 $this->renderPortal( 'lang', $this->data
['language_urls'], 'otherlanguages' );
360 $this->renderPortal( $name, $content );
367 * @param string $name
368 * @param array $content
369 * @param null|string $msg
370 * @param null|string|array $hook
372 protected function renderPortal( $name, $content, $msg = null, $hook = null ) {
373 if ( $msg === null ) {
376 $msgObj = wfMessage( $msg );
378 <div
class="portal" role
="navigation" id
='<?php
379 echo Sanitizer::escapeId( "p-$name" )
381 echo Linker
::tooltip( 'p-' . $name )
382 ?
> aria
-labelledby
='<?php echo Sanitizer::escapeId( "p-$name-label" ) ?>'>
384 $this->html( 'userlangattributes' )
386 echo Sanitizer::escapeId( "p-$name-label" )
388 echo htmlspecialchars( $msgObj->exists() ?
$msgObj->text() : $msg );
392 if ( is_array( $content ) ) { ?
>
395 foreach ( $content as $key => $val ) { ?
>
396 <?php
echo $this->makeListItem( $key, $val ); ?
>
400 if ( $hook !== null ) {
401 wfRunHooks( $hook, array( &$this, true ) );
408 echo $content; /* Allow raw HTML block to be defined by extensions */
411 $this->renderAfterPortlet( $name );
419 * Render one or more navigations elements by name, automatically reveresed
420 * when UI is in RTL mode
422 * @param array $elements
424 protected function renderNavigation( $elements ) {
425 global $wgVectorUseSimpleSearch;
427 // If only one element was given, wrap it in an array, allowing more
428 // flexible arguments
429 if ( !is_array( $elements ) ) {
430 $elements = array( $elements );
431 // If there's a series of elements, reverse them when in RTL mode
432 } elseif ( $this->data
['rtl'] ) {
433 $elements = array_reverse( $elements );
436 foreach ( $elements as $name => $element ) {
437 switch ( $element ) {
440 <div id
="p-namespaces" role
="navigation" class="vectorTabs<?php
441 if ( count( $this->data['namespace_urls'] ) == 0 ) {
442 echo ' emptyPortlet';
444 ?>" aria
-labelledby
="p-namespaces-label">
445 <h3 id
="p-namespaces-label"><?php
$this->msg( 'namespaces' ) ?
></h3
>
446 <ul
<?php
$this->html( 'userlangattributes' ) ?
>>
448 foreach ( $this->data
['namespace_urls'] as $link ) {
451 echo $link['attributes']
452 ?
>><span
><a href
="<?php
453 echo htmlspecialchars( $link['href'] )
457 echo htmlspecialchars( $link['text'] )
468 <div id
="p-variants" role
="navigation" class="vectorMenu<?php
469 if ( count( $this->data['variant_urls'] ) == 0 ) {
470 echo ' emptyPortlet';
472 ?>" aria
-labelledby
="p-variants-label">
473 <h3 id
="mw-vector-current-variant">
475 foreach ( $this->data
['variant_urls'] as $link ) { ?
>
477 if ( stripos( $link['attributes'], 'selected' ) !== false ) {
480 echo htmlspecialchars( $link['text'] )
489 <h3 id
="p-variants-label"><span
><?php
$this->msg( 'variants' ) ?
></span
><a href
="#"></a
></h3
>
493 foreach ( $this->data
['variant_urls'] as $link ) {
496 echo $link['attributes']
498 echo htmlspecialchars( $link['href'] )
500 echo htmlspecialchars( $link['lang'] )
502 echo htmlspecialchars( $link['hreflang'] )
506 echo htmlspecialchars( $link['text'] )
518 <div id
="p-views" role
="navigation" class="vectorTabs<?php
519 if ( count( $this->data['view_urls'] ) == 0 ) {
520 echo ' emptyPortlet';
522 ?>" aria
-labelledby
="p-views-label">
523 <h3 id
="p-views-label"><?php
$this->msg( 'views' ) ?
></h3
>
525 $this->html( 'userlangattributes' )
528 foreach ( $this->data
['view_urls'] as $link ) {
531 echo $link['attributes']
532 ?
>><span
><a href
="<?php
533 echo htmlspecialchars( $link['href'] )
537 // $link['text'] can be undefined - bug 27764
538 if ( array_key_exists( 'text', $link ) ) {
539 echo array_key_exists( 'img', $link )
540 ?
'<img src="' . $link['img'] . '" alt="' . $link['text'] . '" />'
541 : htmlspecialchars( $link['text'] );
553 <div id
="p-cactions" role
="navigation" class="vectorMenu<?php
554 if ( count( $this->data['action_urls'] ) == 0 ) {
555 echo ' emptyPortlet';
557 ?>" aria
-labelledby
="p-cactions-label">
558 <h3 id
="p-cactions-label"><span
><?php
$this->msg( 'actions' ) ?
></span
><a href
="#"></a
></h3
>
560 <ul
<?php
$this->html( 'userlangattributes' ) ?
>>
562 foreach ( $this->data
['action_urls'] as $link ) { ?
>
564 echo $link['attributes']
567 echo htmlspecialchars( $link['href'] )
569 echo $link['key'] ?
>><?php
echo htmlspecialchars( $link['text'] )
582 <div id
="p-personal" role
="navigation" class="<?php
583 if ( count( $this->data['personal_urls'] ) == 0 ) {
584 echo ' emptyPortlet';
586 ?>" aria
-labelledby
="p-personal-label">
587 <h3 id
="p-personal-label"><?php
$this->msg( 'personaltools' ) ?
></h3
>
588 <ul
<?php
$this->html( 'userlangattributes' ) ?
>>
590 $personalTools = $this->getPersonalTools();
591 foreach ( $personalTools as $key => $item ) {
592 echo $this->makeListItem( $key, $item );
601 <div id
="p-search" role
="search">
602 <h3
<?php
$this->html( 'userlangattributes' ) ?
>>
603 <label
for="searchInput"><?php
$this->msg( 'search' ) ?
></label
>
605 <form action
="<?php $this->text( 'wgScript' ) ?>" id
="searchform">
607 if ( $wgVectorUseSimpleSearch ) {
609 <div id
="simpleSearch">
618 echo $this->makeSearchInput( array( 'id' => 'searchInput' ) );
619 echo Html
::hidden( 'title', $this->get( 'searchtitle' ) );
620 // We construct two buttons (for 'go' and 'fulltext' search modes), but only one will be
621 // visible and actionable at a time (they are overlaid on top of each other in CSS).
622 // * Browsers will use the 'fulltext' one by default (as it's the first in tree-order), which
623 // is desirable when they are unable to show search suggestions (either due to being broken
624 // or having JavaScript turned off).
625 // * The mediawiki.searchSuggest module, after doing tests for the broken browsers, removes
626 // the 'fulltext' button and handles 'fulltext' search itself; this will reveal the 'go'
627 // button and cause it to be used.
628 echo $this->makeSearchButton(
630 array( 'id' => 'mw-searchButton', 'class' => 'searchButton mw-fallbackSearchButton' )
632 echo $this->makeSearchButton( 'go', array( 'id' => 'searchButton', 'class' => 'searchButton' ) );