MediaWiki  REL1_20
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->addModuleScripts( 'skins.vector' );
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">
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"><span dir="auto"><?php $this->html( 'title' ) ?></span></h1>
00169                         <!-- /firstHeading -->
00170                         <!-- bodyContent -->
00171                         <div id="bodyContent">
00172                                 <?php if ( $this->data['isarticle'] ): ?>
00173                                 <!-- tagline -->
00174                                 <div id="siteSub"><?php $this->msg( 'tagline' ) ?></div>
00175                                 <!-- /tagline -->
00176                                 <?php endif; ?>
00177                                 <!-- subtitle -->
00178                                 <div id="contentSub"<?php $this->html( 'userlangattributes' ) ?>><?php $this->html( 'subtitle' ) ?></div>
00179                                 <!-- /subtitle -->
00180                                 <?php if ( $this->data['undelete'] ): ?>
00181                                 <!-- undelete -->
00182                                 <div id="contentSub2"><?php $this->html( 'undelete' ) ?></div>
00183                                 <!-- /undelete -->
00184                                 <?php endif; ?>
00185                                 <?php if( $this->data['newtalk'] ): ?>
00186                                 <!-- newtalk -->
00187                                 <div class="usermessage"><?php $this->html( 'newtalk' )  ?></div>
00188                                 <!-- /newtalk -->
00189                                 <?php endif; ?>
00190                                 <?php if ( $this->data['showjumplinks'] ): ?>
00191                                 <!-- jumpto -->
00192                                 <div id="jump-to-nav" class="mw-jump">
00193                                         <?php $this->msg( 'jumpto' ) ?>
00194                                         <a href="#mw-head"><?php $this->msg( 'jumptonavigation' ) ?></a><?php $this->msg( 'comma-separator' ) ?>
00195                                         <a href="#p-search"><?php $this->msg( 'jumptosearch' ) ?></a>
00196                                 </div>
00197                                 <!-- /jumpto -->
00198                                 <?php endif; ?>
00199                                 <!-- bodycontent -->
00200                                 <?php $this->html( 'bodycontent' ) ?>
00201                                 <!-- /bodycontent -->
00202                                 <?php if ( $this->data['printfooter'] ): ?>
00203                                 <!-- printfooter -->
00204                                 <div class="printfooter">
00205                                 <?php $this->html( 'printfooter' ); ?>
00206                                 </div>
00207                                 <!-- /printfooter -->
00208                                 <?php endif; ?>
00209                                 <?php if ( $this->data['catlinks'] ): ?>
00210                                 <!-- catlinks -->
00211                                 <?php $this->html( 'catlinks' ); ?>
00212                                 <!-- /catlinks -->
00213                                 <?php endif; ?>
00214                                 <?php if ( $this->data['dataAfterContent'] ): ?>
00215                                 <!-- dataAfterContent -->
00216                                 <?php $this->html( 'dataAfterContent' ); ?>
00217                                 <!-- /dataAfterContent -->
00218                                 <?php endif; ?>
00219                                 <div class="visualClear"></div>
00220                                 <!-- debughtml -->
00221                                 <?php $this->html( 'debughtml' ); ?>
00222                                 <!-- /debughtml -->
00223                         </div>
00224                         <!-- /bodyContent -->
00225                 </div>
00226                 <!-- /content -->
00227                 <!-- header -->
00228                 <div id="mw-head" class="noprint">
00229                         <?php $this->renderNavigation( 'PERSONAL' ); ?>
00230                         <div id="left-navigation">
00231                                 <?php $this->renderNavigation( array( 'NAMESPACES', 'VARIANTS' ) ); ?>
00232                         </div>
00233                         <div id="right-navigation">
00234                                 <?php $this->renderNavigation( array( 'VIEWS', 'ACTIONS', 'SEARCH' ) ); ?>
00235                         </div>
00236                 </div>
00237                 <!-- /header -->
00238                 <!-- panel -->
00239                         <div id="mw-panel" class="noprint">
00240                                 <!-- logo -->
00241                                         <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 Xml::expandAttributes( Linker::tooltipAndAccesskeyAttribs( 'p-logo' ) ) ?>></a></div>
00242                                 <!-- /logo -->
00243                                 <?php $this->renderPortals( $this->data['sidebar'] ); ?>
00244                         </div>
00245                 <!-- /panel -->
00246                 <!-- footer -->
00247                 <div id="footer"<?php $this->html( 'userlangattributes' ) ?>>
00248                         <?php foreach( $this->getFooterLinks() as $category => $links ): ?>
00249                                 <ul id="footer-<?php echo $category ?>">
00250                                         <?php foreach( $links as $link ): ?>
00251                                                 <li id="footer-<?php echo $category ?>-<?php echo $link ?>"><?php $this->html( $link ) ?></li>
00252                                         <?php endforeach; ?>
00253                                 </ul>
00254                         <?php endforeach; ?>
00255                         <?php $footericons = $this->getFooterIcons("icononly");
00256                         if ( count( $footericons ) > 0 ): ?>
00257                                 <ul id="footer-icons" class="noprint">
00258 <?php                   foreach ( $footericons as $blockName => $footerIcons ): ?>
00259                                         <li id="footer-<?php echo htmlspecialchars( $blockName ); ?>ico">
00260 <?php                           foreach ( $footerIcons as $icon ): ?>
00261                                                 <?php echo $this->getSkin()->makeFooterIcon( $icon ); ?>
00262 
00263 <?php                           endforeach; ?>
00264                                         </li>
00265 <?php                   endforeach; ?>
00266                                 </ul>
00267                         <?php endif; ?>
00268                         <div style="clear:both"></div>
00269                 </div>
00270                 <!-- /footer -->
00271                 <?php $this->printTrail(); ?>
00272 
00273         </body>
00274 </html>
00275 <?php
00276         }
00277 
00283         protected function renderPortals( $portals ) {
00284                 // Force the rendering of the following portals
00285                 if ( !isset( $portals['SEARCH'] ) ) {
00286                         $portals['SEARCH'] = true;
00287                 }
00288                 if ( !isset( $portals['TOOLBOX'] ) ) {
00289                         $portals['TOOLBOX'] = true;
00290                 }
00291                 if ( !isset( $portals['LANGUAGES'] ) ) {
00292                         $portals['LANGUAGES'] = true;
00293                 }
00294                 // Render portals
00295                 foreach ( $portals as $name => $content ) {
00296                         if ( $content === false )
00297                                 continue;
00298 
00299                         echo "\n<!-- {$name} -->\n";
00300                         switch( $name ) {
00301                                 case 'SEARCH':
00302                                         break;
00303                                 case 'TOOLBOX':
00304                                         $this->renderPortal( 'tb', $this->getToolbox(), 'toolbox', 'SkinTemplateToolboxEnd' );
00305                                         break;
00306                                 case 'LANGUAGES':
00307                                         if ( $this->data['language_urls'] ) {
00308                                                 $this->renderPortal( 'lang', $this->data['language_urls'], 'otherlanguages' );
00309                                         }
00310                                         break;
00311                                 default:
00312                                         $this->renderPortal( $name, $content );
00313                                 break;
00314                         }
00315                         echo "\n<!-- /{$name} -->\n";
00316                 }
00317         }
00318 
00325         protected function renderPortal( $name, $content, $msg = null, $hook = null ) {
00326                 if ( $msg === null ) {
00327                         $msg = $name;
00328                 }
00329                 ?>
00330 <div class="portal" id='<?php echo Sanitizer::escapeId( "p-$name" ) ?>'<?php echo Linker::tooltip( 'p-' . $name ) ?>>
00331         <h5<?php $this->html( 'userlangattributes' ) ?>><?php $msgObj = wfMessage( $msg ); echo htmlspecialchars( $msgObj->exists() ? $msgObj->text() : $msg ); ?></h5>
00332         <div class="body">
00333 <?php
00334                 if ( is_array( $content ) ): ?>
00335                 <ul>
00336 <?php
00337                         foreach( $content as $key => $val ): ?>
00338                         <?php echo $this->makeListItem( $key, $val ); ?>
00339 
00340 <?php
00341                         endforeach;
00342                         if ( $hook !== null ) {
00343                                 wfRunHooks( $hook, array( &$this, true ) );
00344                         }
00345                         ?>
00346                 </ul>
00347 <?php
00348                 else: ?>
00349                 <?php echo $content; /* Allow raw HTML block to be defined by extensions */ ?>
00350 <?php
00351                 endif; ?>
00352         </div>
00353 </div>
00354 <?php
00355         }
00356 
00363         protected function renderNavigation( $elements ) {
00364                 global $wgVectorUseSimpleSearch;
00365 
00366                 // If only one element was given, wrap it in an array, allowing more
00367                 // flexible arguments
00368                 if ( !is_array( $elements ) ) {
00369                         $elements = array( $elements );
00370                 // If there's a series of elements, reverse them when in RTL mode
00371                 } elseif ( $this->data['rtl'] ) {
00372                         $elements = array_reverse( $elements );
00373                 }
00374                 // Render elements
00375                 foreach ( $elements as $name => $element ) {
00376                         echo "\n<!-- {$name} -->\n";
00377                         switch ( $element ) {
00378                                 case 'NAMESPACES':
00379 ?>
00380 <div id="p-namespaces" class="vectorTabs<?php if ( count( $this->data['namespace_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
00381         <h5><?php $this->msg( 'namespaces' ) ?></h5>
00382         <ul<?php $this->html( 'userlangattributes' ) ?>>
00383                 <?php foreach ( $this->data['namespace_urls'] as $link ): ?>
00384                         <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>
00385                 <?php endforeach; ?>
00386         </ul>
00387 </div>
00388 <?php
00389                                 break;
00390                                 case 'VARIANTS':
00391 ?>
00392 <div id="p-variants" class="vectorMenu<?php if ( count( $this->data['variant_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
00393         <h4>
00394         <?php foreach ( $this->data['variant_urls'] as $link ): ?>
00395                 <?php if ( stripos( $link['attributes'], 'selected' ) !== false ): ?>
00396                         <?php echo htmlspecialchars( $link['text'] ) ?>
00397                 <?php endif; ?>
00398         <?php endforeach; ?>
00399         </h4>
00400         <h5><span><?php $this->msg( 'variants' ) ?></span><a href="#"></a></h5>
00401         <div class="menu">
00402                 <ul>
00403                         <?php foreach ( $this->data['variant_urls'] as $link ): ?>
00404                                 <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>
00405                         <?php endforeach; ?>
00406                 </ul>
00407         </div>
00408 </div>
00409 <?php
00410                                 break;
00411                                 case 'VIEWS':
00412 ?>
00413 <div id="p-views" class="vectorTabs<?php if ( count( $this->data['view_urls'] ) == 0 ) { echo ' emptyPortlet'; } ?>">
00414         <h5><?php $this->msg('views') ?></h5>
00415         <ul<?php $this->html('userlangattributes') ?>>
00416                 <?php foreach ( $this->data['view_urls'] as $link ): ?>
00417                         <li<?php echo $link['attributes'] ?>><span><a href="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php echo $link['key'] ?>><?php
00418                                 // $link['text'] can be undefined - bug 27764
00419                                 if ( array_key_exists( 'text', $link ) ) {
00420                                         echo array_key_exists( 'img', $link ) ?  '<img src="' . $link['img'] . '" alt="' . $link['text'] . '" />' : htmlspecialchars( $link['text'] );
00421                                 }
00422                                 ?></a></span></li>
00423                 <?php endforeach; ?>
00424         </ul>
00425 </div>
00426 <?php
00427                                 break;
00428                                 case 'ACTIONS':
00429 ?>
00430 <div id="p-cactions" class="vectorMenu<?php if ( count( $this->data['action_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
00431         <h5><span><?php $this->msg( 'actions' ) ?></span><a href="#"></a></h5>
00432         <div class="menu">
00433                 <ul<?php $this->html( 'userlangattributes' ) ?>>
00434                         <?php foreach ( $this->data['action_urls'] as $link ): ?>
00435                                 <li<?php echo $link['attributes'] ?>><a href="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php echo $link['key'] ?>><?php echo htmlspecialchars( $link['text'] ) ?></a></li>
00436                         <?php endforeach; ?>
00437                 </ul>
00438         </div>
00439 </div>
00440 <?php
00441                                 break;
00442                                 case 'PERSONAL':
00443 ?>
00444 <div id="p-personal" class="<?php if ( count( $this->data['personal_urls'] ) == 0 ) echo ' emptyPortlet'; ?>">
00445         <h5><?php $this->msg( 'personaltools' ) ?></h5>
00446         <ul<?php $this->html( 'userlangattributes' ) ?>>
00447 <?php                   foreach( $this->getPersonalTools() as $key => $item ) { ?>
00448                 <?php echo $this->makeListItem( $key, $item ); ?>
00449 
00450 <?php                   } ?>
00451         </ul>
00452 </div>
00453 <?php
00454                                 break;
00455                                 case 'SEARCH':
00456 ?>
00457 <div id="p-search">
00458         <h5<?php $this->html( 'userlangattributes' ) ?>><label for="searchInput"><?php $this->msg( 'search' ) ?></label></h5>
00459         <form action="<?php $this->text( 'wgScript' ) ?>" id="searchform">
00460                 <?php if ( $wgVectorUseSimpleSearch && $this->getSkin()->getUser()->getOption( 'vector-simplesearch' ) ): ?>
00461                 <div id="simpleSearch">
00462                         <?php if ( $this->data['rtl'] ): ?>
00463                         <?php echo $this->makeSearchButton( 'image', array( 'id' => 'searchButton', 'src' => $this->getSkin()->getSkinStylePath( 'images/search-rtl.png' ), 'width' => '12', 'height' => '13' ) ); ?>
00464                         <?php endif; ?>
00465                         <?php echo $this->makeSearchInput( array( 'id' => 'searchInput', 'type' => 'text' ) ); ?>
00466                         <?php if ( !$this->data['rtl'] ): ?>
00467                         <?php echo $this->makeSearchButton( 'image', array( 'id' => 'searchButton', 'src' => $this->getSkin()->getSkinStylePath( 'images/search-ltr.png' ), 'width' => '12', 'height' => '13' ) ); ?>
00468                         <?php endif; ?>
00469                 <?php else: ?>
00470                 <div>
00471                         <?php echo $this->makeSearchInput( array( 'id' => 'searchInput' ) ); ?>
00472                         <?php echo $this->makeSearchButton( 'go', array( 'id' => 'searchGoButton', 'class' => 'searchButton' ) ); ?>
00473                         <?php echo $this->makeSearchButton( 'fulltext', array( 'id' => 'mw-searchButton', 'class' => 'searchButton' ) ); ?>
00474                 <?php endif; ?>
00475                         <input type='hidden' name="title" value="<?php $this->text( 'searchtitle' ) ?>"/>
00476                 </div>
00477         </form>
00478 </div>
00479 <?php
00480 
00481                                 break;
00482                         }
00483                         echo "\n<!-- /{$name} -->\n";
00484                 }
00485         }
00486 }