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 var $skinname = 'vector', $stylename = 'vector',
22 $template = 'VectorTemplate', $useHeadElement = true;
25 * Initializes output page and sets up skin-specific parameters
26 * @param $out OutputPage object to initialize
28 public function initPage( OutputPage
$out ) {
29 global $wgLocalStylePath, $wgRequest;
31 parent
::initPage( $out );
33 // Append CSS which includes IE only behavior fixes for hover support -
34 // this is better than including this in a CSS fille since it doesn't
35 // wait for the CSS file to load before fetching the HTC file.
36 $min = $wgRequest->getFuzzyBool( 'debug' ) ?
'' : '.min';
37 $out->addHeadItem( 'csshover',
38 '<!--[if lt IE 7]><style type="text/css">body{behavior:url("' .
39 htmlspecialchars( $wgLocalStylePath ) .
40 "/{$this->stylename}/csshover{$min}.htc\")}</style><![endif]-->"
43 $out->addModuleScripts( 'skins.vector' );
47 * Load skin and user CSS files in the correct order
49 * @param $out OutputPage object
51 function setupSkinUserCss( OutputPage
$out ){
52 parent
::setupSkinUserCss( $out );
53 $out->addModuleStyles( 'skins.vector' );
58 * QuickTemplate class for Vector skin
61 class VectorTemplate
extends BaseTemplate
{
66 * @var Skin Cached skin object
73 * Outputs the entire contents of the (X)HTML page
75 public function execute() {
76 global $wgLang, $wgVectorUseIconWatch;
78 $this->skin
= $this->data
['skin'];
80 // Build additional attributes for navigation urls
81 //$nav = $this->skin->buildNavigationUrls();
82 $nav = $this->data
['content_navigation'];
84 if ( $wgVectorUseIconWatch ) {
85 $mode = $this->skin
->getTitle()->userIsWatching() ?
'unwatch' : 'watch';
86 if ( isset( $nav['actions'][$mode] ) ) {
87 $nav['views'][$mode] = $nav['actions'][$mode];
88 $nav['views'][$mode]['class'] = rtrim( 'icon ' . $nav['views'][$mode]['class'], ' ' );
89 $nav['views'][$mode]['primary'] = true;
90 unset( $nav['actions'][$mode] );
95 foreach ( $nav as $section => $links ) {
96 foreach ( $links as $key => $link ) {
97 if ( $section == 'views' && !( isset( $link['primary'] ) && $link['primary'] ) ) {
98 $link['class'] = rtrim( 'collapsible ' . $link['class'], ' ' );
101 $xmlID = isset( $link['id'] ) ?
$link['id'] : 'ca-' . $xmlID;
102 $nav[$section][$key]['attributes'] =
103 ' id="' . Sanitizer
::escapeId( $xmlID ) . '"';
104 if ( $link['class'] ) {
105 $nav[$section][$key]['attributes'] .=
106 ' class="' . htmlspecialchars( $link['class'] ) . '"';
107 unset( $nav[$section][$key]['class'] );
109 if ( isset( $link['tooltiponly'] ) && $link['tooltiponly'] ) {
110 $nav[$section][$key]['key'] =
111 Linker
::titleAttrib( $xmlID );
113 $nav[$section][$key]['key'] =
114 Xml
::expandAttributes( Linker
::tooltipAndAccesskeyAttribs( $xmlID ) );
118 $this->data
['namespace_urls'] = $nav['namespaces'];
119 $this->data
['view_urls'] = $nav['views'];
120 $this->data
['action_urls'] = $nav['actions'];
121 $this->data
['variant_urls'] = $nav['variants'];
123 // Reverse horizontally rendered navigation elements
124 if ( $wgLang->isRTL() ) {
125 $this->data
['view_urls'] =
126 array_reverse( $this->data
['view_urls'] );
127 $this->data
['namespace_urls'] =
128 array_reverse( $this->data
['namespace_urls'] );
129 $this->data
['personal_urls'] =
130 array_reverse( $this->data
['personal_urls'] );
133 $this->html( 'headelement' );
135 <div id
="mw-page-base" class="noprint"></div
>
136 <div id
="mw-head-base" class="noprint"></div
>
138 <div id
="content"<?php
$this->html( 'specialpageattributes' ) ?
>>
140 <div id
="mw-js-message" style
="display:none;"<?php
$this->html( 'userlangattributes' ) ?
>></div
>
141 <?php
if ( $this->data
['sitenotice'] ): ?
>
143 <div id
="siteNotice"><?php
$this->html( 'sitenotice' ) ?
></div
>
146 <!-- firstHeading
-->
147 <h1 id
="firstHeading" class="firstHeading"><?php
$this->html( 'title' ) ?
></h1
>
148 <!-- /firstHeading
-->
150 <div id
="bodyContent">
151 <?php
if ( $this->data
['isarticle'] ): ?
>
153 <div id
="siteSub"><?php
$this->msg( 'tagline' ) ?
></div
>
157 <div id
="contentSub"<?php
$this->html( 'userlangattributes' ) ?
>><?php
$this->html( 'subtitle' ) ?
></div
>
159 <?php
if ( $this->data
['undelete'] ): ?
>
161 <div id
="contentSub2"><?php
$this->html( 'undelete' ) ?
></div
>
164 <?php
if( $this->data
['newtalk'] ): ?
>
166 <div
class="usermessage"><?php
$this->html( 'newtalk' ) ?
></div
>
169 <?php
if ( $this->data
['showjumplinks'] ): ?
>
171 <div id
="jump-to-nav">
172 <?php
$this->msg( 'jumpto' ) ?
> <a href
="#mw-head"><?php
$this->msg( 'jumptonavigation' ) ?
></a
>,
173 <a href
="#p-search"><?php
$this->msg( 'jumptosearch' ) ?
></a
>
178 <?php
$this->html( 'bodytext' ) ?
>
180 <?php
if ( $this->data
['printfooter'] ): ?
>
182 <div
class="printfooter">
183 <?php
$this->html( 'printfooter' ); ?
>
185 <!-- /printfooter
-->
187 <?php
if ( $this->data
['catlinks'] ): ?
>
189 <?php
$this->html( 'catlinks' ); ?
>
192 <?php
if ( $this->data
['dataAfterContent'] ): ?
>
193 <!-- dataAfterContent
-->
194 <?php
$this->html( 'dataAfterContent' ); ?
>
195 <!-- /dataAfterContent
-->
197 <div
class="visualClear"></div
>
199 <?php
$this->html( 'debughtml' ); ?
>
202 <!-- /bodyContent
-->
206 <div id
="mw-head" class="noprint">
207 <?php
$this->renderNavigation( 'PERSONAL' ); ?
>
208 <div id
="left-navigation">
209 <?php
$this->renderNavigation( array( 'NAMESPACES', 'VARIANTS' ) ); ?
>
211 <div id
="right-navigation">
212 <?php
$this->renderNavigation( array( 'VIEWS', 'ACTIONS', 'SEARCH' ) ); ?
>
217 <div id
="mw-panel" class="noprint">
219 <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
>
221 <?php
$this->renderPortals( $this->data
['sidebar'] ); ?
>
225 <div id
="footer"<?php
$this->html( 'userlangattributes' ) ?
>>
226 <?php
foreach( $this->getFooterLinks() as $category => $links ): ?
>
227 <ul id
="footer-<?php echo $category ?>">
228 <?php
foreach( $links as $link ): ?
>
229 <li id
="footer-<?php echo $category ?>-<?php echo $link ?>"><?php
$this->html( $link ) ?
></li
>
233 <?php
$footericons = $this->getFooterIcons("icononly");
234 if ( count( $footericons ) > 0 ): ?
>
235 <ul id
="footer-icons" class="noprint">
236 <?php
foreach ( $footericons as $blockName => $footerIcons ): ?
>
237 <li id
="footer-<?php echo htmlspecialchars( $blockName ); ?>ico">
238 <?php
foreach ( $footerIcons as $icon ): ?
>
239 <?php
echo $this->skin
->makeFooterIcon( $icon ); ?
>
246 <div style
="clear:both"></div
>
250 <script type
="<?php $this->text( 'jsmimetype' ) ?>"> if ( window
.isMSIE55
) fixalpha(); </script
>
252 <?php
$this->printTrail(); ?
>
260 * Render a series of portals
262 * @params $portals array
264 private function renderPortals( $portals ) {
265 // Force the rendering of the following portals
266 if ( !isset( $portals['SEARCH'] ) ) {
267 $portals['SEARCH'] = true;
269 if ( !isset( $portals['TOOLBOX'] ) ) {
270 $portals['TOOLBOX'] = true;
272 if ( !isset( $portals['LANGUAGES'] ) ) {
273 $portals['LANGUAGES'] = true;
276 foreach ( $portals as $name => $content ) {
277 echo "\n<!-- {$name} -->\n";
282 $this->renderPortal( 'tb', $this->getToolbox(), 'toolbox', 'SkinTemplateToolboxEnd' );
285 if ( $this->data
['language_urls'] ) {
286 $this->renderPortal( 'lang', $this->data
['language_urls'], 'otherlanguages' );
290 $this->renderPortal( $name, $content );
293 echo "\n<!-- /{$name} -->\n";
297 private function renderPortal( $name, $content, $msg = null, $hook = null ) {
298 if ( !isset( $msg ) ) {
302 <div
class="portal" id
='<?php echo Sanitizer::escapeId( "p-$name" ) ?>'<?php
echo Linker
::titleAttrib( 'p-' . $name ) ?
>>
303 <h5
<?php
$this->html( 'userlangattributes' ) ?
>><?php
$msgObj = wfMessage( $msg ); echo htmlspecialchars( $msgObj->exists() ?
$msgObj->text() : $msg ); ?
></h5
>
306 if ( is_array( $content ) ): ?
>
309 foreach( $content as $key => $val ): ?
>
310 <?php
echo $this->makeListItem( $key, $val ); ?
>
314 if ( isset( $hook ) ) {
315 wfRunHooks( $hook, array( &$this ) );
321 <?php
echo $content; /* Allow raw HTML block to be defined by extensions */ ?
>
330 * Render one or more navigations elements by name, automatically reveresed
331 * when UI is in RTL mode
333 * @param $elements array
335 private function renderNavigation( $elements ) {
336 global $wgVectorUseSimpleSearch, $wgVectorShowVariantName, $wgUser;
338 // If only one element was given, wrap it in an array, allowing more
339 // flexible arguments
340 if ( !is_array( $elements ) ) {
341 $elements = array( $elements );
342 // If there's a series of elements, reverse them when in RTL mode
343 } elseif ( wfUILang()->isRTL() ) {
344 $elements = array_reverse( $elements );
347 foreach ( $elements as $name => $element ) {
348 echo "\n<!-- {$name} -->\n";
349 switch ( $element ) {
352 <div id
="p-namespaces" class="vectorTabs<?php if ( count( $this->data['namespace_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
353 <h5
><?php
$this->msg( 'namespaces' ) ?
></h5
>
354 <ul
<?php
$this->html( 'userlangattributes' ) ?
>>
355 <?php
foreach ( $this->data
['namespace_urls'] as $link ): ?
>
356 <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
>
364 <div id
="p-variants" class="vectorMenu<?php if ( count( $this->data['variant_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
365 <?php
if ( $wgVectorShowVariantName ): ?
>
367 <?php
foreach ( $this->data
['variant_urls'] as $link ): ?
>
368 <?php
if ( stripos( $link['attributes'], 'selected' ) !== false ): ?
>
369 <?php
echo htmlspecialchars( $link['text'] ) ?
>
374 <h5
><span
><?php
$this->msg( 'variants' ) ?
></span
><a href
="#"></a
></h5
>
376 <ul
<?php
$this->html( 'userlangattributes' ) ?
>>
377 <?php
foreach ( $this->data
['variant_urls'] as $link ): ?
>
378 <li
<?php
echo $link['attributes'] ?
>><a href
="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php
echo $link['key'] ?
>><?php
echo htmlspecialchars( $link['text'] ) ?
></a
></li
>
387 <div id
="p-views" class="vectorTabs<?php if ( count( $this->data['view_urls'] ) == 0 ) { echo ' emptyPortlet'; } ?>">
388 <h5
><?php
$this->msg('views') ?
></h5
>
389 <ul
<?php
$this->html('userlangattributes') ?
>>
390 <?php
foreach ( $this->data
['view_urls'] as $link ): ?
>
391 <li
<?php
echo $link['attributes'] ?
>><span
><a href
="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php
echo $link['key'] ?
>><?php
392 // $link['text'] can be undefined - bug 27764
393 if ( array_key_exists( 'text', $link ) ) {
394 echo array_key_exists( 'img', $link ) ?
'<img src="' . $link['img'] . '" alt="' . $link['text'] . '" />' : htmlspecialchars( $link['text'] );
404 <div id
="p-cactions" class="vectorMenu<?php if ( count( $this->data['action_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
405 <h5
><span
><?php
$this->msg( 'actions' ) ?
></span
><a href
="#"></a
></h5
>
407 <ul
<?php
$this->html( 'userlangattributes' ) ?
>>
408 <?php
foreach ( $this->data
['action_urls'] as $link ): ?
>
409 <li
<?php
echo $link['attributes'] ?
>><a href
="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php
echo $link['key'] ?
>><?php
echo htmlspecialchars( $link['text'] ) ?
></a
></li
>
418 <div id
="p-personal" class="<?php if ( count( $this->data['personal_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
419 <h5
><?php
$this->msg( 'personaltools' ) ?
></h5
>
420 <ul
<?php
$this->html( 'userlangattributes' ) ?
>>
421 <?php
foreach( $this->getPersonalTools() as $key => $item ) { ?
>
422 <?php
echo $this->makeListItem( $key, $item ); ?
>
432 <h5
<?php
$this->html( 'userlangattributes' ) ?
>><label
for="searchInput"><?php
$this->msg( 'search' ) ?
></label
></h5
>
433 <form action
="<?php $this->text( 'wgScript' ) ?>" id
="searchform">
434 <input type
='hidden' name
="title" value
="<?php $this->text( 'searchtitle' ) ?>"/>
435 <?php
if ( $wgVectorUseSimpleSearch && $wgUser->getOption( 'vector-simplesearch' ) ): ?
>
436 <div id
="simpleSearch">
437 <?php
if ( $this->data
['rtl'] ): ?
>
438 <?php
echo $this->makeSearchButton( 'image', array( 'id' => 'searchButton', 'src' => $this->skin
->getSkinStylePath( 'images/search-rtl.png' ) ) ); ?
>
440 <?php
echo $this->makeSearchInput( array( 'id' => 'searchInput', 'type' => 'text' ) ); ?
>
441 <?php
if ( !$this->data
['rtl'] ): ?
>
442 <?php
echo $this->makeSearchButton( 'image', array( 'id' => 'searchButton', 'src' => $this->skin
->getSkinStylePath( 'images/search-ltr.png' ) ) ); ?
>
446 <?php
echo $this->makeSearchInput( array( 'id' => 'searchInput' ) ); ?
>
447 <?php
echo $this->makeSearchButton( 'go', array( 'id' => 'searchGoButton', 'class' => 'searchButton' ) ); ?
>
448 <?php
echo $this->makeSearchButton( 'fulltext', array( 'id' => 'mw-searchButton', 'class' => 'searchButton' ) ); ?
>
456 echo "\n<!-- /{$name} -->\n";