Merge IEFixes.js into wikibits.js
[lhc/web/wiklou.git] / skins / Vector.php
1 <?php
2 /**
3 * Vector - Branch of MonoBook which has many usability improvements and
4 * somewhat cleaner code.
5 *
6 * @todo document
7 * @file
8 * @ingroup Skins
9 */
10
11 if( !defined( 'MEDIAWIKI' ) )
12 die( -1 );
13
14 /**
15 * SkinTemplate class for Vector skin
16 * @ingroup Skins
17 */
18 class SkinVector extends SkinTemplate {
19
20 /* Functions */
21 var $skinname = 'vector', $stylename = 'vector',
22 $template = 'VectorTemplate', $useHeadElement = true;
23
24 /**
25 * Initializes output page and sets up skin-specific parameters
26 * @param object $out Output page object to initialize
27 */
28 public function initPage( OutputPage $out ) {
29 global $wgStylePath, $wgJsMimeType, $wgStyleVersion, $wgScriptPath, $wgVectorExtraStyles;
30
31 parent::initPage( $out );
32
33 // Append skin-specific styles
34 $out->addStyle( 'vector/main-rtl.css', 'screen', '', 'rtl' );
35 $out->addStyle( 'vector/main-ltr.css', 'screen', '', 'ltr' );
36 // Append CSS which includes IE only behavior fixes for hover support -
37 // this is better than including this in a CSS fille since it doesn't
38 // wait for the CSS file to load before fetching the HTC file.
39 $out->addScript(
40 '<!--[if lt IE 7]><style type="text/css">body{behavior:url("' .
41 $wgStylePath .
42 '/vector/csshover.htc")}</style><![endif]-->'
43 );
44 // Add extra stylesheets
45 // THIS IS ONLY USEFUL FOR EXPERIMENTING WITH DIFFERNT STYLE OPTIONS! THIS WILL BE REMOVED IN THE NEAR FUTURE.
46 if ( is_array( $wgVectorExtraStyles ) ) {
47 foreach ( $wgVectorExtraStyles as $style ) {
48 $out->addStyle( 'vector/' . $style, 'screen' );
49 }
50 }
51 }
52 /**
53 * Builds a structured array of links used for tabs and menus
54 * @return array
55 * @private
56 */
57 function buildNavigationUrls() {
58 global $wgContLang, $wgLang, $wgOut, $wgUser, $wgRequest, $wgArticle, $wgStylePath;
59 global $wgDisableLangConversion, $wgVectorUseIconWatch;
60
61 wfProfileIn( __METHOD__ );
62
63 $links = array(
64 'namespaces' => array(),
65 'views' => array(),
66 'actions' => array(),
67 'variants' => array()
68 );
69
70 // Detects parameters
71 $action = $wgRequest->getVal( 'action', 'view' );
72 $section = $wgRequest->getVal( 'section' );
73
74 // Checks if page is some kind of content
75 if( $this->iscontent ) {
76
77 // Gets page objects for the related namespaces
78 $subjectPage = $this->mTitle->getSubjectPage();
79 $talkPage = $this->mTitle->getTalkPage();
80
81 // Determines if this is a talk page
82 $isTalk = $this->mTitle->isTalkPage();
83
84 // Generates XML IDs from namespace names
85 $subjectId = $this->mTitle->getNamespaceKey( '' );
86
87 if ( $subjectId == 'main' ) {
88 $talkId = 'talk';
89 } else {
90 $talkId = "{$subjectId}_talk";
91 }
92 $currentId = $isTalk ? $talkId : $subjectId;
93
94 // Adds namespace links
95 $links['namespaces'][$subjectId] = $this->tabAction(
96 $subjectPage, 'vector-namespace-' . $subjectId, !$isTalk, '', true
97 );
98 $links['namespaces'][$subjectId]['context'] = 'subject';
99 $links['namespaces'][$talkId] = $this->tabAction(
100 $talkPage, 'vector-namespace-talk', $isTalk, '', true
101 );
102 $links['namespaces'][$talkId]['context'] = 'talk';
103
104 // Adds view view link
105 if ( $this->mTitle->exists() ) {
106 $links['views']['view'] = $this->tabAction(
107 $isTalk ? $talkPage : $subjectPage,
108 'vector-view-view', ( $action == 'view' ), '', true
109 );
110 }
111
112 wfProfileIn( __METHOD__ . '-edit' );
113
114 // Checks if user can...
115 if (
116 // edit the current page
117 $this->mTitle->quickUserCan( 'edit' ) &&
118 (
119 // if it exists
120 $this->mTitle->exists() ||
121 // or they can create one here
122 $this->mTitle->quickUserCan( 'create' )
123 )
124 ) {
125 // Builds CSS class for talk page links
126 $isTalkClass = $isTalk ? ' istalk' : '';
127
128 // Determines if we're in edit mode
129 $selected = (
130 ( $action == 'edit' || $action == 'submit' ) &&
131 ( $section != 'new' )
132 );
133 $links['views']['edit'] = array(
134 'class' => ( $selected ? 'selected' : '' ) . $isTalkClass,
135 'text' => $this->mTitle->exists()
136 ? wfMsg( 'vector-view-edit' )
137 : wfMsg( 'vector-view-create' ),
138 'href' =>
139 $this->mTitle->getLocalUrl( $this->editUrlOptions() )
140 );
141 // Checks if this is a current rev of talk page and we should show a new
142 // section link
143 if ( ( $isTalk && $wgArticle->isCurrent() ) || ( $wgOut->showNewSectionLink() ) ) {
144 // Checks if we should ever show a new section link
145 if ( !$wgOut->forceHideNewSectionLink() ) {
146 // Adds new section link
147 //$links['actions']['addsection']
148 $links['views']['addsection'] = array(
149 'class' => 'collapsible ' . ( $section == 'new' ? 'selected' : false ),
150 'text' => wfMsg( 'vector-action-addsection' ),
151 'href' => $this->mTitle->getLocalUrl(
152 'action=edit&section=new'
153 )
154 );
155 }
156 }
157 // Checks if the page is known (some kind of viewable content)
158 } elseif ( $this->mTitle->isKnown() ) {
159 // Adds view source view link
160 $links['views']['viewsource'] = array(
161 'class' => ( $action == 'edit' ) ? 'selected' : false,
162 'text' => wfMsg( 'vector-view-viewsource' ),
163 'href' =>
164 $this->mTitle->getLocalUrl( $this->editUrlOptions() )
165 );
166 }
167 wfProfileOut( __METHOD__ . '-edit' );
168
169 wfProfileIn( __METHOD__ . '-live' );
170
171 // Checks if the page exists
172 if ( $this->mTitle->exists() ) {
173 // Adds history view link
174 $links['views']['history'] = array(
175 'class' => 'collapsible ' . ( ($action == 'history') ? 'selected' : false ),
176 'text' => wfMsg( 'vector-view-history' ),
177 'href' => $this->mTitle->getLocalUrl( 'action=history' ),
178 'rel' => 'archives',
179 );
180
181 if( $wgUser->isAllowed( 'delete' ) ) {
182 $links['actions']['delete'] = array(
183 'class' => ($action == 'delete') ? 'selected' : false,
184 'text' => wfMsg( 'vector-action-delete' ),
185 'href' => $this->mTitle->getLocalUrl( 'action=delete' )
186 );
187 }
188 if ( $this->mTitle->quickUserCan( 'move' ) ) {
189 $moveTitle = SpecialPage::getTitleFor(
190 'Movepage', $this->thispage
191 );
192 $links['actions']['move'] = array(
193 'class' => $this->mTitle->isSpecial( 'Movepage' ) ?
194 'selected' : false,
195 'text' => wfMsg( 'vector-action-move' ),
196 'href' => $moveTitle->getLocalUrl()
197 );
198 }
199
200 if (
201 $this->mTitle->getNamespace() !== NS_MEDIAWIKI &&
202 $wgUser->isAllowed( 'protect' )
203 ) {
204 if ( !$this->mTitle->isProtected() ){
205 $links['actions']['protect'] = array(
206 'class' => ($action == 'protect') ?
207 'selected' : false,
208 'text' => wfMsg( 'vector-action-protect' ),
209 'href' =>
210 $this->mTitle->getLocalUrl( 'action=protect' )
211 );
212
213 } else {
214 $links['actions']['unprotect'] = array(
215 'class' => ($action == 'unprotect') ?
216 'selected' : false,
217 'text' => wfMsg( 'vector-action-unprotect' ),
218 'href' =>
219 $this->mTitle->getLocalUrl( 'action=unprotect' )
220 );
221 }
222 }
223 } else {
224 // article doesn't exist or is deleted
225 if (
226 $wgUser->isAllowed( 'deletedhistory' ) &&
227 $wgUser->isAllowed( 'undelete' )
228 ) {
229 if( $n = $this->mTitle->isDeleted() ) {
230 $undelTitle = SpecialPage::getTitleFor( 'Undelete' );
231 $links['actions']['undelete'] = array(
232 'class' => false,
233 'text' => wfMsgExt(
234 'vector-action-undelete',
235 array( 'parsemag' ),
236 $wgLang->formatNum( $n )
237 ),
238 'href' => $undelTitle->getLocalUrl(
239 'target=' . urlencode( $this->thispage )
240 )
241 );
242 }
243 }
244
245 if (
246 $this->mTitle->getNamespace() !== NS_MEDIAWIKI &&
247 $wgUser->isAllowed( 'protect' )
248 ) {
249 if ( !$this->mTitle->getRestrictions( 'create' ) ) {
250 $links['actions']['protect'] = array(
251 'class' => ($action == 'protect') ?
252 'selected' : false,
253 'text' => wfMsg( 'vector-action-protect' ),
254 'href' =>
255 $this->mTitle->getLocalUrl( 'action=protect' )
256 );
257
258 } else {
259 $links['actions']['unprotect'] = array(
260 'class' => ($action == 'unprotect') ?
261 'selected' : false,
262 'text' => wfMsg( 'vector-action-unprotect' ),
263 'href' =>
264 $this->mTitle->getLocalUrl( 'action=unprotect' )
265 );
266 }
267 }
268 }
269 wfProfileOut( __METHOD__ . '-live' );
270 /**
271 * The following actions use messages which, if made particular to
272 * the Vector skin, would break the Ajax code which makes this
273 * action happen entirely inline. Skin::makeGlobalVariablesScript
274 * defines a set of messages in a javascript object - and these
275 * messages are assumed to be global for all skins. Without making
276 * a change to that procedure these messages will have to remain as
277 * the global versions.
278 */
279 // Checks if the user is logged in
280 if ( $this->loggedin ) {
281 if ( $wgVectorUseIconWatch ) {
282 $class = 'icon ';
283 $place = 'views';
284 } else {
285 $class = '';
286 $place = 'actions';
287 }
288 $mode = $this->mTitle->userIsWatching() ? 'unwatch' : 'watch';
289 $links[$place][$mode] = array(
290 'class' => $class . ( ( $action == 'watch' || $action == 'unwatch' ) ? ' selected' : false ),
291 'text' => wfMsg( $mode ), // uses 'watch' or 'unwatch' message
292 'href' => $this->mTitle->getLocalUrl( 'action=' . $mode )
293 );
294 }
295 // This is instead of SkinTemplateTabs - which uses a flat array
296 wfRunHooks( 'SkinTemplateNavigation', array( &$this, &$links ) );
297
298 // If it's not content, it's got to be a special page
299 } else {
300 $links['namespaces']['special'] = array(
301 'class' => 'selected',
302 'text' => wfMsg( 'vector-namespace-special' ),
303 'href' => $wgRequest->getRequestURL()
304 );
305 }
306
307 // Gets list of language variants
308 $variants = $wgContLang->getVariants();
309 // Checks that language conversion is enabled and variants exist
310 if( !$wgDisableLangConversion && count( $variants ) > 1 ) {
311 // Gets preferred variant
312 $preferred = $wgContLang->getPreferredVariant();
313 // Loops over each variant
314 foreach( $variants as $code ) {
315 // Gets variant name from language code
316 $varname = $wgContLang->getVariantname( $code );
317 // Checks if the variant is marked as disabled
318 if( $varname == 'disable' ) {
319 // Skips this variant
320 continue;
321 }
322 // Appends variant link
323 $links['variants'][] = array(
324 'class' => ( $code == $preferred ) ? 'selected' : false,
325 'text' => $varname,
326 'href' => $this->mTitle->getLocalURL( '', $code )
327 );
328 }
329 }
330
331 wfProfileOut( __METHOD__ );
332
333 return $links;
334 }
335 }
336
337 /**
338 * QuickTemplate class for Vector skin
339 * @ingroup Skins
340 */
341 class VectorTemplate extends QuickTemplate {
342
343 /* Members */
344
345 /**
346 * @var Cached skin object
347 */
348 var $skin;
349
350 /* Functions */
351
352 /**
353 * Outputs the entire contents of the XHTML page
354 */
355 public function execute() {
356 global $wgRequest, $wgOut, $wgContLang;
357
358 $this->skin = $this->data['skin'];
359 $action = $wgRequest->getText( 'action' );
360
361 // Build additional attributes for navigation urls
362 $nav = $this->skin->buildNavigationUrls();
363 foreach ( $nav as $section => $links ) {
364 foreach ( $links as $key => $link ) {
365 $xmlID = $key;
366 if ( isset( $link['context'] ) && $link['context'] == 'subject' ) {
367 $xmlID = 'ca-nstab-' . $xmlID;
368 } else if ( isset( $link['context'] ) && $link['context'] == 'talk' ) {
369 $xmlID = 'ca-talk';
370 } else {
371 $xmlID = 'ca-' . $xmlID;
372 }
373 $nav[$section][$key]['attributes'] =
374 ' id="' . Sanitizer::escapeId( $xmlID ) . '"';
375 if ( $nav[$section][$key]['class'] ) {
376 $nav[$section][$key]['attributes'] .=
377 ' class="' . htmlspecialchars( $link['class'] ) . '"';
378 unset( $nav[$section][$key]['class'] );
379 }
380 // We don't want to give the watch tab an accesskey if the page
381 // is being edited, because that conflicts with the accesskey on
382 // the watch checkbox. We also don't want to give the edit tab
383 // an accesskey, because that's fairly superfluous and conflicts
384 // with an accesskey (Ctrl-E) often used for editing in Safari.
385 if (
386 in_array( $action, array( 'edit', 'submit' ) ) &&
387 in_array( $key, array( 'edit', 'watch', 'unwatch' ) )
388 ) {
389 $nav[$section][$key]['key'] =
390 $this->skin->tooltip( $xmlID );
391 } else {
392 $nav[$section][$key]['key'] =
393 $this->skin->tooltipAndAccesskey( $xmlID );
394 }
395 }
396 }
397 $this->data['namespace_urls'] = $nav['namespaces'];
398 $this->data['view_urls'] = $nav['views'];
399 $this->data['action_urls'] = $nav['actions'];
400 $this->data['variant_urls'] = $nav['variants'];
401 // Build additional attributes for personal_urls
402 foreach ( $this->data['personal_urls'] as $key => $item) {
403 $this->data['personal_urls'][$key]['attributes'] =
404 ' id="' . Sanitizer::escapeId( "pt-$key" ) . '"';
405 if ( isset( $item['active'] ) && $item['active'] ) {
406 $this->data['personal_urls'][$key]['attributes'] .=
407 ' class="active"';
408 }
409 $this->data['personal_urls'][$key]['key'] =
410 $this->skin->tooltipAndAccesskey('pt-'.$key);
411 }
412
413 // Generate additional footer links
414 $footerlinks = array(
415 'info' => array(
416 'lastmod',
417 'viewcount',
418 'numberofwatchingusers',
419 'credits',
420 'copyright',
421 'tagline',
422 ),
423 'places' => array(
424 'privacy',
425 'about',
426 'disclaimer',
427 ),
428 );
429 // Reduce footer links down to only those which are being used
430 $validFooterLinks = array();
431 foreach( $footerlinks as $category => $links ) {
432 $validFooterLinks[$category] = array();
433 foreach( $links as $link ) {
434 if( isset( $this->data[$link] ) && $this->data[$link] ) {
435 $validFooterLinks[$category][] = $link;
436 }
437 }
438 }
439 // Reverse horizontally rendered navigation elements
440 if ( $wgContLang->isRTL() ) {
441 $this->data['view_urls'] =
442 array_reverse( $this->data['view_urls'] );
443 $this->data['namespace_urls'] =
444 array_reverse( $this->data['namespace_urls'] );
445 $this->data['personal_urls'] =
446 array_reverse( $this->data['personal_urls'] );
447 }
448 // Output HTML Page
449 $this->html( 'headelement' );
450 ?>
451 <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' ) ?>" dir="<?php $this->text( 'dir' ) ?>">
452 <div id="page-base" class="noprint"></div>
453 <div id="head-base" class="noprint"></div>
454 <!-- content -->
455 <div id="content" <?php $this->html('specialpageattributes') ?>>
456 <a id="top"></a>
457 <div id="mw-js-message" style="display:none;" <?php $this->html('userlangattributes') ?>></div>
458 <?php if ( $this->data['sitenotice'] ): ?>
459 <!-- sitenotice -->
460 <div id="siteNotice"><?php $this->html( 'sitenotice' ) ?></div>
461 <!-- /sitenotice -->
462 <?php endif; ?>
463 <!-- firstHeading -->
464 <h1 id="firstHeading" class="firstHeading"><?php $this->html( 'title' ) ?></h1>
465 <!-- /firstHeading -->
466 <!-- bodyContent -->
467 <div id="bodyContent">
468 <!-- tagline -->
469 <h3 id="siteSub"><?php $this->msg( 'tagline' ) ?></h3>
470 <!-- /tagline -->
471 <!-- subtitle -->
472 <div id="contentSub" <?php $this->html('userlangattributes') ?>><?php $this->html( 'subtitle' ) ?></div>
473 <!-- /subtitle -->
474 <?php if ( $this->data['undelete'] ): ?>
475 <!-- undelete -->
476 <div id="contentSub2"><?php $this->html( 'undelete' ) ?></div>
477 <!-- /undelete -->
478 <?php endif; ?>
479 <?php if($this->data['newtalk'] ): ?>
480 <!-- newtalk -->
481 <div class="usermessage"><?php $this->html( 'newtalk' ) ?></div>
482 <!-- /newtalk -->
483 <?php endif; ?>
484 <?php if ( $this->data['showjumplinks'] ): ?>
485 <!-- jumpto -->
486 <div id="jump-to-nav">
487 <?php $this->msg( 'jumpto' ) ?><a href="#head"><?php $this->msg( 'jumptonavigation' ) ?></a>,
488 <a href="#p-search"><?php $this->msg( 'jumptosearch' ) ?></a>
489 </div>
490 <!-- /jumpto -->
491 <?php endif; ?>
492 <!-- bodytext -->
493 <?php $this->html( 'bodytext' ) ?>
494 <!-- /bodytext -->
495 <?php if ( $this->data['catlinks'] ): ?>
496 <!-- catlinks -->
497 <?php $this->html( 'catlinks' ); ?>
498 <!-- /catlinks -->
499 <?php endif; ?>
500 <?php if ( $this->data['dataAfterContent'] ): ?>
501 <!-- dataAfterContent -->
502 <?php $this->html( 'dataAfterContent' ); ?>
503 <!-- /dataAfterContent -->
504 <?php endif; ?>
505 <div class="visualClear"></div>
506 </div>
507 <!-- /bodyContent -->
508 </div>
509 <!-- /content -->
510 <!-- header -->
511 <div id="head" class="noprint">
512 <?php $this->renderNavigation( 'PERSONAL' ); ?>
513 <div id="left-navigation">
514 <?php $this->renderNavigation( array( 'NAMESPACES', 'VARIANTS' ) ); ?>
515 </div>
516 <div id="right-navigation">
517 <?php $this->renderNavigation( array( 'VIEWS', 'ACTIONS', 'SEARCH' ) ); ?>
518 </div>
519 </div>
520 <!-- /header -->
521 <!-- panel -->
522 <div id="panel" class="noprint">
523 <!-- logo -->
524 <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>
525 <!-- /logo -->
526 <?php $this->renderPortals( $this->data['sidebar'] ); ?>
527 </div>
528 <!-- /panel -->
529 <!-- footer -->
530 <div id="footer" <?php $this->html('userlangattributes') ?>>
531 <?php foreach( $validFooterLinks as $category => $links ): ?>
532 <?php if ( count( $links ) > 0 ): ?>
533 <ul id="footer-<?php echo $category ?>">
534 <?php foreach( $links as $link ): ?>
535 <?php if( isset( $this->data[$link] ) && $this->data[$link] ): ?>
536 <li id="footer-<?php echo $category ?>-<?php echo $link ?>"><?php $this->html( $link ) ?></li>
537 <?php endif; ?>
538 <?php endforeach; ?>
539 </ul>
540 <?php endif; ?>
541 <?php endforeach; ?>
542 <ul id="footer-icons" class="noprint">
543 <?php if ( $this->data['poweredbyico'] ): ?>
544 <li id="footer-icon-poweredby"><?php $this->html( 'poweredbyico' ) ?></li>
545 <?php endif; ?>
546 <?php if ( $this->data['copyrightico'] ): ?>
547 <li id="footer-icon-copyright"><?php $this->html( 'copyrightico' ) ?></li>
548 <?php endif; ?>
549 </ul>
550 <div style="clear:both"></div>
551 </div>
552 <!-- /footer -->
553 <!-- fixalpha -->
554 <script type="<?php $this->text('jsmimetype') ?>"> if ( window.isMSIE55 ) fixalpha(); </script>
555 <!-- /fixalpha -->
556 <?php $this->html( 'bottomscripts' ); /* JS call to runBodyOnloadHook */ ?>
557 <?php $this->html( 'reporttime' ) ?>
558 <?php if ( $this->data['debug'] ): ?>
559 <!-- Debug output: <?php $this->text( 'debug' ); ?> -->
560 <?php endif; ?>
561 </body>
562 </html>
563 <?php
564 }
565
566 /**
567 * Render a series of portals
568 */
569 private function renderPortals( $portals ) {
570 // Force the rendering of the following portals
571 if ( !isset( $portals['SEARCH'] ) ) $portals['SEARCH'] = true;
572 if ( !isset( $portals['TOOLBOX'] ) ) $portals['TOOLBOX'] = true;
573 if ( !isset( $portals['LANGUAGES'] ) ) $portals['LANGUAGES'] = true;
574 // Render portals
575 foreach ( $portals as $name => $content ) {
576 echo "\n<!-- {$name} -->\n";
577 switch( $name ) {
578 case 'SEARCH':
579 break;
580 case 'TOOLBOX':
581 ?>
582 <div class="portal" id="p-tb">
583 <h5 <?php $this->html('userlangattributes') ?>><?php $this->msg( 'toolbox' ) ?></h5>
584 <div class="body">
585 <ul>
586 <?php if( $this->data['notspecialpage'] ): ?>
587 <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>
588 <?php if( $this->data['nav_urls']['recentchangeslinked'] ): ?>
589 <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>
590 <?php endif; ?>
591 <?php endif; ?>
592 <?php if( isset( $this->data['nav_urls']['trackbacklink'] ) ): ?>
593 <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>
594 <?php endif; ?>
595 <?php if( $this->data['feeds']): ?>
596 <li id="feedlinks">
597 <?php foreach( $this->data['feeds'] as $key => $feed ): ?>
598 <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>
599 <?php endforeach; ?>
600 </li>
601 <?php endif; ?>
602 <?php foreach( array( 'contributions', 'log', 'blockip', 'emailuser', 'upload', 'specialpages' ) as $special ): ?>
603 <?php if( $this->data['nav_urls'][$special]): ?>
604 <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>
605 <?php endif; ?>
606 <?php endforeach; ?>
607 <?php if( !empty( $this->data['nav_urls']['print']['href'] ) ): ?>
608 <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>
609 <?php endif; ?>
610 <?php if ( !empty( $this->data['nav_urls']['permalink']['href'] ) ): ?>
611 <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>
612 <?php elseif ( $this->data['nav_urls']['permalink']['href'] === '' ): ?>
613 <li id="t-ispermalink"<?php echo $this->skin->tooltip( 't-ispermalink' ) ?>><?php $this->msg( 'permalink' ) ?></li>
614 <?php endif; ?>
615 <?php wfRunHooks( 'VectorTemplateToolboxEnd', array( &$this ) ); ?>
616 <?php wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this ) ); ?>
617 </ul>
618 </div>
619 </div>
620 <?php
621 break;
622 case 'LANGUAGES':
623 if ( $this->data['language_urls'] ) {
624 ?>
625 <div class="portal" id="p-lang">
626 <h5 <?php $this->html('userlangattributes') ?>><?php $this->msg( 'otherlanguages' ) ?></h5>
627 <div class="body">
628 <ul>
629 <?php foreach ( $this->data['language_urls'] as $langlink ): ?>
630 <li class="<?php echo htmlspecialchars( $langlink['class'] ) ?>"><a href="<?php echo htmlspecialchars( $langlink['href'] ) ?>"><?php echo $langlink['text'] ?></a></li>
631 <?php endforeach; ?>
632 </ul>
633 </div>
634 </div>
635 <?php
636 }
637 break;
638 default:
639 ?>
640 <div class="portal" id='<?php echo Sanitizer::escapeId( "p-$name" ) ?>'<?php echo $this->skin->tooltip( 'p-' . $name ) ?>>
641 <h5 <?php $this->html('userlangattributes') ?>><?php $out = wfMsg( $name ); if ( wfEmptyMsg( $name, $out ) ) echo htmlspecialchars( $name ); else echo htmlspecialchars( $out ); ?></h5>
642 <div class="body">
643 <?php if ( is_array( $content ) ): ?>
644 <ul>
645 <?php foreach( $content as $key => $val ): ?>
646 <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>
647 <?php endforeach; ?>
648 </ul>
649 <?php else: ?>
650 <?php echo $content; /* Allow raw HTML block to be defined by extensions */ ?>
651 <?php endif; ?>
652 </div>
653 </div>
654 <?php
655 break;
656 }
657 echo "\n<!-- /{$name} -->\n";
658 }
659 }
660
661 /**
662 * Render one or more navigations elements by name, automatically reveresed
663 * when UI is in RTL mode
664 */
665 private function renderNavigation( $elements ) {
666 global $wgContLang, $wgVectorUseSimpleSearch, $wgStylePath;
667
668 // If only one element was given, wrap it in an array, allowing more
669 // flexible arguments
670 if ( !is_array( $elements ) ) {
671 $elements = array( $elements );
672 // If there's a series of elements, reverse them when in RTL mode
673 } else if ( $wgContLang->isRTL() ) {
674 $elements = array_reverse( $elements );
675 }
676 // Render elements
677 foreach ( $elements as $name => $element ) {
678 echo "\n<!-- {$name} -->\n";
679 switch ( $element ) {
680 case 'NAMESPACES':
681 ?>
682 <div id="p-namespaces" class="vectorTabs<?php if ( count( $this->data['namespace_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
683 <h5><?php $this->msg('namespaces') ?></h5>
684 <ul <?php $this->html('userlangattributes') ?>>
685 <?php foreach ($this->data['namespace_urls'] as $key => $link ): ?>
686 <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>
687 <?php endforeach; ?>
688 </ul>
689 </div>
690 <?php
691 break;
692 case 'VARIANTS':
693 ?>
694 <div id="p-variants" class="vectorMenu<?php if ( count( $this->data['variant_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
695 <h5><span><?php $this->msg('variants') ?></span><a href="#"></a></h5>
696 <div class="menu">
697 <ul <?php $this->html('userlangattributes') ?>>
698 <?php foreach ($this->data['variant_urls'] as $key => $link ): ?>
699 <li<?php echo $link['attributes'] ?>><a href="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php echo $link['key'] ?>><?php echo htmlspecialchars( $link['text'] ) ?></a></li>
700 <?php endforeach; ?>
701 </ul>
702 </div>
703 </div>
704 <?php
705 break;
706 case 'VIEWS':
707 ?>
708 <div id="p-views" class="vectorTabs<?php if ( count( $this->data['view_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
709 <h5><?php $this->msg('views') ?></h5>
710 <ul <?php $this->html('userlangattributes') ?>>
711 <?php foreach ($this->data['view_urls'] as $key => $link ): ?>
712 <li<?php echo $link['attributes'] ?>><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'].'" />' : '<span>'.htmlspecialchars( $link['text'] ).'</span>') ?></a></li>
713 <?php endforeach; ?>
714 </ul>
715 </div>
716 <?php
717 break;
718 case 'ACTIONS':
719 ?>
720 <div id="p-cactions" class="vectorMenu<?php if ( count( $this->data['action_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
721 <h5><span><?php $this->msg('actions') ?></span><a href="#"></a></h5>
722 <div class="menu">
723 <ul <?php $this->html('userlangattributes') ?>>
724 <?php foreach ($this->data['action_urls'] as $key => $link ): ?>
725 <li<?php echo $link['attributes'] ?>><a href="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php echo $link['key'] ?>><?php echo htmlspecialchars( $link['text'] ) ?></a></li>
726 <?php endforeach; ?>
727 </ul>
728 </div>
729 </div>
730 <?php
731 break;
732 case 'PERSONAL':
733 ?>
734 <div id="p-personal" class="<?php if ( count( $this->data['personal_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
735 <h5><?php $this->msg('personaltools') ?></h5>
736 <ul <?php $this->html('userlangattributes') ?>>
737 <?php foreach($this->data['personal_urls'] as $key => $item): ?>
738 <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>
739 <?php endforeach; ?>
740 </ul>
741 </div>
742 <?php
743 break;
744 case 'SEARCH':
745 ?>
746 <div id="p-search">
747 <h5 <?php $this->html('userlangattributes') ?>><label for="searchInput"><?php $this->msg( 'search' ) ?></label></h5>
748 <form action="<?php $this->text( 'wgScript' ) ?>" id="searchform">
749 <input type='hidden' name="title" value="<?php $this->text( 'searchtitle' ) ?>"/>
750 <?php if ( $wgVectorUseSimpleSearch ): ?>
751 <div id="simpleSearch">
752 <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; ?> />
753 <button id="searchButton" type='submit' name='button' <?php echo $this->skin->tooltipAndAccesskey( 'search-fulltext' ); ?>>&nbsp;</button>
754 </div>
755 <?php else: ?>
756 <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; ?> />
757 <input type='submit' name="go" class="searchButton" id="searchGoButton" value="<?php $this->msg( 'searcharticle' ) ?>"<?php echo $this->skin->tooltipAndAccesskey( 'search-go' ); ?> />
758 <input type="submit" name="fulltext" class="searchButton" id="mw-searchButton" value="<?php $this->msg( 'searchbutton' ) ?>"<?php echo $this->skin->tooltipAndAccesskey( 'search-fulltext' ); ?> />
759 <?php endif; ?>
760 </form>
761 </div>
762 <?php
763
764 break;
765 }
766 echo "\n<!-- /{$name} -->\n";
767 }
768 }
769 }