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]-->"
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 * @var Skin Cached skin object
73 * Outputs the entire contents of the (X)HTML page
75 public function execute() {
76 global $wgLang, $wgVectorUseIconWatch;
78 $this->skin
= $this->data
['skin'];
80 // Build additional attributes for navigation urls
81 //$nav = $this->skin->buildNavigationUrls();
82 $nav = $this->data
['content_navigation'];
84 if ( $wgVectorUseIconWatch ) {
85 $mode = $this->skin
->getTitle()->userIsWatching() ?
'unwatch' : 'watch';
86 if ( isset($nav['actions'][$mode]) ) {
87 $nav['views'][$mode] = $nav['actions'][$mode];
88 $nav['views'][$mode]['class'] = rtrim('icon ' . $nav['views'][$mode]['class'], ' ');
89 $nav['views'][$mode]['primary'] = true;
90 unset($nav['actions'][$mode]);
95 foreach ( $nav as $section => $links ) {
96 foreach ( $links as $key => $link ) {
97 if ( $section == "views" && !(isset($link["primary"]) && $link["primary"]) ) {
98 $link['class'] = rtrim('collapsible ' . $link['class'], ' ');
101 $xmlID = isset($link["id"]) ?
$link["id"] : 'ca-' . $xmlID;
102 $nav[$section][$key]['attributes'] =
103 ' id="' . Sanitizer
::escapeId( $xmlID ) . '"';
104 if ( $link['class'] ) {
105 $nav[$section][$key]['attributes'] .=
106 ' class="' . htmlspecialchars( $link['class'] ) . '"';
107 unset( $nav[$section][$key]['class'] );
109 if ( isset($link['tooltiponly']) && $link['tooltiponly'] ) {
110 $nav[$section][$key]['key'] =
111 Linker
::tooltip( $xmlID );
113 $nav[$section][$key]['key'] =
114 Linker
::tooltipAndAccesskey( $xmlID );
118 $this->data
['namespace_urls'] = $nav['namespaces'];
119 $this->data
['view_urls'] = $nav['views'];
120 $this->data
['action_urls'] = $nav['actions'];
121 $this->data
['variant_urls'] = $nav['variants'];
123 // Reverse horizontally rendered navigation elements
124 if ( $wgLang->isRTL() ) {
125 $this->data
['view_urls'] =
126 array_reverse( $this->data
['view_urls'] );
127 $this->data
['namespace_urls'] =
128 array_reverse( $this->data
['namespace_urls'] );
129 $this->data
['personal_urls'] =
130 array_reverse( $this->data
['personal_urls'] );
133 $this->html( 'headelement' );
135 <div id
="mw-page-base" class="noprint"></div
>
136 <div id
="mw-head-base" class="noprint"></div
>
138 <div id
="content"<?php
$this->html('specialpageattributes') ?
>>
140 <div id
="mw-js-message" style
="display:none;"<?php
$this->html('userlangattributes') ?
>></div
>
141 <?php
if ( $this->data
['sitenotice'] ): ?
>
143 <div id
="siteNotice"><?php
$this->html( 'sitenotice' ) ?
></div
>
146 <!-- firstHeading
-->
147 <h1 id
="firstHeading" class="firstHeading"><?php
$this->html( 'title' ) ?
></h1
>
148 <!-- /firstHeading
-->
150 <div id
="bodyContent">
151 <?php
if ( $this->data
['isarticle'] ): ?
>
153 <div id
="siteSub"><?php
$this->msg( 'tagline' ) ?
></div
>
157 <div id
="contentSub"<?php
$this->html('userlangattributes') ?
>><?php
$this->html( 'subtitle' ) ?
></div
>
159 <?php
if ( $this->data
['undelete'] ): ?
>
161 <div id
="contentSub2"><?php
$this->html( 'undelete' ) ?
></div
>
164 <?php
if($this->data
['newtalk'] ): ?
>
166 <div
class="usermessage"><?php
$this->html( 'newtalk' ) ?
></div
>
169 <?php
if ( $this->data
['showjumplinks'] ): ?
>
171 <div id
="jump-to-nav">
172 <?php
$this->msg( 'jumpto' ) ?
> <a href
="#mw-head"><?php
$this->msg( 'jumptonavigation' ) ?
></a
>,
173 <a href
="#p-search"><?php
$this->msg( 'jumptosearch' ) ?
></a
>
178 <?php
$this->html( 'bodytext' ) ?
>
180 <?php
if ( $this->data
['catlinks'] ): ?
>
182 <?php
$this->html( 'catlinks' ); ?
>
185 <?php
if ( $this->data
['dataAfterContent'] ): ?
>
186 <!-- dataAfterContent
-->
187 <?php
$this->html( 'dataAfterContent' ); ?
>
188 <!-- /dataAfterContent
-->
190 <div
class="visualClear"></div
>
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 Linker
::tooltipAndAccesskey( '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->skin
->makeFooterIcon( $icon ); ?
>
236 <div style
="clear:both"></div
>
240 <script type
="<?php $this->text('jsmimetype') ?>"> if ( window
.isMSIE55
) fixalpha(); </script
>
242 <?php
$this->printTrail(); ?
>
250 * Render a series of portals
252 private function renderPortals( $portals ) {
253 // Force the rendering of the following portals
254 if ( !isset( $portals['SEARCH'] ) ) $portals['SEARCH'] = true;
255 if ( !isset( $portals['TOOLBOX'] ) ) $portals['TOOLBOX'] = true;
256 if ( !isset( $portals['LANGUAGES'] ) ) $portals['LANGUAGES'] = true;
258 foreach ( $portals as $name => $content ) {
259 echo "\n<!-- {$name} -->\n";
264 $this->renderPortal( "tb", $this->getToolbox(), "toolbox", "SkinTemplateToolboxEnd" );
267 if ( $this->data
['language_urls'] ) {
268 $this->renderPortal("lang", $this->data
['language_urls'], "otherlanguages");
272 $this->renderPortal($name, $content);
275 echo "\n<!-- /{$name} -->\n";
279 private function renderPortal($name, $content, $msg=null, $hook=null) {
280 if ( !isset($msg) ) {
284 <div
class="portal" id
='<?php echo Sanitizer::escapeId( "p-$name" ) ?>'<?php
echo Linker
::tooltip( 'p-' . $name ) ?
>>
285 <h5
<?php
$this->html('userlangattributes') ?
>><?php
$out = wfMsg( $msg ); if ( wfEmptyMsg( $msg ) ) echo htmlspecialchars( $msg ); else echo htmlspecialchars( $out ); ?
></h5
>
288 if ( is_array( $content ) ): ?
>
291 foreach( $content as $key => $val ): ?
>
292 <?php
echo $this->makeListItem($key, $val); ?
>
296 if ( isset($hook) ) {
297 wfRunHooks( $hook, array( &$this ) );
303 <?php
echo $content; /* Allow raw HTML block to be defined by extensions */ ?
>
312 * Render one or more navigations elements by name, automatically reveresed
313 * when UI is in RTL mode
315 private function renderNavigation( $elements ) {
316 global $wgVectorUseSimpleSearch, $wgVectorShowVariantName, $wgUser;
318 // If only one element was given, wrap it in an array, allowing more
319 // flexible arguments
320 if ( !is_array( $elements ) ) {
321 $elements = array( $elements );
322 // If there's a series of elements, reverse them when in RTL mode
323 } else if ( wfUILang()->isRTL() ) {
324 $elements = array_reverse( $elements );
327 foreach ( $elements as $name => $element ) {
328 echo "\n<!-- {$name} -->\n";
329 switch ( $element ) {
332 <div id
="p-namespaces" class="vectorTabs<?php if ( count( $this->data['namespace_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
333 <h5
><?php
$this->msg('namespaces') ?
></h5
>
334 <ul
<?php
$this->html('userlangattributes') ?
>>
335 <?php
foreach ($this->data
['namespace_urls'] as $link ): ?
>
336 <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
>
344 <div id
="p-variants" class="vectorMenu<?php if ( count( $this->data['variant_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
345 <?php
if ( $wgVectorShowVariantName ): ?
>
347 <?php
foreach ( $this->data
['variant_urls'] as $link ): ?
>
348 <?php
if ( stripos( $link['attributes'], 'selected' ) !== false ): ?
>
349 <?php
echo htmlspecialchars( $link['text'] ) ?
>
354 <h5
><span
><?php
$this->msg('variants') ?
></span
><a href
="#"></a
></h5
>
356 <ul
<?php
$this->html('userlangattributes') ?
>>
357 <?php
foreach ( $this->data
['variant_urls'] as $link ): ?
>
358 <li
<?php
echo $link['attributes'] ?
>><a href
="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php
echo $link['key'] ?
>><?php
echo htmlspecialchars( $link['text'] ) ?
></a
></li
>
367 <div id
="p-views" class="vectorTabs<?php if ( count( $this->data['view_urls'] ) == 0 ) { echo ' emptyPortlet'; } ?>">
368 <h5
><?php
$this->msg('views') ?
></h5
>
369 <ul
<?php
$this->html('userlangattributes') ?
>>
370 <?php
foreach ( $this->data
['view_urls'] as $link ): ?
>
371 <li
<?php
echo $link['attributes'] ?
>><span
><a href
="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php
echo $link['key'] ?
>><?php
372 // $link['text'] can be undefined - bug 27764
373 if ( array_key_exists( 'text', $link ) ) {
374 echo array_key_exists( 'img', $link ) ?
'<img src="' . $link['img'] . '" alt="' . $link['text'] . '" />' : htmlspecialchars( $link['text'] );
384 <div id
="p-cactions" class="vectorMenu<?php if ( count( $this->data['action_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
385 <h5
><span
><?php
$this->msg('actions') ?
></span
><a href
="#"></a
></h5
>
387 <ul
<?php
$this->html('userlangattributes') ?
>>
388 <?php
foreach ($this->data
['action_urls'] as $link ): ?
>
389 <li
<?php
echo $link['attributes'] ?
>><a href
="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php
echo $link['key'] ?
>><?php
echo htmlspecialchars( $link['text'] ) ?
></a
></li
>
398 <div id
="p-personal" class="<?php if ( count( $this->data['personal_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
399 <h5
><?php
$this->msg('personaltools') ?
></h5
>
400 <ul
<?php
$this->html('userlangattributes') ?
>>
401 <?php
foreach($this->getPersonalTools() as $key => $item) { ?
>
402 <?php
echo $this->makeListItem($key, $item); ?
>
412 <h5
<?php
$this->html('userlangattributes') ?
>><label
for="searchInput"><?php
$this->msg( 'search' ) ?
></label
></h5
>
413 <form action
="<?php $this->text( 'wgScript' ) ?>" id
="searchform">
414 <input type
='hidden' name
="title" value
="<?php $this->text( 'searchtitle' ) ?>"/>
415 <?php
if ( $wgVectorUseSimpleSearch && $wgUser->getOption( 'vector-simplesearch' ) ): ?
>
416 <div id
="simpleSearch">
417 <?php
if ( $this->data
['rtl'] ): ?
>
418 <?php
echo $this->makeSearchButton("image", array( "id" => "searchButton", "src" => $this->skin
->getSkinStylePath('images/search-rtl.png') )); ?
>
420 <?php
echo $this->makeSearchInput(array( "id" => "searchInput", "type" => "text" )); ?
>
421 <?php
if ( !$this->data
['rtl'] ): ?
>
422 <?php
echo $this->makeSearchButton("image", array( "id" => "searchButton", "src" => $this->skin
->getSkinStylePath('images/search-ltr.png') )); ?
>
426 <?php
echo $this->makeSearchInput(array( "id" => "searchInput" )); ?
>
427 <?php
echo $this->makeSearchButton("go", array( "id" => "searchGoButton", "class" => "searchButton" )); ?
>
428 <?php
echo $this->makeSearchButton("fulltext", array( "id" => "mw-searchButton", "class" => "searchButton" )); ?
>
436 echo "\n<!-- /{$name} -->\n";