3 * Vector - Modern version of MonoBook with fresh look and many usability
11 if( !defined( 'MEDIAWIKI' ) ) {
16 * SkinTemplate class for Vector skin
19 class SkinVector
extends SkinTemplate
{
21 protected static $bodyClasses = array( 'vector-animateLayout' );
23 var $skinname = 'vector', $stylename = 'vector',
24 $template = 'VectorTemplate', $useHeadElement = true;
27 * Initializes output page and sets up skin-specific parameters
28 * @param $out OutputPage object to initialize
30 public function initPage( OutputPage
$out ) {
31 global $wgLocalStylePath;
33 parent
::initPage( $out );
35 // Append CSS which includes IE only behavior fixes for hover support -
36 // this is better than including this in a CSS fille since it doesn't
37 // wait for the CSS file to load before fetching the HTC file.
38 $min = $this->getRequest()->getFuzzyBool( 'debug' ) ?
'' : '.min';
39 $out->addHeadItem( 'csshover',
40 '<!--[if lt IE 7]><style type="text/css">body{behavior:url("' .
41 htmlspecialchars( $wgLocalStylePath ) .
42 "/{$this->stylename}/csshover{$min}.htc\")}</style><![endif]-->"
45 $out->addModuleScripts( 'skins.vector' );
49 * Load skin and user CSS files in the correct order
51 * @param $out OutputPage object
53 function setupSkinUserCss( OutputPage
$out ){
54 parent
::setupSkinUserCss( $out );
55 $out->addModuleStyles( 'skins.vector' );
59 * Adds classes to the body element.
61 * @param $out OutputPage object
62 * @param &$bodyAttrs Array of attributes that will be set on the body element
64 function addToBodyAttributes( $out, &$bodyAttrs ) {
65 if ( isset( $bodyAttrs['class'] ) && strlen( $bodyAttrs['class'] ) > 0 ) {
66 $bodyAttrs['class'] .= ' ' . implode( ' ', static::$bodyClasses );
68 $bodyAttrs['class'] = implode( ' ', static::$bodyClasses );
74 * QuickTemplate class for Vector skin
77 class VectorTemplate
extends BaseTemplate
{
82 * Outputs the entire contents of the (X)HTML page
84 public function execute() {
85 global $wgVectorUseIconWatch;
87 // Build additional attributes for navigation urls
88 $nav = $this->data
['content_navigation'];
90 if ( $wgVectorUseIconWatch ) {
91 $mode = $this->getSkin()->getRelevantTitle()->userIsWatching() ?
'unwatch' : 'watch';
92 if ( isset( $nav['actions'][$mode] ) ) {
93 $nav['views'][$mode] = $nav['actions'][$mode];
94 $nav['views'][$mode]['class'] = rtrim( 'icon ' . $nav['views'][$mode]['class'], ' ' );
95 $nav['views'][$mode]['primary'] = true;
96 unset( $nav['actions'][$mode] );
101 foreach ( $nav as $section => $links ) {
102 foreach ( $links as $key => $link ) {
103 if ( $section == 'views' && !( isset( $link['primary'] ) && $link['primary'] ) ) {
104 $link['class'] = rtrim( 'collapsible ' . $link['class'], ' ' );
107 $xmlID = isset( $link['id'] ) ?
$link['id'] : 'ca-' . $xmlID;
108 $nav[$section][$key]['attributes'] =
109 ' id="' . Sanitizer
::escapeId( $xmlID ) . '"';
110 if ( $link['class'] ) {
111 $nav[$section][$key]['attributes'] .=
112 ' class="' . htmlspecialchars( $link['class'] ) . '"';
113 unset( $nav[$section][$key]['class'] );
115 if ( isset( $link['tooltiponly'] ) && $link['tooltiponly'] ) {
116 $nav[$section][$key]['key'] =
117 Linker
::tooltip( $xmlID );
119 $nav[$section][$key]['key'] =
120 Xml
::expandAttributes( Linker
::tooltipAndAccesskeyAttribs( $xmlID ) );
124 $this->data
['namespace_urls'] = $nav['namespaces'];
125 $this->data
['view_urls'] = $nav['views'];
126 $this->data
['action_urls'] = $nav['actions'];
127 $this->data
['variant_urls'] = $nav['variants'];
129 // Reverse horizontally rendered navigation elements
130 if ( $this->data
['rtl'] ) {
131 $this->data
['view_urls'] =
132 array_reverse( $this->data
['view_urls'] );
133 $this->data
['namespace_urls'] =
134 array_reverse( $this->data
['namespace_urls'] );
135 $this->data
['personal_urls'] =
136 array_reverse( $this->data
['personal_urls'] );
139 $this->html( 'headelement' );
141 <div id
="mw-page-base" class="noprint"></div
>
142 <div id
="mw-head-base" class="noprint"></div
>
144 <div id
="content" class="mw-body">
146 <div id
="mw-js-message" style
="display:none;"<?php
$this->html( 'userlangattributes' ) ?
>></div
>
147 <?php
if ( $this->data
['sitenotice'] ): ?
>
149 <div id
="siteNotice"><?php
$this->html( 'sitenotice' ) ?
></div
>
152 <!-- firstHeading
-->
153 <h1 id
="firstHeading" class="firstHeading"><span dir
="auto"><?php
$this->html( 'title' ) ?
></span
></h1
>
154 <!-- /firstHeading
-->
156 <div id
="bodyContent">
157 <?php
if ( $this->data
['isarticle'] ): ?
>
159 <div id
="siteSub"><?php
$this->msg( 'tagline' ) ?
></div
>
163 <div id
="contentSub"<?php
$this->html( 'userlangattributes' ) ?
>><?php
$this->html( 'subtitle' ) ?
></div
>
165 <?php
if ( $this->data
['undelete'] ): ?
>
167 <div id
="contentSub2"><?php
$this->html( 'undelete' ) ?
></div
>
170 <?php
if( $this->data
['newtalk'] ): ?
>
172 <div
class="usermessage"><?php
$this->html( 'newtalk' ) ?
></div
>
175 <?php
if ( $this->data
['showjumplinks'] ): ?
>
177 <div id
="jump-to-nav" class="mw-jump">
178 <?php
$this->msg( 'jumpto' ) ?
> <a href
="#mw-head"><?php
$this->msg( 'jumptonavigation' ) ?
></a
>,
179 <a href
="#p-search"><?php
$this->msg( 'jumptosearch' ) ?
></a
>
184 <?php
$this->html( 'bodycontent' ) ?
>
185 <!-- /bodycontent
-->
186 <?php
if ( $this->data
['printfooter'] ): ?
>
188 <div
class="printfooter">
189 <?php
$this->html( 'printfooter' ); ?
>
191 <!-- /printfooter
-->
193 <?php
if ( $this->data
['catlinks'] ): ?
>
195 <?php
$this->html( 'catlinks' ); ?
>
198 <?php
if ( $this->data
['dataAfterContent'] ): ?
>
199 <!-- dataAfterContent
-->
200 <?php
$this->html( 'dataAfterContent' ); ?
>
201 <!-- /dataAfterContent
-->
203 <div
class="visualClear"></div
>
205 <?php
$this->html( 'debughtml' ); ?
>
208 <!-- /bodyContent
-->
212 <div id
="mw-head" class="noprint">
213 <?php
$this->renderNavigation( 'PERSONAL' ); ?
>
214 <div id
="left-navigation">
215 <?php
$this->renderNavigation( array( 'NAMESPACES', 'VARIANTS' ) ); ?
>
217 <div id
="right-navigation">
218 <?php
$this->renderNavigation( array( 'VIEWS', 'ACTIONS', 'SEARCH' ) ); ?
>
223 <div id
="mw-panel" class="noprint">
225 <div id
="p-logo"><a style
="background-image: url(<?php $this->text( 'logopath' ) ?>);" href
="<?php echo htmlspecialchars( $this->data['nav_urls']['mainpage']['href'] ) ?>" <?php
echo Xml
::expandAttributes( Linker
::tooltipAndAccesskeyAttribs( 'p-logo' ) ) ?
>></a
></div
>
227 <?php
$this->renderPortals( $this->data
['sidebar'] ); ?
>
231 <div id
="footer"<?php
$this->html( 'userlangattributes' ) ?
>>
232 <?php
foreach( $this->getFooterLinks() as $category => $links ): ?
>
233 <ul id
="footer-<?php echo $category ?>">
234 <?php
foreach( $links as $link ): ?
>
235 <li id
="footer-<?php echo $category ?>-<?php echo $link ?>"><?php
$this->html( $link ) ?
></li
>
239 <?php
$footericons = $this->getFooterIcons("icononly");
240 if ( count( $footericons ) > 0 ): ?
>
241 <ul id
="footer-icons" class="noprint">
242 <?php
foreach ( $footericons as $blockName => $footerIcons ): ?
>
243 <li id
="footer-<?php echo htmlspecialchars( $blockName ); ?>ico">
244 <?php
foreach ( $footerIcons as $icon ): ?
>
245 <?php
echo $this->getSkin()->makeFooterIcon( $icon ); ?
>
252 <div style
="clear:both"></div
>
255 <?php
$this->printTrail(); ?
>
263 * Render a series of portals
265 * @param $portals array
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 )
283 echo "\n<!-- {$name} -->\n";
288 $this->renderPortal( 'tb', $this->getToolbox(), 'toolbox', 'SkinTemplateToolboxEnd' );
291 if ( $this->data
['language_urls'] ) {
292 $this->renderPortal( 'lang', $this->data
['language_urls'], 'otherlanguages' );
296 $this->renderPortal( $name, $content );
299 echo "\n<!-- /{$name} -->\n";
304 * @param $name string
305 * @param $content array
306 * @param $msg null|string
307 * @param $hook null|string|array
309 protected function renderPortal( $name, $content, $msg = null, $hook = null ) {
310 if ( $msg === null ) {
314 <div
class="portal" id
='<?php echo Sanitizer::escapeId( "p-$name" ) ?>'<?php
echo Linker
::tooltip( 'p-' . $name ) ?
>>
315 <h5
<?php
$this->html( 'userlangattributes' ) ?
>><?php
$msgObj = wfMessage( $msg ); echo htmlspecialchars( $msgObj->exists() ?
$msgObj->text() : $msg ); ?
></h5
>
318 if ( is_array( $content ) ): ?
>
321 foreach( $content as $key => $val ): ?
>
322 <?php
echo $this->makeListItem( $key, $val ); ?
>
326 if ( $hook !== null ) {
327 wfRunHooks( $hook, array( &$this, true ) );
333 <?php
echo $content; /* Allow raw HTML block to be defined by extensions */ ?
>
342 * Render one or more navigations elements by name, automatically reveresed
343 * when UI is in RTL mode
345 * @param $elements array
347 protected function renderNavigation( $elements ) {
348 global $wgVectorUseSimpleSearch;
350 // If only one element was given, wrap it in an array, allowing more
351 // flexible arguments
352 if ( !is_array( $elements ) ) {
353 $elements = array( $elements );
354 // If there's a series of elements, reverse them when in RTL mode
355 } elseif ( $this->data
['rtl'] ) {
356 $elements = array_reverse( $elements );
359 foreach ( $elements as $name => $element ) {
360 echo "\n<!-- {$name} -->\n";
361 switch ( $element ) {
364 <div id
="p-namespaces" class="vectorTabs<?php if ( count( $this->data['namespace_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
365 <h5
><?php
$this->msg( 'namespaces' ) ?
></h5
>
366 <ul
<?php
$this->html( 'userlangattributes' ) ?
>>
367 <?php
foreach ( $this->data
['namespace_urls'] as $link ): ?
>
368 <li
<?php
echo $link['attributes'] ?
>><span
><a href
="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php
echo $link['key'] ?
>><?php
echo htmlspecialchars( $link['text'] ) ?
></a
></span
></li
>
376 <div id
="p-variants" class="vectorMenu<?php if ( count( $this->data['variant_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
378 <?php
foreach ( $this->data
['variant_urls'] as $link ): ?
>
379 <?php
if ( stripos( $link['attributes'], 'selected' ) !== false ): ?
>
380 <?php
echo htmlspecialchars( $link['text'] ) ?
>
384 <h5
><span
><?php
$this->msg( 'variants' ) ?
></span
><a href
="#"></a
></h5
>
387 <?php
foreach ( $this->data
['variant_urls'] as $link ): ?
>
388 <li
<?php
echo $link['attributes'] ?
>><a href
="<?php echo htmlspecialchars( $link['href'] ) ?>" lang
="<?php echo htmlspecialchars( $link['lang'] ) ?>" hreflang
="<?php echo htmlspecialchars( $link['hreflang'] ) ?>" <?php
echo $link['key'] ?
>><?php
echo htmlspecialchars( $link['text'] ) ?
></a
></li
>
397 <div id
="p-views" class="vectorTabs<?php if ( count( $this->data['view_urls'] ) == 0 ) { echo ' emptyPortlet'; } ?>">
398 <h5
><?php
$this->msg('views') ?
></h5
>
399 <ul
<?php
$this->html('userlangattributes') ?
>>
400 <?php
foreach ( $this->data
['view_urls'] as $link ): ?
>
401 <li
<?php
echo $link['attributes'] ?
>><span
><a href
="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php
echo $link['key'] ?
>><?php
402 // $link['text'] can be undefined - bug 27764
403 if ( array_key_exists( 'text', $link ) ) {
404 echo array_key_exists( 'img', $link ) ?
'<img src="' . $link['img'] . '" alt="' . $link['text'] . '" />' : htmlspecialchars( $link['text'] );
414 <div id
="p-cactions" class="vectorMenu<?php if ( count( $this->data['action_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
415 <h5
><span
><?php
$this->msg( 'actions' ) ?
></span
><a href
="#"></a
></h5
>
417 <ul
<?php
$this->html( 'userlangattributes' ) ?
>>
418 <?php
foreach ( $this->data
['action_urls'] as $link ): ?
>
419 <li
<?php
echo $link['attributes'] ?
>><a href
="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php
echo $link['key'] ?
>><?php
echo htmlspecialchars( $link['text'] ) ?
></a
></li
>
428 <div id
="p-personal" class="<?php if ( count( $this->data['personal_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
429 <h5
><?php
$this->msg( 'personaltools' ) ?
></h5
>
430 <ul
<?php
$this->html( 'userlangattributes' ) ?
>>
431 <?php
foreach( $this->getPersonalTools() as $key => $item ) { ?
>
432 <?php
echo $this->makeListItem( $key, $item ); ?
>
442 <h5
<?php
$this->html( 'userlangattributes' ) ?
>><label
for="searchInput"><?php
$this->msg( 'search' ) ?
></label
></h5
>
443 <form action
="<?php $this->text( 'wgScript' ) ?>" id
="searchform">
444 <?php
if ( $wgVectorUseSimpleSearch && $this->getSkin()->getUser()->getOption( 'vector-simplesearch' ) ): ?
>
445 <div id
="simpleSearch">
446 <?php
if ( $this->data
['rtl'] ): ?
>
447 <?php
echo $this->makeSearchButton( 'image', array( 'id' => 'searchButton', 'src' => $this->getSkin()->getSkinStylePath( 'images/search-rtl.png' ), 'width' => '12', 'height' => '13' ) ); ?
>
449 <?php
echo $this->makeSearchInput( array( 'id' => 'searchInput', 'type' => 'text' ) ); ?
>
450 <?php
if ( !$this->data
['rtl'] ): ?
>
451 <?php
echo $this->makeSearchButton( 'image', array( 'id' => 'searchButton', 'src' => $this->getSkin()->getSkinStylePath( 'images/search-ltr.png' ), 'width' => '12', 'height' => '13' ) ); ?
>
455 <?php
echo $this->makeSearchInput( array( 'id' => 'searchInput' ) ); ?
>
456 <?php
echo $this->makeSearchButton( 'go', array( 'id' => 'searchGoButton', 'class' => 'searchButton' ) ); ?
>
457 <?php
echo $this->makeSearchButton( 'fulltext', array( 'id' => 'mw-searchButton', 'class' => 'searchButton' ) ); ?
>
459 <input type
='hidden' name
="title" value
="<?php $this->text( 'searchtitle' ) ?>"/>
467 echo "\n<!-- /{$name} -->\n";