Add makeSearchInput and makeSearchButton to BaseTemplate and make use of it in Vector...
[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 BaseTemplate {
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 = $this->data["footerlinks"];
416
417 // Reduce footer links down to only those which are being used
418 $validFooterLinks = array();
419 foreach( $footerlinks as $category => $links ) {
420 $validFooterLinks[$category] = array();
421 foreach( $links as $link ) {
422 if( isset( $this->data[$link] ) && $this->data[$link] ) {
423 $validFooterLinks[$category][] = $link;
424 }
425 }
426 }
427
428 // Generate additional footer icons
429 $footericons = $this->data["footericons"];
430 // Unset any icons which don't have an image
431 foreach ( $footericons as $footerIconsKey => &$footerIconsBlock ) {
432 foreach ( $footerIconsBlock as $footerIconKey => $footerIcon ) {
433 if ( !is_string($footerIcon) && !isset($footerIcon["src"]) ) {
434 unset($footerIconsBlock[$footerIconKey]);
435 }
436 }
437 }
438 // Redo removal of any empty blocks
439 foreach ( $footericons as $footerIconsKey => &$footerIconsBlock ) {
440 if ( count($footerIconsBlock) <= 0 ) {
441 unset($footericons[$footerIconsKey]);
442 }
443 }
444
445 // Reverse horizontally rendered navigation elements
446 if ( $wgLang->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 $this->html( 'headelement' );
456 ?>
457 <div id="mw-page-base" class="noprint"></div>
458 <div id="mw-head-base" class="noprint"></div>
459 <!-- content -->
460 <div id="content"<?php $this->html('specialpageattributes') ?>>
461 <a id="top"></a>
462 <div id="mw-js-message" style="display:none;"<?php $this->html('userlangattributes') ?>></div>
463 <?php if ( $this->data['sitenotice'] ): ?>
464 <!-- sitenotice -->
465 <div id="siteNotice"><?php $this->html( 'sitenotice' ) ?></div>
466 <!-- /sitenotice -->
467 <?php endif; ?>
468 <!-- firstHeading -->
469 <h1 id="firstHeading" class="firstHeading"><?php $this->html( 'title' ) ?></h1>
470 <!-- /firstHeading -->
471 <!-- bodyContent -->
472 <div id="bodyContent">
473 <!-- tagline -->
474 <div id="siteSub"><?php $this->msg( 'tagline' ) ?></div>
475 <!-- /tagline -->
476 <!-- subtitle -->
477 <div id="contentSub"<?php $this->html('userlangattributes') ?>><?php $this->html( 'subtitle' ) ?></div>
478 <!-- /subtitle -->
479 <?php if ( $this->data['undelete'] ): ?>
480 <!-- undelete -->
481 <div id="contentSub2"><?php $this->html( 'undelete' ) ?></div>
482 <!-- /undelete -->
483 <?php endif; ?>
484 <?php if($this->data['newtalk'] ): ?>
485 <!-- newtalk -->
486 <div class="usermessage"><?php $this->html( 'newtalk' ) ?></div>
487 <!-- /newtalk -->
488 <?php endif; ?>
489 <?php if ( $this->data['showjumplinks'] ): ?>
490 <!-- jumpto -->
491 <div id="jump-to-nav">
492 <?php $this->msg( 'jumpto' ) ?> <a href="#mw-head"><?php $this->msg( 'jumptonavigation' ) ?></a>,
493 <a href="#p-search"><?php $this->msg( 'jumptosearch' ) ?></a>
494 </div>
495 <!-- /jumpto -->
496 <?php endif; ?>
497 <!-- bodytext -->
498 <?php $this->html( 'bodytext' ) ?>
499 <!-- /bodytext -->
500 <?php if ( $this->data['catlinks'] ): ?>
501 <!-- catlinks -->
502 <?php $this->html( 'catlinks' ); ?>
503 <!-- /catlinks -->
504 <?php endif; ?>
505 <?php if ( $this->data['dataAfterContent'] ): ?>
506 <!-- dataAfterContent -->
507 <?php $this->html( 'dataAfterContent' ); ?>
508 <!-- /dataAfterContent -->
509 <?php endif; ?>
510 <div class="visualClear"></div>
511 </div>
512 <!-- /bodyContent -->
513 </div>
514 <!-- /content -->
515 <!-- header -->
516 <div id="mw-head" class="noprint">
517 <?php $this->renderNavigation( 'PERSONAL' ); ?>
518 <div id="left-navigation">
519 <?php $this->renderNavigation( array( 'NAMESPACES', 'VARIANTS' ) ); ?>
520 </div>
521 <div id="right-navigation">
522 <?php $this->renderNavigation( array( 'VIEWS', 'ACTIONS', 'SEARCH' ) ); ?>
523 </div>
524 </div>
525 <!-- /header -->
526 <!-- panel -->
527 <div id="mw-panel" class="noprint">
528 <!-- logo -->
529 <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>
530 <!-- /logo -->
531 <?php $this->renderPortals( $this->data['sidebar'] ); ?>
532 </div>
533 <!-- /panel -->
534 <!-- footer -->
535 <div id="footer"<?php $this->html('userlangattributes') ?>>
536 <?php foreach( $validFooterLinks as $category => $links ): ?>
537 <?php if ( count( $links ) > 0 ): ?>
538 <ul id="footer-<?php echo $category ?>">
539 <?php foreach( $links as $link ): ?>
540 <?php if( isset( $this->data[$link] ) && $this->data[$link] ): ?>
541 <li id="footer-<?php echo $category ?>-<?php echo $link ?>"><?php $this->html( $link ) ?></li>
542 <?php endif; ?>
543 <?php endforeach; ?>
544 </ul>
545 <?php endif; ?>
546 <?php endforeach; ?>
547 <?php if ( count( $footericons ) > 0 ): ?>
548 <ul id="footer-icons" class="noprint">
549 <?php foreach ( $footericons as $blockName => $footerIcons ): ?>
550 <li id="footer-<?php echo htmlspecialchars($blockName); ?>ico">
551 <?php foreach ( $footerIcons as $icon ): ?>
552 <?php echo $this->skin->makeFooterIcon( $icon ); ?>
553
554 <?php endforeach; ?>
555 </li>
556 <?php endforeach; ?>
557 </ul>
558 <?php endif; ?>
559 <div style="clear:both"></div>
560 </div>
561 <!-- /footer -->
562 <?php $this->html( 'bottomscripts' ); /* JS call to runBodyOnloadHook */ ?>
563 <!-- fixalpha -->
564 <script type="<?php $this->text('jsmimetype') ?>"> if ( window.isMSIE55 ) fixalpha(); </script>
565 <!-- /fixalpha -->
566 <?php $this->html( 'reporttime' ) ?>
567 <?php if ( $this->data['debug'] ): ?>
568 <!-- Debug output: <?php $this->text( 'debug' ); ?> -->
569 <?php endif; ?>
570 </body>
571 </html>
572 <?php
573 }
574
575 /**
576 * Render a series of portals
577 */
578 private function renderPortals( $portals ) {
579 // Force the rendering of the following portals
580 if ( !isset( $portals['SEARCH'] ) ) $portals['SEARCH'] = true;
581 if ( !isset( $portals['TOOLBOX'] ) ) $portals['TOOLBOX'] = true;
582 if ( !isset( $portals['LANGUAGES'] ) ) $portals['LANGUAGES'] = true;
583 // Render portals
584 foreach ( $portals as $name => $content ) {
585 echo "\n<!-- {$name} -->\n";
586 switch( $name ) {
587 case 'SEARCH':
588 break;
589 case 'TOOLBOX':
590 ?>
591 <div class="portal" id="p-tb">
592 <h5<?php $this->html('userlangattributes') ?>><?php $this->msg( 'toolbox' ) ?></h5>
593 <div class="body">
594 <ul>
595 <?php
596 foreach ( $this->getToolbox() as $key => $tbitem ): ?>
597 <?php echo $this->makeListItem($key, $tbitem); ?>
598
599 <?php
600 endforeach;
601 wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this ) ); ?>
602 </ul>
603 </div>
604 </div>
605 <?php
606 break;
607 case 'LANGUAGES':
608 if ( $this->data['language_urls'] ) {
609 ?>
610 <div class="portal" id="p-lang">
611 <h5<?php $this->html('userlangattributes') ?>><?php $this->msg( 'otherlanguages' ) ?></h5>
612 <div class="body">
613 <ul>
614 <?php foreach ( $this->data['language_urls'] as $key => $langlink ): ?>
615 <?php echo $this->makeListItem($key, $langlink); ?>
616
617 <?php endforeach; ?>
618 </ul>
619 </div>
620 </div>
621 <?php
622 }
623 break;
624 default:
625 ?>
626 <div class="portal" id='<?php echo Sanitizer::escapeId( "p-$name" ) ?>'<?php echo $this->skin->tooltip( 'p-' . $name ) ?>>
627 <h5<?php $this->html('userlangattributes') ?>><?php $out = wfMsg( $name ); if ( wfEmptyMsg( $name, $out ) ) echo htmlspecialchars( $name ); else echo htmlspecialchars( $out ); ?></h5>
628 <div class="body">
629 <?php if ( is_array( $content ) ): ?>
630 <ul>
631 <?php foreach( $content as $key => $val ): ?>
632 <?php echo $this->makeListItem($key, $val); ?>
633
634 <?php endforeach; ?>
635 </ul>
636 <?php else: ?>
637 <?php echo $content; /* Allow raw HTML block to be defined by extensions */ ?>
638 <?php endif; ?>
639 </div>
640 </div>
641 <?php
642 break;
643 }
644 echo "\n<!-- /{$name} -->\n";
645 }
646 }
647
648 /**
649 * Render one or more navigations elements by name, automatically reveresed
650 * when UI is in RTL mode
651 */
652 private function renderNavigation( $elements ) {
653 global $wgVectorUseSimpleSearch, $wgVectorShowVariantName, $wgUser;
654
655 // If only one element was given, wrap it in an array, allowing more
656 // flexible arguments
657 if ( !is_array( $elements ) ) {
658 $elements = array( $elements );
659 // If there's a series of elements, reverse them when in RTL mode
660 } else if ( wfUILang()->isRTL() ) {
661 $elements = array_reverse( $elements );
662 }
663 // Render elements
664 foreach ( $elements as $name => $element ) {
665 echo "\n<!-- {$name} -->\n";
666 switch ( $element ) {
667 case 'NAMESPACES':
668 ?>
669 <div id="p-namespaces" class="vectorTabs<?php if ( count( $this->data['namespace_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
670 <h5><?php $this->msg('namespaces') ?></h5>
671 <ul<?php $this->html('userlangattributes') ?>>
672 <?php foreach ($this->data['namespace_urls'] as $link ): ?>
673 <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>
674 <?php endforeach; ?>
675 </ul>
676 </div>
677 <?php
678 break;
679 case 'VARIANTS':
680 ?>
681 <div id="p-variants" class="vectorMenu<?php if ( count( $this->data['variant_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
682 <?php if ( $wgVectorShowVariantName ): ?>
683 <h4>
684 <?php foreach ( $this->data['variant_urls'] as $link ): ?>
685 <?php if ( stripos( $link['attributes'], 'selected' ) !== false ): ?>
686 <?php echo htmlspecialchars( $link['text'] ) ?>
687 <?php endif; ?>
688 <?php endforeach; ?>
689 </h4>
690 <?php endif; ?>
691 <h5><span><?php $this->msg('variants') ?></span><a href="#"></a></h5>
692 <div class="menu">
693 <ul<?php $this->html('userlangattributes') ?>>
694 <?php foreach ( $this->data['variant_urls'] as $link ): ?>
695 <li<?php echo $link['attributes'] ?>><a href="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php echo $link['key'] ?>><?php echo htmlspecialchars( $link['text'] ) ?></a></li>
696 <?php endforeach; ?>
697 </ul>
698 </div>
699 </div>
700 <?php
701 break;
702 case 'VIEWS':
703 ?>
704 <div id="p-views" class="vectorTabs<?php if ( count( $this->data['view_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
705 <h5><?php $this->msg('views') ?></h5>
706 <ul<?php $this->html('userlangattributes') ?>>
707 <?php foreach ( $this->data['view_urls'] as $link ): ?>
708 <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>
709 <?php endforeach; ?>
710 </ul>
711 </div>
712 <?php
713 break;
714 case 'ACTIONS':
715 ?>
716 <div id="p-cactions" class="vectorMenu<?php if ( count( $this->data['action_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
717 <h5><span><?php $this->msg('actions') ?></span><a href="#"></a></h5>
718 <div class="menu">
719 <ul<?php $this->html('userlangattributes') ?>>
720 <?php foreach ($this->data['action_urls'] as $link ): ?>
721 <li<?php echo $link['attributes'] ?>><a href="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php echo $link['key'] ?>><?php echo htmlspecialchars( $link['text'] ) ?></a></li>
722 <?php endforeach; ?>
723 </ul>
724 </div>
725 </div>
726 <?php
727 break;
728 case 'PERSONAL':
729 ?>
730 <div id="p-personal" class="<?php if ( count( $this->data['personal_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
731 <h5><?php $this->msg('personaltools') ?></h5>
732 <ul<?php $this->html('userlangattributes') ?>>
733 <?php foreach($this->data['personal_urls'] as $item): ?>
734 <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>
735 <?php endforeach; ?>
736 </ul>
737 </div>
738 <?php
739 break;
740 case 'SEARCH':
741 ?>
742 <div id="p-search">
743 <h5<?php $this->html('userlangattributes') ?>><label for="searchInput"><?php $this->msg( 'search' ) ?></label></h5>
744 <form action="<?php $this->text( 'wgScript' ) ?>" id="searchform">
745 <input type='hidden' name="title" value="<?php $this->text( 'searchtitle' ) ?>"/>
746 <?php if ( $wgVectorUseSimpleSearch && $wgUser->getOption( 'vector-simplesearch' ) ): ?>
747 <div id="simpleSearch">
748 <?php echo $this->makeSearchInput(array( "id" => "searchInput" )); ?>
749 <?php echo $this->makeSearchButton("image", array( "id" => "searchButton",
750 "src" => $this->skin->getSkinStylePath('images/search-' . ( $this->data['rtl'] ? 'rtl' : 'ltr' ) . '.png') )); ?>
751 </div>
752 <?php else: ?>
753 <?php echo $this->makeSearchInput(array( "id" => "searchInput" )); ?>
754 <?php echo $this->makeSearchButton("go", array( "id" => "searchGoButton", "class" => "searchButton" )); ?>
755 <?php echo $this->makeSearchButton("fulltext", array( "id" => "mw-searchButton", "class" => "searchButton" )); ?>
756 <?php endif; ?>
757 </form>
758 </div>
759 <?php
760
761 break;
762 }
763 echo "\n<!-- /{$name} -->\n";
764 }
765 }
766 }