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 $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 private 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";
289 private function renderPortal( $name, $content, $msg = null, $hook = null ) {
290 if ( $msg === null ) {
294 <div
class="portal" id
='<?php echo Sanitizer::escapeId( "p-$name" ) ?>'<?php
echo Linker
::tooltip( 'p-' . $name ) ?
>>
295 <h5
<?php
$this->html( 'userlangattributes' ) ?
>><?php
$msgObj = wfMessage( $msg ); echo htmlspecialchars( $msgObj->exists() ?
$msgObj->text() : $msg ); ?
></h5
>
298 if ( is_array( $content ) ): ?
>
301 foreach( $content as $key => $val ): ?
>
302 <?php
echo $this->makeListItem( $key, $val ); ?
>
306 if ( $hook !== null ) {
307 wfRunHooks( $hook, array( &$this, true ) );
313 <?php
echo $content; /* Allow raw HTML block to be defined by extensions */ ?
>
322 * Render one or more navigations elements by name, automatically reveresed
323 * when UI is in RTL mode
325 * @param $elements array
327 private function renderNavigation( $elements ) {
328 global $wgVectorUseSimpleSearch;
330 // If only one element was given, wrap it in an array, allowing more
331 // flexible arguments
332 if ( !is_array( $elements ) ) {
333 $elements = array( $elements );
334 // If there's a series of elements, reverse them when in RTL mode
335 } elseif ( $this->data
['rtl'] ) {
336 $elements = array_reverse( $elements );
339 foreach ( $elements as $name => $element ) {
340 echo "\n<!-- {$name} -->\n";
341 switch ( $element ) {
344 <div id
="p-namespaces" class="vectorTabs<?php if ( count( $this->data['namespace_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
345 <h5
><?php
$this->msg( 'namespaces' ) ?
></h5
>
346 <ul
<?php
$this->html( 'userlangattributes' ) ?
>>
347 <?php
foreach ( $this->data
['namespace_urls'] as $link ): ?
>
348 <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
>
356 <div id
="p-variants" class="vectorMenu<?php if ( count( $this->data['variant_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
358 <?php
foreach ( $this->data
['variant_urls'] as $link ): ?
>
359 <?php
if ( stripos( $link['attributes'], 'selected' ) !== false ): ?
>
360 <?php
echo htmlspecialchars( $link['text'] ) ?
>
364 <h5
><span
><?php
$this->msg( 'variants' ) ?
></span
><a href
="#"></a
></h5
>
366 <ul
<?php
$this->html( 'userlangattributes' ) ?
>>
367 <?php
foreach ( $this->data
['variant_urls'] as $link ): ?
>
368 <li
<?php
echo $link['attributes'] ?
>><a href
="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php
echo $link['key'] ?
>><?php
echo htmlspecialchars( $link['text'] ) ?
></a
></li
>
377 <div id
="p-views" class="vectorTabs<?php if ( count( $this->data['view_urls'] ) == 0 ) { echo ' emptyPortlet'; } ?>">
378 <h5
><?php
$this->msg('views') ?
></h5
>
379 <ul
<?php
$this->html('userlangattributes') ?
>>
380 <?php
foreach ( $this->data
['view_urls'] as $link ): ?
>
381 <li
<?php
echo $link['attributes'] ?
>><span
><a href
="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php
echo $link['key'] ?
>><?php
382 // $link['text'] can be undefined - bug 27764
383 if ( array_key_exists( 'text', $link ) ) {
384 echo array_key_exists( 'img', $link ) ?
'<img src="' . $link['img'] . '" alt="' . $link['text'] . '" />' : htmlspecialchars( $link['text'] );
394 <div id
="p-cactions" class="vectorMenu<?php if ( count( $this->data['action_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
395 <h5
><span
><?php
$this->msg( 'actions' ) ?
></span
><a href
="#"></a
></h5
>
397 <ul
<?php
$this->html( 'userlangattributes' ) ?
>>
398 <?php
foreach ( $this->data
['action_urls'] as $link ): ?
>
399 <li
<?php
echo $link['attributes'] ?
>><a href
="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php
echo $link['key'] ?
>><?php
echo htmlspecialchars( $link['text'] ) ?
></a
></li
>
408 <div id
="p-personal" class="<?php if ( count( $this->data['personal_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
409 <h5
><?php
$this->msg( 'personaltools' ) ?
></h5
>
410 <ul
<?php
$this->html( 'userlangattributes' ) ?
>>
411 <?php
foreach( $this->getPersonalTools() as $key => $item ) { ?
>
412 <?php
echo $this->makeListItem( $key, $item ); ?
>
422 <h5
<?php
$this->html( 'userlangattributes' ) ?
>><label
for="searchInput"><?php
$this->msg( 'search' ) ?
></label
></h5
>
423 <form action
="<?php $this->text( 'wgScript' ) ?>" id
="searchform">
424 <?php
if ( $wgVectorUseSimpleSearch && $this->getSkin()->getUser()->getOption( 'vector-simplesearch' ) ): ?
>
425 <div id
="simpleSearch">
426 <?php
if ( $this->data
['rtl'] ): ?
>
427 <?php
echo $this->makeSearchButton( 'image', array( 'id' => 'searchButton', 'src' => $this->getSkin()->getSkinStylePath( 'images/search-rtl.png' ) ) ); ?
>
429 <?php
echo $this->makeSearchInput( array( 'id' => 'searchInput', 'type' => 'text' ) ); ?
>
430 <?php
if ( !$this->data
['rtl'] ): ?
>
431 <?php
echo $this->makeSearchButton( 'image', array( 'id' => 'searchButton', 'src' => $this->getSkin()->getSkinStylePath( 'images/search-ltr.png' ) ) ); ?
>
435 <?php
echo $this->makeSearchInput( array( 'id' => 'searchInput' ) ); ?
>
436 <?php
echo $this->makeSearchButton( 'go', array( 'id' => 'searchGoButton', 'class' => 'searchButton' ) ); ?
>
437 <?php
echo $this->makeSearchButton( 'fulltext', array( 'id' => 'mw-searchButton', 'class' => 'searchButton' ) ); ?
>
439 <input type
='hidden' name
="title" value
="<?php $this->text( 'searchtitle' ) ?>"/>
447 echo "\n<!-- /{$name} -->\n";