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 $skinname = 'vector';
36 public $stylename = 'vector';
37 public $template = 'VectorTemplate';
39 protected static $bodyClasses = array( 'vector-animateLayout' );
42 * Initializes output page and sets up skin-specific parameters
43 * @param OutputPage $out Object to initialize
45 public function initPage( OutputPage
$out ) {
46 global $wgLocalStylePath;
48 parent
::initPage( $out );
50 // Append CSS which includes IE only behavior fixes for hover support -
51 // this is better than including this in a CSS file since it doesn't
52 // wait for the CSS file to load before fetching the HTC file.
53 $min = $this->getRequest()->getFuzzyBool( 'debug' ) ?
'' : '.min';
54 $out->addHeadItem( 'csshover',
55 '<!--[if lt IE 7]><style type="text/css">body{behavior:url("' .
56 htmlspecialchars( $wgLocalStylePath ) .
57 "/{$this->stylename}/csshover{$min}.htc\")}</style><![endif]-->"
60 $out->addModules( array( 'skins.vector.js' ) );
64 * Loads skin and user CSS files.
65 * @param OutputPage $out
67 function setupSkinUserCss( OutputPage
$out ) {
68 parent
::setupSkinUserCss( $out );
70 $styles = array( 'mediawiki.skinning.interface', 'skins.vector.styles' );
71 wfRunHooks( 'SkinVectorStyleModules', array( $this, &$styles ) );
72 $out->addModuleStyles( $styles );
76 * Adds classes to the body element.
78 * @param OutputPage $out
79 * @param array &$bodyAttrs Array of attributes that will be set on the body element
81 function addToBodyAttributes( $out, &$bodyAttrs ) {
82 if ( isset( $bodyAttrs['class'] ) && strlen( $bodyAttrs['class'] ) > 0 ) {
83 $bodyAttrs['class'] .= ' ' . implode( ' ', static::$bodyClasses );
85 $bodyAttrs['class'] = implode( ' ', static::$bodyClasses );
91 * QuickTemplate class for Vector skin
94 class VectorTemplate
extends BaseTemplate
{
98 * Outputs the entire contents of the (X)HTML page
100 public function execute() {
101 global $wgVectorUseIconWatch;
103 // Build additional attributes for navigation urls
104 $nav = $this->data
['content_navigation'];
106 if ( $wgVectorUseIconWatch ) {
107 $mode = $this->getSkin()->getUser()->isWatched( $this->getSkin()->getRelevantTitle() )
111 if ( isset( $nav['actions'][$mode] ) ) {
112 $nav['views'][$mode] = $nav['actions'][$mode];
113 $nav['views'][$mode]['class'] = rtrim( 'icon ' . $nav['views'][$mode]['class'], ' ' );
114 $nav['views'][$mode]['primary'] = true;
115 unset( $nav['actions'][$mode] );
120 foreach ( $nav as $section => $links ) {
121 foreach ( $links as $key => $link ) {
122 if ( $section == 'views' && !( isset( $link['primary'] ) && $link['primary'] ) ) {
123 $link['class'] = rtrim( 'collapsible ' . $link['class'], ' ' );
126 $xmlID = isset( $link['id'] ) ?
$link['id'] : 'ca-' . $xmlID;
127 $nav[$section][$key]['attributes'] =
128 ' id="' . Sanitizer
::escapeId( $xmlID ) . '"';
129 if ( $link['class'] ) {
130 $nav[$section][$key]['attributes'] .=
131 ' class="' . htmlspecialchars( $link['class'] ) . '"';
132 unset( $nav[$section][$key]['class'] );
134 if ( isset( $link['tooltiponly'] ) && $link['tooltiponly'] ) {
135 $nav[$section][$key]['key'] =
136 Linker
::tooltip( $xmlID );
138 $nav[$section][$key]['key'] =
139 Xml
::expandAttributes( Linker
::tooltipAndAccesskeyAttribs( $xmlID ) );
143 $this->data
['namespace_urls'] = $nav['namespaces'];
144 $this->data
['view_urls'] = $nav['views'];
145 $this->data
['action_urls'] = $nav['actions'];
146 $this->data
['variant_urls'] = $nav['variants'];
148 // Reverse horizontally rendered navigation elements
149 if ( $this->data
['rtl'] ) {
150 $this->data
['view_urls'] =
151 array_reverse( $this->data
['view_urls'] );
152 $this->data
['namespace_urls'] =
153 array_reverse( $this->data
['namespace_urls'] );
154 $this->data
['personal_urls'] =
155 array_reverse( $this->data
['personal_urls'] );
158 $this->html( 'headelement' );
160 <div id
="mw-page-base" class="noprint"></div
>
161 <div id
="mw-head-base" class="noprint"></div
>
162 <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" class="mw-body-content">
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
>
249 <?php
$this->renderNavigation( 'PERSONAL' ); ?
>
250 <div id
="left-navigation">
251 <?php
$this->renderNavigation( array( 'NAMESPACES', 'VARIANTS' ) ); ?
>
253 <div id
="right-navigation">
254 <?php
$this->renderNavigation( array( 'VIEWS', 'ACTIONS', 'SEARCH' ) ); ?
>
258 <div id
="p-logo" role
="banner"><a style
="background-image: url(<?php
259 $this->text( 'logopath' )
261 echo htmlspecialchars( $this->data['nav_urls']['mainpage']['href'] )
263 echo Xml
::expandAttributes( Linker
::tooltipAndAccesskeyAttribs( 'p-logo' ) )
265 <?php
$this->renderPortals( $this->data
['sidebar'] ); ?
>
268 <div id
="footer" role
="contentinfo"<?php
$this->html( 'userlangattributes' ) ?
>>
270 foreach ( $this->getFooterLinks() as $category => $links ) {
276 foreach ( $links as $link ) {
292 <?php
$footericons = $this->getFooterIcons( "icononly" );
293 if ( count( $footericons ) > 0 ) {
295 <ul id
="footer-icons" class="noprint">
297 foreach ( $footericons as $blockName => $footerIcons ) {
300 echo htmlspecialchars( $blockName ); ?>ico">
302 foreach ( $footerIcons as $icon ) {
305 echo $this->getSkin()->makeFooterIcon( $icon );
319 <div style
="clear:both"></div
>
321 <?php
$this->printTrail(); ?
>
329 * Render a series of portals
331 * @param array $portals
333 protected function renderPortals( $portals ) {
334 // Force the rendering of the following portals
335 if ( !isset( $portals['SEARCH'] ) ) {
336 $portals['SEARCH'] = true;
338 if ( !isset( $portals['TOOLBOX'] ) ) {
339 $portals['TOOLBOX'] = true;
341 if ( !isset( $portals['LANGUAGES'] ) ) {
342 $portals['LANGUAGES'] = true;
345 foreach ( $portals as $name => $content ) {
346 if ( $content === false ) {
354 $this->renderPortal( 'tb', $this->getToolbox(), 'toolbox', 'SkinTemplateToolboxEnd' );
357 if ( $this->data
['language_urls'] !== false ) {
358 $this->renderPortal( 'lang', $this->data
['language_urls'], 'otherlanguages' );
362 $this->renderPortal( $name, $content );
369 * @param string $name
370 * @param array $content
371 * @param null|string $msg
372 * @param null|string|array $hook
374 protected function renderPortal( $name, $content, $msg = null, $hook = null ) {
375 if ( $msg === null ) {
378 $msgObj = wfMessage( $msg );
380 <div
class="portal" role
="navigation" id
='<?php
381 echo Sanitizer::escapeId( "p-$name" )
383 echo Linker
::tooltip( 'p-' . $name )
384 ?
> aria
-labelledby
='<?php echo Sanitizer::escapeId( "p-$name-label" ) ?>'>
386 $this->html( 'userlangattributes' )
388 echo Sanitizer::escapeId( "p-$name-label" )
390 echo htmlspecialchars( $msgObj->exists() ?
$msgObj->text() : $msg );
395 if ( is_array( $content ) ) {
399 foreach ( $content as $key => $val ) {
401 <?php
echo $this->makeListItem( $key, $val ); ?
>
405 if ( $hook !== null ) {
406 wfRunHooks( $hook, array( &$this, true ) );
414 echo $content; /* Allow raw HTML block to be defined by extensions */
417 $this->renderAfterPortlet( $name );
425 * Render one or more navigations elements by name, automatically reveresed
426 * when UI is in RTL mode
428 * @param array $elements
430 protected function renderNavigation( $elements ) {
431 global $wgVectorUseSimpleSearch;
433 // If only one element was given, wrap it in an array, allowing more
434 // flexible arguments
435 if ( !is_array( $elements ) ) {
436 $elements = array( $elements );
437 // If there's a series of elements, reverse them when in RTL mode
438 } elseif ( $this->data
['rtl'] ) {
439 $elements = array_reverse( $elements );
442 foreach ( $elements as $name => $element ) {
443 switch ( $element ) {
446 <div id
="p-namespaces" role
="navigation" class="vectorTabs<?php
447 if ( count( $this->data['namespace_urls'] ) == 0 ) {
448 echo ' emptyPortlet';
450 ?>" aria
-labelledby
="p-namespaces-label">
451 <h3 id
="p-namespaces-label"><?php
$this->msg( 'namespaces' ) ?
></h3
>
452 <ul
<?php
$this->html( 'userlangattributes' ) ?
>>
454 foreach ( $this->data
['namespace_urls'] as $link ) {
457 echo $link['attributes']
458 ?
>><span
><a href
="<?php
459 echo htmlspecialchars( $link['href'] )
463 echo htmlspecialchars( $link['text'] )
474 <div id
="p-variants" role
="navigation" class="vectorMenu<?php
475 if ( count( $this->data['variant_urls'] ) == 0 ) {
476 echo ' emptyPortlet';
478 ?>" aria
-labelledby
="p-variants-label">
479 <h3 id
="mw-vector-current-variant">
481 foreach ( $this->data
['variant_urls'] as $link ) {
484 if ( stripos( $link['attributes'], 'selected' ) !== false ) {
487 echo htmlspecialchars( $link['text'] )
497 <h3 id
="p-variants-label"><span
><?php
$this->msg( 'variants' ) ?
></span
><a href
="#"></a
></h3
>
502 foreach ( $this->data
['variant_urls'] as $link ) {
505 echo $link['attributes']
507 echo htmlspecialchars( $link['href'] )
509 echo htmlspecialchars( $link['lang'] )
511 echo htmlspecialchars( $link['hreflang'] )
515 echo htmlspecialchars( $link['text'] )
527 <div id
="p-views" role
="navigation" class="vectorTabs<?php
528 if ( count( $this->data['view_urls'] ) == 0 ) {
529 echo ' emptyPortlet';
531 ?>" aria
-labelledby
="p-views-label">
532 <h3 id
="p-views-label"><?php
$this->msg( 'views' ) ?
></h3
>
534 $this->html( 'userlangattributes' )
537 foreach ( $this->data
['view_urls'] as $link ) {
540 echo $link['attributes']
541 ?
>><span
><a href
="<?php
542 echo htmlspecialchars( $link['href'] )
546 // $link['text'] can be undefined - bug 27764
547 if ( array_key_exists( 'text', $link ) ) {
548 echo array_key_exists( 'img', $link )
549 ?
'<img src="' . $link['img'] . '" alt="' . $link['text'] . '" />'
550 : htmlspecialchars( $link['text'] );
562 <div id
="p-cactions" role
="navigation" class="vectorMenu<?php
563 if ( count( $this->data['action_urls'] ) == 0 ) {
564 echo ' emptyPortlet';
566 ?>" aria
-labelledby
="p-cactions-label">
567 <h3 id
="p-cactions-label"><span
><?php
$this->msg( 'vector-more-actions' ) ?
></span
><a href
="#"></a
></h3
>
570 <ul
<?php
$this->html( 'userlangattributes' ) ?
>>
572 foreach ( $this->data
['action_urls'] as $link ) {
575 echo $link['attributes']
578 echo htmlspecialchars( $link['href'] )
580 echo $link['key'] ?
>><?php
echo htmlspecialchars( $link['text'] )
593 <div id
="p-personal" role
="navigation" class="<?php
594 if ( count( $this->data['personal_urls'] ) == 0 ) {
595 echo ' emptyPortlet';
597 ?>" aria
-labelledby
="p-personal-label">
598 <h3 id
="p-personal-label"><?php
$this->msg( 'personaltools' ) ?
></h3
>
599 <ul
<?php
$this->html( 'userlangattributes' ) ?
>>
601 $personalTools = $this->getPersonalTools();
602 foreach ( $personalTools as $key => $item ) {
603 echo $this->makeListItem( $key, $item );
612 <div id
="p-search" role
="search">
613 <h3
<?php
$this->html( 'userlangattributes' ) ?
>>
614 <label
for="searchInput"><?php
$this->msg( 'search' ) ?
></label
>
617 <form action
="<?php $this->text( 'wgScript' ) ?>" id
="searchform">
619 if ($wgVectorUseSimpleSearch) {
621 <div id
="simpleSearch">
630 echo $this->makeSearchInput( array( 'id' => 'searchInput' ) );
631 echo Html
::hidden( 'title', $this->get( 'searchtitle' ) );
632 // We construct two buttons (for 'go' and 'fulltext' search modes),
633 // but only one will be visible and actionable at a time (they are
634 // overlaid on top of each other in CSS).
635 // * Browsers will use the 'fulltext' one by default (as it's the
636 // first in tree-order), which is desirable when they are unable
637 // to show search suggestions (either due to being broken or
638 // having JavaScript turned off).
639 // * The mediawiki.searchSuggest module, after doing tests for the
640 // broken browsers, removes the 'fulltext' button and handles
641 // 'fulltext' search itself; this will reveal the 'go' button and
642 // cause it to be used.
643 echo $this->makeSearchButton(
645 array( 'id' => 'mw-searchButton', 'class' => 'searchButton mw-fallbackSearchButton' )
647 echo $this->makeSearchButton(
649 array( 'id' => 'searchButton', 'class' => 'searchButton' )