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