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 Xml
::expandAttributes( Linker
::tooltipAndAccesskeyAttribs( $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
['printfooter'] ): ?
>
182 <div
class="printfooter">
183 <?php
$this->html( 'printfooter' ); ?
>
185 <!-- /printfooter
-->
188 <?php
$this->html('debughtml'); ?
>
190 <?php
if ( $this->data
['catlinks'] ): ?
>
192 <?php
$this->html( 'catlinks' ); ?
>
195 <?php
if ( $this->data
['dataAfterContent'] ): ?
>
196 <!-- dataAfterContent
-->
197 <?php
$this->html( 'dataAfterContent' ); ?
>
198 <!-- /dataAfterContent
-->
200 <div
class="visualClear"></div
>
202 <!-- /bodyContent
-->
206 <div id
="mw-head" class="noprint">
207 <?php
$this->renderNavigation( 'PERSONAL' ); ?
>
208 <div id
="left-navigation">
209 <?php
$this->renderNavigation( array( 'NAMESPACES', 'VARIANTS' ) ); ?
>
211 <div id
="right-navigation">
212 <?php
$this->renderNavigation( array( 'VIEWS', 'ACTIONS', 'SEARCH' ) ); ?
>
217 <div id
="mw-panel" class="noprint">
219 <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
::tooltipAndAccesskeyAttribs( 'p-logo' ) ?
>></a
></div
>
221 <?php
$this->renderPortals( $this->data
['sidebar'] ); ?
>
225 <div id
="footer"<?php
$this->html('userlangattributes') ?
>>
226 <?php
foreach( $this->getFooterLinks() as $category => $links ): ?
>
227 <ul id
="footer-<?php echo $category ?>">
228 <?php
foreach( $links as $link ): ?
>
229 <li id
="footer-<?php echo $category ?>-<?php echo $link ?>"><?php
$this->html( $link ) ?
></li
>
233 <?php
$footericons = $this->getFooterIcons("icononly");
234 if ( count( $footericons ) > 0 ): ?
>
235 <ul id
="footer-icons" class="noprint">
236 <?php
foreach ( $footericons as $blockName => $footerIcons ): ?
>
237 <li id
="footer-<?php echo htmlspecialchars($blockName); ?>ico">
238 <?php
foreach ( $footerIcons as $icon ): ?
>
239 <?php
echo $this->skin
->makeFooterIcon( $icon ); ?
>
246 <div style
="clear:both"></div
>
250 <script type
="<?php $this->text('jsmimetype') ?>"> if ( window
.isMSIE55
) fixalpha(); </script
>
252 <?php
$this->printTrail(); ?
>
260 * Render a series of portals
262 private function renderPortals( $portals ) {
263 // Force the rendering of the following portals
264 if ( !isset( $portals['SEARCH'] ) ) $portals['SEARCH'] = true;
265 if ( !isset( $portals['TOOLBOX'] ) ) $portals['TOOLBOX'] = true;
266 if ( !isset( $portals['LANGUAGES'] ) ) $portals['LANGUAGES'] = true;
268 foreach ( $portals as $name => $content ) {
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 ( !isset($msg) ) {
294 <div
class="portal" id
='<?php echo Sanitizer::escapeId( "p-$name" ) ?>'<?php
echo Linker
::tooltip( 'p-' . $name ) ?
>>
295 <h5
<?php
$this->html('userlangattributes') ?
>><?php
$out = wfMsg( $msg ); if ( wfEmptyMsg( $msg ) ) echo htmlspecialchars( $msg ); else echo htmlspecialchars( $out ); ?
></h5
>
298 if ( is_array( $content ) ): ?
>
301 foreach( $content as $key => $val ): ?
>
302 <?php
echo $this->makeListItem($key, $val); ?
>
306 if ( isset($hook) ) {
307 wfRunHooks( $hook, array( &$this ) );
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 private function renderNavigation( $elements ) {
326 global $wgVectorUseSimpleSearch, $wgVectorShowVariantName, $wgUser;
328 // If only one element was given, wrap it in an array, allowing more
329 // flexible arguments
330 if ( !is_array( $elements ) ) {
331 $elements = array( $elements );
332 // If there's a series of elements, reverse them when in RTL mode
333 } else if ( wfUILang()->isRTL() ) {
334 $elements = array_reverse( $elements );
337 foreach ( $elements as $name => $element ) {
338 echo "\n<!-- {$name} -->\n";
339 switch ( $element ) {
342 <div id
="p-namespaces" class="vectorTabs<?php if ( count( $this->data['namespace_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
343 <h5
><?php
$this->msg('namespaces') ?
></h5
>
344 <ul
<?php
$this->html('userlangattributes') ?
>>
345 <?php
foreach ($this->data
['namespace_urls'] as $link ): ?
>
346 <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
>
354 <div id
="p-variants" class="vectorMenu<?php if ( count( $this->data['variant_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
355 <?php
if ( $wgVectorShowVariantName ): ?
>
357 <?php
foreach ( $this->data
['variant_urls'] as $link ): ?
>
358 <?php
if ( stripos( $link['attributes'], 'selected' ) !== false ): ?
>
359 <?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 <input type
='hidden' name
="title" value
="<?php $this->text( 'searchtitle' ) ?>"/>
425 <?php
if ( $wgVectorUseSimpleSearch && $wgUser->getOption( 'vector-simplesearch' ) ): ?
>
426 <div id
="simpleSearch">
427 <?php
if ( $this->data
['rtl'] ): ?
>
428 <?php
echo $this->makeSearchButton("image", array( "id" => "searchButton", "src" => $this->skin
->getSkinStylePath('images/search-rtl.png') )); ?
>
430 <?php
echo $this->makeSearchInput(array( "id" => "searchInput", "type" => "text" )); ?
>
431 <?php
if ( !$this->data
['rtl'] ): ?
>
432 <?php
echo $this->makeSearchButton("image", array( "id" => "searchButton", "src" => $this->skin
->getSkinStylePath('images/search-ltr.png') )); ?
>
436 <?php
echo $this->makeSearchInput(array( "id" => "searchInput" )); ?
>
437 <?php
echo $this->makeSearchButton("go", array( "id" => "searchGoButton", "class" => "searchButton" )); ?
>
438 <?php
echo $this->makeSearchButton("fulltext", array( "id" => "mw-searchButton", "class" => "searchButton" )); ?
>
446 echo "\n<!-- /{$name} -->\n";