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