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