[ Index ] |
PHP Cross Reference of MediaWiki-1.24.0 |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Vector - Modern version of MonoBook with fresh look and many usability 4 * improvements. 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License along 17 * with this program; if not, write to the Free Software Foundation, Inc., 18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 * http://www.gnu.org/copyleft/gpl.html 20 * 21 * @file 22 * @ingroup Skins 23 */ 24 25 /** 26 * QuickTemplate class for Vector skin 27 * @ingroup Skins 28 */ 29 class VectorTemplate extends BaseTemplate { 30 /* Functions */ 31 32 /** 33 * Outputs the entire contents of the (X)HTML page 34 */ 35 public function execute() { 36 // Build additional attributes for navigation urls 37 $nav = $this->data['content_navigation']; 38 39 if ( $this->config->get( 'VectorUseIconWatch' ) ) { 40 $mode = $this->getSkin()->getUser()->isWatched( $this->getSkin()->getRelevantTitle() ) 41 ? 'unwatch' 42 : 'watch'; 43 44 if ( isset( $nav['actions'][$mode] ) ) { 45 $nav['views'][$mode] = $nav['actions'][$mode]; 46 $nav['views'][$mode]['class'] = rtrim( 'icon ' . $nav['views'][$mode]['class'], ' ' ); 47 $nav['views'][$mode]['primary'] = true; 48 unset( $nav['actions'][$mode] ); 49 } 50 } 51 52 $xmlID = ''; 53 foreach ( $nav as $section => $links ) { 54 foreach ( $links as $key => $link ) { 55 if ( $section == 'views' && !( isset( $link['primary'] ) && $link['primary'] ) ) { 56 $link['class'] = rtrim( 'collapsible ' . $link['class'], ' ' ); 57 } 58 59 $xmlID = isset( $link['id'] ) ? $link['id'] : 'ca-' . $xmlID; 60 $nav[$section][$key]['attributes'] = 61 ' id="' . Sanitizer::escapeId( $xmlID ) . '"'; 62 if ( $link['class'] ) { 63 $nav[$section][$key]['attributes'] .= 64 ' class="' . htmlspecialchars( $link['class'] ) . '"'; 65 unset( $nav[$section][$key]['class'] ); 66 } 67 if ( isset( $link['tooltiponly'] ) && $link['tooltiponly'] ) { 68 $nav[$section][$key]['key'] = 69 Linker::tooltip( $xmlID ); 70 } else { 71 $nav[$section][$key]['key'] = 72 Xml::expandAttributes( Linker::tooltipAndAccesskeyAttribs( $xmlID ) ); 73 } 74 } 75 } 76 $this->data['namespace_urls'] = $nav['namespaces']; 77 $this->data['view_urls'] = $nav['views']; 78 $this->data['action_urls'] = $nav['actions']; 79 $this->data['variant_urls'] = $nav['variants']; 80 81 // Reverse horizontally rendered navigation elements 82 if ( $this->data['rtl'] ) { 83 $this->data['view_urls'] = 84 array_reverse( $this->data['view_urls'] ); 85 $this->data['namespace_urls'] = 86 array_reverse( $this->data['namespace_urls'] ); 87 $this->data['personal_urls'] = 88 array_reverse( $this->data['personal_urls'] ); 89 } 90 // Output HTML Page 91 $this->html( 'headelement' ); 92 ?> 93 <div id="mw-page-base" class="noprint"></div> 94 <div id="mw-head-base" class="noprint"></div> 95 <div id="content" class="mw-body" role="main"> 96 <a id="top"></a> 97 98 <?php 99 if ( $this->data['sitenotice'] ) { 100 ?> 101 <div id="siteNotice"><?php $this->html( 'sitenotice' ) ?></div> 102 <?php 103 } 104 ?> 105 <h1 id="firstHeading" class="firstHeading" lang="<?php 106 $this->data['pageLanguage'] = 107 $this->getSkin()->getTitle()->getPageViewLanguage()->getHtmlCode(); 108 $this->text( 'pageLanguage' ); 109 ?>"><span dir="auto"><?php $this->html( 'title' ) ?></span></h1> 110 <?php $this->html( 'prebodyhtml' ) ?> 111 <div id="bodyContent" class="mw-body-content"> 112 <?php 113 if ( $this->data['isarticle'] ) { 114 ?> 115 <div id="siteSub"><?php $this->msg( 'tagline' ) ?></div> 116 <?php 117 } 118 ?> 119 <div id="contentSub"<?php 120 $this->html( 'userlangattributes' ) 121 ?>><?php $this->html( 'subtitle' ) ?></div> 122 <?php 123 if ( $this->data['undelete'] ) { 124 ?> 125 <div id="contentSub2"><?php $this->html( 'undelete' ) ?></div> 126 <?php 127 } 128 ?> 129 <?php 130 if ( $this->data['newtalk'] ) { 131 ?> 132 <div class="usermessage"><?php $this->html( 'newtalk' ) ?></div> 133 <?php 134 } 135 ?> 136 <div id="jump-to-nav" class="mw-jump"> 137 <?php $this->msg( 'jumpto' ) ?> 138 <a href="#mw-navigation"><?php 139 $this->msg( 'jumptonavigation' ) 140 ?></a><?php 141 $this->msg( 'comma-separator' ) 142 ?> 143 <a href="#p-search"><?php $this->msg( 'jumptosearch' ) ?></a> 144 </div> 145 <?php $this->html( 'bodycontent' ) ?> 146 <?php 147 if ( $this->data['printfooter'] ) { 148 ?> 149 <div class="printfooter"> 150 <?php $this->html( 'printfooter' ); ?> 151 </div> 152 <?php 153 } 154 ?> 155 <?php 156 if ( $this->data['catlinks'] ) { 157 ?> 158 <?php 159 $this->html( 'catlinks' ); 160 ?> 161 <?php 162 } 163 ?> 164 <?php 165 if ( $this->data['dataAfterContent'] ) { 166 ?> 167 <?php 168 $this->html( 'dataAfterContent' ); 169 ?> 170 <?php 171 } 172 ?> 173 <div class="visualClear"></div> 174 <?php $this->html( 'debughtml' ); ?> 175 </div> 176 </div> 177 <div id="mw-navigation"> 178 <h2><?php $this->msg( 'navigation-heading' ) ?></h2> 179 180 <div id="mw-head"> 181 <?php $this->renderNavigation( 'PERSONAL' ); ?> 182 <div id="left-navigation"> 183 <?php $this->renderNavigation( array( 'NAMESPACES', 'VARIANTS' ) ); ?> 184 </div> 185 <div id="right-navigation"> 186 <?php $this->renderNavigation( array( 'VIEWS', 'ACTIONS', 'SEARCH' ) ); ?> 187 </div> 188 </div> 189 <div id="mw-panel"> 190 <div id="p-logo" role="banner"><a style="background-image: url(<?php 191 $this->text( 'logopath' ) 192 ?>);" href="<?php 193 echo htmlspecialchars( $this->data['nav_urls']['mainpage']['href'] ) 194 ?>" <?php 195 echo Xml::expandAttributes( Linker::tooltipAndAccesskeyAttribs( 'p-logo' ) ) 196 ?>></a></div> 197 <?php $this->renderPortals( $this->data['sidebar'] ); ?> 198 </div> 199 </div> 200 <div id="footer" role="contentinfo"<?php $this->html( 'userlangattributes' ) ?>> 201 <?php 202 foreach ( $this->getFooterLinks() as $category => $links ) { 203 ?> 204 <ul id="footer-<?php 205 echo $category 206 ?>"> 207 <?php 208 foreach ( $links as $link ) { 209 ?> 210 <li id="footer-<?php 211 echo $category 212 ?>-<?php 213 echo $link 214 ?>"><?php 215 $this->html( $link ) 216 ?></li> 217 <?php 218 } 219 ?> 220 </ul> 221 <?php 222 } 223 ?> 224 <?php $footericons = $this->getFooterIcons( "icononly" ); 225 if ( count( $footericons ) > 0 ) { 226 ?> 227 <ul id="footer-icons" class="noprint"> 228 <?php 229 foreach ( $footericons as $blockName => $footerIcons ) { 230 ?> 231 <li id="footer-<?php 232 echo htmlspecialchars( $blockName ); ?>ico"> 233 <?php 234 foreach ( $footerIcons as $icon ) { 235 ?> 236 <?php 237 echo $this->getSkin()->makeFooterIcon( $icon ); 238 ?> 239 240 <?php 241 } 242 ?> 243 </li> 244 <?php 245 } 246 ?> 247 </ul> 248 <?php 249 } 250 ?> 251 <div style="clear:both"></div> 252 </div> 253 <?php $this->printTrail(); ?> 254 255 </body> 256 </html> 257 <?php 258 } 259 260 /** 261 * Render a series of portals 262 * 263 * @param array $portals 264 */ 265 protected function renderPortals( $portals ) { 266 // Force the rendering of the following portals 267 if ( !isset( $portals['SEARCH'] ) ) { 268 $portals['SEARCH'] = true; 269 } 270 if ( !isset( $portals['TOOLBOX'] ) ) { 271 $portals['TOOLBOX'] = true; 272 } 273 if ( !isset( $portals['LANGUAGES'] ) ) { 274 $portals['LANGUAGES'] = true; 275 } 276 // Render portals 277 foreach ( $portals as $name => $content ) { 278 if ( $content === false ) { 279 continue; 280 } 281 282 switch ( $name ) { 283 case 'SEARCH': 284 break; 285 case 'TOOLBOX': 286 $this->renderPortal( 'tb', $this->getToolbox(), 'toolbox', 'SkinTemplateToolboxEnd' ); 287 break; 288 case 'LANGUAGES': 289 if ( $this->data['language_urls'] !== false ) { 290 $this->renderPortal( 'lang', $this->data['language_urls'], 'otherlanguages' ); 291 } 292 break; 293 default: 294 $this->renderPortal( $name, $content ); 295 break; 296 } 297 } 298 } 299 300 /** 301 * @param string $name 302 * @param array $content 303 * @param null|string $msg 304 * @param null|string|array $hook 305 */ 306 protected function renderPortal( $name, $content, $msg = null, $hook = null ) { 307 if ( $msg === null ) { 308 $msg = $name; 309 } 310 $msgObj = wfMessage( $msg ); 311 ?> 312 <div class="portal" role="navigation" id='<?php 313 echo Sanitizer::escapeId( "p-$name" ) 314 ?>'<?php 315 echo Linker::tooltip( 'p-' . $name ) 316 ?> aria-labelledby='<?php echo Sanitizer::escapeId( "p-$name-label" ) ?>'> 317 <h3<?php 318 $this->html( 'userlangattributes' ) 319 ?> id='<?php 320 echo Sanitizer::escapeId( "p-$name-label" ) 321 ?>'><?php 322 echo htmlspecialchars( $msgObj->exists() ? $msgObj->text() : $msg ); 323 ?></h3> 324 325 <div class="body"> 326 <?php 327 if ( is_array( $content ) ) { 328 ?> 329 <ul> 330 <?php 331 foreach ( $content as $key => $val ) { 332 ?> 333 <?php echo $this->makeListItem( $key, $val ); ?> 334 335 <?php 336 } 337 if ( $hook !== null ) { 338 wfRunHooks( $hook, array( &$this, true ) ); 339 } 340 ?> 341 </ul> 342 <?php 343 } else { 344 ?> 345 <?php 346 echo $content; /* Allow raw HTML block to be defined by extensions */ 347 } 348 349 $this->renderAfterPortlet( $name ); 350 ?> 351 </div> 352 </div> 353 <?php 354 } 355 356 /** 357 * Render one or more navigations elements by name, automatically reveresed 358 * when UI is in RTL mode 359 * 360 * @param array $elements 361 */ 362 protected function renderNavigation( $elements ) { 363 // If only one element was given, wrap it in an array, allowing more 364 // flexible arguments 365 if ( !is_array( $elements ) ) { 366 $elements = array( $elements ); 367 // If there's a series of elements, reverse them when in RTL mode 368 } elseif ( $this->data['rtl'] ) { 369 $elements = array_reverse( $elements ); 370 } 371 // Render elements 372 foreach ( $elements as $name => $element ) { 373 switch ( $element ) { 374 case 'NAMESPACES': 375 ?> 376 <div id="p-namespaces" role="navigation" class="vectorTabs<?php 377 if ( count( $this->data['namespace_urls'] ) == 0 ) { 378 echo ' emptyPortlet'; 379 } 380 ?>" aria-labelledby="p-namespaces-label"> 381 <h3 id="p-namespaces-label"><?php $this->msg( 'namespaces' ) ?></h3> 382 <ul<?php $this->html( 'userlangattributes' ) ?>> 383 <?php 384 foreach ( $this->data['namespace_urls'] as $link ) { 385 ?> 386 <li <?php 387 echo $link['attributes'] 388 ?>><span><a href="<?php 389 echo htmlspecialchars( $link['href'] ) 390 ?>" <?php 391 echo $link['key'] 392 ?>><?php 393 echo htmlspecialchars( $link['text'] ) 394 ?></a></span></li> 395 <?php 396 } 397 ?> 398 </ul> 399 </div> 400 <?php 401 break; 402 case 'VARIANTS': 403 ?> 404 <div id="p-variants" role="navigation" class="vectorMenu<?php 405 if ( count( $this->data['variant_urls'] ) == 0 ) { 406 echo ' emptyPortlet'; 407 } 408 ?>" aria-labelledby="p-variants-label"> 409 <?php 410 // Replace the label with the name of currently chosen variant, if any 411 $variantLabel = $this->getMsg( 'variants' )->text(); 412 foreach ( $this->data['variant_urls'] as $link ) { 413 if ( stripos( $link['attributes'], 'selected' ) !== false ) { 414 $variantLabel = $link['text']; 415 break; 416 } 417 } 418 ?> 419 <h3 id="p-variants-label"><span><?php echo htmlspecialchars( $variantLabel ) ?></span><a href="#"></a></h3> 420 421 <div class="menu"> 422 <ul> 423 <?php 424 foreach ( $this->data['variant_urls'] as $link ) { 425 ?> 426 <li<?php 427 echo $link['attributes'] 428 ?>><a href="<?php 429 echo htmlspecialchars( $link['href'] ) 430 ?>" lang="<?php 431 echo htmlspecialchars( $link['lang'] ) 432 ?>" hreflang="<?php 433 echo htmlspecialchars( $link['hreflang'] ) 434 ?>" <?php 435 echo $link['key'] 436 ?>><?php 437 echo htmlspecialchars( $link['text'] ) 438 ?></a></li> 439 <?php 440 } 441 ?> 442 </ul> 443 </div> 444 </div> 445 <?php 446 break; 447 case 'VIEWS': 448 ?> 449 <div id="p-views" role="navigation" class="vectorTabs<?php 450 if ( count( $this->data['view_urls'] ) == 0 ) { 451 echo ' emptyPortlet'; 452 } 453 ?>" aria-labelledby="p-views-label"> 454 <h3 id="p-views-label"><?php $this->msg( 'views' ) ?></h3> 455 <ul<?php 456 $this->html( 'userlangattributes' ) 457 ?>> 458 <?php 459 foreach ( $this->data['view_urls'] as $link ) { 460 ?> 461 <li<?php 462 echo $link['attributes'] 463 ?>><span><a href="<?php 464 echo htmlspecialchars( $link['href'] ) 465 ?>" <?php 466 echo $link['key'] 467 ?>><?php 468 // $link['text'] can be undefined - bug 27764 469 if ( array_key_exists( 'text', $link ) ) { 470 echo array_key_exists( 'img', $link ) 471 ? '<img src="' . $link['img'] . '" alt="' . $link['text'] . '" />' 472 : htmlspecialchars( $link['text'] ); 473 } 474 ?></a></span></li> 475 <?php 476 } 477 ?> 478 </ul> 479 </div> 480 <?php 481 break; 482 case 'ACTIONS': 483 ?> 484 <div id="p-cactions" role="navigation" class="vectorMenu<?php 485 if ( count( $this->data['action_urls'] ) == 0 ) { 486 echo ' emptyPortlet'; 487 } 488 ?>" aria-labelledby="p-cactions-label"> 489 <h3 id="p-cactions-label"><span><?php 490 $this->msg( 'vector-more-actions' ) 491 ?></span><a href="#"></a></h3> 492 493 <div class="menu"> 494 <ul<?php $this->html( 'userlangattributes' ) ?>> 495 <?php 496 foreach ( $this->data['action_urls'] as $link ) { 497 ?> 498 <li<?php 499 echo $link['attributes'] 500 ?>> 501 <a href="<?php 502 echo htmlspecialchars( $link['href'] ) 503 ?>" <?php 504 echo $link['key'] ?>><?php echo htmlspecialchars( $link['text'] ) 505 ?></a> 506 </li> 507 <?php 508 } 509 ?> 510 </ul> 511 </div> 512 </div> 513 <?php 514 break; 515 case 'PERSONAL': 516 ?> 517 <div id="p-personal" role="navigation" class="<?php 518 if ( count( $this->data['personal_urls'] ) == 0 ) { 519 echo ' emptyPortlet'; 520 } 521 ?>" aria-labelledby="p-personal-label"> 522 <h3 id="p-personal-label"><?php $this->msg( 'personaltools' ) ?></h3> 523 <ul<?php $this->html( 'userlangattributes' ) ?>> 524 <?php 525 $personalTools = $this->getPersonalTools(); 526 foreach ( $personalTools as $key => $item ) { 527 echo $this->makeListItem( $key, $item ); 528 } 529 ?> 530 </ul> 531 </div> 532 <?php 533 break; 534 case 'SEARCH': 535 ?> 536 <div id="p-search" role="search"> 537 <h3<?php $this->html( 'userlangattributes' ) ?>> 538 <label for="searchInput"><?php $this->msg( 'search' ) ?></label> 539 </h3> 540 541 <form action="<?php $this->text( 'wgScript' ) ?>" id="searchform"> 542 <?php 543 if ( $this->config->get( 'VectorUseSimpleSearch' ) ) { 544 ?> 545 <div id="simpleSearch"> 546 <?php 547 } else { 548 ?> 549 <div> 550 <?php 551 } 552 ?> 553 <?php 554 echo $this->makeSearchInput( array( 'id' => 'searchInput' ) ); 555 echo Html::hidden( 'title', $this->get( 'searchtitle' ) ); 556 // We construct two buttons (for 'go' and 'fulltext' search modes), 557 // but only one will be visible and actionable at a time (they are 558 // overlaid on top of each other in CSS). 559 // * Browsers will use the 'fulltext' one by default (as it's the 560 // first in tree-order), which is desirable when they are unable 561 // to show search suggestions (either due to being broken or 562 // having JavaScript turned off). 563 // * The mediawiki.searchSuggest module, after doing tests for the 564 // broken browsers, removes the 'fulltext' button and handles 565 // 'fulltext' search itself; this will reveal the 'go' button and 566 // cause it to be used. 567 echo $this->makeSearchButton( 568 'fulltext', 569 array( 'id' => 'mw-searchButton', 'class' => 'searchButton mw-fallbackSearchButton' ) 570 ); 571 echo $this->makeSearchButton( 572 'go', 573 array( 'id' => 'searchButton', 'class' => 'searchButton' ) 574 ); 575 ?> 576 </div> 577 </form> 578 </div> 579 <?php 580 581 break; 582 } 583 } 584 } 585 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 14:03:12 2014 | Cross-referenced by PHPXref 0.7.1 |