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, $wgOut;
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
163 echo $wgOut->headElement( $this->skin
);
164 ?
> <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') ?>">
165 <div id
="page-base" class="noprint"></div
>
166 <div id
="head-base" class="noprint"></div
>
169 <a name
="top" id
="top"></a
>
170 <div id
="mw-js-message" style
="display:none;"></div
>
172 <?php
if($this->data
['sitenotice']) { ?
><div id
="siteNotice"><?php
$this->html('sitenotice') ?
></div
><?php
} ?
>
174 <!-- firstHeading
-->
175 <h1 id
="firstHeading" class="firstHeading"><?php
$this->html('title') ?
></h1
>
176 <!-- /firstHeading
-->
178 <div id
="bodyContent">
180 <h3 id
="siteSub"><?php
$this->msg('tagline') ?
></h3
>
183 <div id
="contentSub"><?php
$this->html('subtitle') ?
></div
>
185 <?php
if($this->data
['undelete']): ?
>
187 <div id
="contentSub2"><?php
$this->html('undelete') ?
></div
>
190 <?php
if($this->data
['newtalk'] ): ?
>
192 <div
class="usermessage"><?php
$this->html('newtalk') ?
></div
>
195 <?php
if($this->data
['showjumplinks']): ?
>
197 <div id
="jump-to-nav">
198 <?php
$this->msg('jumpto') ?
> <a href
="#head"><?php
$this->msg('jumptonavigation') ?
></a
>,
199 <a href
="#search"><?php
$this->msg('jumptosearch') ?
></a
>
204 <?php
$this->html('bodytext') ?
>
207 <?php
if($this->data
['catlinks']) { $this->html('catlinks'); } ?
>
209 <!-- dataAfterContent
-->
210 <?php
if($this->data
['dataAfterContent']) { $this->html('dataAfterContent'); } ?
>
211 <!-- /dataAfterContent
-->
212 <div
class="visualClear"></div
>
214 <!-- /bodyContent
-->
218 <div id
="head" class="noprint">
220 <?php
if ( count( $this->data
['personal_urls'] ) > 0 ): ?
>
221 <div id
="p-personal">
222 <h5
><?php
$this->msg('personaltools') ?
></h5
>
223 <ul
<?php
$this->html('userlangattributes') ?
>>
224 <?php
foreach($this->data
['personal_urls'] as $key => $item): ?
>
225 <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
>
231 <div id
="left-navigation">
233 <?php
if ( count( $this->data
['namespace_urls'] ) > 0 ): ?
>
234 <div id
="namespaces" class="vectorTabs">
235 <h5
><?php
$this->msg('namespaces') ?
></h5
>
236 <ul
<?php
$this->html('userlangattributes') ?
>>
237 <?php
foreach ($this->data
['namespace_urls'] as $key => $link ): ?
>
238 <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
>
245 <?php
if ( count( $this->data
['variant_urls'] ) > 0 ): ?
>
246 <div id
="variants" class="vectorMenu">
247 <h5
><span
><?php
$this->msg('variants') ?
></span
><a href
="#"> 
;</a
></h5
>
249 <ul
<?php
$this->html('userlangattributes') ?
>>
250 <?php
foreach ($this->data
['variant_urls'] as $key => $link ): ?
>
251 <li
<?php
echo $link['attributes'] ?
>><a href
="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php
echo $link['key'] ?
>><?php
echo htmlspecialchars( $link['text'] ) ?
></a
></li
>
259 <div id
="right-navigation">
261 <?php
if ( count( $this->data
['view_urls'] ) > 0 ): ?
>
262 <div id
="views" class="vectorTabs">
263 <h5
><?php
$this->msg('views') ?
></h5
>
264 <ul
<?php
$this->html('userlangattributes') ?
>>
265 <?php
foreach ($this->data
['view_urls'] as $key => $link ): ?
>
266 <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
>
273 <?php
if ( count( $this->data
['action_urls'] ) > 0 ): ?
>
274 <div id
="p-cactions" class="vectorMenu">
275 <h5
><span
><?php
$this->msg('actions') ?
></span
><a href
="#"> 
;</a
></h5
>
277 <ul
<?php
$this->html('userlangattributes') ?
>>
278 <?php
foreach ($this->data
['action_urls'] as $key => $link ): ?
>
279 <li
<?php
echo $link['attributes'] ?
>><a href
="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php
echo $link['key'] ?
>><?php
echo htmlspecialchars( $link['text'] ) ?
></a
></li
>
288 <h5
<?php
$this->html('userlangattributes') ?
>><label
for="searchInput"><?php
$this->msg( 'search' ) ?
></label
></h5
>
289 <form action
="<?php $this->text( 'wgScript' ) ?>" id
="searchform">
290 <input type
='hidden' name
="title" value
="<?php $this->text( 'searchtitle' ) ?>"/>
291 <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; ?
> />
292 <input type
='submit' name
="go" class="searchButton" id
="searchGoButton" value
="<?php $this->msg( 'searcharticle' ) ?>"<?php
echo $this->skin
->tooltipAndAccesskey( 'search-go' ); ?
> />
293 <?php
if ( $wgUseTwoButtonsSearchForm ): ?
>
294 <input type
="submit" name
="fulltext" class="searchButton" id
="mw-searchButton" value
="<?php $this->msg( 'searchbutton' ) ?>"<?php
echo $this->skin
->tooltipAndAccesskey( 'search-fulltext' ); ?
> />
296 <div
><a href
="<?php $this->text( 'searchaction' ) ?>" rel
="search"><?php
$this->msg( 'powersearch-legend' ) ?
></a
></div
>
305 <div id
="panel" class="noprint">
308 $sidebar = $this->data
['sidebar'];
309 $sidebar['TOOLBOX'] = ( !isset( $sidebar['TOOLBOX'] ) );
310 $sidebar['LANGUAGES'] = ( !isset( $sidebar['LANGUAGES'] ) );
311 foreach ( $sidebar as $name => $content ) {
319 $this->languageBox();
322 $this->customBox( $name, $content );
330 <div
class="break"></div
>
333 <?php
foreach( $validFooterLinks as $category => $links ): ?
>
334 <?php
if ( count( $links ) > 0 ): ?
>
335 <ul id
="foot-<?php echo $category ?>">
336 <?php
foreach( $links as $link ): ?
>
337 <?php
if( isset( $this->data
[$link] ) && $this->data
[$link] ): ?
>
338 <li id
="foot-<?php echo $category ?>-<?php echo $link ?>"><?php
$this->html( $link ) ?
></li
>
344 <ul id
="foot-icons" class="noprint">
345 <?php
if( $this->data
['poweredbyico'] ): ?
>
346 <li id
="foot-icon-poweredby"><?php
$this->html( 'poweredbyico' ) ?
></li
>
348 <?php
if( $this->data
['copyrightico'] ): ?
>
349 <li id
="foot-icon-copyright"><?php
$this->html( 'copyrightico' ) ?
></li
>
352 <div style
="clear:both"></div
>
357 <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
>
361 <script type
="<?php $this->text('jsmimetype') ?>"> if (window
.isMSIE55
) fixalpha( 'p-logo' ); </script
>
363 <?php
$this->html( 'bottomscripts' ); /* JS call to runBodyOnloadHook */ ?
>
364 <?php
$this->html( 'reporttime' ) ?
>
365 <?php
if ( $this->data
['debug'] ): ?
>
367 <?php
$this->text( 'debug' ); ?
>
373 // We're done with abusing arrays now...
378 * Outputs a box with a list of tools
380 private function toolBox() {
382 <div
class="portal" id
="p-tb">
383 <h5
<?php
$this->html('userlangattributes') ?
>><?php
$this->msg( 'toolbox' ) ?
></h5
>
386 <?php
if( $this->data
['notspecialpage'] ): ?
>
387 <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
>
388 <?php
if( $this->data
['nav_urls']['recentchangeslinked'] ): ?
>
389 <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
>
392 <?php
if( isset( $this->data
['nav_urls']['trackbacklink'] ) ): ?
>
393 <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
>
395 <?php
if( $this->data
['feeds']): ?
>
397 <?php
foreach( $this->data
['feeds'] as $key => $feed ): ?
>
398 <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
>
402 <?php
foreach( array( 'contributions', 'log', 'blockip', 'emailuser', 'upload', 'specialpages' ) as $special ): ?
>
403 <?php
if( $this->data
['nav_urls'][$special]): ?
>
404 <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
>
407 <?php
if( !empty( $this->data
['nav_urls']['print']['href'] ) ): ?
>
408 <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
>
410 <?php
if ( !empty( $this->data
['nav_urls']['permalink']['href'] ) ): ?
>
411 <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
>
412 <?php
elseif ( $this->data
['nav_urls']['permalink']['href'] === '' ): ?
>
413 <li id
="t-ispermalink"<?php
echo $this->skin
->tooltip( 't-ispermalink' ) ?
>><?php
$this->msg( 'permalink' ) ?
></li
>
415 <?php
wfRunHooks( 'VectorTemplateToolboxEnd', array( &$this ) ); ?
>
416 <?php
wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this ) ); ?
>
424 * Outputs a box with a list of alternative languages for this page
426 private function languageBox() {
427 if( $this->data
['language_urls'] ) {
429 <div
class="portal" id
="p-lang">
430 <h5
<?php
$this->html('userlangattributes') ?
>><?php
$this->msg( 'otherlanguages' ) ?
></h5
>
433 <?php
foreach ( $this->data
['language_urls'] as $langlink ): ?
>
434 <li
class="<?php echo htmlspecialchars( $langlink['class'] ) ?>"><a href
="<?php echo htmlspecialchars( $langlink['href'] ) ?>"><?php
echo $langlink['text'] ?
></a
></li
>
444 * Outputs a box with a custom list of items or HTML content
445 * @param string $bar Message name for title of box
446 * @param mixed $content HTML or array of items to build a list from
448 private function customBox( $bar, $content ) {
450 <div
class="portal" id
='<?php echo Sanitizer::escapeId( "p-$bar" ) ?>'<?php
echo $this->skin
->tooltip( 'p-' . $bar ) ?
>>
451 <h5
<?php
$this->html('userlangattributes') ?
>><?php
$out = wfMsg( $bar ); if ( wfEmptyMsg( $bar, $out ) ) echo htmlspecialchars( $bar ); else echo htmlspecialchars( $out ); ?
></h5
>
453 <?php
if ( is_array( $content ) ): ?
>
455 <?php
foreach( $content as $key => $val ): ?
>
456 <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
>
460 <?php
echo $content; /* Allow raw HTML block to be defined by extensions */ ?
>