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]-->"
45 * Load skin and user CSS files in the correct order
47 * @param $out OutputPage object
49 function setupSkinUserCss( OutputPage
$out ){
50 parent
::setupSkinUserCss( $out );
51 $out->addModuleStyles( 'skins.vector' );
56 * QuickTemplate class for Vector skin
59 class VectorTemplate
extends BaseTemplate
{
64 * @var Skin Cached skin object
71 * Outputs the entire contents of the (X)HTML page
73 public function execute() {
74 global $wgLang, $wgVectorUseIconWatch;
76 $this->skin
= $this->data
['skin'];
78 // Build additional attributes for navigation urls
79 //$nav = $this->skin->buildNavigationUrls();
80 $nav = $this->data
['content_navigation'];
82 if ( $wgVectorUseIconWatch ) {
83 $mode = $this->skin
->getTitle()->userIsWatching() ?
'unwatch' : 'watch';
84 if ( isset($nav['actions'][$mode]) ) {
85 $nav['views'][$mode] = $nav['actions'][$mode];
86 $nav['views'][$mode]['class'] = rtrim('icon ' . $nav['views'][$mode]['class'], ' ');
87 $nav['views'][$mode]['primary'] = true;
88 unset($nav['actions'][$mode]);
93 foreach ( $nav as $section => $links ) {
94 foreach ( $links as $key => $link ) {
95 if ( $section == "views" && !(isset($link["primary"]) && $link["primary"]) ) {
96 $link['class'] = rtrim('collapsible ' . $link['class'], ' ');
99 $xmlID = isset($link["id"]) ?
$link["id"] : 'ca-' . $xmlID;
100 $nav[$section][$key]['attributes'] =
101 ' id="' . Sanitizer
::escapeId( $xmlID ) . '"';
102 if ( $link['class'] ) {
103 $nav[$section][$key]['attributes'] .=
104 ' class="' . htmlspecialchars( $link['class'] ) . '"';
105 unset( $nav[$section][$key]['class'] );
107 if ( isset($link['tooltiponly']) && $link['tooltiponly'] ) {
108 $nav[$section][$key]['key'] =
109 $this->skin
->tooltip( $xmlID );
111 $nav[$section][$key]['key'] =
112 $this->skin
->tooltipAndAccesskey( $xmlID );
116 $this->data
['namespace_urls'] = $nav['namespaces'];
117 $this->data
['view_urls'] = $nav['views'];
118 $this->data
['action_urls'] = $nav['actions'];
119 $this->data
['variant_urls'] = $nav['variants'];
121 // Reverse horizontally rendered navigation elements
122 if ( $wgLang->isRTL() ) {
123 $this->data
['view_urls'] =
124 array_reverse( $this->data
['view_urls'] );
125 $this->data
['namespace_urls'] =
126 array_reverse( $this->data
['namespace_urls'] );
127 $this->data
['personal_urls'] =
128 array_reverse( $this->data
['personal_urls'] );
131 $this->html( 'headelement' );
133 <div id
="mw-page-base" class="noprint"></div
>
134 <div id
="mw-head-base" class="noprint"></div
>
136 <div id
="content"<?php
$this->html('specialpageattributes') ?
>>
138 <div id
="mw-js-message" style
="display:none;"<?php
$this->html('userlangattributes') ?
>></div
>
139 <?php
if ( $this->data
['sitenotice'] ): ?
>
141 <div id
="siteNotice"><?php
$this->html( 'sitenotice' ) ?
></div
>
144 <!-- firstHeading
-->
145 <h1 id
="firstHeading" class="firstHeading"><?php
$this->html( 'title' ) ?
></h1
>
146 <!-- /firstHeading
-->
148 <div id
="bodyContent">
150 <div id
="siteSub"><?php
$this->msg( 'tagline' ) ?
></div
>
153 <div id
="contentSub"<?php
$this->html('userlangattributes') ?
>><?php
$this->html( 'subtitle' ) ?
></div
>
155 <?php
if ( $this->data
['undelete'] ): ?
>
157 <div id
="contentSub2"><?php
$this->html( 'undelete' ) ?
></div
>
160 <?php
if($this->data
['newtalk'] ): ?
>
162 <div
class="usermessage"><?php
$this->html( 'newtalk' ) ?
></div
>
165 <?php
if ( $this->data
['showjumplinks'] ): ?
>
167 <div id
="jump-to-nav">
168 <?php
$this->msg( 'jumpto' ) ?
> <a href
="#mw-head"><?php
$this->msg( 'jumptonavigation' ) ?
></a
>,
169 <a href
="#p-search"><?php
$this->msg( 'jumptosearch' ) ?
></a
>
174 <?php
$this->html( 'bodytext' ) ?
>
176 <?php
if ( $this->data
['catlinks'] ): ?
>
178 <?php
$this->html( 'catlinks' ); ?
>
181 <?php
if ( $this->data
['dataAfterContent'] ): ?
>
182 <!-- dataAfterContent
-->
183 <?php
$this->html( 'dataAfterContent' ); ?
>
184 <!-- /dataAfterContent
-->
186 <div
class="visualClear"></div
>
188 <!-- /bodyContent
-->
192 <div id
="mw-head" class="noprint">
193 <?php
$this->renderNavigation( 'PERSONAL' ); ?
>
194 <div id
="left-navigation">
195 <?php
$this->renderNavigation( array( 'NAMESPACES', 'VARIANTS' ) ); ?
>
197 <div id
="right-navigation">
198 <?php
$this->renderNavigation( array( 'VIEWS', 'ACTIONS', 'SEARCH' ) ); ?
>
203 <div id
="mw-panel" class="noprint">
205 <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 $this->skin
->tooltipAndAccesskey( 'p-logo' ) ?
>></a
></div
>
207 <?php
$this->renderPortals( $this->data
['sidebar'] ); ?
>
211 <div id
="footer"<?php
$this->html('userlangattributes') ?
>>
212 <?php
foreach( $this->getFooterLinks() as $category => $links ): ?
>
213 <ul id
="footer-<?php echo $category ?>">
214 <?php
foreach( $links as $link ): ?
>
215 <li id
="footer-<?php echo $category ?>-<?php echo $link ?>"><?php
$this->html( $link ) ?
></li
>
219 <?php
$footericons = $this->getFooterIcons("icononly");
220 if ( count( $footericons ) > 0 ): ?
>
221 <ul id
="footer-icons" class="noprint">
222 <?php
foreach ( $footericons as $blockName => $footerIcons ): ?
>
223 <li id
="footer-<?php echo htmlspecialchars($blockName); ?>ico">
224 <?php
foreach ( $footerIcons as $icon ): ?
>
225 <?php
echo $this->skin
->makeFooterIcon( $icon ); ?
>
232 <div style
="clear:both"></div
>
236 <script type
="<?php $this->text('jsmimetype') ?>"> if ( window
.isMSIE55
) fixalpha(); </script
>
238 <?php
$this->printTrail(); ?
>
246 * Render a series of portals
248 private function renderPortals( $portals ) {
249 // Force the rendering of the following portals
250 if ( !isset( $portals['SEARCH'] ) ) $portals['SEARCH'] = true;
251 if ( !isset( $portals['TOOLBOX'] ) ) $portals['TOOLBOX'] = true;
252 if ( !isset( $portals['LANGUAGES'] ) ) $portals['LANGUAGES'] = true;
254 foreach ( $portals as $name => $content ) {
255 echo "\n<!-- {$name} -->\n";
260 $this->renderPortal( "tb", $this->getToolbox(), "toolbox", "SkinTemplateToolboxEnd" );
263 if ( $this->data
['language_urls'] ) {
264 $this->renderPortal("lang", $this->data
['language_urls'], "otherlanguages");
268 $this->renderPortal($name, $content);
271 echo "\n<!-- /{$name} -->\n";
275 private function renderPortal($name, $content, $msg=null, $hook=null) {
276 if ( !isset($msg) ) {
280 <div
class="portal" id
='<?php echo Sanitizer::escapeId( "p-$name" ) ?>'<?php
echo $this->skin
->tooltip( 'p-' . $name ) ?
>>
281 <h5
<?php
$this->html('userlangattributes') ?
>><?php
$out = wfMsg( $msg ); if ( wfEmptyMsg( $msg, $out ) ) echo htmlspecialchars( $msg ); else echo htmlspecialchars( $out ); ?
></h5
>
284 if ( is_array( $content ) ): ?
>
287 foreach( $content as $key => $val ): ?
>
288 <?php
echo $this->makeListItem($key, $val); ?
>
292 if ( isset($hook) ) {
293 wfRunHooks( $hook, array( &$this ) );
299 <?php
echo $content; /* Allow raw HTML block to be defined by extensions */ ?
>
308 * Render one or more navigations elements by name, automatically reveresed
309 * when UI is in RTL mode
311 private function renderNavigation( $elements ) {
312 global $wgVectorUseSimpleSearch, $wgVectorShowVariantName, $wgUser;
314 // If only one element was given, wrap it in an array, allowing more
315 // flexible arguments
316 if ( !is_array( $elements ) ) {
317 $elements = array( $elements );
318 // If there's a series of elements, reverse them when in RTL mode
319 } else if ( wfUILang()->isRTL() ) {
320 $elements = array_reverse( $elements );
323 foreach ( $elements as $name => $element ) {
324 echo "\n<!-- {$name} -->\n";
325 switch ( $element ) {
328 <div id
="p-namespaces" class="vectorTabs<?php if ( count( $this->data['namespace_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
329 <h5
><?php
$this->msg('namespaces') ?
></h5
>
330 <ul
<?php
$this->html('userlangattributes') ?
>>
331 <?php
foreach ($this->data
['namespace_urls'] as $link ): ?
>
332 <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
>
340 <div id
="p-variants" class="vectorMenu<?php if ( count( $this->data['variant_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
341 <?php
if ( $wgVectorShowVariantName ): ?
>
343 <?php
foreach ( $this->data
['variant_urls'] as $link ): ?
>
344 <?php
if ( stripos( $link['attributes'], 'selected' ) !== false ): ?
>
345 <?php
echo htmlspecialchars( $link['text'] ) ?
>
350 <h5
><span
><?php
$this->msg('variants') ?
></span
><a href
="#"></a
></h5
>
352 <ul
<?php
$this->html('userlangattributes') ?
>>
353 <?php
foreach ( $this->data
['variant_urls'] as $link ): ?
>
354 <li
<?php
echo $link['attributes'] ?
>><a href
="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php
echo $link['key'] ?
>><?php
echo htmlspecialchars( $link['text'] ) ?
></a
></li
>
363 <div id
="p-views" class="vectorTabs<?php if ( count( $this->data['view_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
364 <h5
><?php
$this->msg('views') ?
></h5
>
365 <ul
<?php
$this->html('userlangattributes') ?
>>
366 <?php
foreach ( $this->data
['view_urls'] as $link ): ?
>
367 <li
<?php
echo $link['attributes'] ?
>><span
><a href
="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php
echo $link['key'] ?
>><?php
echo (array_key_exists('img',$link) ?
'<img src="'.$link['img'].'" alt="'.$link['text'].'" />' : htmlspecialchars( $link['text'] ) ) ?
></a
></span
></li
>
375 <div id
="p-cactions" class="vectorMenu<?php if ( count( $this->data['action_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
376 <h5
><span
><?php
$this->msg('actions') ?
></span
><a href
="#"></a
></h5
>
378 <ul
<?php
$this->html('userlangattributes') ?
>>
379 <?php
foreach ($this->data
['action_urls'] as $link ): ?
>
380 <li
<?php
echo $link['attributes'] ?
>><a href
="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php
echo $link['key'] ?
>><?php
echo htmlspecialchars( $link['text'] ) ?
></a
></li
>
389 <div id
="p-personal" class="<?php if ( count( $this->data['personal_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
390 <h5
><?php
$this->msg('personaltools') ?
></h5
>
391 <ul
<?php
$this->html('userlangattributes') ?
>>
392 <?php
foreach($this->getPersonalTools() as $key => $item) { ?
>
393 <?php
echo $this->makeListItem($key, $item); ?
>
403 <h5
<?php
$this->html('userlangattributes') ?
>><label
for="searchInput"><?php
$this->msg( 'search' ) ?
></label
></h5
>
404 <form action
="<?php $this->text( 'wgScript' ) ?>" id
="searchform">
405 <input type
='hidden' name
="title" value
="<?php $this->text( 'searchtitle' ) ?>"/>
406 <?php
if ( $wgVectorUseSimpleSearch && $wgUser->getOption( 'vector-simplesearch' ) ): ?
>
407 <div id
="simpleSearch">
408 <?php
if ( $this->data
['rtl'] ): ?
>
409 <?php
echo $this->makeSearchButton("image", array( "id" => "searchButton", "src" => $this->skin
->getSkinStylePath('images/search-rtl.png') )); ?
>
411 <?php
echo $this->makeSearchInput(array( "id" => "searchInput", "type" => "text" )); ?
>
412 <?php
if ( !$this->data
['rtl'] ): ?
>
413 <?php
echo $this->makeSearchButton("image", array( "id" => "searchButton", "src" => $this->skin
->getSkinStylePath('images/search-ltr.png') )); ?
>
417 <?php
echo $this->makeSearchInput(array( "id" => "searchInput" )); ?
>
418 <?php
echo $this->makeSearchButton("go", array( "id" => "searchGoButton", "class" => "searchButton" )); ?
>
419 <?php
echo $this->makeSearchButton("fulltext", array( "id" => "mw-searchButton", "class" => "searchButton" )); ?
>
427 echo "\n<!-- /{$name} -->\n";