* (bug 25488) Disallowing anonymous users to read pages no longer throws error on...
[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 parent::setupSkinUserCss( $out );
51 $out->addModuleStyles( 'skins.vector' );
52 }
53
54 /**
55 * Builds a structured array of links used for tabs and menus
56 * @return array
57 * @private
58 */
59 function buildNavigationUrls() {
60 global $wgContLang, $wgLang, $wgOut, $wgUser, $wgRequest, $wgArticle;
61 global $wgDisableLangConversion, $wgVectorUseIconWatch;
62
63 wfProfileIn( __METHOD__ );
64
65 $links = array(
66 'namespaces' => array(),
67 'views' => array(),
68 'actions' => array(),
69 'variants' => array()
70 );
71
72 // Detects parameters
73 $action = $wgRequest->getVal( 'action', 'view' );
74 $section = $wgRequest->getVal( 'section' );
75
76 // Checks if page is some kind of content
77 if( $this->iscontent ) {
78 // Gets page objects for the related namespaces
79 $subjectPage = $this->mTitle->getSubjectPage();
80 $talkPage = $this->mTitle->getTalkPage();
81
82 // Determines if this is a talk page
83 $isTalk = $this->mTitle->isTalkPage();
84
85 // Generates XML IDs from namespace names
86 $subjectId = $this->mTitle->getNamespaceKey( '' );
87
88 if ( $subjectId == 'main' ) {
89 $talkId = 'talk';
90 } else {
91 $talkId = "{$subjectId}_talk";
92 }
93
94 // Adds namespace links
95 $links['namespaces'][$subjectId] = $this->tabAction(
96 $subjectPage, 'nstab-' . $subjectId, !$isTalk, '', true
97 );
98 $links['namespaces'][$subjectId]['context'] = 'subject';
99 $links['namespaces'][$talkId] = $this->tabAction(
100 $talkPage, '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 && $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 has some kind of viewable content
158 } elseif ( $this->mTitle->hasSourceText() ) {
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 $n = $this->mTitle->isDeleted();
230 if( $n ) {
231 $undelTitle = SpecialPage::getTitleFor( 'Undelete' );
232 $links['actions']['undelete'] = array(
233 'class' => false,
234 'text' => wfMsgExt(
235 'vector-action-undelete',
236 array( 'parsemag' ),
237 $wgLang->formatNum( $n )
238 ),
239 'href' => $undelTitle->getLocalURL(
240 'target=' . urlencode( $this->thispage )
241 )
242 );
243 }
244 }
245
246 if (
247 $this->mTitle->getNamespace() !== NS_MEDIAWIKI &&
248 $wgUser->isAllowed( 'protect' )
249 ) {
250 if ( !$this->mTitle->getRestrictions( 'create' ) ) {
251 $links['actions']['protect'] = array(
252 'class' => ( $action == 'protect' ) ?
253 'selected' : false,
254 'text' => wfMsg( 'vector-action-protect' ),
255 'href' =>
256 $this->mTitle->getLocalURL( 'action=protect' )
257 );
258
259 } else {
260 $links['actions']['unprotect'] = array(
261 'class' => ( $action == 'unprotect' ) ?
262 'selected' : false,
263 'text' => wfMsg( 'vector-action-unprotect' ),
264 'href' =>
265 $this->mTitle->getLocalURL( 'action=unprotect' )
266 );
267 }
268 }
269 }
270 wfProfileOut( __METHOD__ . '-live' );
271 /**
272 * The following actions use messages which, if made particular to
273 * the Vector skin, would break the Ajax code which makes this
274 * action happen entirely inline. Skin::makeGlobalVariablesScript
275 * defines a set of messages in a javascript object - and these
276 * messages are assumed to be global for all skins. Without making
277 * a change to that procedure these messages will have to remain as
278 * the global versions.
279 */
280 // Checks if the user is logged in
281 if ( $this->loggedin ) {
282 if ( $wgVectorUseIconWatch ) {
283 $class = 'icon';
284 $place = 'views';
285 } else {
286 $class = '';
287 $place = 'actions';
288 }
289 $mode = $this->mTitle->userIsWatching() ? 'unwatch' : 'watch';
290 $links[$place][$mode] = array(
291 'class' => $class . ( ( $action == 'watch' || $action == 'unwatch' ) ? ' selected' : false ),
292 'text' => wfMsg( $mode ), // uses 'watch' or 'unwatch' message
293 'href' => $this->mTitle->getLocalURL( 'action=' . $mode )
294 );
295 }
296 // This is instead of SkinTemplateTabs - which uses a flat array
297 wfRunHooks( 'SkinTemplateNavigation', array( &$this, &$links ) );
298
299 // If it's not content, it's got to be a special page
300 } else {
301 $links['namespaces']['special'] = array(
302 'class' => 'selected',
303 'text' => wfMsg( 'nstab-special' ),
304 'href' => $wgRequest->getRequestURL()
305 );
306 }
307
308 // Gets list of language variants
309 $variants = $wgContLang->getVariants();
310 // Checks that language conversion is enabled and variants exist
311 if( !$wgDisableLangConversion && count( $variants ) > 1 ) {
312 // Gets preferred variant
313 $preferred = $wgContLang->getPreferredVariant();
314 // Loops over each variant
315 foreach( $variants as $code ) {
316 // Gets variant name from language code
317 $varname = $wgContLang->getVariantname( $code );
318 // Checks if the variant is marked as disabled
319 if( $varname == 'disable' ) {
320 // Skips this variant
321 continue;
322 }
323 // Appends variant link
324 $links['variants'][] = array(
325 'class' => ( $code == $preferred ) ? 'selected' : false,
326 'text' => $varname,
327 'href' => $this->mTitle->getLocalURL( '', $code )
328 );
329 }
330 }
331
332 wfProfileOut( __METHOD__ );
333
334 return $links;
335 }
336 }
337
338 /**
339 * QuickTemplate class for Vector skin
340 * @ingroup Skins
341 */
342 class VectorTemplate extends QuickTemplate {
343
344 /* Members */
345
346 /**
347 * @var Cached skin object
348 */
349 var $skin;
350
351 /* Functions */
352
353 /**
354 * Outputs the entire contents of the XHTML page
355 */
356 public function execute() {
357 global $wgRequest, $wgLang;
358
359 $this->skin = $this->data['skin'];
360 $action = $wgRequest->getText( 'action' );
361
362 // Build additional attributes for navigation urls
363 $nav = $this->skin->buildNavigationUrls();
364 foreach ( $nav as $section => $links ) {
365 foreach ( $links as $key => $link ) {
366 $xmlID = $key;
367 if ( isset( $link['context'] ) && $link['context'] == 'subject' ) {
368 $xmlID = 'ca-nstab-' . $xmlID;
369 } else if ( isset( $link['context'] ) && $link['context'] == 'talk' ) {
370 $xmlID = 'ca-talk';
371 } else {
372 $xmlID = 'ca-' . $xmlID;
373 }
374 $nav[$section][$key]['attributes'] =
375 ' id="' . Sanitizer::escapeId( $xmlID ) . '"';
376 if ( $nav[$section][$key]['class'] ) {
377 $nav[$section][$key]['attributes'] .=
378 ' class="' . htmlspecialchars( $link['class'] ) . '"';
379 unset( $nav[$section][$key]['class'] );
380 }
381 // We don't want to give the watch tab an accesskey if the page
382 // is being edited, because that conflicts with the accesskey on
383 // the watch checkbox. We also don't want to give the edit tab
384 // an accesskey, because that's fairly superfluous and conflicts
385 // with an accesskey (Ctrl-E) often used for editing in Safari.
386 if (
387 in_array( $action, array( 'edit', 'submit' ) ) &&
388 in_array( $key, array( 'edit', 'watch', 'unwatch' ) )
389 ) {
390 $nav[$section][$key]['key'] =
391 $this->skin->tooltip( $xmlID );
392 } else {
393 $nav[$section][$key]['key'] =
394 $this->skin->tooltipAndAccesskey( $xmlID );
395 }
396 }
397 }
398 $this->data['namespace_urls'] = $nav['namespaces'];
399 $this->data['view_urls'] = $nav['views'];
400 $this->data['action_urls'] = $nav['actions'];
401 $this->data['variant_urls'] = $nav['variants'];
402 // Build additional attributes for personal_urls
403 foreach ( $this->data['personal_urls'] as $key => $item) {
404 $this->data['personal_urls'][$key]['attributes'] =
405 ' id="' . Sanitizer::escapeId( "pt-$key" ) . '"';
406 if ( isset( $item['active'] ) && $item['active'] ) {
407 $this->data['personal_urls'][$key]['attributes'] .=
408 ' class="active"';
409 }
410 $this->data['personal_urls'][$key]['key'] =
411 $this->skin->tooltipAndAccesskey('pt-'.$key);
412 }
413
414 // Generate additional footer links
415 $footerlinks = array(
416 'info' => array(
417 'lastmod',
418 'viewcount',
419 'numberofwatchingusers',
420 'credits',
421 'copyright',
422 'tagline',
423 ),
424 'places' => array(
425 'privacy',
426 'about',
427 'disclaimer',
428 ),
429 'icons' => array(
430 'poweredbyico',
431 'copyrightico',
432 ),
433 );
434 $footerlinksClasses = array(
435 'icons' => array( 'noprint' )
436 );
437
438 // Reduce footer links down to only those which are being used
439 $validFooterLinks = array();
440 foreach( $footerlinks as $category => $links ) {
441 $validFooterLinks[$category] = array();
442 foreach( $links as $link ) {
443 if( isset( $this->data[$link] ) && $this->data[$link] ) {
444 $validFooterLinks[$category][] = $link;
445 }
446 }
447 }
448 // Reverse horizontally rendered navigation elements
449 if ( $wgLang->isRTL() ) {
450 $this->data['view_urls'] =
451 array_reverse( $this->data['view_urls'] );
452 $this->data['namespace_urls'] =
453 array_reverse( $this->data['namespace_urls'] );
454 $this->data['personal_urls'] =
455 array_reverse( $this->data['personal_urls'] );
456 }
457 // Output HTML Page
458 $this->html( 'headelement' );
459 ?>
460 <div id="mw-page-base" class="noprint"></div>
461 <div id="mw-head-base" class="noprint"></div>
462 <!-- content -->
463 <div id="content"<?php $this->html('specialpageattributes') ?>>
464 <a id="top"></a>
465 <div id="mw-js-message" style="display:none;"<?php $this->html('userlangattributes') ?>></div>
466 <?php if ( $this->data['sitenotice'] ): ?>
467 <!-- sitenotice -->
468 <div id="siteNotice"><?php $this->html( 'sitenotice' ) ?></div>
469 <!-- /sitenotice -->
470 <?php endif; ?>
471 <!-- firstHeading -->
472 <h1 id="firstHeading" class="firstHeading"><?php $this->html( 'title' ) ?></h1>
473 <!-- /firstHeading -->
474 <!-- bodyContent -->
475 <div id="bodyContent">
476 <!-- tagline -->
477 <div id="siteSub"><?php $this->msg( 'tagline' ) ?></div>
478 <!-- /tagline -->
479 <!-- subtitle -->
480 <div id="contentSub"<?php $this->html('userlangattributes') ?>><?php $this->html( 'subtitle' ) ?></div>
481 <!-- /subtitle -->
482 <?php if ( $this->data['undelete'] ): ?>
483 <!-- undelete -->
484 <div id="contentSub2"><?php $this->html( 'undelete' ) ?></div>
485 <!-- /undelete -->
486 <?php endif; ?>
487 <?php if($this->data['newtalk'] ): ?>
488 <!-- newtalk -->
489 <div class="usermessage"><?php $this->html( 'newtalk' ) ?></div>
490 <!-- /newtalk -->
491 <?php endif; ?>
492 <?php if ( $this->data['showjumplinks'] ): ?>
493 <!-- jumpto -->
494 <div id="jump-to-nav">
495 <?php $this->msg( 'jumpto' ) ?> <a href="#mw-head"><?php $this->msg( 'jumptonavigation' ) ?></a>,
496 <a href="#p-search"><?php $this->msg( 'jumptosearch' ) ?></a>
497 </div>
498 <!-- /jumpto -->
499 <?php endif; ?>
500 <!-- bodytext -->
501 <?php $this->html( 'bodytext' ) ?>
502 <!-- /bodytext -->
503 <?php if ( $this->data['catlinks'] ): ?>
504 <!-- catlinks -->
505 <?php $this->html( 'catlinks' ); ?>
506 <!-- /catlinks -->
507 <?php endif; ?>
508 <?php if ( $this->data['dataAfterContent'] ): ?>
509 <!-- dataAfterContent -->
510 <?php $this->html( 'dataAfterContent' ); ?>
511 <!-- /dataAfterContent -->
512 <?php endif; ?>
513 <div class="visualClear"></div>
514 </div>
515 <!-- /bodyContent -->
516 </div>
517 <!-- /content -->
518 <!-- header -->
519 <div id="mw-head" class="noprint">
520 <?php $this->renderNavigation( 'PERSONAL' ); ?>
521 <div id="left-navigation">
522 <?php $this->renderNavigation( array( 'NAMESPACES', 'VARIANTS' ) ); ?>
523 </div>
524 <div id="right-navigation">
525 <?php $this->renderNavigation( array( 'VIEWS', 'ACTIONS', 'SEARCH' ) ); ?>
526 </div>
527 </div>
528 <!-- /header -->
529 <!-- panel -->
530 <div id="mw-panel" class="noprint">
531 <!-- logo -->
532 <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>
533 <!-- /logo -->
534 <?php $this->renderPortals( $this->data['sidebar'] ); ?>
535 </div>
536 <!-- /panel -->
537 <!-- footer -->
538 <div id="footer"<?php $this->html('userlangattributes') ?>>
539 <?php foreach( $validFooterLinks as $category => $links ): ?>
540 <?php if ( count( $links ) > 0 ): ?>
541 <ul id="footer-<?php echo $category ?>"<?php if (isset($footerlinksClasses[$category])) echo ' class="' . implode(" ", $footerlinksClasses[$category]) . '"'; ?>>
542 <?php foreach( $links as $link ): ?>
543 <?php if( isset( $this->data[$link] ) && $this->data[$link] ): ?>
544 <li id="footer-<?php echo $category ?>-<?php echo $link ?>"><?php $this->html( $link ) ?></li>
545 <?php endif; ?>
546 <?php endforeach; ?>
547 </ul>
548 <?php endif; ?>
549 <?php endforeach; ?>
550 <div style="clear:both"></div>
551 </div>
552 <!-- /footer -->
553 <?php $this->html( 'bottomscripts' ); /* JS call to runBodyOnloadHook */ ?>
554 <!-- fixalpha -->
555 <script type="<?php $this->text('jsmimetype') ?>"> if ( window.isMSIE55 ) fixalpha(); </script>
556 <!-- /fixalpha -->
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( 'SkinTemplateToolboxEnd', array( &$this ) ); ?>
616 </ul>
617 </div>
618 </div>
619 <?php
620 break;
621 case 'LANGUAGES':
622 if ( $this->data['language_urls'] ) {
623 ?>
624 <div class="portal" id="p-lang">
625 <h5<?php $this->html('userlangattributes') ?>><?php $this->msg( 'otherlanguages' ) ?></h5>
626 <div class="body">
627 <ul>
628 <?php foreach ( $this->data['language_urls'] as $langlink ): ?>
629 <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>
630 <?php endforeach; ?>
631 </ul>
632 </div>
633 </div>
634 <?php
635 }
636 break;
637 default:
638 ?>
639 <div class="portal" id='<?php echo Sanitizer::escapeId( "p-$name" ) ?>'<?php echo $this->skin->tooltip( 'p-' . $name ) ?>>
640 <h5<?php $this->html('userlangattributes') ?>><?php $out = wfMsg( $name ); if ( wfEmptyMsg( $name, $out ) ) echo htmlspecialchars( $name ); else echo htmlspecialchars( $out ); ?></h5>
641 <div class="body">
642 <?php if ( is_array( $content ) ): ?>
643 <ul>
644 <?php foreach( $content as $val ): ?>
645 <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>
646 <?php endforeach; ?>
647 </ul>
648 <?php else: ?>
649 <?php echo $content; /* Allow raw HTML block to be defined by extensions */ ?>
650 <?php endif; ?>
651 </div>
652 </div>
653 <?php
654 break;
655 }
656 echo "\n<!-- /{$name} -->\n";
657 }
658 }
659
660 /**
661 * Render one or more navigations elements by name, automatically reveresed
662 * when UI is in RTL mode
663 */
664 private function renderNavigation( $elements ) {
665 global $wgVectorUseSimpleSearch, $wgVectorShowVariantName, $wgUser;
666
667 // If only one element was given, wrap it in an array, allowing more
668 // flexible arguments
669 if ( !is_array( $elements ) ) {
670 $elements = array( $elements );
671 // If there's a series of elements, reverse them when in RTL mode
672 } else if ( wfUILang()->isRTL() ) {
673 $elements = array_reverse( $elements );
674 }
675 // Render elements
676 foreach ( $elements as $name => $element ) {
677 echo "\n<!-- {$name} -->\n";
678 switch ( $element ) {
679 case 'NAMESPACES':
680 ?>
681 <div id="p-namespaces" class="vectorTabs<?php if ( count( $this->data['namespace_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
682 <h5><?php $this->msg('namespaces') ?></h5>
683 <ul<?php $this->html('userlangattributes') ?>>
684 <?php foreach ($this->data['namespace_urls'] as $link ): ?>
685 <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>
686 <?php endforeach; ?>
687 </ul>
688 </div>
689 <?php
690 break;
691 case 'VARIANTS':
692 ?>
693 <div id="p-variants" class="vectorMenu<?php if ( count( $this->data['variant_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
694 <?php if ( $wgVectorShowVariantName ): ?>
695 <h4>
696 <?php foreach ( $this->data['variant_urls'] as $link ): ?>
697 <?php if ( stripos( $link['attributes'], 'selected' ) !== false ): ?>
698 <?php echo htmlspecialchars( $link['text'] ) ?>
699 <?php endif; ?>
700 <?php endforeach; ?>
701 </h4>
702 <?php endif; ?>
703 <h5><span><?php $this->msg('variants') ?></span><a href="#"></a></h5>
704 <div class="menu">
705 <ul<?php $this->html('userlangattributes') ?>>
706 <?php foreach ( $this->data['variant_urls'] as $link ): ?>
707 <li<?php echo $link['attributes'] ?>><a href="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php echo $link['key'] ?>><?php echo htmlspecialchars( $link['text'] ) ?></a></li>
708 <?php endforeach; ?>
709 </ul>
710 </div>
711 </div>
712 <?php
713 break;
714 case 'VIEWS':
715 ?>
716 <div id="p-views" class="vectorTabs<?php if ( count( $this->data['view_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
717 <h5><?php $this->msg('views') ?></h5>
718 <ul<?php $this->html('userlangattributes') ?>>
719 <?php foreach ( $this->data['view_urls'] as $link ): ?>
720 <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>
721 <?php endforeach; ?>
722 </ul>
723 </div>
724 <?php
725 break;
726 case 'ACTIONS':
727 ?>
728 <div id="p-cactions" class="vectorMenu<?php if ( count( $this->data['action_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
729 <h5><span><?php $this->msg('actions') ?></span><a href="#"></a></h5>
730 <div class="menu">
731 <ul<?php $this->html('userlangattributes') ?>>
732 <?php foreach ($this->data['action_urls'] as $link ): ?>
733 <li<?php echo $link['attributes'] ?>><a href="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php echo $link['key'] ?>><?php echo htmlspecialchars( $link['text'] ) ?></a></li>
734 <?php endforeach; ?>
735 </ul>
736 </div>
737 </div>
738 <?php
739 break;
740 case 'PERSONAL':
741 ?>
742 <div id="p-personal" class="<?php if ( count( $this->data['personal_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
743 <h5><?php $this->msg('personaltools') ?></h5>
744 <ul<?php $this->html('userlangattributes') ?>>
745 <?php foreach($this->data['personal_urls'] as $item): ?>
746 <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>
747 <?php endforeach; ?>
748 </ul>
749 </div>
750 <?php
751 break;
752 case 'SEARCH':
753 ?>
754 <div id="p-search">
755 <h5<?php $this->html('userlangattributes') ?>><label for="searchInput"><?php $this->msg( 'search' ) ?></label></h5>
756 <form action="<?php $this->text( 'wgScript' ) ?>" id="searchform">
757 <input type='hidden' name="title" value="<?php $this->text( 'searchtitle' ) ?>"/>
758 <?php if ( $wgVectorUseSimpleSearch && $wgUser->getOption( 'vector-simplesearch' ) ): ?>
759 <div id="simpleSearch">
760 <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; ?> />
761 <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>
762 </div>
763 <?php else: ?>
764 <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; ?> />
765 <input type='submit' name="go" class="searchButton" id="searchGoButton" value="<?php $this->msg( 'searcharticle' ) ?>"<?php echo $this->skin->tooltipAndAccesskey( 'search-go' ); ?> />
766 <input type="submit" name="fulltext" class="searchButton" id="mw-searchButton" value="<?php $this->msg( 'searchbutton' ) ?>"<?php echo $this->skin->tooltipAndAccesskey( 'search-fulltext' ); ?> />
767 <?php endif; ?>
768 </form>
769 </div>
770 <?php
771
772 break;
773 }
774 echo "\n<!-- /{$name} -->\n";
775 }
776 }
777 }