3 * Vector - Branch of MonoBook which has many usability improvements and
4 * somewhat cleaner code.
11 if( !defined( 'MEDIAWIKI' ) )
15 * SkinTemplate class for Vector skin
18 class SkinVector
extends SkinTemplate
{
23 * Initializes output page and sets up skin-specific parameters
24 * @param object $out Output page object to initialize
26 public function initPage( OutputPage
$out ) {
27 parent
::initPage( $out );
28 $this->skinname
= 'vector';
29 $this->stylename
= 'vector';
30 $this->template
= 'VectorTemplate';
34 * Defines CSS files to be included
35 * @param object $out Output page to add styles to
37 public function setupSkinUserCss( OutputPage
$out ) {
39 // Append to the default screen common & print styles...
40 if ( $wgContLang->isRTL() ) {
41 $out->addStyle( 'vector/main-rtl.css', 'screen' );
43 $out->addStyle( 'vector/main-ltr.css', 'screen' );
46 parent
::setupSkinUserCss( $out );
52 * QuickTemplate class for Vector skin
55 class VectorTemplate
extends QuickTemplate
{
60 * @var Cached skin object
67 * Outputs the entire contents of the XHTML page
69 public function execute() {
70 global $wgRequest, $wgUseTwoButtonsSearchForm;
72 $this->skin
= $this->data
['skin'];
73 $action = $wgRequest->getText( 'action' );
75 // Suppress warnings to prevent notices about missing indexes in
76 // $this->data (is this really the best way to handle this?)
79 // Build additional attributes for navigation urls
80 $nav = $this->skin
->buildNavigationUrls();
81 foreach ( $nav as $section => $links ) {
82 foreach ( $links as $key => $link ) {
84 if ( isset( $link['context'] ) && $link['context'] == 'subject' ) {
85 $xmlID = 'ca-nstab-' . $xmlID;
86 } else if ( isset( $link['context'] ) && $link['context'] == 'talk' ) {
89 $xmlID = 'ca-' . $xmlID;
91 $nav[$section][$key]['attributes'] =
92 ' id="' . Sanitizer
::escapeId( $xmlID ) . '"';
93 if ( $nav[$section][$key]['class'] ) {
94 $nav[$section][$key]['attributes'] .=
95 ' class="' . htmlspecialchars( $link['class'] ) . '"';
96 unset( $nav[$section][$key]['class'] );
99 // We don't want to give the watch tab an accesskey if the page is
100 // being edited, because that conflicts with the accesskey on the
101 // watch checkbox. We also don't want to give the edit tab an
102 // accesskey, because that's fairly superfluous and conflicts with
103 // an accesskey (Ctrl-E) often used for editing in Safari.
105 in_array( $action, array( 'edit', 'submit' ) ) &&
106 in_array( $key, array( 'edit', 'watch', 'unwatch' ) )
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 // Build additional attributes for personal_urls
122 foreach ( $this->data
['personal_urls'] as $key => $item) {
123 $this->data
['personal_urls'][$key]['attributes'] =
124 ' id="' . Sanitizer
::escapeId( "pt-$key" ) . '"';
125 if ( $item['active'] ) {
126 $this->data
['personal_urls'][$key]['attributes'] .=
129 $this->data
['personal_urls'][$key]['key'] =
130 $this->skin
->tooltipAndAccesskey('pt-'.$key);
133 // Generate additional footer links
134 $footerlinks = array(
138 'numberofwatchingusers',
150 // Build list of valid footer links
151 $validFooterLinks = array();
152 foreach( $footerlinks as $category => $links ) {
153 $validFooterLinks[$category] = array();
154 foreach( $links as $link ) {
155 if( isset( $this->data
[$link] ) && $this->data
[$link] ) {
156 $validFooterLinks[$category][] = $link;
161 // Begin content output
162 ?
><!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
163 <html xmlns
="<?php $this->text('xhtmldefaultnamespace') ?>" <?php
foreach($this->data
['xhtmlnamespaces'] as $tag => $ns): ?
>xmlns
:<?php
echo "{$tag}=\"{$ns}\" "; ?
><?php
endforeach ?
>xml
:lang
="<?php $this->text('lang') ?>" lang
="<?php $this->text('lang') ?>" dir
="<?php $this->text('dir') ?>">
165 <meta http
-equiv
="Content-Type" content
="<?php $this->text('mimetype') ?>; charset=<?php $this->text('charset') ?>" />
166 <title
><?php
$this->text('pagetitle') ?
></title
>
168 <?php
$this->html('headlinks') ?
>
171 <?php
$this->html('csslinks') ?
>
174 <!--[if lt IE
7]><script type
="<?php $this->text('jsmimetype') ?>" src
="<?php $this->text('stylepath') ?>/common/IEFixes.js?<?php echo $GLOBALS['wgStyleVersion'] ?>"></script
>
175 <meta http
-equiv
="imagetoolbar" content
="no" /><![endif]-->
176 <style type
="text/css">body
{behavior
:url("<?php $this->text('stylepath') ?>/vector/csshover.htc")}</style
>
178 <!-- globalVariablesScript
-->
179 <?php
echo Skin
::makeGlobalVariablesScript( $this->data
); ?
>
180 <!-- /globalVariablesScript
-->
182 <script type
="<?php $this->text('jsmimetype') ?>" src
="<?php $this->text('stylepath' ) ?>/common/wikibits.js?<?php echo $GLOBALS['wgStyleVersion'] ?>"><!-- wikibits js
--></script
>
185 <?php
$this->html('headscripts') ?
>
186 <!-- /headscripts
-->
187 <?php
if($this->data
['jsvarurl']): ?
>
189 <script type
="<?php $this->text('jsmimetype') ?>" src
="<?php $this->text('jsvarurl') ?>"><!-- site js
--></script
>
192 <?php
if($this->data
['pagecss']): ?
>
194 <style type
="text/css"><?php
$this->html('pagecss') ?
></style
>
197 <?php
if($this->data
['usercss']): ?
>
199 <style type
="text/css"><?php
$this->html('usercss') ?
></style
>
202 <?php
if($this->data
['userjs']): ?
>
204 <script type
="<?php $this->text('jsmimetype') ?>" src
="<?php $this->text('userjs' ) ?>"></script
>
207 <?php
if($this->data
['userjsprev']): ?
>
209 <script type
="<?php $this->text('jsmimetype') ?>"><?php
$this->html('userjsprev') ?
></script
>
212 <?php
if($this->data
['trackbackhtml']): ?
>
213 <!-- trackbackhtml
-->
214 <?php
echo $this->data
['trackbackhtml']; ?
>
215 <!-- /trackbackhtml
-->
218 <body
<?php
if($this->data
['body_ondblclick']): ?
> ondblclick
="<?php $this->text('body_ondblclick') ?>"<?php
endif; ?
> <?php
if($this->data
['body_onload']): ?
> onload
="<?php $this->text('body_onload') ?>"<?php
endif; ?
> class="mediawiki <?php $this->text('dir') ?> <?php $this->text('pageclass') ?> <?php $this->text('skinnameclass') ?>">
219 <div id
="page-base" class="noprint"></div
>
220 <div id
="head-base" class="noprint"></div
>
223 <a name
="top" id
="top"></a
>
224 <div id
="mw-js-message" style
="display:none;"></div
>
226 <?php
if($this->data
['sitenotice']) { ?
><div id
="siteNotice"><?php
$this->html('sitenotice') ?
></div
><?php
} ?
>
228 <!-- firstHeading
-->
229 <h1 id
="firstHeading" class="firstHeading"><?php
$this->html('title') ?
></h1
>
230 <!-- /firstHeading
-->
232 <div id
="bodyContent">
234 <h3 id
="siteSub"><?php
$this->msg('tagline') ?
></h3
>
237 <div id
="contentSub"><?php
$this->html('subtitle') ?
></div
>
239 <?php
if($this->data
['undelete']): ?
>
241 <div id
="contentSub2"><?php
$this->html('undelete') ?
></div
>
244 <?php
if($this->data
['newtalk'] ): ?
>
246 <div
class="usermessage"><?php
$this->html('newtalk') ?
></div
>
249 <?php
if($this->data
['showjumplinks']): ?
>
251 <div id
="jump-to-nav">
252 <?php
$this->msg('jumpto') ?
> <a href
="#head"><?php
$this->msg('jumptonavigation') ?
></a
>,
253 <a href
="#search"><?php
$this->msg('jumptosearch') ?
></a
>
258 <?php
$this->html('bodytext') ?
>
261 <?php
if($this->data
['catlinks']) { $this->html('catlinks'); } ?
>
263 <!-- dataAfterContent
-->
264 <?php
if($this->data
['dataAfterContent']) { $this->html('dataAfterContent'); } ?
>
265 <!-- /dataAfterContent
-->
266 <div
class="visualClear"></div
>
268 <!-- /bodyContent
-->
272 <div id
="head" class="noprint">
274 <?php
if ( count( $this->data
['personal_urls'] ) > 0 ): ?
>
275 <div id
="p-personal">
276 <h5
><?php
$this->msg('personaltools') ?
></h5
>
277 <ul
<?php
$this->html('userlangattributes') ?
>>
278 <?php
foreach($this->data
['personal_urls'] as $key => $item): ?
>
279 <li
<?php
echo $item['attributes'] ?
>><a href
="<?php echo htmlspecialchars($item['href']) ?>"<?php
echo $item['key'] ?
><?php
if(!empty($item['class'])): ?
> class="<?php echo htmlspecialchars($item['class']) ?>"<?php
endif; ?
>><?php
echo htmlspecialchars($item['text']) ?
></a
></li
>
285 <div id
="left-navigation">
287 <?php
if ( count( $this->data
['namespace_urls'] ) > 0 ): ?
>
288 <div id
="namespaces" class="vectorTabs">
289 <h5
><?php
$this->msg('namespaces') ?
></h5
>
290 <ul
<?php
$this->html('userlangattributes') ?
>>
291 <?php
foreach ($this->data
['namespace_urls'] as $key => $link ): ?
>
292 <li
<?php
echo $link['attributes'] ?
>><a href
="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php
echo $link['key'] ?
>><span
><?php
echo htmlspecialchars( $link['text'] ) ?
></span
></a
></li
>
299 <?php
if ( count( $this->data
['variant_urls'] ) > 0 ): ?
>
300 <div id
="variants" class="vectorMenu">
301 <h5
><span
><?php
$this->msg('variants') ?
></span
><a href
="#"> 
;</a
></h5
>
303 <ul
<?php
$this->html('userlangattributes') ?
>>
304 <?php
foreach ($this->data
['variant_urls'] as $key => $link ): ?
>
305 <li
<?php
echo $link['attributes'] ?
>><a href
="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php
echo $link['key'] ?
>><?php
echo htmlspecialchars( $link['text'] ) ?
></a
></li
>
313 <div id
="right-navigation">
315 <?php
if ( count( $this->data
['view_urls'] ) > 0 ): ?
>
316 <div id
="views" class="vectorTabs">
317 <h5
><?php
$this->msg('views') ?
></h5
>
318 <ul
<?php
$this->html('userlangattributes') ?
>>
319 <?php
foreach ($this->data
['view_urls'] as $key => $link ): ?
>
320 <li
<?php
echo $link['attributes'] ?
>><a href
="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php
echo $link['key'] ?
>><span
><?php
echo htmlspecialchars( $link['text'] ) ?
></span
></a
></li
>
327 <?php
if ( count( $this->data
['action_urls'] ) > 0 ): ?
>
328 <div id
="p-cactions" class="vectorMenu">
329 <h5
><span
><?php
$this->msg('actions') ?
></span
><a href
="#"> 
;</a
></h5
>
331 <ul
<?php
$this->html('userlangattributes') ?
>>
332 <?php
foreach ($this->data
['action_urls'] as $key => $link ): ?
>
333 <li
<?php
echo $link['attributes'] ?
>><a href
="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php
echo $link['key'] ?
>><?php
echo htmlspecialchars( $link['text'] ) ?
></a
></li
>
342 <h5
<?php
$this->html('userlangattributes') ?
>><label
for="searchInput"><?php
$this->msg( 'search' ) ?
></label
></h5
>
343 <form action
="<?php $this->text( 'wgScript' ) ?>" id
="searchform">
344 <input type
='hidden' name
="title" value
="<?php $this->text( 'searchtitle' ) ?>"/>
345 <input id
="searchInput" name
="search" type
="text" <?php
echo $this->skin
->tooltipAndAccesskey( 'search' ); ?
> <?php
if( isset( $this->data
['search'] ) ): ?
> value
="<?php $this->text( 'search' ) ?>"<?php
endif; ?
> />
346 <input type
='submit' name
="go" class="searchButton" id
="searchGoButton" value
="<?php $this->msg( 'searcharticle' ) ?>"<?php
echo $this->skin
->tooltipAndAccesskey( 'search-go' ); ?
> />
347 <?php
if ( $wgUseTwoButtonsSearchForm ): ?
>
348 <input type
="submit" name
="fulltext" class="searchButton" id
="mw-searchButton" value
="<?php $this->msg( 'searchbutton' ) ?>"<?php
echo $this->skin
->tooltipAndAccesskey( 'search-fulltext' ); ?
> />
350 <div
><a href
="<?php $this->text( 'searchaction' ) ?>" rel
="search"><?php
$this->msg( 'powersearch-legend' ) ?
></a
></div
>
359 <div id
="panel" class="noprint">
362 $sidebar = $this->data
['sidebar'];
363 $sidebar['TOOLBOX'] = ( !isset( $sidebar['TOOLBOX'] ) );
364 $sidebar['LANGUAGES'] = ( !isset( $sidebar['LANGUAGES'] ) );
365 foreach ( $sidebar as $name => $content ) {
373 $this->languageBox();
376 $this->customBox( $name, $content );
384 <div
class="break"></div
>
387 <?php
foreach( $validFooterLinks as $category => $links ): ?
>
388 <?php
if ( count( $links ) > 0 ): ?
>
389 <ul id
="foot-<?php echo $category ?>">
390 <?php
foreach( $links as $link ): ?
>
391 <?php
if( isset( $this->data
[$link] ) && $this->data
[$link] ): ?
>
392 <li id
="foot-<?php echo $category ?>-<?php echo $link ?>"><?php
$this->html( $link ) ?
></li
>
398 <ul id
="foot-icons" class="noprint">
399 <?php
if( $this->data
['poweredbyico'] ): ?
>
400 <li id
="foot-icon-poweredby"><?php
$this->html( 'poweredbyico' ) ?
></li
>
402 <?php
if( $this->data
['copyrightico'] ): ?
>
403 <li id
="foot-icon-copyright"><?php
$this->html( 'copyrightico' ) ?
></li
>
406 <div style
="clear:both"></div
>
411 <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
>
415 <script type
="<?php $this->text('jsmimetype') ?>"> if (window
.isMSIE55
) fixalpha( 'p-logo' ); </script
>
417 <?php
$this->html( 'bottomscripts' ); /* JS call to runBodyOnloadHook */ ?
>
418 <?php
$this->html( 'reporttime' ) ?
>
419 <?php
if ( $this->data
['debug'] ): ?
>
421 <?php
$this->text( 'debug' ); ?
>
427 // We're done with abusing arrays now...
432 * Outputs a box with a list of tools
434 private function toolBox() {
436 <div
class="portal" id
="p-tb">
437 <h5
<?php
$this->html('userlangattributes') ?
>><?php
$this->msg( 'toolbox' ) ?
></h5
>
440 <?php
if( $this->data
['notspecialpage'] ): ?
>
441 <li id
="t-whatlinkshere"><a href
="<?php echo htmlspecialchars( $this->data['nav_urls']['whatlinkshere']['href'] ) ?>"<?php
echo $this->skin
->tooltipAndAccesskey( 't-whatlinkshere' ) ?
>><?php
$this->msg( 'whatlinkshere' ) ?
></a
></li
>
442 <?php
if( $this->data
['nav_urls']['recentchangeslinked'] ): ?
>
443 <li id
="t-recentchangeslinked"><a href
="<?php echo htmlspecialchars( $this->data['nav_urls']['recentchangeslinked']['href'] ) ?>"<?php
echo $this->skin
->tooltipAndAccesskey( 't-recentchangeslinked' ) ?
>><?php
$this->msg( 'recentchangeslinked-toolbox' ) ?
></a
></li
>
446 <?php
if( isset( $this->data
['nav_urls']['trackbacklink'] ) ): ?
>
447 <li id
="t-trackbacklink"><a href
="<?php echo htmlspecialchars( $this->data['nav_urls']['trackbacklink']['href'] ) ?>"<?php
echo $this->skin
->tooltipAndAccesskey( 't-trackbacklink' ) ?
>><?php
$this->msg( 'trackbacklink' ) ?
></a
></li
>
449 <?php
if( $this->data
['feeds']): ?
>
451 <?php
foreach( $this->data
['feeds'] as $key => $feed ): ?
>
452 <a id
="<?php echo Sanitizer::escapeId( "feed
-$key" ) ?>" href
="<?php echo htmlspecialchars( $feed['href'] ) ?>" rel
="alternate" type
="application/<?php echo $key ?>+xml" class="feedlink"<?php
echo $this->skin
->tooltipAndAccesskey( 'feed-' . $key ) ?
>><?php
echo htmlspecialchars( $feed['text'] ) ?
></a
>
456 <?php
foreach( array( 'contributions', 'log', 'blockip', 'emailuser', 'upload', 'specialpages' ) as $special ): ?
>
457 <?php
if( $this->data
['nav_urls'][$special]): ?
>
458 <li id
="t-<?php echo $special ?>"><a href
="<?php echo htmlspecialchars( $this->data['nav_urls'][$special]['href'] ) ?>"<?php
echo $this->skin
->tooltipAndAccesskey( 't-' . $special ) ?
>><?php
$this->msg( $special ) ?
></a
></li
>
461 <?php
if( !empty( $this->data
['nav_urls']['print']['href'] ) ): ?
>
462 <li id
="t-print"><a href
="<?php echo htmlspecialchars( $this->data['nav_urls']['print']['href'] ) ?>" rel
="alternate"<?php
echo $this->skin
->tooltipAndAccesskey( 't-print' ) ?
>><?php
$this->msg( 'printableversion' ) ?
></a
></li
>
464 <?php
if ( !empty( $this->data
['nav_urls']['permalink']['href'] ) ): ?
>
465 <li id
="t-permalink"><a href
="<?php echo htmlspecialchars( $this->data['nav_urls']['permalink']['href'] ) ?>"<?php
echo $this->skin
->tooltipAndAccesskey( 't-permalink' ) ?
>><?php
$this->msg( 'permalink' ) ?
></a
></li
>
466 <?php
elseif ( $this->data
['nav_urls']['permalink']['href'] === '' ): ?
>
467 <li id
="t-ispermalink"<?php
echo $this->skin
->tooltip( 't-ispermalink' ) ?
>><?php
$this->msg( 'permalink' ) ?
></li
>
469 <?php
wfRunHooks( 'VectorTemplateToolboxEnd', array( &$this ) ); ?
>
470 <?php
wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this ) ); ?
>
478 * Outputs a box with a list of alternative languages for this page
480 private function languageBox() {
481 if( $this->data
['language_urls'] ) {
483 <div
class="portal" id
="p-lang">
484 <h5
<?php
$this->html('userlangattributes') ?
>><?php
$this->msg( 'otherlanguages' ) ?
></h5
>
487 <?php
foreach ( $this->data
['language_urls'] as $langlink ): ?
>
488 <li
class="<?php echo htmlspecialchars( $langlink['class'] ) ?>"><a href
="<?php echo htmlspecialchars( $langlink['href'] ) ?>"><?php
echo $langlink['text'] ?
></a
></li
>
498 * Outputs a box with a custom list of items or HTML content
499 * @param string $bar Message name for title of box
500 * @param mixed $content HTML or array of items to build a list from
502 private function customBox( $bar, $content ) {
504 <div
class="portal" id
='<?php echo Sanitizer::escapeId( "p-$bar" ) ?>'<?php
echo $this->skin
->tooltip( 'p-' . $bar ) ?
>>
505 <h5
<?php
$this->html('userlangattributes') ?
>><?php
$out = wfMsg( $bar ); if ( wfEmptyMsg( $bar, $out ) ) echo htmlspecialchars( $bar ); else echo htmlspecialchars( $out ); ?
></h5
>
507 <?php
if ( is_array( $content ) ): ?
>
509 <?php
foreach( $content as $key => $val ): ?
>
510 <li id
="<?php echo Sanitizer::escapeId( $val['id'] ) ?>"<?php
if ( $val['active'] ): ?
> class="active" <?php
endif; ?
>><a href
="<?php echo htmlspecialchars( $val['href'] ) ?>"<?php
echo $this->skin
->tooltipAndAccesskey( $val['id'] ) ?
>><?php
echo htmlspecialchars( $val['text'] ) ?
></a
></li
>
514 <?php
echo $content; /* Allow raw HTML block to be defined by extensions */ ?
>