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()->getRelevantTitle()->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 $nav[$section][$key]['key'] =
101 Linker
::tooltip( $xmlID );
103 $nav[$section][$key]['key'] =
104 Xml
::expandAttributes( Linker
::tooltipAndAccesskeyAttribs( $xmlID ) );
108 $this->data
['namespace_urls'] = $nav['namespaces'];
109 $this->data
['view_urls'] = $nav['views'];
110 $this->data
['action_urls'] = $nav['actions'];
111 $this->data
['variant_urls'] = $nav['variants'];
113 // Reverse horizontally rendered navigation elements
114 if ( $this->data
['rtl'] ) {
115 $this->data
['view_urls'] =
116 array_reverse( $this->data
['view_urls'] );
117 $this->data
['namespace_urls'] =
118 array_reverse( $this->data
['namespace_urls'] );
119 $this->data
['personal_urls'] =
120 array_reverse( $this->data
['personal_urls'] );
123 $this->html( 'headelement' );
125 <div id
="mw-page-base" class="noprint"></div
>
126 <div id
="mw-head-base" class="noprint"></div
>
128 <div id
="content" class="mw-body">
130 <div id
="mw-js-message" style
="display:none;"<?php
$this->html( 'userlangattributes' ) ?
>></div
>
131 <?php
if ( $this->data
['sitenotice'] ): ?
>
133 <div id
="siteNotice"><?php
$this->html( 'sitenotice' ) ?
></div
>
136 <!-- firstHeading
-->
137 <h1 id
="firstHeading" class="firstHeading">
138 <span dir
="auto"><?php
$this->html( 'title' ) ?
></span
>
140 <!-- /firstHeading
-->
142 <div id
="bodyContent">
143 <?php
if ( $this->data
['isarticle'] ): ?
>
145 <div id
="siteSub"><?php
$this->msg( 'tagline' ) ?
></div
>
149 <div id
="contentSub"<?php
$this->html( 'userlangattributes' ) ?
>><?php
$this->html( 'subtitle' ) ?
></div
>
151 <?php
if ( $this->data
['undelete'] ): ?
>
153 <div id
="contentSub2"><?php
$this->html( 'undelete' ) ?
></div
>
156 <?php
if( $this->data
['newtalk'] ): ?
>
158 <div
class="usermessage"><?php
$this->html( 'newtalk' ) ?
></div
>
161 <?php
if ( $this->data
['showjumplinks'] ): ?
>
163 <div id
="jump-to-nav" class="mw-jump">
164 <?php
$this->msg( 'jumpto' ) ?
> <a href
="#mw-head"><?php
$this->msg( 'jumptonavigation' ) ?
></a
>,
165 <a href
="#p-search"><?php
$this->msg( 'jumptosearch' ) ?
></a
>
170 <?php
$this->html( 'bodycontent' ) ?
>
171 <!-- /bodycontent
-->
172 <?php
if ( $this->data
['printfooter'] ): ?
>
174 <div
class="printfooter">
175 <?php
$this->html( 'printfooter' ); ?
>
177 <!-- /printfooter
-->
179 <?php
if ( $this->data
['catlinks'] ): ?
>
181 <?php
$this->html( 'catlinks' ); ?
>
184 <?php
if ( $this->data
['dataAfterContent'] ): ?
>
185 <!-- dataAfterContent
-->
186 <?php
$this->html( 'dataAfterContent' ); ?
>
187 <!-- /dataAfterContent
-->
189 <div
class="visualClear"></div
>
191 <?php
$this->html( 'debughtml' ); ?
>
194 <!-- /bodyContent
-->
198 <div id
="mw-head" class="noprint">
199 <?php
$this->renderNavigation( 'PERSONAL' ); ?
>
200 <div id
="left-navigation">
201 <?php
$this->renderNavigation( array( 'NAMESPACES', 'VARIANTS' ) ); ?
>
203 <div id
="right-navigation">
204 <?php
$this->renderNavigation( array( 'VIEWS', 'ACTIONS', 'SEARCH' ) ); ?
>
209 <div id
="mw-panel" class="noprint">
211 <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
>
213 <?php
$this->renderPortals( $this->data
['sidebar'] ); ?
>
217 <div id
="footer"<?php
$this->html( 'userlangattributes' ) ?
>>
218 <?php
foreach( $this->getFooterLinks() as $category => $links ): ?
>
219 <ul id
="footer-<?php echo $category ?>">
220 <?php
foreach( $links as $link ): ?
>
221 <li id
="footer-<?php echo $category ?>-<?php echo $link ?>"><?php
$this->html( $link ) ?
></li
>
225 <?php
$footericons = $this->getFooterIcons("icononly");
226 if ( count( $footericons ) > 0 ): ?
>
227 <ul id
="footer-icons" class="noprint">
228 <?php
foreach ( $footericons as $blockName => $footerIcons ): ?
>
229 <li id
="footer-<?php echo htmlspecialchars( $blockName ); ?>ico">
230 <?php
foreach ( $footerIcons as $icon ): ?
>
231 <?php
echo $this->getSkin()->makeFooterIcon( $icon ); ?
>
238 <div style
="clear:both"></div
>
241 <?php
$this->printTrail(); ?
>
249 * Render a series of portals
251 * @param $portals array
253 protected function renderPortals( $portals ) {
254 // Force the rendering of the following portals
255 if ( !isset( $portals['SEARCH'] ) ) {
256 $portals['SEARCH'] = true;
258 if ( !isset( $portals['TOOLBOX'] ) ) {
259 $portals['TOOLBOX'] = true;
261 if ( !isset( $portals['LANGUAGES'] ) ) {
262 $portals['LANGUAGES'] = true;
265 foreach ( $portals as $name => $content ) {
266 if ( $content === false )
269 echo "\n<!-- {$name} -->\n";
274 $this->renderPortal( 'tb', $this->getToolbox(), 'toolbox', 'SkinTemplateToolboxEnd' );
277 if ( $this->data
['language_urls'] ) {
278 $this->renderPortal( 'lang', $this->data
['language_urls'], 'otherlanguages' );
282 $this->renderPortal( $name, $content );
285 echo "\n<!-- /{$name} -->\n";
290 * @param $name string
291 * @param $content array
292 * @param $msg null|string
293 * @param $hook null|string|array
295 protected function renderPortal( $name, $content, $msg = null, $hook = null ) {
296 if ( $msg === null ) {
300 <div
class="portal" id
='<?php echo Sanitizer::escapeId( "p-$name" ) ?>'<?php
echo Linker
::tooltip( 'p-' . $name ) ?
>>
301 <h5
<?php
$this->html( 'userlangattributes' ) ?
>><?php
$msgObj = wfMessage( $msg ); echo htmlspecialchars( $msgObj->exists() ?
$msgObj->text() : $msg ); ?
></h5
>
304 if ( is_array( $content ) ): ?
>
307 foreach( $content as $key => $val ): ?
>
308 <?php
echo $this->makeListItem( $key, $val ); ?
>
312 if ( $hook !== null ) {
313 wfRunHooks( $hook, array( &$this, true ) );
319 <?php
echo $content; /* Allow raw HTML block to be defined by extensions */ ?
>
328 * Render one or more navigations elements by name, automatically reveresed
329 * when UI is in RTL mode
331 * @param $elements array
333 protected function renderNavigation( $elements ) {
334 global $wgVectorUseSimpleSearch;
336 // If only one element was given, wrap it in an array, allowing more
337 // flexible arguments
338 if ( !is_array( $elements ) ) {
339 $elements = array( $elements );
340 // If there's a series of elements, reverse them when in RTL mode
341 } elseif ( $this->data
['rtl'] ) {
342 $elements = array_reverse( $elements );
345 foreach ( $elements as $name => $element ) {
346 echo "\n<!-- {$name} -->\n";
347 switch ( $element ) {
350 <div id
="p-namespaces" class="vectorTabs<?php if ( count( $this->data['namespace_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
351 <h5
><?php
$this->msg( 'namespaces' ) ?
></h5
>
352 <ul
<?php
$this->html( 'userlangattributes' ) ?
>>
353 <?php
foreach ( $this->data
['namespace_urls'] as $link ): ?
>
354 <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
>
362 <div id
="p-variants" class="vectorMenu<?php if ( count( $this->data['variant_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
364 <?php
foreach ( $this->data
['variant_urls'] as $link ): ?
>
365 <?php
if ( stripos( $link['attributes'], 'selected' ) !== false ): ?
>
366 <?php
echo htmlspecialchars( $link['text'] ) ?
>
370 <h5
><span
><?php
$this->msg( 'variants' ) ?
></span
><a href
="#"></a
></h5
>
373 <?php
foreach ( $this->data
['variant_urls'] as $link ): ?
>
374 <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
>
383 <div id
="p-views" class="vectorTabs<?php if ( count( $this->data['view_urls'] ) == 0 ) { echo ' emptyPortlet'; } ?>">
384 <h5
><?php
$this->msg('views') ?
></h5
>
385 <ul
<?php
$this->html('userlangattributes') ?
>>
386 <?php
foreach ( $this->data
['view_urls'] as $link ): ?
>
387 <li
<?php
echo $link['attributes'] ?
>><span
><a href
="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php
echo $link['key'] ?
>><?php
388 // $link['text'] can be undefined - bug 27764
389 if ( array_key_exists( 'text', $link ) ) {
390 echo array_key_exists( 'img', $link ) ?
'<img src="' . $link['img'] . '" alt="' . $link['text'] . '" />' : htmlspecialchars( $link['text'] );
400 <div id
="p-cactions" class="vectorMenu<?php if ( count( $this->data['action_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
401 <h5
><span
><?php
$this->msg( 'actions' ) ?
></span
><a href
="#"></a
></h5
>
403 <ul
<?php
$this->html( 'userlangattributes' ) ?
>>
404 <?php
foreach ( $this->data
['action_urls'] as $link ): ?
>
405 <li
<?php
echo $link['attributes'] ?
>><a href
="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php
echo $link['key'] ?
>><?php
echo htmlspecialchars( $link['text'] ) ?
></a
></li
>
414 <div id
="p-personal" class="<?php if ( count( $this->data['personal_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
415 <h5
><?php
$this->msg( 'personaltools' ) ?
></h5
>
416 <ul
<?php
$this->html( 'userlangattributes' ) ?
>>
417 <?php
foreach( $this->getPersonalTools() as $key => $item ) { ?
>
418 <?php
echo $this->makeListItem( $key, $item ); ?
>
428 <h5
<?php
$this->html( 'userlangattributes' ) ?
>><label
for="searchInput"><?php
$this->msg( 'search' ) ?
></label
></h5
>
429 <form action
="<?php $this->text( 'wgScript' ) ?>" id
="searchform">
430 <?php
if ( $wgVectorUseSimpleSearch && $this->getSkin()->getUser()->getOption( 'vector-simplesearch' ) ): ?
>
431 <div id
="simpleSearch">
432 <?php
if ( $this->data
['rtl'] ): ?
>
433 <?php
echo $this->makeSearchButton( 'image', array( 'id' => 'searchButton', 'src' => $this->getSkin()->getSkinStylePath( 'images/search-rtl.png' ), 'width' => '12', 'height' => '13' ) ); ?
>
435 <?php
echo $this->makeSearchInput( array( 'id' => 'searchInput', 'type' => 'text' ) ); ?
>
436 <?php
if ( !$this->data
['rtl'] ): ?
>
437 <?php
echo $this->makeSearchButton( 'image', array( 'id' => 'searchButton', 'src' => $this->getSkin()->getSkinStylePath( 'images/search-ltr.png' ), 'width' => '12', 'height' => '13' ) ); ?
>
441 <?php
echo $this->makeSearchInput( array( 'id' => 'searchInput' ) ); ?
>
442 <?php
echo $this->makeSearchButton( 'go', array( 'id' => 'searchGoButton', 'class' => 'searchButton' ) ); ?
>
443 <?php
echo $this->makeSearchButton( 'fulltext', array( 'id' => 'mw-searchButton', 'class' => 'searchButton' ) ); ?
>
445 <input type
='hidden' name
="title" value
="<?php $this->text( 'searchtitle' ) ?>"/>
453 echo "\n<!-- /{$name} -->\n";