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"><span dir
="auto"><?php
$this->html( 'title' ) ?
></span
></h1
>
138 <!-- /firstHeading
-->
140 <div id
="bodyContent">
141 <?php
if ( $this->data
['isarticle'] ): ?
>
143 <div id
="siteSub"><?php
$this->msg( 'tagline' ) ?
></div
>
147 <div id
="contentSub"<?php
$this->html( 'userlangattributes' ) ?
>><?php
$this->html( 'subtitle' ) ?
></div
>
149 <?php
if ( $this->data
['undelete'] ): ?
>
151 <div id
="contentSub2"><?php
$this->html( 'undelete' ) ?
></div
>
154 <?php
if( $this->data
['newtalk'] ): ?
>
156 <div
class="usermessage"><?php
$this->html( 'newtalk' ) ?
></div
>
159 <?php
if ( $this->data
['showjumplinks'] ): ?
>
161 <div id
="jump-to-nav" class="mw-jump">
162 <?php
$this->msg( 'jumpto' ) ?
> <a href
="#mw-head"><?php
$this->msg( 'jumptonavigation' ) ?
></a
>,
163 <a href
="#p-search"><?php
$this->msg( 'jumptosearch' ) ?
></a
>
168 <?php
$this->html( 'bodycontent' ) ?
>
169 <!-- /bodycontent
-->
170 <?php
if ( $this->data
['printfooter'] ): ?
>
172 <div
class="printfooter">
173 <?php
$this->html( 'printfooter' ); ?
>
175 <!-- /printfooter
-->
177 <?php
if ( $this->data
['catlinks'] ): ?
>
179 <?php
$this->html( 'catlinks' ); ?
>
182 <?php
if ( $this->data
['dataAfterContent'] ): ?
>
183 <!-- dataAfterContent
-->
184 <?php
$this->html( 'dataAfterContent' ); ?
>
185 <!-- /dataAfterContent
-->
187 <div
class="visualClear"></div
>
189 <?php
$this->html( 'debughtml' ); ?
>
192 <!-- /bodyContent
-->
196 <div id
="mw-head" class="noprint">
197 <?php
$this->renderNavigation( 'PERSONAL' ); ?
>
198 <div id
="left-navigation">
199 <?php
$this->renderNavigation( array( 'NAMESPACES', 'VARIANTS' ) ); ?
>
201 <div id
="right-navigation">
202 <?php
$this->renderNavigation( array( 'VIEWS', 'ACTIONS', 'SEARCH' ) ); ?
>
207 <div id
="mw-panel" class="noprint">
209 <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
>
211 <?php
$this->renderPortals( $this->data
['sidebar'] ); ?
>
215 <div id
="footer"<?php
$this->html( 'userlangattributes' ) ?
>>
216 <?php
foreach( $this->getFooterLinks() as $category => $links ): ?
>
217 <ul id
="footer-<?php echo $category ?>">
218 <?php
foreach( $links as $link ): ?
>
219 <li id
="footer-<?php echo $category ?>-<?php echo $link ?>"><?php
$this->html( $link ) ?
></li
>
223 <?php
$footericons = $this->getFooterIcons("icononly");
224 if ( count( $footericons ) > 0 ): ?
>
225 <ul id
="footer-icons" class="noprint">
226 <?php
foreach ( $footericons as $blockName => $footerIcons ): ?
>
227 <li id
="footer-<?php echo htmlspecialchars( $blockName ); ?>ico">
228 <?php
foreach ( $footerIcons as $icon ): ?
>
229 <?php
echo $this->getSkin()->makeFooterIcon( $icon ); ?
>
236 <div style
="clear:both"></div
>
239 <?php
$this->printTrail(); ?
>
247 * Render a series of portals
249 * @param $portals array
251 protected function renderPortals( $portals ) {
252 // Force the rendering of the following portals
253 if ( !isset( $portals['SEARCH'] ) ) {
254 $portals['SEARCH'] = true;
256 if ( !isset( $portals['TOOLBOX'] ) ) {
257 $portals['TOOLBOX'] = true;
259 if ( !isset( $portals['LANGUAGES'] ) ) {
260 $portals['LANGUAGES'] = true;
263 foreach ( $portals as $name => $content ) {
264 if ( $content === false )
267 echo "\n<!-- {$name} -->\n";
272 $this->renderPortal( 'tb', $this->getToolbox(), 'toolbox', 'SkinTemplateToolboxEnd' );
275 if ( $this->data
['language_urls'] ) {
276 $this->renderPortal( 'lang', $this->data
['language_urls'], 'otherlanguages' );
280 $this->renderPortal( $name, $content );
283 echo "\n<!-- /{$name} -->\n";
288 * @param $name string
289 * @param $content array
290 * @param $msg null|string
291 * @param $hook null|string|array
293 protected function renderPortal( $name, $content, $msg = null, $hook = null ) {
294 if ( $msg === null ) {
298 <div
class="portal" id
='<?php echo Sanitizer::escapeId( "p-$name" ) ?>'<?php
echo Linker
::tooltip( 'p-' . $name ) ?
>>
299 <h5
<?php
$this->html( 'userlangattributes' ) ?
>><?php
$msgObj = wfMessage( $msg ); echo htmlspecialchars( $msgObj->exists() ?
$msgObj->text() : $msg ); ?
></h5
>
302 if ( is_array( $content ) ): ?
>
305 foreach( $content as $key => $val ): ?
>
306 <?php
echo $this->makeListItem( $key, $val ); ?
>
310 if ( $hook !== null ) {
311 wfRunHooks( $hook, array( &$this, true ) );
317 <?php
echo $content; /* Allow raw HTML block to be defined by extensions */ ?
>
326 * Render one or more navigations elements by name, automatically reveresed
327 * when UI is in RTL mode
329 * @param $elements array
331 protected function renderNavigation( $elements ) {
332 global $wgVectorUseSimpleSearch;
334 // If only one element was given, wrap it in an array, allowing more
335 // flexible arguments
336 if ( !is_array( $elements ) ) {
337 $elements = array( $elements );
338 // If there's a series of elements, reverse them when in RTL mode
339 } elseif ( $this->data
['rtl'] ) {
340 $elements = array_reverse( $elements );
343 foreach ( $elements as $name => $element ) {
344 echo "\n<!-- {$name} -->\n";
345 switch ( $element ) {
348 <div id
="p-namespaces" class="vectorTabs<?php if ( count( $this->data['namespace_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
349 <h5
><?php
$this->msg( 'namespaces' ) ?
></h5
>
350 <ul
<?php
$this->html( 'userlangattributes' ) ?
>>
351 <?php
foreach ( $this->data
['namespace_urls'] as $link ): ?
>
352 <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
>
360 <div id
="p-variants" class="vectorMenu<?php if ( count( $this->data['variant_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
362 <?php
foreach ( $this->data
['variant_urls'] as $link ): ?
>
363 <?php
if ( stripos( $link['attributes'], 'selected' ) !== false ): ?
>
364 <?php
echo htmlspecialchars( $link['text'] ) ?
>
368 <h5
><span
><?php
$this->msg( 'variants' ) ?
></span
><a href
="#"></a
></h5
>
371 <?php
foreach ( $this->data
['variant_urls'] as $link ): ?
>
372 <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
>
381 <div id
="p-views" class="vectorTabs<?php if ( count( $this->data['view_urls'] ) == 0 ) { echo ' emptyPortlet'; } ?>">
382 <h5
><?php
$this->msg('views') ?
></h5
>
383 <ul
<?php
$this->html('userlangattributes') ?
>>
384 <?php
foreach ( $this->data
['view_urls'] as $link ): ?
>
385 <li
<?php
echo $link['attributes'] ?
>><span
><a href
="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php
echo $link['key'] ?
>><?php
386 // $link['text'] can be undefined - bug 27764
387 if ( array_key_exists( 'text', $link ) ) {
388 echo array_key_exists( 'img', $link ) ?
'<img src="' . $link['img'] . '" alt="' . $link['text'] . '" />' : htmlspecialchars( $link['text'] );
398 <div id
="p-cactions" class="vectorMenu<?php if ( count( $this->data['action_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
399 <h5
><span
><?php
$this->msg( 'actions' ) ?
></span
><a href
="#"></a
></h5
>
401 <ul
<?php
$this->html( 'userlangattributes' ) ?
>>
402 <?php
foreach ( $this->data
['action_urls'] as $link ): ?
>
403 <li
<?php
echo $link['attributes'] ?
>><a href
="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php
echo $link['key'] ?
>><?php
echo htmlspecialchars( $link['text'] ) ?
></a
></li
>
412 <div id
="p-personal" class="<?php if ( count( $this->data['personal_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
413 <h5
><?php
$this->msg( 'personaltools' ) ?
></h5
>
414 <ul
<?php
$this->html( 'userlangattributes' ) ?
>>
415 <?php
foreach( $this->getPersonalTools() as $key => $item ) { ?
>
416 <?php
echo $this->makeListItem( $key, $item ); ?
>
426 <h5
<?php
$this->html( 'userlangattributes' ) ?
>><label
for="searchInput"><?php
$this->msg( 'search' ) ?
></label
></h5
>
427 <form action
="<?php $this->text( 'wgScript' ) ?>" id
="searchform">
428 <?php
if ( $wgVectorUseSimpleSearch && $this->getSkin()->getUser()->getOption( 'vector-simplesearch' ) ): ?
>
429 <div id
="simpleSearch">
430 <?php
if ( $this->data
['rtl'] ): ?
>
431 <?php
echo $this->makeSearchButton( 'image', array( 'id' => 'searchButton', 'src' => $this->getSkin()->getSkinStylePath( 'images/search-rtl.png' ), 'width' => '12', 'height' => '13' ) ); ?
>
433 <?php
echo $this->makeSearchInput( array( 'id' => 'searchInput', 'type' => 'text' ) ); ?
>
434 <?php
if ( !$this->data
['rtl'] ): ?
>
435 <?php
echo $this->makeSearchButton( 'image', array( 'id' => 'searchButton', 'src' => $this->getSkin()->getSkinStylePath( 'images/search-ltr.png' ), 'width' => '12', 'height' => '13' ) ); ?
>
439 <?php
echo $this->makeSearchInput( array( 'id' => 'searchInput' ) ); ?
>
440 <?php
echo $this->makeSearchButton( 'go', array( 'id' => 'searchGoButton', 'class' => 'searchButton' ) ); ?
>
441 <?php
echo $this->makeSearchButton( 'fulltext', array( 'id' => 'mw-searchButton', 'class' => 'searchButton' ) ); ?
>
443 <input type
='hidden' name
="title" value
="<?php $this->text( 'searchtitle' ) ?>"/>
451 echo "\n<!-- /{$name} -->\n";