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