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;
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 = $this->getRequest()->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 * Outputs the entire contents of the (X)HTML page
68 public function execute() {
69 global $wgVectorUseIconWatch;
71 // Build additional attributes for navigation urls
72 $nav = $this->data
['content_navigation'];
74 if ( $wgVectorUseIconWatch ) {
75 $mode = $this->getSkin()->getTitle()->userIsWatching() ?
'unwatch' : 'watch';
76 if ( isset( $nav['actions'][$mode] ) ) {
77 $nav['views'][$mode] = $nav['actions'][$mode];
78 $nav['views'][$mode]['class'] = rtrim( 'icon ' . $nav['views'][$mode]['class'], ' ' );
79 $nav['views'][$mode]['primary'] = true;
80 unset( $nav['actions'][$mode] );
85 foreach ( $nav as $section => $links ) {
86 foreach ( $links as $key => $link ) {
87 if ( $section == 'views' && !( isset( $link['primary'] ) && $link['primary'] ) ) {
88 $link['class'] = rtrim( 'collapsible ' . $link['class'], ' ' );
91 $xmlID = isset( $link['id'] ) ?
$link['id'] : 'ca-' . $xmlID;
92 $nav[$section][$key]['attributes'] =
93 ' id="' . Sanitizer
::escapeId( $xmlID ) . '"';
94 if ( $link['class'] ) {
95 $nav[$section][$key]['attributes'] .=
96 ' class="' . htmlspecialchars( $link['class'] ) . '"';
97 unset( $nav[$section][$key]['class'] );
99 if ( isset( $link['tooltiponly'] ) && $link['tooltiponly'] ) {
100 $tooltip = Linker
::titleAttrib( $xmlID );
101 $tooltip = $tooltip === false ?
'' : Xml
::expandAttributes( array( 'title' => $tooltip ) );
102 $nav[$section][$key]['key'] = $tooltip;
105 $nav[$section][$key]['key'] =
106 Xml
::expandAttributes( Linker
::tooltipAndAccesskeyAttribs( $xmlID ) );
110 $this->data
['namespace_urls'] = $nav['namespaces'];
111 $this->data
['view_urls'] = $nav['views'];
112 $this->data
['action_urls'] = $nav['actions'];
113 $this->data
['variant_urls'] = $nav['variants'];
115 // Reverse horizontally rendered navigation elements
116 if ( $this->data
['rtl'] ) {
117 $this->data
['view_urls'] =
118 array_reverse( $this->data
['view_urls'] );
119 $this->data
['namespace_urls'] =
120 array_reverse( $this->data
['namespace_urls'] );
121 $this->data
['personal_urls'] =
122 array_reverse( $this->data
['personal_urls'] );
125 $this->html( 'headelement' );
127 <div id
="mw-page-base" class="noprint"></div
>
128 <div id
="mw-head-base" class="noprint"></div
>
130 <div id
="content" class="mw-body">
132 <div id
="mw-js-message" style
="display:none;"<?php
$this->html( 'userlangattributes' ) ?
>></div
>
133 <?php
if ( $this->data
['sitenotice'] ): ?
>
135 <div id
="siteNotice"><?php
$this->html( 'sitenotice' ) ?
></div
>
138 <!-- firstHeading
-->
139 <h1 id
="firstHeading" class="firstHeading">
140 <span dir
="auto"><?php
$this->html( 'title' ) ?
></span
>
142 <!-- /firstHeading
-->
144 <div id
="bodyContent">
145 <?php
if ( $this->data
['isarticle'] ): ?
>
147 <div id
="siteSub"><?php
$this->msg( 'tagline' ) ?
></div
>
151 <div id
="contentSub"<?php
$this->html( 'userlangattributes' ) ?
>><?php
$this->html( 'subtitle' ) ?
></div
>
153 <?php
if ( $this->data
['undelete'] ): ?
>
155 <div id
="contentSub2"><?php
$this->html( 'undelete' ) ?
></div
>
158 <?php
if( $this->data
['newtalk'] ): ?
>
160 <div
class="usermessage"><?php
$this->html( 'newtalk' ) ?
></div
>
163 <?php
if ( $this->data
['showjumplinks'] ): ?
>
165 <div id
="jump-to-nav" class="mw-jump">
166 <?php
$this->msg( 'jumpto' ) ?
> <a href
="#mw-head"><?php
$this->msg( 'jumptonavigation' ) ?
></a
>,
167 <a href
="#p-search"><?php
$this->msg( 'jumptosearch' ) ?
></a
>
172 <?php
$this->html( 'bodycontent' ) ?
>
173 <!-- /bodycontent
-->
174 <?php
if ( $this->data
['printfooter'] ): ?
>
176 <div
class="printfooter">
177 <?php
$this->html( 'printfooter' ); ?
>
179 <!-- /printfooter
-->
181 <?php
if ( $this->data
['catlinks'] ): ?
>
183 <?php
$this->html( 'catlinks' ); ?
>
186 <?php
if ( $this->data
['dataAfterContent'] ): ?
>
187 <!-- dataAfterContent
-->
188 <?php
$this->html( 'dataAfterContent' ); ?
>
189 <!-- /dataAfterContent
-->
191 <div
class="visualClear"></div
>
193 <?php
$this->html( 'debughtml' ); ?
>
196 <!-- /bodyContent
-->
200 <div id
="mw-head" class="noprint">
201 <?php
$this->renderNavigation( 'PERSONAL' ); ?
>
202 <div id
="left-navigation">
203 <?php
$this->renderNavigation( array( 'NAMESPACES', 'VARIANTS' ) ); ?
>
205 <div id
="right-navigation">
206 <?php
$this->renderNavigation( array( 'VIEWS', 'ACTIONS', 'SEARCH' ) ); ?
>
211 <div id
="mw-panel" class="noprint">
213 <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
>
215 <?php
$this->renderPortals( $this->data
['sidebar'] ); ?
>
219 <div id
="footer"<?php
$this->html( 'userlangattributes' ) ?
>>
220 <?php
foreach( $this->getFooterLinks() as $category => $links ): ?
>
221 <ul id
="footer-<?php echo $category ?>">
222 <?php
foreach( $links as $link ): ?
>
223 <li id
="footer-<?php echo $category ?>-<?php echo $link ?>"><?php
$this->html( $link ) ?
></li
>
227 <?php
$footericons = $this->getFooterIcons("icononly");
228 if ( count( $footericons ) > 0 ): ?
>
229 <ul id
="footer-icons" class="noprint">
230 <?php
foreach ( $footericons as $blockName => $footerIcons ): ?
>
231 <li id
="footer-<?php echo htmlspecialchars( $blockName ); ?>ico">
232 <?php
foreach ( $footerIcons as $icon ): ?
>
233 <?php
echo $this->getSkin()->makeFooterIcon( $icon ); ?
>
240 <div style
="clear:both"></div
>
244 <script type
="<?php $this->text( 'jsmimetype' ) ?>"> if ( window
.isMSIE55
) fixalpha(); </script
>
246 <?php
$this->printTrail(); ?
>
254 * Render a series of portals
256 * @param $portals array
258 private function renderPortals( $portals ) {
259 // Force the rendering of the following portals
260 if ( !isset( $portals['SEARCH'] ) ) {
261 $portals['SEARCH'] = true;
263 if ( !isset( $portals['TOOLBOX'] ) ) {
264 $portals['TOOLBOX'] = true;
266 if ( !isset( $portals['LANGUAGES'] ) ) {
267 $portals['LANGUAGES'] = true;
270 foreach ( $portals as $name => $content ) {
271 if ( $content === false )
274 echo "\n<!-- {$name} -->\n";
279 $this->renderPortal( 'tb', $this->getToolbox(), 'toolbox', 'SkinTemplateToolboxEnd' );
282 if ( $this->data
['language_urls'] ) {
283 $this->renderPortal( 'lang', $this->data
['language_urls'], 'otherlanguages' );
287 $this->renderPortal( $name, $content );
290 echo "\n<!-- /{$name} -->\n";
294 private function renderPortal( $name, $content, $msg = null, $hook = null ) {
295 if ( $msg === null ) {
299 <div
class="portal" id
='<?php echo Sanitizer::escapeId( "p-$name" ) ?>'<?php
echo Linker
::tooltip( 'p-' . $name ) ?
>>
300 <h5
<?php
$this->html( 'userlangattributes' ) ?
>><?php
$msgObj = wfMessage( $msg ); echo htmlspecialchars( $msgObj->exists() ?
$msgObj->text() : $msg ); ?
></h5
>
303 if ( is_array( $content ) ): ?
>
306 foreach( $content as $key => $val ): ?
>
307 <?php
echo $this->makeListItem( $key, $val ); ?
>
311 if ( $hook !== null ) {
312 wfRunHooks( $hook, array( &$this, true ) );
318 <?php
echo $content; /* Allow raw HTML block to be defined by extensions */ ?
>
327 * Render one or more navigations elements by name, automatically reveresed
328 * when UI is in RTL mode
330 * @param $elements array
332 private function renderNavigation( $elements ) {
333 global $wgVectorUseSimpleSearch;
335 // If only one element was given, wrap it in an array, allowing more
336 // flexible arguments
337 if ( !is_array( $elements ) ) {
338 $elements = array( $elements );
339 // If there's a series of elements, reverse them when in RTL mode
340 } elseif ( $this->data
['rtl'] ) {
341 $elements = array_reverse( $elements );
344 foreach ( $elements as $name => $element ) {
345 echo "\n<!-- {$name} -->\n";
346 switch ( $element ) {
349 <div id
="p-namespaces" class="vectorTabs<?php if ( count( $this->data['namespace_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
350 <h5
><?php
$this->msg( 'namespaces' ) ?
></h5
>
351 <ul
<?php
$this->html( 'userlangattributes' ) ?
>>
352 <?php
foreach ( $this->data
['namespace_urls'] as $link ): ?
>
353 <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
>
361 <div id
="p-variants" class="vectorMenu<?php if ( count( $this->data['variant_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
363 <?php
foreach ( $this->data
['variant_urls'] as $link ): ?
>
364 <?php
if ( stripos( $link['attributes'], 'selected' ) !== false ): ?
>
365 <?php
echo htmlspecialchars( $link['text'] ) ?
>
369 <h5
><span
><?php
$this->msg( 'variants' ) ?
></span
><a href
="#"></a
></h5
>
371 <ul
<?php
$this->html( 'userlangattributes' ) ?
>>
372 <?php
foreach ( $this->data
['variant_urls'] as $link ): ?
>
373 <li
<?php
echo $link['attributes'] ?
>><a href
="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php
echo $link['key'] ?
>><?php
echo htmlspecialchars( $link['text'] ) ?
></a
></li
>
382 <div id
="p-views" class="vectorTabs<?php if ( count( $this->data['view_urls'] ) == 0 ) { echo ' emptyPortlet'; } ?>">
383 <h5
><?php
$this->msg('views') ?
></h5
>
384 <ul
<?php
$this->html('userlangattributes') ?
>>
385 <?php
foreach ( $this->data
['view_urls'] as $link ): ?
>
386 <li
<?php
echo $link['attributes'] ?
>><span
><a href
="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php
echo $link['key'] ?
>><?php
387 // $link['text'] can be undefined - bug 27764
388 if ( array_key_exists( 'text', $link ) ) {
389 echo array_key_exists( 'img', $link ) ?
'<img src="' . $link['img'] . '" alt="' . $link['text'] . '" />' : htmlspecialchars( $link['text'] );
399 <div id
="p-cactions" class="vectorMenu<?php if ( count( $this->data['action_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
400 <h5
><span
><?php
$this->msg( 'actions' ) ?
></span
><a href
="#"></a
></h5
>
402 <ul
<?php
$this->html( 'userlangattributes' ) ?
>>
403 <?php
foreach ( $this->data
['action_urls'] as $link ): ?
>
404 <li
<?php
echo $link['attributes'] ?
>><a href
="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php
echo $link['key'] ?
>><?php
echo htmlspecialchars( $link['text'] ) ?
></a
></li
>
413 <div id
="p-personal" class="<?php if ( count( $this->data['personal_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
414 <h5
><?php
$this->msg( 'personaltools' ) ?
></h5
>
415 <ul
<?php
$this->html( 'userlangattributes' ) ?
>>
416 <?php
foreach( $this->getPersonalTools() as $key => $item ) { ?
>
417 <?php
echo $this->makeListItem( $key, $item ); ?
>
427 <h5
<?php
$this->html( 'userlangattributes' ) ?
>><label
for="searchInput"><?php
$this->msg( 'search' ) ?
></label
></h5
>
428 <form action
="<?php $this->text( 'wgScript' ) ?>" id
="searchform">
429 <?php
if ( $wgVectorUseSimpleSearch && $this->getSkin()->getUser()->getOption( 'vector-simplesearch' ) ): ?
>
430 <div id
="simpleSearch">
431 <?php
if ( $this->data
['rtl'] ): ?
>
432 <?php
echo $this->makeSearchButton( 'image', array( 'id' => 'searchButton', 'src' => $this->getSkin()->getSkinStylePath( 'images/search-rtl.png' ) ) ); ?
>
434 <?php
echo $this->makeSearchInput( array( 'id' => 'searchInput', 'type' => 'text' ) ); ?
>
435 <?php
if ( !$this->data
['rtl'] ): ?
>
436 <?php
echo $this->makeSearchButton( 'image', array( 'id' => 'searchButton', 'src' => $this->getSkin()->getSkinStylePath( 'images/search-ltr.png' ) ) ); ?
>
440 <?php
echo $this->makeSearchInput( array( 'id' => 'searchInput' ) ); ?
>
441 <?php
echo $this->makeSearchButton( 'go', array( 'id' => 'searchGoButton', 'class' => 'searchButton' ) ); ?
>
442 <?php
echo $this->makeSearchButton( 'fulltext', array( 'id' => 'mw-searchButton', 'class' => 'searchButton' ) ); ?
>
444 <input type
='hidden' name
="title" value
="<?php $this->text( 'searchtitle' ) ?>"/>
452 echo "\n<!-- /{$name} -->\n";