MediaWiki  REL1_21
Vector.php
Go to the documentation of this file.
00001 <?php
00026 if( !defined( 'MEDIAWIKI' ) ) {
00027         die( -1 );
00028 }
00029 
00034 class SkinVector extends SkinTemplate {
00035 
00036         protected static $bodyClasses = array( 'vector-animateLayout' );
00037 
00038         var $skinname = 'vector', $stylename = 'vector',
00039                 $template = 'VectorTemplate', $useHeadElement = true;
00040 
00045         public function initPage( OutputPage $out ) {
00046                 global $wgLocalStylePath;
00047 
00048                 parent::initPage( $out );
00049 
00050                 // Append CSS which includes IE only behavior fixes for hover support -
00051                 // this is better than including this in a CSS fille since it doesn't
00052                 // wait for the CSS file to load before fetching the HTC file.
00053                 $min = $this->getRequest()->getFuzzyBool( 'debug' ) ? '' : '.min';
00054                 $out->addHeadItem( 'csshover',
00055                         '<!--[if lt IE 7]><style type="text/css">body{behavior:url("' .
00056                                 htmlspecialchars( $wgLocalStylePath ) .
00057                                 "/{$this->stylename}/csshover{$min}.htc\")}</style><![endif]-->"
00058                 );
00059 
00060                 $out->addModules( 'skins.vector.js' );
00061         }
00062 
00068         function setupSkinUserCss( OutputPage $out ) {
00069                 parent::setupSkinUserCss( $out );
00070                 $out->addModuleStyles( 'skins.vector' );
00071         }
00072 
00079         function addToBodyAttributes( $out, &$bodyAttrs ) {
00080                 if ( isset( $bodyAttrs['class'] ) && strlen( $bodyAttrs['class'] ) > 0 ) {
00081                         $bodyAttrs['class'] .= ' ' . implode( ' ', static::$bodyClasses );
00082                 } else {
00083                         $bodyAttrs['class'] = implode( ' ', static::$bodyClasses );
00084                 }
00085         }
00086 }
00087 
00092 class VectorTemplate extends BaseTemplate {
00093 
00094         /* Functions */
00095 
00099         public function execute() {
00100                 global $wgVectorUseIconWatch;
00101 
00102                 // Build additional attributes for navigation urls
00103                 $nav = $this->data['content_navigation'];
00104 
00105                 if ( $wgVectorUseIconWatch ) {
00106                         $mode = $this->getSkin()->getUser()->isWatched( $this->getSkin()->getRelevantTitle() ) ? 'unwatch' : 'watch';
00107                         if ( isset( $nav['actions'][$mode] ) ) {
00108                                 $nav['views'][$mode] = $nav['actions'][$mode];
00109                                 $nav['views'][$mode]['class'] = rtrim( 'icon ' . $nav['views'][$mode]['class'], ' ' );
00110                                 $nav['views'][$mode]['primary'] = true;
00111                                 unset( $nav['actions'][$mode] );
00112                         }
00113                 }
00114 
00115                 $xmlID = '';
00116                 foreach ( $nav as $section => $links ) {
00117                         foreach ( $links as $key => $link ) {
00118                                 if ( $section == 'views' && !( isset( $link['primary'] ) && $link['primary'] ) ) {
00119                                         $link['class'] = rtrim( 'collapsible ' . $link['class'], ' ' );
00120                                 }
00121 
00122                                 $xmlID = isset( $link['id'] ) ? $link['id'] : 'ca-' . $xmlID;
00123                                 $nav[$section][$key]['attributes'] =
00124                                         ' id="' . Sanitizer::escapeId( $xmlID ) . '"';
00125                                 if ( $link['class'] ) {
00126                                         $nav[$section][$key]['attributes'] .=
00127                                                 ' class="' . htmlspecialchars( $link['class'] ) . '"';
00128                                         unset( $nav[$section][$key]['class'] );
00129                                 }
00130                                 if ( isset( $link['tooltiponly'] ) && $link['tooltiponly'] ) {
00131                                         $nav[$section][$key]['key'] =
00132                                                 Linker::tooltip( $xmlID );
00133                                 } else {
00134                                         $nav[$section][$key]['key'] =
00135                                                 Xml::expandAttributes( Linker::tooltipAndAccesskeyAttribs( $xmlID ) );
00136                                 }
00137                         }
00138                 }
00139                 $this->data['namespace_urls'] = $nav['namespaces'];
00140                 $this->data['view_urls'] = $nav['views'];
00141                 $this->data['action_urls'] = $nav['actions'];
00142                 $this->data['variant_urls'] = $nav['variants'];
00143 
00144                 // Reverse horizontally rendered navigation elements
00145                 if ( $this->data['rtl'] ) {
00146                         $this->data['view_urls'] =
00147                                 array_reverse( $this->data['view_urls'] );
00148                         $this->data['namespace_urls'] =
00149                                 array_reverse( $this->data['namespace_urls'] );
00150                         $this->data['personal_urls'] =
00151                                 array_reverse( $this->data['personal_urls'] );
00152                 }
00153                 // Output HTML Page
00154                 $this->html( 'headelement' );
00155 ?>
00156                 <div id="mw-page-base" class="noprint"></div>
00157                 <div id="mw-head-base" class="noprint"></div>
00158                 <!-- content -->
00159                 <div id="content" class="mw-body" role="main">
00160                         <a id="top"></a>
00161                         <div id="mw-js-message" style="display:none;"<?php $this->html( 'userlangattributes' ) ?>></div>
00162                         <?php if ( $this->data['sitenotice'] ): ?>
00163                         <!-- sitenotice -->
00164                         <div id="siteNotice"><?php $this->html( 'sitenotice' ) ?></div>
00165                         <!-- /sitenotice -->
00166                         <?php endif; ?>
00167                         <!-- firstHeading -->
00168                         <h1 id="firstHeading" class="firstHeading" lang="<?php
00169                                 $this->data['pageLanguage'] = $this->getSkin()->getTitle()->getPageViewLanguage()->getCode();
00170                                 $this->html( 'pageLanguage' );
00171                         ?>"><span dir="auto"><?php $this->html( 'title' ) ?></span></h1>
00172                         <!-- /firstHeading -->
00173                         <!-- bodyContent -->
00174                         <div id="bodyContent">
00175                                 <?php if ( $this->data['isarticle'] ): ?>
00176                                 <!-- tagline -->
00177                                 <div id="siteSub"><?php $this->msg( 'tagline' ) ?></div>
00178                                 <!-- /tagline -->
00179                                 <?php endif; ?>
00180                                 <!-- subtitle -->
00181                                 <div id="contentSub"<?php $this->html( 'userlangattributes' ) ?>><?php $this->html( 'subtitle' ) ?></div>
00182                                 <!-- /subtitle -->
00183                                 <?php if ( $this->data['undelete'] ): ?>
00184                                 <!-- undelete -->
00185                                 <div id="contentSub2"><?php $this->html( 'undelete' ) ?></div>
00186                                 <!-- /undelete -->
00187                                 <?php endif; ?>
00188                                 <?php if( $this->data['newtalk'] ): ?>
00189                                 <!-- newtalk -->
00190                                 <div class="usermessage"><?php $this->html( 'newtalk' )  ?></div>
00191                                 <!-- /newtalk -->
00192                                 <?php endif; ?>
00193                                 <?php if ( $this->data['showjumplinks'] ): ?>
00194                                 <!-- jumpto -->
00195                                 <div id="jump-to-nav" class="mw-jump">
00196                                         <?php $this->msg( 'jumpto' ) ?>
00197                                         <a href="#mw-navigation"><?php $this->msg( 'jumptonavigation' ) ?></a><?php $this->msg( 'comma-separator' ) ?>
00198                                         <a href="#p-search"><?php $this->msg( 'jumptosearch' ) ?></a>
00199                                 </div>
00200                                 <!-- /jumpto -->
00201                                 <?php endif; ?>
00202                                 <!-- bodycontent -->
00203                                 <?php $this->html( 'bodycontent' ) ?>
00204                                 <!-- /bodycontent -->
00205                                 <?php if ( $this->data['printfooter'] ): ?>
00206                                 <!-- printfooter -->
00207                                 <div class="printfooter">
00208                                 <?php $this->html( 'printfooter' ); ?>
00209                                 </div>
00210                                 <!-- /printfooter -->
00211                                 <?php endif; ?>
00212                                 <?php if ( $this->data['catlinks'] ): ?>
00213                                 <!-- catlinks -->
00214                                 <?php $this->html( 'catlinks' ); ?>
00215                                 <!-- /catlinks -->
00216                                 <?php endif; ?>
00217                                 <?php if ( $this->data['dataAfterContent'] ): ?>
00218                                 <!-- dataAfterContent -->
00219                                 <?php $this->html( 'dataAfterContent' ); ?>
00220                                 <!-- /dataAfterContent -->
00221                                 <?php endif; ?>
00222                                 <div class="visualClear"></div>
00223                                 <!-- debughtml -->
00224                                 <?php $this->html( 'debughtml' ); ?>
00225                                 <!-- /debughtml -->
00226                         </div>
00227                         <!-- /bodyContent -->
00228                 </div>
00229                 <!-- /content -->
00230                 <div id="mw-navigation">
00231                         <h2><?php $this->msg( 'navigation-heading' ) ?></h2>
00232                         <!-- header -->
00233                         <div id="mw-head">
00234                                 <?php $this->renderNavigation( 'PERSONAL' ); ?>
00235                                 <div id="left-navigation">
00236                                         <?php $this->renderNavigation( array( 'NAMESPACES', 'VARIANTS' ) ); ?>
00237                                 </div>
00238                                 <div id="right-navigation">
00239                                         <?php $this->renderNavigation( array( 'VIEWS', 'ACTIONS', 'SEARCH' ) ); ?>
00240                                 </div>
00241                         </div>
00242                         <!-- /header -->
00243                         <!-- panel -->
00244                         <div id="mw-panel">
00245                                 <!-- logo -->
00246                                         <div id="p-logo" role="banner"><a style="background-image: url(<?php $this->text( 'logopath' ) ?>);" href="<?php echo htmlspecialchars( $this->data['nav_urls']['mainpage']['href'] ) ?>" <?php echo Xml::expandAttributes( Linker::tooltipAndAccesskeyAttribs( 'p-logo' ) ) ?>></a></div>
00247                                 <!-- /logo -->
00248                                 <?php $this->renderPortals( $this->data['sidebar'] ); ?>
00249                         </div>
00250                         <!-- /panel -->
00251                 </div>
00252                 <!-- footer -->
00253                 <div id="footer" role="contentinfo"<?php $this->html( 'userlangattributes' ) ?>>
00254                         <?php foreach( $this->getFooterLinks() as $category => $links ): ?>
00255                                 <ul id="footer-<?php echo $category ?>">
00256                                         <?php foreach( $links as $link ): ?>
00257                                                 <li id="footer-<?php echo $category ?>-<?php echo $link ?>"><?php $this->html( $link ) ?></li>
00258                                         <?php endforeach; ?>
00259                                 </ul>
00260                         <?php endforeach; ?>
00261                         <?php $footericons = $this->getFooterIcons("icononly");
00262                         if ( count( $footericons ) > 0 ): ?>
00263                                 <ul id="footer-icons" class="noprint">
00264 <?php                   foreach ( $footericons as $blockName => $footerIcons ): ?>
00265                                         <li id="footer-<?php echo htmlspecialchars( $blockName ); ?>ico">
00266 <?php                           foreach ( $footerIcons as $icon ): ?>
00267                                                 <?php echo $this->getSkin()->makeFooterIcon( $icon ); ?>
00268 
00269 <?php                           endforeach; ?>
00270                                         </li>
00271 <?php                   endforeach; ?>
00272                                 </ul>
00273                         <?php endif; ?>
00274                         <div style="clear:both"></div>
00275                 </div>
00276                 <!-- /footer -->
00277                 <?php $this->printTrail(); ?>
00278 
00279         </body>
00280 </html>
00281 <?php
00282         }
00283 
00289         protected function renderPortals( $portals ) {
00290                 // Force the rendering of the following portals
00291                 if ( !isset( $portals['SEARCH'] ) ) {
00292                         $portals['SEARCH'] = true;
00293                 }
00294                 if ( !isset( $portals['TOOLBOX'] ) ) {
00295                         $portals['TOOLBOX'] = true;
00296                 }
00297                 if ( !isset( $portals['LANGUAGES'] ) ) {
00298                         $portals['LANGUAGES'] = true;
00299                 }
00300                 // Render portals
00301                 foreach ( $portals as $name => $content ) {
00302                         if ( $content === false )
00303                                 continue;
00304 
00305                         echo "\n<!-- {$name} -->\n";
00306                         switch( $name ) {
00307                                 case 'SEARCH':
00308                                         break;
00309                                 case 'TOOLBOX':
00310                                         $this->renderPortal( 'tb', $this->getToolbox(), 'toolbox', 'SkinTemplateToolboxEnd' );
00311                                         break;
00312                                 case 'LANGUAGES':
00313                                         if ( $this->data['language_urls'] ) {
00314                                                 $this->renderPortal( 'lang', $this->data['language_urls'], 'otherlanguages' );
00315                                         }
00316                                         break;
00317                                 default:
00318                                         $this->renderPortal( $name, $content );
00319                                 break;
00320                         }
00321                         echo "\n<!-- /{$name} -->\n";
00322                 }
00323         }
00324 
00331         protected function renderPortal( $name, $content, $msg = null, $hook = null ) {
00332                 if ( $msg === null ) {
00333                         $msg = $name;
00334                 }
00335                 ?>
00336 <div class="portal" role="navigation" id='<?php echo Sanitizer::escapeId( "p-$name" ) ?>'<?php echo Linker::tooltip( 'p-' . $name ) ?>>
00337         <h3<?php $this->html( 'userlangattributes' ) ?>><?php $msgObj = wfMessage( $msg ); echo htmlspecialchars( $msgObj->exists() ? $msgObj->text() : $msg ); ?></h3>
00338         <div class="body">
00339 <?php
00340                 if ( is_array( $content ) ): ?>
00341                 <ul>
00342 <?php
00343                         foreach( $content as $key => $val ): ?>
00344                         <?php echo $this->makeListItem( $key, $val ); ?>
00345 
00346 <?php
00347                         endforeach;
00348                         if ( $hook !== null ) {
00349                                 wfRunHooks( $hook, array( &$this, true ) );
00350                         }
00351                         ?>
00352                 </ul>
00353 <?php
00354                 else: ?>
00355                 <?php echo $content; /* Allow raw HTML block to be defined by extensions */ ?>
00356 <?php
00357                 endif; ?>
00358         </div>
00359 </div>
00360 <?php
00361         }
00362 
00369         protected function renderNavigation( $elements ) {
00370                 global $wgVectorUseSimpleSearch;
00371 
00372                 // If only one element was given, wrap it in an array, allowing more
00373                 // flexible arguments
00374                 if ( !is_array( $elements ) ) {
00375                         $elements = array( $elements );
00376                 // If there's a series of elements, reverse them when in RTL mode
00377                 } elseif ( $this->data['rtl'] ) {
00378                         $elements = array_reverse( $elements );
00379                 }
00380                 // Render elements
00381                 foreach ( $elements as $name => $element ) {
00382                         echo "\n<!-- {$name} -->\n";
00383                         switch ( $element ) {
00384                                 case 'NAMESPACES':
00385 ?>
00386 <div id="p-namespaces" role="navigation" class="vectorTabs<?php if ( count( $this->data['namespace_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
00387         <h3><?php $this->msg( 'namespaces' ) ?></h3>
00388         <ul<?php $this->html( 'userlangattributes' ) ?>>
00389                 <?php foreach ( $this->data['namespace_urls'] as $link ): ?>
00390                         <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>
00391                 <?php endforeach; ?>
00392         </ul>
00393 </div>
00394 <?php
00395                                 break;
00396                                 case 'VARIANTS':
00397 ?>
00398 <div id="p-variants" role="navigation" class="vectorMenu<?php if ( count( $this->data['variant_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
00399         <h3 id="mw-vector-current-variant">
00400         <?php foreach ( $this->data['variant_urls'] as $link ): ?>
00401                 <?php if ( stripos( $link['attributes'], 'selected' ) !== false ): ?>
00402                         <?php echo htmlspecialchars( $link['text'] ) ?>
00403                 <?php endif; ?>
00404         <?php endforeach; ?>
00405         </h3>
00406         <h3><span><?php $this->msg( 'variants' ) ?></span><a href="#"></a></h3>
00407         <div class="menu">
00408                 <ul>
00409                         <?php foreach ( $this->data['variant_urls'] as $link ): ?>
00410                                 <li<?php echo $link['attributes'] ?>><a href="<?php echo htmlspecialchars( $link['href'] ) ?>" lang="<?php echo htmlspecialchars( $link['lang'] ) ?>" hreflang="<?php echo htmlspecialchars( $link['hreflang'] ) ?>" <?php echo $link['key'] ?>><?php echo htmlspecialchars( $link['text'] ) ?></a></li>
00411                         <?php endforeach; ?>
00412                 </ul>
00413         </div>
00414 </div>
00415 <?php
00416                                 break;
00417                                 case 'VIEWS':
00418 ?>
00419 <div id="p-views" role="navigation" class="vectorTabs<?php if ( count( $this->data['view_urls'] ) == 0 ) { echo ' emptyPortlet'; } ?>">
00420         <h3><?php $this->msg('views') ?></h3>
00421         <ul<?php $this->html('userlangattributes') ?>>
00422                 <?php foreach ( $this->data['view_urls'] as $link ): ?>
00423                         <li<?php echo $link['attributes'] ?>><span><a href="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php echo $link['key'] ?>><?php
00424                                 // $link['text'] can be undefined - bug 27764
00425                                 if ( array_key_exists( 'text', $link ) ) {
00426                                         echo array_key_exists( 'img', $link ) ?  '<img src="' . $link['img'] . '" alt="' . $link['text'] . '" />' : htmlspecialchars( $link['text'] );
00427                                 }
00428                                 ?></a></span></li>
00429                 <?php endforeach; ?>
00430         </ul>
00431 </div>
00432 <?php
00433                                 break;
00434                                 case 'ACTIONS':
00435 ?>
00436 <div id="p-cactions" role="navigation" class="vectorMenu<?php if ( count( $this->data['action_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
00437         <h3><span><?php $this->msg( 'actions' ) ?></span><a href="#"></a></h3>
00438         <div class="menu">
00439                 <ul<?php $this->html( 'userlangattributes' ) ?>>
00440                         <?php foreach ( $this->data['action_urls'] as $link ): ?>
00441                                 <li<?php echo $link['attributes'] ?>><a href="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php echo $link['key'] ?>><?php echo htmlspecialchars( $link['text'] ) ?></a></li>
00442                         <?php endforeach; ?>
00443                 </ul>
00444         </div>
00445 </div>
00446 <?php
00447                                 break;
00448                                 case 'PERSONAL':
00449 ?>
00450 <div id="p-personal" role="navigation" class="<?php if ( count( $this->data['personal_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
00451         <h3><?php $this->msg( 'personaltools' ) ?></h3>
00452         <ul<?php $this->html( 'userlangattributes' ) ?>>
00453 <?php
00454                                         $personalTools = $this->getPersonalTools();
00455                                         foreach ( $personalTools as $key => $item ) {
00456                                                 echo $this->makeListItem( $key, $item );
00457                                         }
00458 ?>
00459         </ul>
00460 </div>
00461 <?php
00462                                 break;
00463                                 case 'SEARCH':
00464 ?>
00465 <div id="p-search" role="search">
00466         <h3<?php $this->html( 'userlangattributes' ) ?>><label for="searchInput"><?php $this->msg( 'search' ) ?></label></h3>
00467         <form action="<?php $this->text( 'wgScript' ) ?>" id="searchform">
00468                 <?php if ( $wgVectorUseSimpleSearch && $this->getSkin()->getUser()->getOption( 'vector-simplesearch' ) ): ?>
00469                 <div id="simpleSearch">
00470                         <?php if ( $this->data['rtl'] ): ?>
00471                         <?php echo $this->makeSearchButton( 'image', array( 'id' => 'searchButton', 'src' => $this->getSkin()->getSkinStylePath( 'images/search-rtl.png' ), 'width' => '12', 'height' => '13' ) ); ?>
00472                         <?php endif; ?>
00473                         <?php echo $this->makeSearchInput( array( 'id' => 'searchInput', 'type' => 'text' ) ); ?>
00474                         <?php if ( !$this->data['rtl'] ): ?>
00475                         <?php echo $this->makeSearchButton( 'image', array( 'id' => 'searchButton', 'src' => $this->getSkin()->getSkinStylePath( 'images/search-ltr.png' ), 'width' => '12', 'height' => '13' ) ); ?>
00476                         <?php endif; ?>
00477                 <?php else: ?>
00478                 <div>
00479                         <?php echo $this->makeSearchInput( array( 'id' => 'searchInput' ) ); ?>
00480                         <?php echo $this->makeSearchButton( 'go', array( 'id' => 'searchGoButton', 'class' => 'searchButton' ) ); ?>
00481                         <?php echo $this->makeSearchButton( 'fulltext', array( 'id' => 'mw-searchButton', 'class' => 'searchButton' ) ); ?>
00482                 <?php endif; ?>
00483                         <input type='hidden' name="title" value="<?php $this->text( 'searchtitle' ) ?>"/>
00484                 </div>
00485         </form>
00486 </div>
00487 <?php
00488 
00489                                 break;
00490                         }
00491                         echo "\n<!-- /{$name} -->\n";
00492                 }
00493         }
00494 }