MediaWiki
REL1_22
|
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 file 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( array( 'skins.vector.js', 'skins.vector.collapsibleNav' ) ); 00061 } 00062 00067 function setupSkinUserCss( OutputPage $out ) { 00068 parent::setupSkinUserCss( $out ); 00069 00070 $styles = array( 'skins.vector' ); 00071 wfRunHooks( 'SkinVectorStyleModules', array( &$this, &$styles ) ); 00072 $out->addModuleStyles( $styles ); 00073 } 00074 00081 function addToBodyAttributes( $out, &$bodyAttrs ) { 00082 if ( isset( $bodyAttrs['class'] ) && strlen( $bodyAttrs['class'] ) > 0 ) { 00083 $bodyAttrs['class'] .= ' ' . implode( ' ', static::$bodyClasses ); 00084 } else { 00085 $bodyAttrs['class'] = implode( ' ', static::$bodyClasses ); 00086 } 00087 } 00088 } 00089 00094 class VectorTemplate extends BaseTemplate { 00095 00096 /* Functions */ 00097 00101 public function execute() { 00102 global $wgVectorUseIconWatch; 00103 00104 // Build additional attributes for navigation urls 00105 $nav = $this->data['content_navigation']; 00106 00107 if ( $wgVectorUseIconWatch ) { 00108 $mode = $this->getSkin()->getUser()->isWatched( $this->getSkin()->getRelevantTitle() ) ? 'unwatch' : 'watch'; 00109 if ( isset( $nav['actions'][$mode] ) ) { 00110 $nav['views'][$mode] = $nav['actions'][$mode]; 00111 $nav['views'][$mode]['class'] = rtrim( 'icon ' . $nav['views'][$mode]['class'], ' ' ); 00112 $nav['views'][$mode]['primary'] = true; 00113 unset( $nav['actions'][$mode] ); 00114 } 00115 } 00116 00117 $xmlID = ''; 00118 foreach ( $nav as $section => $links ) { 00119 foreach ( $links as $key => $link ) { 00120 if ( $section == 'views' && !( isset( $link['primary'] ) && $link['primary'] ) ) { 00121 $link['class'] = rtrim( 'collapsible ' . $link['class'], ' ' ); 00122 } 00123 00124 $xmlID = isset( $link['id'] ) ? $link['id'] : 'ca-' . $xmlID; 00125 $nav[$section][$key]['attributes'] = 00126 ' id="' . Sanitizer::escapeId( $xmlID ) . '"'; 00127 if ( $link['class'] ) { 00128 $nav[$section][$key]['attributes'] .= 00129 ' class="' . htmlspecialchars( $link['class'] ) . '"'; 00130 unset( $nav[$section][$key]['class'] ); 00131 } 00132 if ( isset( $link['tooltiponly'] ) && $link['tooltiponly'] ) { 00133 $nav[$section][$key]['key'] = 00134 Linker::tooltip( $xmlID ); 00135 } else { 00136 $nav[$section][$key]['key'] = 00137 Xml::expandAttributes( Linker::tooltipAndAccesskeyAttribs( $xmlID ) ); 00138 } 00139 } 00140 } 00141 $this->data['namespace_urls'] = $nav['namespaces']; 00142 $this->data['view_urls'] = $nav['views']; 00143 $this->data['action_urls'] = $nav['actions']; 00144 $this->data['variant_urls'] = $nav['variants']; 00145 00146 // Reverse horizontally rendered navigation elements 00147 if ( $this->data['rtl'] ) { 00148 $this->data['view_urls'] = 00149 array_reverse( $this->data['view_urls'] ); 00150 $this->data['namespace_urls'] = 00151 array_reverse( $this->data['namespace_urls'] ); 00152 $this->data['personal_urls'] = 00153 array_reverse( $this->data['personal_urls'] ); 00154 } 00155 // Output HTML Page 00156 $this->html( 'headelement' ); 00157 ?> 00158 <div id="mw-page-base" class="noprint"></div> 00159 <div id="mw-head-base" class="noprint"></div> 00160 <div id="content" class="mw-body" role="main"> 00161 <a id="top"></a> 00162 <div id="mw-js-message" style="display:none;"<?php $this->html( 'userlangattributes' ) ?>></div> 00163 <?php if ( $this->data['sitenotice'] ) { ?> 00164 <div id="siteNotice"><?php $this->html( 'sitenotice' ) ?></div> 00165 <?php } ?> 00166 <h1 id="firstHeading" class="firstHeading" lang="<?php 00167 $this->data['pageLanguage'] = $this->getSkin()->getTitle()->getPageViewLanguage()->getHtmlCode(); 00168 $this->text( 'pageLanguage' ); 00169 ?>"><span dir="auto"><?php $this->html( 'title' ) ?></span></h1> 00170 <div id="bodyContent"> 00171 <?php if ( $this->data['isarticle'] ) { ?> 00172 <div id="siteSub"><?php $this->msg( 'tagline' ) ?></div> 00173 <?php } ?> 00174 <div id="contentSub"<?php $this->html( 'userlangattributes' ) ?>><?php $this->html( 'subtitle' ) ?></div> 00175 <?php if ( $this->data['undelete'] ) { ?> 00176 <div id="contentSub2"><?php $this->html( 'undelete' ) ?></div> 00177 <?php } ?> 00178 <?php if ( $this->data['newtalk'] ) { ?> 00179 <div class="usermessage"><?php $this->html( 'newtalk' ) ?></div> 00180 <?php } ?> 00181 <div id="jump-to-nav" class="mw-jump"> 00182 <?php $this->msg( 'jumpto' ) ?> 00183 <a href="#mw-navigation"><?php $this->msg( 'jumptonavigation' ) ?></a><?php $this->msg( 'comma-separator' ) ?> 00184 <a href="#p-search"><?php $this->msg( 'jumptosearch' ) ?></a> 00185 </div> 00186 <?php $this->html( 'bodycontent' ) ?> 00187 <?php if ( $this->data['printfooter'] ) { ?> 00188 <div class="printfooter"> 00189 <?php $this->html( 'printfooter' ); ?> 00190 </div> 00191 <?php } ?> 00192 <?php if ( $this->data['catlinks'] ) { ?> 00193 <?php $this->html( 'catlinks' ); ?> 00194 <?php } ?> 00195 <?php if ( $this->data['dataAfterContent'] ) { ?> 00196 <?php $this->html( 'dataAfterContent' ); ?> 00197 <?php } ?> 00198 <div class="visualClear"></div> 00199 <?php $this->html( 'debughtml' ); ?> 00200 </div> 00201 </div> 00202 <div id="mw-navigation"> 00203 <h2><?php $this->msg( 'navigation-heading' ) ?></h2> 00204 <div id="mw-head"> 00205 <?php $this->renderNavigation( 'PERSONAL' ); ?> 00206 <div id="left-navigation"> 00207 <?php $this->renderNavigation( array( 'NAMESPACES', 'VARIANTS' ) ); ?> 00208 </div> 00209 <div id="right-navigation"> 00210 <?php $this->renderNavigation( array( 'VIEWS', 'ACTIONS', 'SEARCH' ) ); ?> 00211 </div> 00212 </div> 00213 <div id="mw-panel"> 00214 <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> 00215 <?php $this->renderPortals( $this->data['sidebar'] ); ?> 00216 </div> 00217 </div> 00218 <div id="footer" role="contentinfo"<?php $this->html( 'userlangattributes' ) ?>> 00219 <?php foreach ( $this->getFooterLinks() as $category => $links ) { ?> 00220 <ul id="footer-<?php echo $category ?>"> 00221 <?php foreach ( $links as $link ) { ?> 00222 <li id="footer-<?php echo $category ?>-<?php echo $link ?>"><?php $this->html( $link ) ?></li> 00223 <?php } ?> 00224 </ul> 00225 <?php } ?> 00226 <?php $footericons = $this->getFooterIcons( "icononly" ); 00227 if ( count( $footericons ) > 0 ) { ?> 00228 <ul id="footer-icons" class="noprint"> 00229 <?php foreach ( $footericons as $blockName => $footerIcons ) { ?> 00230 <li id="footer-<?php echo htmlspecialchars( $blockName ); ?>ico"> 00231 <?php foreach ( $footerIcons as $icon ) { ?> 00232 <?php echo $this->getSkin()->makeFooterIcon( $icon ); ?> 00233 00234 <?php } ?> 00235 </li> 00236 <?php } ?> 00237 </ul> 00238 <?php } ?> 00239 <div style="clear:both"></div> 00240 </div> 00241 <?php $this->printTrail(); ?> 00242 00243 </body> 00244 </html> 00245 <?php 00246 } 00247 00253 protected 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 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 } 00286 } 00287 00294 protected function renderPortal( $name, $content, $msg = null, $hook = null ) { 00295 if ( $msg === null ) { 00296 $msg = $name; 00297 } 00298 $msgObj = wfMessage( $msg ); 00299 ?> 00300 <div class="portal" role="navigation" id='<?php echo Sanitizer::escapeId( "p-$name" ) ?>'<?php echo Linker::tooltip( 'p-' . $name ) ?> aria-labelledby='<?php echo Sanitizer::escapeId( "p-$name-label" ) ?>'> 00301 <h3<?php $this->html( 'userlangattributes' ) ?> id='<?php echo Sanitizer::escapeId( "p-$name-label" ) ?>'><?php echo htmlspecialchars( $msgObj->exists() ? $msgObj->text() : $msg ); ?></h3> 00302 <div class="body"> 00303 <?php 00304 if ( is_array( $content ) ) { ?> 00305 <ul> 00306 <?php 00307 foreach ( $content as $key => $val ) { ?> 00308 <?php echo $this->makeListItem( $key, $val ); ?> 00309 00310 <?php 00311 } 00312 if ( $hook !== null ) { 00313 wfRunHooks( $hook, array( &$this, true ) ); 00314 } 00315 ?> 00316 </ul> 00317 <?php 00318 } else { ?> 00319 <?php echo $content; /* Allow raw HTML block to be defined by extensions */ ?> 00320 <?php 00321 } ?> 00322 </div> 00323 </div> 00324 <?php 00325 } 00326 00333 protected function renderNavigation( $elements ) { 00334 global $wgVectorUseSimpleSearch; 00335 00336 // If only one element was given, wrap it in an array, allowing more 00337 // flexible arguments 00338 if ( !is_array( $elements ) ) { 00339 $elements = array( $elements ); 00340 // If there's a series of elements, reverse them when in RTL mode 00341 } elseif ( $this->data['rtl'] ) { 00342 $elements = array_reverse( $elements ); 00343 } 00344 // Render elements 00345 foreach ( $elements as $name => $element ) { 00346 switch ( $element ) { 00347 case 'NAMESPACES': 00348 ?> 00349 <div id="p-namespaces" role="navigation" class="vectorTabs<?php if ( count( $this->data['namespace_urls'] ) == 0 ) { echo ' emptyPortlet'; } ?>" aria-labelledby="p-namespaces-label"> 00350 <h3 id="p-namespaces-label"><?php $this->msg( 'namespaces' ) ?></h3> 00351 <ul<?php $this->html( 'userlangattributes' ) ?>> 00352 <?php foreach ( $this->data['namespace_urls'] as $link ) { ?> 00353 <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> 00354 <?php } ?> 00355 </ul> 00356 </div> 00357 <?php 00358 break; 00359 case 'VARIANTS': 00360 ?> 00361 <div id="p-variants" role="navigation" class="vectorMenu<?php if ( count( $this->data['variant_urls'] ) == 0 ) { echo ' emptyPortlet'; } ?>" aria-labelledby="p-variants-label"> 00362 <h3 id="mw-vector-current-variant"> 00363 <?php foreach ( $this->data['variant_urls'] as $link ) { ?> 00364 <?php if ( stripos( $link['attributes'], 'selected' ) !== false ) { ?> 00365 <?php echo htmlspecialchars( $link['text'] ) ?> 00366 <?php } ?> 00367 <?php } ?> 00368 </h3> 00369 <h3 id="p-variants-label"><span><?php $this->msg( 'variants' ) ?></span><a href="#"></a></h3> 00370 <div class="menu"> 00371 <ul> 00372 <?php foreach ( $this->data['variant_urls'] as $link ) { ?> 00373 <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> 00374 <?php } ?> 00375 </ul> 00376 </div> 00377 </div> 00378 <?php 00379 break; 00380 case 'VIEWS': 00381 ?> 00382 <div id="p-views" role="navigation" class="vectorTabs<?php if ( count( $this->data['view_urls'] ) == 0 ) { echo ' emptyPortlet'; } ?>" aria-labelledby="p-views-label"> 00383 <h3 id="p-views-label"><?php $this->msg( 'views' ) ?></h3> 00384 <ul<?php $this->html( 'userlangattributes' ) ?>> 00385 <?php foreach ( $this->data['view_urls'] as $link ) { ?> 00386 <li<?php echo $link['attributes'] ?>><span><a href="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php echo $link['key'] ?>><?php 00387 // $link['text'] can be undefined - bug 27764 00388 if ( array_key_exists( 'text', $link ) ) { 00389 echo array_key_exists( 'img', $link ) ? '<img src="' . $link['img'] . '" alt="' . $link['text'] . '" />' : htmlspecialchars( $link['text'] ); 00390 } 00391 ?></a></span></li> 00392 <?php } ?> 00393 </ul> 00394 </div> 00395 <?php 00396 break; 00397 case 'ACTIONS': 00398 ?> 00399 <div id="p-cactions" role="navigation" class="vectorMenu<?php if ( count( $this->data['action_urls'] ) == 0 ) { echo ' emptyPortlet'; } ?>" aria-labelledby="p-cactions-label"> 00400 <h3 id="p-cactions-label"><span><?php $this->msg( 'actions' ) ?></span><a href="#"></a></h3> 00401 <div class="menu"> 00402 <ul<?php $this->html( 'userlangattributes' ) ?>> 00403 <?php foreach ( $this->data['action_urls'] as $link ) { ?> 00404 <li<?php echo $link['attributes'] ?>><a href="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php echo $link['key'] ?>><?php echo htmlspecialchars( $link['text'] ) ?></a></li> 00405 <?php } ?> 00406 </ul> 00407 </div> 00408 </div> 00409 <?php 00410 break; 00411 case 'PERSONAL': 00412 ?> 00413 <div id="p-personal" role="navigation" class="<?php if ( count( $this->data['personal_urls'] ) == 0 ) { echo ' emptyPortlet'; } ?>" aria-labelledby="p-personal-label"> 00414 <h3 id="p-personal-label"><?php $this->msg( 'personaltools' ) ?></h3> 00415 <ul<?php $this->html( 'userlangattributes' ) ?>> 00416 <?php 00417 $personalTools = $this->getPersonalTools(); 00418 foreach ( $personalTools as $key => $item ) { 00419 echo $this->makeListItem( $key, $item ); 00420 } 00421 ?> 00422 </ul> 00423 </div> 00424 <?php 00425 break; 00426 case 'SEARCH': 00427 ?> 00428 <div id="p-search" role="search"> 00429 <h3<?php $this->html( 'userlangattributes' ) ?>><label for="searchInput"><?php $this->msg( 'search' ) ?></label></h3> 00430 <form action="<?php $this->text( 'wgScript' ) ?>" id="searchform"> 00431 <?php if ( $wgVectorUseSimpleSearch && $this->getSkin()->getUser()->getOption( 'vector-simplesearch' ) ) { ?> 00432 <div id="simpleSearch"> 00433 <?php if ( $this->data['rtl'] ) { ?> 00434 <?php echo $this->makeSearchButton( 'image', array( 'id' => 'searchButton', 'src' => $this->getSkin()->getSkinStylePath( 'images/search-rtl.png' ), 'width' => '12', 'height' => '13' ) ); ?> 00435 <?php } ?> 00436 <?php echo $this->makeSearchInput( array( 'id' => 'searchInput', 'type' => 'text' ) ); ?> 00437 <?php if ( !$this->data['rtl'] ) { ?> 00438 <?php echo $this->makeSearchButton( 'image', array( 'id' => 'searchButton', 'src' => $this->getSkin()->getSkinStylePath( 'images/search-ltr.png' ), 'width' => '12', 'height' => '13' ) ); ?> 00439 <?php } ?> 00440 <?php } else { ?> 00441 <div> 00442 <?php echo $this->makeSearchInput( array( 'id' => 'searchInput' ) ); ?> 00443 <?php echo $this->makeSearchButton( 'go', array( 'id' => 'searchGoButton', 'class' => 'searchButton' ) ); ?> 00444 <?php echo $this->makeSearchButton( 'fulltext', array( 'id' => 'mw-searchButton', 'class' => 'searchButton' ) ); ?> 00445 <?php } ?> 00446 <input type='hidden' name="title" value="<?php $this->text( 'searchtitle' ) ?>"/> 00447 </div> 00448 </form> 00449 </div> 00450 <?php 00451 00452 break; 00453 } 00454 } 00455 } 00456 }