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 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
->mTitle
->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]);
92 foreach ( $nav as $section => $links ) {
93 foreach ( $links as $key => $link ) {
94 if ( $section == "views" && !(isset($link["primary"]) && $link["primary"]) ) {
95 $link['class'] = rtrim('collapsible ' . $link['class'], ' ');
98 $xmlID = isset($link["id"]) ?
$link["id"] : 'ca-' . $xmlID;
99 $nav[$section][$key]['attributes'] =
100 ' id="' . Sanitizer
::escapeId( $xmlID ) . '"';
101 if ( $link['class'] ) {
102 $nav[$section][$key]['attributes'] .=
103 ' class="' . htmlspecialchars( $link['class'] ) . '"';
104 unset( $nav[$section][$key]['class'] );
106 if ( isset($link['tooltiponly']) && $link['tooltiponly'] ) {
107 $nav[$section][$key]['key'] =
108 $this->skin
->tooltip( $xmlID );
110 $nav[$section][$key]['key'] =
111 $this->skin
->tooltipAndAccesskey( $xmlID );
115 $this->data
['namespace_urls'] = $nav['namespaces'];
116 $this->data
['view_urls'] = $nav['views'];
117 $this->data
['action_urls'] = $nav['actions'];
118 $this->data
['variant_urls'] = $nav['variants'];
120 // Reverse horizontally rendered navigation elements
121 if ( $wgLang->isRTL() ) {
122 $this->data
['view_urls'] =
123 array_reverse( $this->data
['view_urls'] );
124 $this->data
['namespace_urls'] =
125 array_reverse( $this->data
['namespace_urls'] );
126 $this->data
['personal_urls'] =
127 array_reverse( $this->data
['personal_urls'] );
130 $this->html( 'headelement' );
132 <div id
="mw-page-base" class="noprint"></div
>
133 <div id
="mw-head-base" class="noprint"></div
>
135 <div id
="content"<?php
$this->html('specialpageattributes') ?
>>
137 <div id
="mw-js-message" style
="display:none;"<?php
$this->html('userlangattributes') ?
>></div
>
138 <?php
if ( $this->data
['sitenotice'] ): ?
>
140 <div id
="siteNotice"><?php
$this->html( 'sitenotice' ) ?
></div
>
143 <!-- firstHeading
-->
144 <h1 id
="firstHeading" class="firstHeading"><?php
$this->html( 'title' ) ?
></h1
>
145 <!-- /firstHeading
-->
147 <div id
="bodyContent">
149 <div id
="siteSub"><?php
$this->msg( 'tagline' ) ?
></div
>
152 <div id
="contentSub"<?php
$this->html('userlangattributes') ?
>><?php
$this->html( 'subtitle' ) ?
></div
>
154 <?php
if ( $this->data
['undelete'] ): ?
>
156 <div id
="contentSub2"><?php
$this->html( 'undelete' ) ?
></div
>
159 <?php
if($this->data
['newtalk'] ): ?
>
161 <div
class="usermessage"><?php
$this->html( 'newtalk' ) ?
></div
>
164 <?php
if ( $this->data
['showjumplinks'] ): ?
>
166 <div id
="jump-to-nav">
167 <?php
$this->msg( 'jumpto' ) ?
> <a href
="#mw-head"><?php
$this->msg( 'jumptonavigation' ) ?
></a
>,
168 <a href
="#p-search"><?php
$this->msg( 'jumptosearch' ) ?
></a
>
173 <?php
$this->html( 'bodytext' ) ?
>
175 <?php
if ( $this->data
['catlinks'] ): ?
>
177 <?php
$this->html( 'catlinks' ); ?
>
180 <?php
if ( $this->data
['dataAfterContent'] ): ?
>
181 <!-- dataAfterContent
-->
182 <?php
$this->html( 'dataAfterContent' ); ?
>
183 <!-- /dataAfterContent
-->
185 <div
class="visualClear"></div
>
187 <!-- /bodyContent
-->
191 <div id
="mw-head" class="noprint">
192 <?php
$this->renderNavigation( 'PERSONAL' ); ?
>
193 <div id
="left-navigation">
194 <?php
$this->renderNavigation( array( 'NAMESPACES', 'VARIANTS' ) ); ?
>
196 <div id
="right-navigation">
197 <?php
$this->renderNavigation( array( 'VIEWS', 'ACTIONS', 'SEARCH' ) ); ?
>
202 <div id
="mw-panel" class="noprint">
204 <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
>
206 <?php
$this->renderPortals( $this->data
['sidebar'] ); ?
>
210 <div id
="footer"<?php
$this->html('userlangattributes') ?
>>
211 <?php
foreach( $this->getFooterLinks() as $category => $links ): ?
>
212 <ul id
="footer-<?php echo $category ?>">
213 <?php
foreach( $links as $link ): ?
>
214 <li id
="footer-<?php echo $category ?>-<?php echo $link ?>"><?php
$this->html( $link ) ?
></li
>
218 <?php
$footericons = $this->getFooterIcons("icononly");
219 if ( count( $footericons ) > 0 ): ?
>
220 <ul id
="footer-icons" class="noprint">
221 <?php
foreach ( $footericons as $blockName => $footerIcons ): ?
>
222 <li id
="footer-<?php echo htmlspecialchars($blockName); ?>ico">
223 <?php
foreach ( $footerIcons as $icon ): ?
>
224 <?php
echo $this->skin
->makeFooterIcon( $icon ); ?
>
231 <div style
="clear:both"></div
>
235 <script type
="<?php $this->text('jsmimetype') ?>"> if ( window
.isMSIE55
) fixalpha(); </script
>
237 <?php
$this->printTrail(); ?
>
245 * Render a series of portals
247 private function renderPortals( $portals ) {
248 // Force the rendering of the following portals
249 if ( !isset( $portals['SEARCH'] ) ) $portals['SEARCH'] = true;
250 if ( !isset( $portals['TOOLBOX'] ) ) $portals['TOOLBOX'] = true;
251 if ( !isset( $portals['LANGUAGES'] ) ) $portals['LANGUAGES'] = true;
253 foreach ( $portals as $name => $content ) {
254 echo "\n<!-- {$name} -->\n";
259 $this->renderPortal( "tb", $this->getToolbox(), "toolbox", "SkinTemplateToolboxEnd" );
262 if ( $this->data
['language_urls'] ) {
263 $this->renderPortal("lang", $this->data
['language_urls'], "otherlanguages");
267 $this->renderPortal($name, $content);
270 echo "\n<!-- /{$name} -->\n";
274 private function renderPortal($name, $content, $msg=null, $hook=null) {
275 if ( !isset($msg) ) {
279 <div
class="portal" id
='<?php echo Sanitizer::escapeId( "p-$name" ) ?>'<?php
echo $this->skin
->tooltip( 'p-' . $name ) ?
>>
280 <h5
<?php
$this->html('userlangattributes') ?
>><?php
$out = wfMsg( $msg ); if ( wfEmptyMsg( $msg, $out ) ) echo htmlspecialchars( $msg ); else echo htmlspecialchars( $out ); ?
></h5
>
283 if ( is_array( $content ) ): ?
>
286 foreach( $content as $key => $val ): ?
>
287 <?php
echo $this->makeListItem($key, $val); ?
>
291 if ( isset($hook) ) {
292 wfRunHooks( $hook, array( &$this ) );
298 <?php
echo $content; /* Allow raw HTML block to be defined by extensions */ ?
>
307 * Render one or more navigations elements by name, automatically reveresed
308 * when UI is in RTL mode
310 private function renderNavigation( $elements ) {
311 global $wgVectorUseSimpleSearch, $wgVectorShowVariantName, $wgUser;
313 // If only one element was given, wrap it in an array, allowing more
314 // flexible arguments
315 if ( !is_array( $elements ) ) {
316 $elements = array( $elements );
317 // If there's a series of elements, reverse them when in RTL mode
318 } else if ( wfUILang()->isRTL() ) {
319 $elements = array_reverse( $elements );
322 foreach ( $elements as $name => $element ) {
323 echo "\n<!-- {$name} -->\n";
324 switch ( $element ) {
327 <div id
="p-namespaces" class="vectorTabs<?php if ( count( $this->data['namespace_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
328 <h5
><?php
$this->msg('namespaces') ?
></h5
>
329 <ul
<?php
$this->html('userlangattributes') ?
>>
330 <?php
foreach ($this->data
['namespace_urls'] as $link ): ?
>
331 <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
>
339 <div id
="p-variants" class="vectorMenu<?php if ( count( $this->data['variant_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
340 <?php
if ( $wgVectorShowVariantName ): ?
>
342 <?php
foreach ( $this->data
['variant_urls'] as $link ): ?
>
343 <?php
if ( stripos( $link['attributes'], 'selected' ) !== false ): ?
>
344 <?php
echo htmlspecialchars( $link['text'] ) ?
>
349 <h5
><span
><?php
$this->msg('variants') ?
></span
><a href
="#"></a
></h5
>
351 <ul
<?php
$this->html('userlangattributes') ?
>>
352 <?php
foreach ( $this->data
['variant_urls'] as $link ): ?
>
353 <li
<?php
echo $link['attributes'] ?
>><a href
="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php
echo $link['key'] ?
>><?php
echo htmlspecialchars( $link['text'] ) ?
></a
></li
>
362 <div id
="p-views" class="vectorTabs<?php if ( count( $this->data['view_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
363 <h5
><?php
$this->msg('views') ?
></h5
>
364 <ul
<?php
$this->html('userlangattributes') ?
>>
365 <?php
foreach ( $this->data
['view_urls'] as $link ): ?
>
366 <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
>
374 <div id
="p-cactions" class="vectorMenu<?php if ( count( $this->data['action_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
375 <h5
><span
><?php
$this->msg('actions') ?
></span
><a href
="#"></a
></h5
>
377 <ul
<?php
$this->html('userlangattributes') ?
>>
378 <?php
foreach ($this->data
['action_urls'] as $link ): ?
>
379 <li
<?php
echo $link['attributes'] ?
>><a href
="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php
echo $link['key'] ?
>><?php
echo htmlspecialchars( $link['text'] ) ?
></a
></li
>
388 <div id
="p-personal" class="<?php if ( count( $this->data['personal_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
389 <h5
><?php
$this->msg('personaltools') ?
></h5
>
390 <ul
<?php
$this->html('userlangattributes') ?
>>
391 <?php
foreach($this->getPersonalTools() as $key => $item) { ?
>
392 <?php
echo $this->makeListItem($key, $item); ?
>
402 <h5
<?php
$this->html('userlangattributes') ?
>><label
for="searchInput"><?php
$this->msg( 'search' ) ?
></label
></h5
>
403 <form action
="<?php $this->text( 'wgScript' ) ?>" id
="searchform">
404 <input type
='hidden' name
="title" value
="<?php $this->text( 'searchtitle' ) ?>"/>
405 <?php
if ( $wgVectorUseSimpleSearch && $wgUser->getOption( 'vector-simplesearch' ) ): ?
>
406 <div id
="simpleSearch">
407 <?php
if ( $this->data
['rtl'] ): ?
>
408 <?php
echo $this->makeSearchButton("image", array( "id" => "searchButton", "src" => $this->skin
->getSkinStylePath('images/search-rtl.png') )); ?
>
410 <?php
echo $this->makeSearchInput(array( "id" => "searchInput", "type" => "text" )); ?
>
411 <?php
if ( !$this->data
['rtl'] ): ?
>
412 <?php
echo $this->makeSearchButton("image", array( "id" => "searchButton", "src" => $this->skin
->getSkinStylePath('images/search-ltr.png') )); ?
>
416 <?php
echo $this->makeSearchInput(array( "id" => "searchInput" )); ?
>
417 <?php
echo $this->makeSearchButton("go", array( "id" => "searchGoButton", "class" => "searchButton" )); ?
>
418 <?php
echo $this->makeSearchButton("fulltext", array( "id" => "mw-searchButton", "class" => "searchButton" )); ?
>
426 echo "\n<!-- /{$name} -->\n";