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