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