MediaWiki
REL1_23
|
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( 'mediawiki.skinning.interface', 'skins.vector.styles' ); 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 <?php $this->html( 'prebodyhtml' ) ?> 00171 <div id="bodyContent"> 00172 <?php if ( $this->data['isarticle'] ) { ?> 00173 <div id="siteSub"><?php $this->msg( 'tagline' ) ?></div> 00174 <?php } ?> 00175 <div id="contentSub"<?php $this->html( 'userlangattributes' ) ?>><?php $this->html( 'subtitle' ) ?></div> 00176 <?php if ( $this->data['undelete'] ) { ?> 00177 <div id="contentSub2"><?php $this->html( 'undelete' ) ?></div> 00178 <?php } ?> 00179 <?php if ( $this->data['newtalk'] ) { ?> 00180 <div class="usermessage"><?php $this->html( 'newtalk' ) ?></div> 00181 <?php } ?> 00182 <div id="jump-to-nav" class="mw-jump"> 00183 <?php $this->msg( 'jumpto' ) ?> 00184 <a href="#mw-navigation"><?php $this->msg( 'jumptonavigation' ) ?></a><?php $this->msg( 'comma-separator' ) ?> 00185 <a href="#p-search"><?php $this->msg( 'jumptosearch' ) ?></a> 00186 </div> 00187 <?php $this->html( 'bodycontent' ) ?> 00188 <?php if ( $this->data['printfooter'] ) { ?> 00189 <div class="printfooter"> 00190 <?php $this->html( 'printfooter' ); ?> 00191 </div> 00192 <?php } ?> 00193 <?php if ( $this->data['catlinks'] ) { ?> 00194 <?php $this->html( 'catlinks' ); ?> 00195 <?php } ?> 00196 <?php if ( $this->data['dataAfterContent'] ) { ?> 00197 <?php $this->html( 'dataAfterContent' ); ?> 00198 <?php } ?> 00199 <div class="visualClear"></div> 00200 <?php $this->html( 'debughtml' ); ?> 00201 </div> 00202 </div> 00203 <div id="mw-navigation"> 00204 <h2><?php $this->msg( 'navigation-heading' ) ?></h2> 00205 <div id="mw-head"> 00206 <?php $this->renderNavigation( 'PERSONAL' ); ?> 00207 <div id="left-navigation"> 00208 <?php $this->renderNavigation( array( 'NAMESPACES', 'VARIANTS' ) ); ?> 00209 </div> 00210 <div id="right-navigation"> 00211 <?php $this->renderNavigation( array( 'VIEWS', 'ACTIONS', 'SEARCH' ) ); ?> 00212 </div> 00213 </div> 00214 <div id="mw-panel"> 00215 <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> 00216 <?php $this->renderPortals( $this->data['sidebar'] ); ?> 00217 </div> 00218 </div> 00219 <div id="footer" role="contentinfo"<?php $this->html( 'userlangattributes' ) ?>> 00220 <?php foreach ( $this->getFooterLinks() as $category => $links ) { ?> 00221 <ul id="footer-<?php echo $category ?>"> 00222 <?php foreach ( $links as $link ) { ?> 00223 <li id="footer-<?php echo $category ?>-<?php echo $link ?>"><?php $this->html( $link ) ?></li> 00224 <?php } ?> 00225 </ul> 00226 <?php } ?> 00227 <?php $footericons = $this->getFooterIcons( "icononly" ); 00228 if ( count( $footericons ) > 0 ) { ?> 00229 <ul id="footer-icons" class="noprint"> 00230 <?php foreach ( $footericons as $blockName => $footerIcons ) { ?> 00231 <li id="footer-<?php echo htmlspecialchars( $blockName ); ?>ico"> 00232 <?php foreach ( $footerIcons as $icon ) { ?> 00233 <?php echo $this->getSkin()->makeFooterIcon( $icon ); ?> 00234 00235 <?php } ?> 00236 </li> 00237 <?php } ?> 00238 </ul> 00239 <?php } ?> 00240 <div style="clear:both"></div> 00241 </div> 00242 <?php $this->printTrail(); ?> 00243 00244 </body> 00245 </html> 00246 <?php 00247 } 00248 00254 protected function renderPortals( $portals ) { 00255 // Force the rendering of the following portals 00256 if ( !isset( $portals['SEARCH'] ) ) { 00257 $portals['SEARCH'] = true; 00258 } 00259 if ( !isset( $portals['TOOLBOX'] ) ) { 00260 $portals['TOOLBOX'] = true; 00261 } 00262 if ( !isset( $portals['LANGUAGES'] ) ) { 00263 $portals['LANGUAGES'] = true; 00264 } 00265 // Render portals 00266 foreach ( $portals as $name => $content ) { 00267 if ( $content === false ) { 00268 continue; 00269 } 00270 00271 switch ( $name ) { 00272 case 'SEARCH': 00273 break; 00274 case 'TOOLBOX': 00275 $this->renderPortal( 'tb', $this->getToolbox(), 'toolbox', 'SkinTemplateToolboxEnd' ); 00276 break; 00277 case 'LANGUAGES': 00278 if ( $this->data['language_urls'] !== false ) { 00279 $this->renderPortal( 'lang', $this->data['language_urls'], 'otherlanguages' ); 00280 } 00281 break; 00282 default: 00283 $this->renderPortal( $name, $content ); 00284 break; 00285 } 00286 } 00287 } 00288 00295 protected function renderPortal( $name, $content, $msg = null, $hook = null ) { 00296 if ( $msg === null ) { 00297 $msg = $name; 00298 } 00299 $msgObj = wfMessage( $msg ); 00300 ?> 00301 <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" ) ?>'> 00302 <h3<?php $this->html( 'userlangattributes' ) ?> id='<?php echo Sanitizer::escapeId( "p-$name-label" ) ?>'><?php echo htmlspecialchars( $msgObj->exists() ? $msgObj->text() : $msg ); ?></h3> 00303 <div class="body"> 00304 <?php 00305 if ( is_array( $content ) ) { ?> 00306 <ul> 00307 <?php 00308 foreach ( $content as $key => $val ) { ?> 00309 <?php echo $this->makeListItem( $key, $val ); ?> 00310 00311 <?php 00312 } 00313 if ( $hook !== null ) { 00314 wfRunHooks( $hook, array( &$this, true ) ); 00315 } 00316 ?> 00317 </ul> 00318 <?php 00319 } else { ?> 00320 <?php 00321 echo $content; /* Allow raw HTML block to be defined by extensions */ 00322 } 00323 00324 $this->renderAfterPortlet( $name ); 00325 ?> 00326 </div> 00327 </div> 00328 <?php 00329 } 00330 00337 protected function renderNavigation( $elements ) { 00338 global $wgVectorUseSimpleSearch; 00339 00340 // If only one element was given, wrap it in an array, allowing more 00341 // flexible arguments 00342 if ( !is_array( $elements ) ) { 00343 $elements = array( $elements ); 00344 // If there's a series of elements, reverse them when in RTL mode 00345 } elseif ( $this->data['rtl'] ) { 00346 $elements = array_reverse( $elements ); 00347 } 00348 // Render elements 00349 foreach ( $elements as $name => $element ) { 00350 switch ( $element ) { 00351 case 'NAMESPACES': 00352 ?> 00353 <div id="p-namespaces" role="navigation" class="vectorTabs<?php if ( count( $this->data['namespace_urls'] ) == 0 ) { echo ' emptyPortlet'; } ?>" aria-labelledby="p-namespaces-label"> 00354 <h3 id="p-namespaces-label"><?php $this->msg( 'namespaces' ) ?></h3> 00355 <ul<?php $this->html( 'userlangattributes' ) ?>> 00356 <?php foreach ( $this->data['namespace_urls'] as $link ) { ?> 00357 <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> 00358 <?php } ?> 00359 </ul> 00360 </div> 00361 <?php 00362 break; 00363 case 'VARIANTS': 00364 ?> 00365 <div id="p-variants" role="navigation" class="vectorMenu<?php if ( count( $this->data['variant_urls'] ) == 0 ) { echo ' emptyPortlet'; } ?>" aria-labelledby="p-variants-label"> 00366 <h3 id="mw-vector-current-variant"> 00367 <?php foreach ( $this->data['variant_urls'] as $link ) { ?> 00368 <?php if ( stripos( $link['attributes'], 'selected' ) !== false ) { ?> 00369 <?php echo htmlspecialchars( $link['text'] ) ?> 00370 <?php } ?> 00371 <?php } ?> 00372 </h3> 00373 <h3 id="p-variants-label"><span><?php $this->msg( 'variants' ) ?></span><a href="#"></a></h3> 00374 <div class="menu"> 00375 <ul> 00376 <?php foreach ( $this->data['variant_urls'] as $link ) { ?> 00377 <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> 00378 <?php } ?> 00379 </ul> 00380 </div> 00381 </div> 00382 <?php 00383 break; 00384 case 'VIEWS': 00385 ?> 00386 <div id="p-views" role="navigation" class="vectorTabs<?php if ( count( $this->data['view_urls'] ) == 0 ) { echo ' emptyPortlet'; } ?>" aria-labelledby="p-views-label"> 00387 <h3 id="p-views-label"><?php $this->msg( 'views' ) ?></h3> 00388 <ul<?php $this->html( 'userlangattributes' ) ?>> 00389 <?php foreach ( $this->data['view_urls'] as $link ) { ?> 00390 <li<?php echo $link['attributes'] ?>><span><a href="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php echo $link['key'] ?>><?php 00391 // $link['text'] can be undefined - bug 27764 00392 if ( array_key_exists( 'text', $link ) ) { 00393 echo array_key_exists( 'img', $link ) ? '<img src="' . $link['img'] . '" alt="' . $link['text'] . '" />' : htmlspecialchars( $link['text'] ); 00394 } 00395 ?></a></span></li> 00396 <?php } ?> 00397 </ul> 00398 </div> 00399 <?php 00400 break; 00401 case 'ACTIONS': 00402 ?> 00403 <div id="p-cactions" role="navigation" class="vectorMenu<?php if ( count( $this->data['action_urls'] ) == 0 ) { echo ' emptyPortlet'; } ?>" aria-labelledby="p-cactions-label"> 00404 <h3 id="p-cactions-label"><span><?php $this->msg( 'actions' ) ?></span><a href="#"></a></h3> 00405 <div class="menu"> 00406 <ul<?php $this->html( 'userlangattributes' ) ?>> 00407 <?php foreach ( $this->data['action_urls'] as $link ) { ?> 00408 <li<?php echo $link['attributes'] ?>><a href="<?php echo htmlspecialchars( $link['href'] ) ?>" <?php echo $link['key'] ?>><?php echo htmlspecialchars( $link['text'] ) ?></a></li> 00409 <?php } ?> 00410 </ul> 00411 </div> 00412 </div> 00413 <?php 00414 break; 00415 case 'PERSONAL': 00416 ?> 00417 <div id="p-personal" role="navigation" class="<?php if ( count( $this->data['personal_urls'] ) == 0 ) { echo ' emptyPortlet'; } ?>" aria-labelledby="p-personal-label"> 00418 <h3 id="p-personal-label"><?php $this->msg( 'personaltools' ) ?></h3> 00419 <ul<?php $this->html( 'userlangattributes' ) ?>> 00420 <?php 00421 $personalTools = $this->getPersonalTools(); 00422 foreach ( $personalTools as $key => $item ) { 00423 echo $this->makeListItem( $key, $item ); 00424 } 00425 ?> 00426 </ul> 00427 </div> 00428 <?php 00429 break; 00430 case 'SEARCH': 00431 ?> 00432 <div id="p-search" role="search"> 00433 <h3<?php $this->html( 'userlangattributes' ) ?>><label for="searchInput"><?php $this->msg( 'search' ) ?></label></h3> 00434 <form action="<?php $this->text( 'wgScript' ) ?>" id="searchform"> 00435 <?php if ( $wgVectorUseSimpleSearch ) { ?> 00436 <div id="simpleSearch"> 00437 <?php } else { ?> 00438 <div> 00439 <?php } ?> 00440 <?php 00441 echo $this->makeSearchInput( array( 'id' => 'searchInput' ) ); 00442 echo Html::hidden( 'title', $this->get( 'searchtitle' ) ); 00443 // We construct two buttons (for 'go' and 'fulltext' search modes), but only one will be 00444 // visible and actionable at a time (they are overlaid on top of each other in CSS). 00445 // * Browsers will use the 'fulltext' one by default (as it's the first in tree-order), which 00446 // is desirable when they are unable to show search suggestions (either due to being broken 00447 // or having JavaScript turned off). 00448 // * The mediawiki.searchSuggest module, after doing tests for the broken browsers, removes 00449 // the 'fulltext' button and handles 'fulltext' search itself; this will reveal the 'go' 00450 // button and cause it to be used. 00451 echo $this->makeSearchButton( 'fulltext', array( 'id' => 'mw-searchButton', 'class' => 'searchButton mw-fallbackSearchButton' ) ); 00452 echo $this->makeSearchButton( 'go', array( 'id' => 'searchButton', 'class' => 'searchButton' ) ); 00453 ?> 00454 </div> 00455 </form> 00456 </div> 00457 <?php 00458 00459 break; 00460 } 00461 } 00462 } 00463 }