00001 <?php
00006 if ( !defined( 'MEDIAWIKI' ) ) {
00007 die( 1 );
00008 }
00009
00018 class Skin extends Linker {
00022 var $mWatchLinkNum = 0;
00023
00024 protected $searchboxes = '';
00026 protected $mRevisionId;
00027 protected $skinname = 'standard';
00028
00029
00030
00032 function __construct() {
00033 parent::__construct();
00034 }
00035
00040 static function getSkinNames() {
00041 global $wgValidSkinNames;
00042 static $skinsInitialised = false;
00043 if ( !$skinsInitialised ) {
00044 # Get a list of available skins
00045 # Build using the regular expression '^(.*).php$'
00046 # Array keys are all lower case, array value keep the case used by filename
00047 #
00048 wfProfileIn( __METHOD__ . '-init' );
00049 global $wgStyleDirectory;
00050 $skinDir = dir( $wgStyleDirectory );
00051
00052 # while code from www.php.net
00053 while( false !== ( $file = $skinDir->read() ) ) {
00054
00055 $matches = array();
00056 if( preg_match( '/^([^.]*)\.php$/', $file, $matches ) ) {
00057 $aSkin = $matches[1];
00058 $wgValidSkinNames[strtolower( $aSkin )] = $aSkin;
00059 }
00060 }
00061 $skinDir->close();
00062 $skinsInitialised = true;
00063 wfProfileOut( __METHOD__ . '-init' );
00064 }
00065 return $wgValidSkinNames;
00066 }
00067
00074 public static function getUsableSkins() {
00075 global $wgSkipSkins;
00076 $usableSkins = self::getSkinNames();
00077 foreach ( $wgSkipSkins as $skip ) {
00078 unset( $usableSkins[$skip] );
00079 }
00080 return $usableSkins;
00081 }
00082
00090 static function normalizeKey( $key ) {
00091 global $wgDefaultSkin;
00092 $skinNames = Skin::getSkinNames();
00093
00094 if( $key == '' ) {
00095
00096
00097 $key = $wgDefaultSkin;
00098 }
00099
00100 if( isset( $skinNames[$key] ) ) {
00101 return $key;
00102 }
00103
00104
00105
00106 $fallback = array(
00107 0 => $wgDefaultSkin,
00108 1 => 'nostalgia',
00109 2 => 'cologneblue'
00110 );
00111
00112 if( isset( $fallback[$key] ) ) {
00113 $key = $fallback[$key];
00114 }
00115
00116 if( isset( $skinNames[$key] ) ) {
00117 return $key;
00118 } else {
00119 return 'monobook';
00120 }
00121 }
00122
00128 static function &newFromKey( $key ) {
00129 global $wgStyleDirectory;
00130
00131 $key = Skin::normalizeKey( $key );
00132
00133 $skinNames = Skin::getSkinNames();
00134 $skinName = $skinNames[$key];
00135 $className = 'Skin' . ucfirst( $key );
00136
00137 # Grab the skin class and initialise it.
00138 if ( !class_exists( $className ) ) {
00139
00140 $deps = "{$wgStyleDirectory}/{$skinName}.deps.php";
00141 if( file_exists( $deps ) ) {
00142 include_once( $deps );
00143 }
00144 require_once( "{$wgStyleDirectory}/{$skinName}.php" );
00145
00146 # Check if we got if not failback to default skin
00147 if( !class_exists( $className ) ) {
00148 # DO NOT die if the class isn't found. This breaks maintenance
00149 # scripts and can cause a user account to be unrecoverable
00150 # except by SQL manipulation if a previously valid skin name
00151 # is no longer valid.
00152 wfDebug( "Skin class does not exist: $className\n" );
00153 $className = 'SkinMonobook';
00154 require_once( "{$wgStyleDirectory}/MonoBook.php" );
00155 }
00156 }
00157 $skin = new $className;
00158 return $skin;
00159 }
00160
00162 function getStylesheet() {
00163 return 'common/wikistandard.css';
00164 }
00165
00167 public function getSkinName() {
00168 return $this->skinname;
00169 }
00170
00171 function qbSetting() {
00172 global $wgOut, $wgUser;
00173
00174 if ( $wgOut->isQuickbarSuppressed() ) {
00175 return 0;
00176 }
00177 $q = $wgUser->getOption( 'quickbar', 0 );
00178 return $q;
00179 }
00180
00181 function initPage( OutputPage $out ) {
00182 global $wgFavicon, $wgAppleTouchIcon;
00183
00184 wfProfileIn( __METHOD__ );
00185
00186 # Generally the order of the favicon and apple-touch-icon links
00187 # should not matter, but Konqueror (3.5.9 at least) incorrectly
00188 # uses whichever one appears later in the HTML source. Make sure
00189 # apple-touch-icon is specified first to avoid this.
00190 if( false !== $wgAppleTouchIcon ) {
00191 $out->addLink( array( 'rel' => 'apple-touch-icon', 'href' => $wgAppleTouchIcon ) );
00192 }
00193
00194 if( false !== $wgFavicon ) {
00195 $out->addLink( array( 'rel' => 'shortcut icon', 'href' => $wgFavicon ) );
00196 }
00197
00198 # OpenSearch description link
00199 $out->addLink( array(
00200 'rel' => 'search',
00201 'type' => 'application/opensearchdescription+xml',
00202 'href' => wfScript( 'opensearch_desc' ),
00203 'title' => wfMsgForContent( 'opensearch-desc' ),
00204 ));
00205
00206 $this->addMetadataLinks( $out );
00207
00208 $this->mRevisionId = $out->mRevisionId;
00209
00210 $this->preloadExistence();
00211
00212 wfProfileOut( __METHOD__ );
00213 }
00214
00218 function preloadExistence() {
00219 global $wgUser;
00220
00221
00222 $titles = array( $wgUser->getUserPage(), $wgUser->getTalkPage() );
00223
00224
00225 if ( $this->mTitle->getNamespace() == NS_SPECIAL ) {
00226
00227 } elseif ( $this->mTitle->isTalkPage() ) {
00228 $titles[] = $this->mTitle->getSubjectPage();
00229 } else {
00230 $titles[] = $this->mTitle->getTalkPage();
00231 }
00232
00233 $lb = new LinkBatch( $titles );
00234 $lb->execute();
00235 }
00236
00242 function addMetadataLinks( OutputPage $out ) {
00243 global $wgEnableDublinCoreRdf, $wgEnableCreativeCommonsRdf;
00244 global $wgRightsPage, $wgRightsUrl;
00245
00246 if( $out->isArticleRelated() ) {
00247 # note: buggy CC software only reads first "meta" link
00248 if( $wgEnableCreativeCommonsRdf ) {
00249 $out->addMetadataLink( array(
00250 'title' => 'Creative Commons',
00251 'type' => 'application/rdf+xml',
00252 'href' => $this->mTitle->getLocalURL( 'action=creativecommons' ) )
00253 );
00254 }
00255 if( $wgEnableDublinCoreRdf ) {
00256 $out->addMetadataLink( array(
00257 'title' => 'Dublin Core',
00258 'type' => 'application/rdf+xml',
00259 'href' => $this->mTitle->getLocalURL( 'action=dublincore' ) )
00260 );
00261 }
00262 }
00263 $copyright = '';
00264 if( $wgRightsPage ) {
00265 $copy = Title::newFromText( $wgRightsPage );
00266 if( $copy ) {
00267 $copyright = $copy->getLocalURL();
00268 }
00269 }
00270 if( !$copyright && $wgRightsUrl ) {
00271 $copyright = $wgRightsUrl;
00272 }
00273 if( $copyright ) {
00274 $out->addLink( array(
00275 'rel' => 'copyright',
00276 'href' => $copyright )
00277 );
00278 }
00279 }
00280
00284 protected function setMembers() {
00285 global $wgUser;
00286 $this->mUser = $wgUser;
00287 $this->userpage = $wgUser->getUserPage()->getPrefixedText();
00288 $this->usercss = false;
00289 }
00290
00295 public function setTitle( $t ) {
00296 $this->mTitle = $t;
00297 }
00298
00300 public function getTitle() {
00301 return $this->mTitle;
00302 }
00303
00308 function outputPage( OutputPage $out ) {
00309 global $wgDebugComments;
00310 wfProfileIn( __METHOD__ );
00311
00312 $this->setMembers();
00313 $this->initPage( $out );
00314
00315
00316 $afterContent = $this->afterContentHook();
00317
00318 $out->out( $out->headElement( $this ) );
00319
00320 if ( $wgDebugComments ) {
00321 $out->out( "<!-- Wiki debugging output:\n" .
00322 $out->mDebugtext . "-->\n" );
00323 }
00324
00325 $out->out( $this->beforeContent() );
00326
00327 $out->out( $out->mBodytext . "\n" );
00328
00329 $out->out( $this->afterContent() );
00330
00331 $out->out( $afterContent );
00332
00333 $out->out( $this->bottomScripts() );
00334
00335 $out->out( wfReportTime() );
00336
00337 $out->out( "\n</body></html>" );
00338 wfProfileOut( __METHOD__ );
00339 }
00340
00341 static function makeVariablesScript( $data ) {
00342 if( $data ) {
00343 $r = array();
00344 foreach ( $data as $name => $value ) {
00345 $encValue = Xml::encodeJsVar( $value );
00346 $r[] = "$name=$encValue";
00347 }
00348 $js = 'var ' . implode( ",\n", $r ) . ';';
00349 return Html::inlineScript( "\n$js\n" );
00350 } else {
00351 return '';
00352 }
00353 }
00354
00361 static function makeGlobalVariablesScript( $skinName ) {
00362 if ( is_array( $skinName ) ) {
00363 # Weird back-compat stuff.
00364 $skinName = $skinName['skinname'];
00365 }
00366 global $wgScript, $wgTitle, $wgStylePath, $wgUser, $wgScriptExtension;
00367 global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang;
00368 global $wgOut, $wgArticle;
00369 global $wgBreakFrames, $wgRequest, $wgVariantArticlePath, $wgActionPaths;
00370 global $wgUseAjax, $wgAjaxWatch;
00371 global $wgVersion, $wgEnableAPI, $wgEnableWriteAPI;
00372 global $wgRestrictionTypes;
00373 global $wgMWSuggestTemplate, $wgDBname, $wgEnableMWSuggest;
00374 global $wgSitename;
00375
00376 $ns = $wgTitle->getNamespace();
00377 $nsname = MWNamespace::exists( $ns ) ? MWNamespace::getCanonicalName( $ns ) : $wgTitle->getNsText();
00378 $separatorTransTable = $wgContLang->separatorTransformTable();
00379 $separatorTransTable = $separatorTransTable ? $separatorTransTable : array();
00380 $compactSeparatorTransTable = array(
00381 implode( "\t", array_keys( $separatorTransTable ) ),
00382 implode( "\t", $separatorTransTable ),
00383 );
00384 $digitTransTable = $wgContLang->digitTransformTable();
00385 $digitTransTable = $digitTransTable ? $digitTransTable : array();
00386 $compactDigitTransTable = array(
00387 implode( "\t", array_keys( $digitTransTable ) ),
00388 implode( "\t", $digitTransTable ),
00389 );
00390
00391 $mainPage = Title::newFromText( wfMsgForContent( 'mainpage' ) );
00392 $vars = array(
00393 'skin' => $skinName,
00394 'stylepath' => $wgStylePath,
00395 'wgUrlProtocols' => wfUrlProtocols(),
00396 'wgArticlePath' => $wgArticlePath,
00397 'wgScriptPath' => $wgScriptPath,
00398 'wgScriptExtension' => $wgScriptExtension,
00399 'wgScript' => $wgScript,
00400 'wgVariantArticlePath' => $wgVariantArticlePath,
00401 'wgActionPaths' => (object)$wgActionPaths,
00402 'wgServer' => $wgServer,
00403 'wgCanonicalNamespace' => $nsname,
00404 'wgCanonicalSpecialPageName' => $ns == NS_SPECIAL ?
00405 SpecialPage::resolveAlias( $wgTitle->getDBkey() ) : false, # bug 21115
00406 'wgNamespaceNumber' => $wgTitle->getNamespace(),
00407 'wgPageName' => $wgTitle->getPrefixedDBKey(),
00408 'wgTitle' => $wgTitle->getText(),
00409 'wgAction' => $wgRequest->getText( 'action', 'view' ),
00410 'wgArticleId' => $wgTitle->getArticleId(),
00411 'wgIsArticle' => $wgOut->isArticle(),
00412 'wgUserName' => $wgUser->isAnon() ? null : $wgUser->getName(),
00413 'wgUserGroups' => $wgUser->isAnon() ? null : $wgUser->getEffectiveGroups(),
00414 'wgUserLanguage' => $wgLang->getCode(),
00415 'wgContentLanguage' => $wgContLang->getCode(),
00416 'wgBreakFrames' => $wgOut->getFrameOptions() == 'DENY',
00417 'wgCurRevisionId' => isset( $wgArticle ) ? $wgArticle->getLatest() : 0,
00418 'wgVersion' => $wgVersion,
00419 'wgEnableAPI' => $wgEnableAPI,
00420 'wgEnableWriteAPI' => $wgEnableWriteAPI,
00421 'wgSeparatorTransformTable' => $compactSeparatorTransTable,
00422 'wgDigitTransformTable' => $compactDigitTransTable,
00423 'wgMainPageTitle' => $mainPage ? $mainPage->getPrefixedText() : null,
00424 'wgFormattedNamespaces' => $wgContLang->getFormattedNamespaces(),
00425 'wgNamespaceIds' => $wgContLang->getNamespaceIds(),
00426 'wgSiteName' => $wgSitename,
00427 'wgCategories' => $wgOut->getCategories(),
00428 );
00429 if ( $wgContLang->hasVariants() ) {
00430 $vars['wgUserVariant'] = $wgContLang->getPreferredVariant();
00431 }
00432
00433
00434 if( SpecialPage::resolveAlias( $wgTitle->getDBkey() ) == 'Upload' ) {
00435 global $wgFileExtensions, $wgAjaxUploadInterface;
00436 $vars['wgFileExtensions'] = $wgFileExtensions;
00437 }
00438
00439 if( $wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false ) ) {
00440 $vars['wgMWSuggestTemplate'] = SearchEngine::getMWSuggestTemplate();
00441 $vars['wgDBname'] = $wgDBname;
00442 $vars['wgSearchNamespaces'] = SearchEngine::userNamespaces( $wgUser );
00443 $vars['wgMWSuggestMessages'] = array( wfMsg( 'search-mwsuggest-enabled' ), wfMsg( 'search-mwsuggest-disabled' ) );
00444 }
00445
00446 foreach( $wgRestrictionTypes as $type ) {
00447 $vars['wgRestriction' . ucfirst( $type )] = $wgTitle->getRestrictions( $type );
00448 }
00449
00450 if ( $wgOut->isArticleRelated() && $wgUseAjax && $wgAjaxWatch && $wgUser->isLoggedIn() ) {
00451 $msgs = (object)array();
00452 foreach ( array( 'watch', 'unwatch', 'watching', 'unwatching',
00453 'tooltip-ca-watch', 'tooltip-ca-unwatch' ) as $msgName ) {
00454 $msgs->{$msgName . 'Msg'} = wfMsg( $msgName );
00455 }
00456 $vars['wgAjaxWatch'] = $msgs;
00457 }
00458
00459
00460 wfRunHooks( 'MakeGlobalVariablesScript', array( &$vars ) );
00461
00462 return self::makeVariablesScript( $vars );
00463 }
00464
00475 public function userCanPreview( $action ) {
00476 global $wgRequest, $wgUser;
00477
00478 if( $action != 'submit' ) {
00479 return false;
00480 }
00481 if( !$wgRequest->wasPosted() ) {
00482 return false;
00483 }
00484 if( !$this->mTitle->userCanEditCssSubpage() ) {
00485 return false;
00486 }
00487 if( !$this->mTitle->userCanEditJsSubpage() ) {
00488 return false;
00489 }
00490 return $wgUser->matchEditToken(
00491 $wgRequest->getVal( 'wpEditToken' ) );
00492 }
00493
00508 public function generateUserJs( $skinName = null ) {
00509 global $wgStylePath;
00510
00511 wfProfileIn( __METHOD__ );
00512 if( !$skinName ) {
00513 $skinName = $this->getSkinName();
00514 }
00515
00516 $s = "/* generated javascript */\n";
00517 $s .= "var skin = '" . Xml::escapeJsString( $skinName ) . "';\n";
00518 $s .= "var stylepath = '" . Xml::escapeJsString( $wgStylePath ) . "';";
00519 $s .= "\n\n/* MediaWiki:Common.js */\n";
00520 $commonJs = wfMsgExt( 'common.js', 'content' );
00521 if ( !wfEmptyMsg( 'common.js', $commonJs ) ) {
00522 $s .= $commonJs;
00523 }
00524
00525 $s .= "\n\n/* MediaWiki:" . ucfirst( $skinName ) . ".js */\n";
00526
00527
00528 $msgKey = ucfirst( $skinName ) . '.js';
00529 $userJS = wfMsgExt( $msgKey, 'content' );
00530 if ( !wfEmptyMsg( $msgKey, $userJS ) ) {
00531 $s .= $userJS;
00532 }
00533
00534 wfProfileOut( __METHOD__ );
00535 return $s;
00536 }
00537
00541 public function generateUserStylesheet() {
00542 wfProfileIn( __METHOD__ );
00543 $s = "/* generated user stylesheet */\n" .
00544 $this->reallyGenerateUserStylesheet();
00545 wfProfileOut( __METHOD__ );
00546 return $s;
00547 }
00548
00552 protected function reallyGenerateUserStylesheet() {
00553 global $wgUser;
00554 $s = '';
00555 if( ( $undopt = $wgUser->getOption( 'underline' ) ) < 2 ) {
00556 $underline = $undopt ? 'underline' : 'none';
00557 $s .= "a { text-decoration: $underline; }\n";
00558 }
00559 if( $wgUser->getOption( 'highlightbroken' ) ) {
00560 $s .= "a.new, #quickbar a.new { color: #CC2200; }\n";
00561 } else {
00562 $s .= <<<CSS
00563 a.new, #quickbar a.new,
00564 a.stub, #quickbar a.stub {
00565 color: inherit;
00566 }
00567 a.new:after, #quickbar a.new:after {
00568 content: "?";
00569 color: #CC2200;
00570 }
00571 a.stub:after, #quickbar a.stub:after {
00572 content: "!";
00573 color: #772233;
00574 }
00575 CSS;
00576 }
00577 if( $wgUser->getOption( 'justify' ) ) {
00578 $s .= "#article, #bodyContent, #mw_content { text-align: justify; }\n";
00579 }
00580 if( !$wgUser->getOption( 'showtoc' ) ) {
00581 $s .= "#toc { display: none; }\n";
00582 }
00583 if( !$wgUser->getOption( 'editsection' ) ) {
00584 $s .= ".editsection { display: none; }\n";
00585 }
00586 $fontstyle = $wgUser->getOption( 'editfont' );
00587 if ( $fontstyle !== 'default' ) {
00588 $s .= "textarea { font-family: $fontstyle; }\n";
00589 }
00590 return $s;
00591 }
00592
00596 function setupUserCss( OutputPage $out ) {
00597 global $wgRequest, $wgContLang, $wgUser;
00598 global $wgAllowUserCss, $wgUseSiteCss, $wgSquidMaxage, $wgStylePath;
00599
00600 wfProfileIn( __METHOD__ );
00601
00602 $this->setupSkinUserCss( $out );
00603
00604 $siteargs = array(
00605 'action' => 'raw',
00606 'maxage' => $wgSquidMaxage,
00607 );
00608
00609
00610 foreach ( $out->getExtStyle() as $url ) {
00611 $out->addStyle( $url );
00612 }
00613
00614
00615
00616 if( $wgUseSiteCss ) {
00617 global $wgHandheldStyle;
00618 $query = wfArrayToCGI( array(
00619 'usemsgcache' => 'yes',
00620 'ctype' => 'text/css',
00621 'smaxage' => $wgSquidMaxage
00622 ) + $siteargs );
00623 # Site settings must override extension css! (bug 15025)
00624 $out->addStyle( self::makeNSUrl( 'Common.css', $query, NS_MEDIAWIKI ) );
00625 $out->addStyle( self::makeNSUrl( 'Print.css', $query, NS_MEDIAWIKI ), 'print' );
00626 if( $wgHandheldStyle ) {
00627 $out->addStyle( self::makeNSUrl( 'Handheld.css', $query, NS_MEDIAWIKI ), 'handheld' );
00628 }
00629 $out->addStyle( self::makeNSUrl( $this->getSkinName() . '.css', $query, NS_MEDIAWIKI ) );
00630 }
00631
00632 if( $wgUser->isLoggedIn() ) {
00633
00634
00635 $siteargs['smaxage'] = '0';
00636 $siteargs['ts'] = $wgUser->mTouched;
00637 }
00638
00639 $siteargs['gen'] = 'css';
00640 if( ( $us = $wgRequest->getVal( 'useskin', '' ) ) !== '' ) {
00641 $siteargs['useskin'] = $us;
00642 }
00643 $out->addStyle( self::makeUrl( '-', wfArrayToCGI( $siteargs ) ) );
00644
00645
00646 if( $wgAllowUserCss && $wgUser->isLoggedIn() ) {
00647 $action = $wgRequest->getVal( 'action' );
00648 # If we're previewing the CSS page, use it
00649 if( $this->mTitle->isCssSubpage() && $this->userCanPreview( $action ) ) {
00650
00651 $out->addInlineStyle( $wgRequest->getText( 'wpTextbox1' ) );
00652 } else {
00653 $out->addStyle( self::makeUrl(
00654 $this->userpage . '/' . $this->getSkinName() . '.css',
00655 'action=raw&ctype=text/css' )
00656 );
00657 }
00658 }
00659
00660 wfProfileOut( __METHOD__ );
00661 }
00662
00667 function setupSkinUserCss( OutputPage $out ) {
00668 $out->addStyle( 'common/shared.css' );
00669 $out->addStyle( 'common/oldshared.css' );
00670 $out->addStyle( $this->getStylesheet() );
00671 $out->addStyle( 'common/common_rtl.css', '', '', 'rtl' );
00672 }
00673
00674 function getPageClasses( $title ) {
00675 $numeric = 'ns-' . $title->getNamespace();
00676 if( $title->getNamespace() == NS_SPECIAL ) {
00677 $type = 'ns-special';
00678 } elseif( $title->isTalkPage() ) {
00679 $type = 'ns-talk';
00680 } else {
00681 $type = 'ns-subject';
00682 }
00683 $name = Sanitizer::escapeClass( 'page-' . $title->getPrefixedText() );
00684 return "$numeric $type $name";
00685 }
00686
00690 function getLogo() {
00691 global $wgLogo;
00692 return $wgLogo;
00693 }
00694
00699 function beforeContent() {
00700 return $this->doBeforeContent();
00701 }
00702
00703 function doBeforeContent() {
00704 global $wgContLang;
00705 wfProfileIn( __METHOD__ );
00706
00707 $s = '';
00708 $qb = $this->qbSetting();
00709
00710 $langlinks = $this->otherLanguages();
00711 if( $langlinks ) {
00712 $rows = 2;
00713 $borderhack = '';
00714 } else {
00715 $rows = 1;
00716 $langlinks = false;
00717 $borderhack = 'class="top"';
00718 }
00719
00720 $s .= "\n<div id='content'>\n<div id='topbar'>\n" .
00721 "<table border='0' cellspacing='0' width='98%'>\n<tr>\n";
00722
00723 $shove = ( $qb != 0 );
00724 $left = ( $qb == 1 || $qb == 3 );
00725 if( $wgContLang->isRTL() ) {
00726 $left = !$left;
00727 }
00728
00729 if( !$shove ) {
00730 $s .= "<td class='top' align='left' valign='top' rowspan='{$rows}'>\n" .
00731 $this->logoText() . '</td>';
00732 } elseif( $left ) {
00733 $s .= $this->getQuickbarCompensator( $rows );
00734 }
00735 $l = $wgContLang->alignStart();
00736 $s .= "<td {$borderhack} align='$l' valign='top'>\n";
00737
00738 $s .= $this->topLinks();
00739 $s .= '<p class="subtitle">' . $this->pageTitleLinks() . "</p>\n";
00740
00741 $r = $wgContLang->alignEnd();
00742 $s .= "</td>\n<td {$borderhack} valign='top' align='$r' nowrap='nowrap'>";
00743 $s .= $this->nameAndLogin();
00744 $s .= "\n<br />" . $this->searchForm() . '</td>';
00745
00746 if ( $langlinks ) {
00747 $s .= "</tr>\n<tr>\n<td class='top' colspan=\"2\">$langlinks</td>\n";
00748 }
00749
00750 if ( $shove && !$left ) { # Right
00751 $s .= $this->getQuickbarCompensator( $rows );
00752 }
00753 $s .= "</tr>\n</table>\n</div>\n";
00754 $s .= "\n<div id='article'>\n";
00755
00756 $notice = wfGetSiteNotice();
00757 if( $notice ) {
00758 $s .= "\n<div id='siteNotice'>$notice</div>\n";
00759 }
00760 $s .= $this->pageTitle();
00761 $s .= $this->pageSubtitle();
00762 $s .= $this->getCategories();
00763 wfProfileOut( __METHOD__ );
00764 return $s;
00765 }
00766
00767 function getCategoryLinks() {
00768 global $wgOut, $wgUseCategoryBrowser;
00769 global $wgContLang, $wgUser;
00770
00771 if( count( $wgOut->mCategoryLinks ) == 0 ) {
00772 return '';
00773 }
00774
00775 # Separator
00776 $sep = wfMsgExt( 'catseparator', array( 'parsemag', 'escapenoentities' ) );
00777
00778
00779
00780 $dir = $wgContLang->getDir();
00781 $embed = "<span dir='$dir'>";
00782 $pop = '</span>';
00783
00784 $allCats = $wgOut->getCategoryLinks();
00785 $s = '';
00786 $colon = wfMsgExt( 'colon-separator', 'escapenoentities' );
00787 if ( !empty( $allCats['normal'] ) ) {
00788 $t = $embed . implode( "{$pop} {$sep} {$embed}" , $allCats['normal'] ) . $pop;
00789
00790 $msg = wfMsgExt( 'pagecategories', array( 'parsemag', 'escapenoentities' ), count( $allCats['normal'] ) );
00791 $s .= '<div id="mw-normal-catlinks">' .
00792 $this->link( Title::newFromText( wfMsgForContent( 'pagecategorieslink' ) ), $msg )
00793 . $colon . $t . '</div>';
00794 }
00795
00796 # Hidden categories
00797 if ( isset( $allCats['hidden'] ) ) {
00798 if ( $wgUser->getBoolOption( 'showhiddencats' ) ) {
00799 $class ='mw-hidden-cats-user-shown';
00800 } elseif ( $this->mTitle->getNamespace() == NS_CATEGORY ) {
00801 $class = 'mw-hidden-cats-ns-shown';
00802 } else {
00803 $class = 'mw-hidden-cats-hidden';
00804 }
00805 $s .= "<div id=\"mw-hidden-catlinks\" class=\"$class\">" .
00806 wfMsgExt( 'hidden-categories', array( 'parsemag', 'escapenoentities' ), count( $allCats['hidden'] ) ) .
00807 $colon . $embed . implode( "$pop $sep $embed", $allCats['hidden'] ) . $pop .
00808 '</div>';
00809 }
00810
00811 # optional 'dmoz-like' category browser. Will be shown under the list
00812 # of categories an article belong to
00813 if( $wgUseCategoryBrowser ) {
00814 $s .= '<br /><hr />';
00815
00816 # get a big array of the parents tree
00817 $parenttree = $this->mTitle->getParentCategoryTree();
00818 # Skin object passed by reference cause it can not be
00819 # accessed under the method subfunction drawCategoryBrowser
00820 $tempout = explode( "\n", Skin::drawCategoryBrowser( $parenttree, $this ) );
00821 # Clean out bogus first entry and sort them
00822 unset( $tempout[0] );
00823 asort( $tempout );
00824 # Output one per line
00825 $s .= implode( "<br />\n", $tempout );
00826 }
00827
00828 return $s;
00829 }
00830
00837 function drawCategoryBrowser( $tree, &$skin ) {
00838 $return = '';
00839 foreach( $tree as $element => $parent ) {
00840 if( empty( $parent ) ) {
00841 # element start a new list
00842 $return .= "\n";
00843 } else {
00844 # grab the others elements
00845 $return .= Skin::drawCategoryBrowser( $parent, $skin ) . ' > ';
00846 }
00847 # add our current element to the list
00848 $eltitle = Title::newFromText( $element );
00849 $return .= $skin->link( $eltitle, $eltitle->getText() );
00850 }
00851 return $return;
00852 }
00853
00854 function getCategories() {
00855 $catlinks = $this->getCategoryLinks();
00856
00857 $classes = 'catlinks';
00858
00859
00860 global $wgOut, $wgUser;
00861 $allCats = $wgOut->getCategoryLinks();
00862 $showHidden = $wgUser->getBoolOption( 'showhiddencats' ) ||
00863 $this->mTitle->getNamespace() == NS_CATEGORY;
00864
00865 if( empty( $allCats['normal'] ) && !( !empty( $allCats['hidden'] ) && $showHidden ) ) {
00866 $classes .= ' catlinks-allhidden';
00867 }
00868
00869 return "<div id='catlinks' class='$classes'>{$catlinks}</div>";
00870 }
00871
00872 function getQuickbarCompensator( $rows = 1 ) {
00873 return "<td width='152' rowspan='{$rows}'> </td>";
00874 }
00875
00890 protected function afterContentHook() {
00891 $data = '';
00892
00893 if( wfRunHooks( 'SkinAfterContent', array( &$data ) ) ) {
00894
00895
00896 if( trim( $data ) != '' ) {
00897
00898
00899
00900 $data = "<div id='mw-data-after-content'>\n" .
00901 "\t$data\n" .
00902 "</div>\n";
00903 }
00904 } else {
00905 wfDebug( "Hook SkinAfterContent changed output processing.\n" );
00906 }
00907
00908 return $data;
00909 }
00910
00916 protected function generateDebugHTML() {
00917 global $wgShowDebug, $wgOut;
00918 if ( $wgShowDebug ) {
00919 $listInternals = $this->formatDebugHTML( $wgOut->mDebugtext );
00920 return "\n<hr />\n<strong>Debug data:</strong><ul style=\"font-family:monospace;\" id=\"mw-debug-html\">" .
00921 $listInternals . "</ul>\n";
00922 }
00923 return '';
00924 }
00925
00926 private function formatDebugHTML( $debugText ) {
00927 $lines = explode( "\n", $debugText );
00928 $curIdent = 0;
00929 $ret = '<li>';
00930 foreach( $lines as $line ) {
00931 $m = array();
00932 $display = ltrim( $line );
00933 $ident = strlen( $line ) - strlen( $display );
00934 $diff = $ident - $curIdent;
00935
00936 if ( $display == '' ) {
00937 $display = "\xc2\xa0";
00938 }
00939
00940 if ( !$ident && $diff < 0 && substr( $display, 0, 9 ) != 'Entering ' && substr( $display, 0, 8 ) != 'Exiting ' ) {
00941 $ident = $curIdent;
00942 $diff = 0;
00943 $display = '<span style="background:yellow;">' . htmlspecialchars( $display ) . '</span>';
00944 } else {
00945 $display = htmlspecialchars( $display );
00946 }
00947
00948 if ( $diff < 0 ) {
00949 $ret .= str_repeat( "</li></ul>\n", -$diff ) . "</li><li>\n";
00950 } elseif ( $diff == 0 ) {
00951 $ret .= "</li><li>\n";
00952 } else {
00953 $ret .= str_repeat( "<ul><li>\n", $diff );
00954 }
00955 $ret .= $display . "\n";
00956
00957 $curIdent = $ident;
00958 }
00959 $ret .= str_repeat( '</li></ul>', $curIdent ) . '</li>';
00960 return $ret;
00961 }
00962
00967 function afterContent() {
00968 $printfooter = "<div class=\"printfooter\">\n" . $this->printFooter() . "</div>\n";
00969 return $printfooter . $this->generateDebugHTML() . $this->doAfterContent();
00970 }
00971
00976 function bottomScripts() {
00977 $bottomScriptText = "\n" . Html::inlineScript( 'if (window.runOnloadHook) runOnloadHook();' ) . "\n";
00978 wfRunHooks( 'SkinAfterBottomScripts', array( $this, &$bottomScriptText ) );
00979 return $bottomScriptText;
00980 }
00981
00983 function printSource() {
00984 $url = htmlspecialchars( $this->mTitle->getFullURL() );
00985 return wfMsg( 'retrievedfrom', '<a href="' . $url . '">' . $url . '</a>' );
00986 }
00987
00988 function printFooter() {
00989 return "<p>" . $this->printSource() .
00990 "</p>\n\n<p>" . $this->pageStats() . "</p>\n";
00991 }
00992
00994 function doAfterContent() {
00995 return '</div></div>';
00996 }
00997
00998 function pageTitleLinks() {
00999 global $wgOut, $wgUser, $wgRequest, $wgLang;
01000
01001 $oldid = $wgRequest->getVal( 'oldid' );
01002 $diff = $wgRequest->getVal( 'diff' );
01003 $action = $wgRequest->getText( 'action' );
01004
01005 $s[] = $this->printableLink();
01006 $disclaimer = $this->disclaimerLink(); # may be empty
01007 if( $disclaimer ) {
01008 $s[] = $disclaimer;
01009 }
01010 $privacy = $this->privacyLink(); # may be empty too
01011 if( $privacy ) {
01012 $s[] = $privacy;
01013 }
01014
01015 if ( $wgOut->isArticleRelated() ) {
01016 if ( $this->mTitle->getNamespace() == NS_FILE ) {
01017 $name = $this->mTitle->getDBkey();
01018 $image = wfFindFile( $this->mTitle );
01019 if( $image ) {
01020 $link = htmlspecialchars( $image->getURL() );
01021 $style = $this->getInternalLinkAttributes( $link, $name );
01022 $s[] = "<a href=\"{$link}\"{$style}>{$name}</a>";
01023 }
01024 }
01025 }
01026 if ( 'history' == $action || isset( $diff ) || isset( $oldid ) ) {
01027 $s[] .= $this->link(
01028 $this->mTitle,
01029 wfMsg( 'currentrev' ),
01030 array(),
01031 array(),
01032 array( 'known', 'noclasses' )
01033 );
01034 }
01035
01036 if ( $wgUser->getNewtalk() ) {
01037 # do not show "You have new messages" text when we are viewing our
01038 # own talk page
01039 if( !$this->mTitle->equals( $wgUser->getTalkPage() ) ) {
01040 $tl = $this->link(
01041 $wgUser->getTalkPage(),
01042 wfMsgHtml( 'newmessageslink' ),
01043 array(),
01044 array( 'redirect' => 'no' ),
01045 array( 'known', 'noclasses' )
01046 );
01047
01048 $dl = $this->link(
01049 $wgUser->getTalkPage(),
01050 wfMsgHtml( 'newmessagesdifflink' ),
01051 array(),
01052 array( 'diff' => 'cur' ),
01053 array( 'known', 'noclasses' )
01054 );
01055 $s[] = '<strong>'. wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
01056 # disable caching
01057 $wgOut->setSquidMaxage( 0 );
01058 $wgOut->enableClientCache( false );
01059 }
01060 }
01061
01062 $undelete = $this->getUndeleteLink();
01063 if( !empty( $undelete ) ) {
01064 $s[] = $undelete;
01065 }
01066 return $wgLang->pipeList( $s );
01067 }
01068
01069 function getUndeleteLink() {
01070 global $wgUser, $wgContLang, $wgLang, $wgRequest;
01071
01072 $action = $wgRequest->getVal( 'action', 'view' );
01073
01074 if ( $wgUser->isAllowed( 'deletedhistory' ) &&
01075 ( $this->mTitle->getArticleId() == 0 || $action == 'history' ) ) {
01076 $n = $this->mTitle->isDeleted();
01077 if ( $n ) {
01078 if ( $wgUser->isAllowed( 'undelete' ) ) {
01079 $msg = 'thisisdeleted';
01080 } else {
01081 $msg = 'viewdeleted';
01082 }
01083 return wfMsg(
01084 $msg,
01085 $this->link(
01086 SpecialPage::getTitleFor( 'Undelete', $this->mTitle->getPrefixedDBkey() ),
01087 wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) ),
01088 array(),
01089 array(),
01090 array( 'known', 'noclasses' )
01091 )
01092 );
01093 }
01094 }
01095 return '';
01096 }
01097
01098 function printableLink() {
01099 global $wgOut, $wgFeedClasses, $wgRequest, $wgLang;
01100
01101 $s = array();
01102
01103 if ( !$wgOut->isPrintable() ) {
01104 $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
01105 $s[] = "<a href=\"$printurl\" rel=\"alternate\">" . wfMsg( 'printableversion' ) . '</a>';
01106 }
01107
01108 if( $wgOut->isSyndicated() ) {
01109 foreach( $wgFeedClasses as $format => $class ) {
01110 $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
01111 $s[] = "<a href=\"$feedurl\" rel=\"alternate\" type=\"application/{$format}+xml\""
01112 . " class=\"feedlink\">" . wfMsgHtml( "feed-$format" ) . "</a>";
01113 }
01114 }
01115 return $wgLang->pipeList( $s );
01116 }
01117
01122 function pageTitle() {
01123 global $wgOut;
01124 $s = '<h1 class="pagetitle">' . $wgOut->getPageTitle() . '</h1>';
01125 return $s;
01126 }
01127
01128 function pageSubtitle() {
01129 global $wgOut;
01130
01131 $sub = $wgOut->getSubtitle();
01132 if ( $sub == '' ) {
01133 global $wgExtraSubtitle;
01134 $sub = wfMsgExt( 'tagline', 'parsemag' ) . $wgExtraSubtitle;
01135 }
01136 $subpages = $this->subPageSubtitle();
01137 $sub .= !empty( $subpages ) ? "</p><p class='subpages'>$subpages" : '';
01138 $s = "<p class='subtitle'>{$sub}</p>\n";
01139 return $s;
01140 }
01141
01142 function subPageSubtitle() {
01143 $subpages = '';
01144 if( !wfRunHooks( 'SkinSubPageSubtitle', array( &$subpages ) ) ) {
01145 return $subpages;
01146 }
01147
01148 global $wgOut;
01149 if( $wgOut->isArticle() && MWNamespace::hasSubpages( $this->mTitle->getNamespace() ) ) {
01150 $ptext = $this->mTitle->getPrefixedText();
01151 if( preg_match( '/\//', $ptext ) ) {
01152 $links = explode( '/', $ptext );
01153 array_pop( $links );
01154 $c = 0;
01155 $growinglink = '';
01156 $display = '';
01157 foreach( $links as $link ) {
01158 $growinglink .= $link;
01159 $display .= $link;
01160 $linkObj = Title::newFromText( $growinglink );
01161 if( is_object( $linkObj ) && $linkObj->exists() ) {
01162 $getlink = $this->link(
01163 $linkObj,
01164 htmlspecialchars( $display ),
01165 array(),
01166 array(),
01167 array( 'known', 'noclasses' )
01168 );
01169 $c++;
01170 if( $c > 1 ) {
01171 $subpages .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
01172 } else {
01173 $subpages .= '< ';
01174 }
01175 $subpages .= $getlink;
01176 $display = '';
01177 } else {
01178 $display .= '/';
01179 }
01180 $growinglink .= '/';
01181 }
01182 }
01183 }
01184 return $subpages;
01185 }
01186
01190 function showIPinHeader() {
01191 global $wgShowIPinHeader;
01192 return $wgShowIPinHeader && session_id() != '';
01193 }
01194
01195 function nameAndLogin() {
01196 global $wgUser, $wgLang, $wgContLang;
01197
01198 $logoutPage = $wgContLang->specialPage( 'Userlogout' );
01199
01200 $ret = '';
01201 if ( $wgUser->isAnon() ) {
01202 if( $this->showIPinHeader() ) {
01203 $name = wfGetIP();
01204
01205 $talkLink = $this->link( $wgUser->getTalkPage(),
01206 $wgLang->getNsText( NS_TALK ) );
01207
01208 $ret .= "$name ($talkLink)";
01209 } else {
01210 $ret .= wfMsg( 'notloggedin' );
01211 }
01212
01213 $returnTo = $this->mTitle->getPrefixedDBkey();
01214 $query = array();
01215 if ( $logoutPage != $returnTo ) {
01216 $query['returnto'] = $returnTo;
01217 }
01218
01219 $loginlink = $wgUser->isAllowed( 'createaccount' )
01220 ? 'nav-login-createaccount'
01221 : 'login';
01222 $ret .= "\n<br />" . $this->link(
01223 SpecialPage::getTitleFor( 'Userlogin' ),
01224 wfMsg( $loginlink ), array(), $query
01225 );
01226 } else {
01227 $returnTo = $this->mTitle->getPrefixedDBkey();
01228 $talkLink = $this->link( $wgUser->getTalkPage(),
01229 $wgLang->getNsText( NS_TALK ) );
01230
01231 $ret .= $this->link( $wgUser->getUserPage(),
01232 htmlspecialchars( $wgUser->getName() ) );
01233 $ret .= " ($talkLink)<br />";
01234 $ret .= $wgLang->pipeList( array(
01235 $this->link(
01236 SpecialPage::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
01237 array(), array( 'returnto' => $returnTo )
01238 ),
01239 $this->specialLink( 'preferences' ),
01240 ) );
01241 }
01242 $ret = $wgLang->pipeList( array(
01243 $ret,
01244 $this->link(
01245 Title::newFromText( wfMsgForContent( 'helppage' ) ),
01246 wfMsg( 'help' )
01247 ),
01248 ) );
01249
01250 return $ret;
01251 }
01252
01253 function getSearchLink() {
01254 $searchPage = SpecialPage::getTitleFor( 'Search' );
01255 return $searchPage->getLocalURL();
01256 }
01257
01258 function escapeSearchLink() {
01259 return htmlspecialchars( $this->getSearchLink() );
01260 }
01261
01262 function searchForm() {
01263 global $wgRequest, $wgUseTwoButtonsSearchForm;
01264 $search = $wgRequest->getText( 'search' );
01265
01266 $s = '<form id="searchform' . $this->searchboxes . '" name="search" class="inline" method="post" action="'
01267 . $this->escapeSearchLink() . "\">\n"
01268 . '<input type="text" id="searchInput' . $this->searchboxes . '" name="search" size="19" value="'
01269 . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />\n"
01270 . '<input type="submit" name="go" value="' . wfMsg( 'searcharticle' ) . '" />';
01271
01272 if( $wgUseTwoButtonsSearchForm ) {
01273 $s .= ' <input type="submit" name="fulltext" value="' . wfMsg( 'searchbutton' ) . "\" />\n";
01274 } else {
01275 $s .= ' <a href="' . $this->escapeSearchLink() . '" rel="search">' . wfMsg( 'powersearch-legend' ) . "</a>\n";
01276 }
01277
01278 $s .= '</form>';
01279
01280
01281 $this->searchboxes = $this->searchboxes == '' ? 2 : $this->searchboxes + 1;
01282
01283 return $s;
01284 }
01285
01286 function topLinks() {
01287 global $wgOut;
01288
01289 $s = array(
01290 $this->mainPageLink(),
01291 $this->specialLink( 'recentchanges' )
01292 );
01293
01294 if ( $wgOut->isArticleRelated() ) {
01295 $s[] = $this->editThisPage();
01296 $s[] = $this->historyLink();
01297 }
01298 # Many people don't like this dropdown box
01299 #$s[] = $this->specialPagesList();
01300
01301 if( $this->variantLinks() ) {
01302 $s[] = $this->variantLinks();
01303 }
01304
01305 if( $this->extensionTabLinks() ) {
01306 $s[] = $this->extensionTabLinks();
01307 }
01308
01309
01310 return implode( $s, wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n" );
01311 }
01312
01319 function extensionTabLinks() {
01320 $tabs = array();
01321 $out = '';
01322 $s = array();
01323 wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) );
01324 foreach( $tabs as $tab ) {
01325 $s[] = Xml::element( 'a',
01326 array( 'href' => $tab['href'] ),
01327 $tab['text'] );
01328 }
01329
01330 if( count( $s ) ) {
01331 global $wgLang;
01332
01333 $out = wfMsgExt( 'pipe-separator' , 'escapenoentities' );
01334 $out .= $wgLang->pipeList( $s );
01335 }
01336
01337 return $out;
01338 }
01339
01344 function variantLinks() {
01345 $s = '';
01346
01347 global $wgDisableLangConversion, $wgLang, $wgContLang;
01348 $variants = $wgContLang->getVariants();
01349 if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
01350 foreach( $variants as $code ) {
01351 $varname = $wgContLang->getVariantname( $code );
01352 if( $varname == 'disable' ) {
01353 continue;
01354 }
01355 $s = $wgLang->pipeList( array(
01356 $s,
01357 '<a href="' . $this->mTitle->escapeLocalURL( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>'
01358 ) );
01359 }
01360 }
01361 return $s;
01362 }
01363
01364 function bottomLinks() {
01365 global $wgOut, $wgUser, $wgUseTrackbacks;
01366 $sep = wfMsgExt( 'pipe-separator', 'escapenoentities' ) . "\n";
01367
01368 $s = '';
01369 if ( $wgOut->isArticleRelated() ) {
01370 $element[] = '<strong>' . $this->editThisPage() . '</strong>';
01371 if ( $wgUser->isLoggedIn() ) {
01372 $element[] = $this->watchThisPage();
01373 }
01374 $element[] = $this->talkLink();
01375 $element[] = $this->historyLink();
01376 $element[] = $this->whatLinksHere();
01377 $element[] = $this->watchPageLinksLink();
01378
01379 if( $wgUseTrackbacks ) {
01380 $element[] = $this->trackbackLink();
01381 }
01382
01383 if (
01384 $this->mTitle->getNamespace() == NS_USER ||
01385 $this->mTitle->getNamespace() == NS_USER_TALK
01386 )
01387 {
01388 $id = User::idFromName( $this->mTitle->getText() );
01389 $ip = User::isIP( $this->mTitle->getText() );
01390
01391 # Both anons and non-anons have contributions list
01392 if( $id || $ip ) {
01393 $element[] = $this->userContribsLink();
01394 }
01395 if( $this->showEmailUser( $id ) ) {
01396 $element[] = $this->emailUserLink();
01397 }
01398 }
01399
01400 $s = implode( $element, $sep );
01401
01402 if ( $this->mTitle->getArticleId() ) {
01403 $s .= "\n<br />";
01404
01405 if( $wgUser->isAllowed( 'delete' ) ) {
01406 $s .= $this->deleteThisPage();
01407 }
01408 if( $wgUser->isAllowed( 'protect' ) ) {
01409 $s .= $sep . $this->protectThisPage();
01410 }
01411 if( $wgUser->isAllowed( 'move' ) ) {
01412 $s .= $sep . $this->moveThisPage();
01413 }
01414 }
01415 $s .= "<br />\n" . $this->otherLanguages();
01416 }
01417
01418 return $s;
01419 }
01420
01421 function pageStats() {
01422 global $wgOut, $wgLang, $wgArticle, $wgRequest, $wgUser;
01423 global $wgDisableCounters, $wgMaxCredits, $wgShowCreditsIfMax, $wgPageShowWatchingUsers;
01424
01425 $oldid = $wgRequest->getVal( 'oldid' );
01426 $diff = $wgRequest->getVal( 'diff' );
01427 if ( !$wgOut->isArticle() ) {
01428 return '';
01429 }
01430 if( !$wgArticle instanceof Article ) {
01431 return '';
01432 }
01433 if ( isset( $oldid ) || isset( $diff ) ) {
01434 return '';
01435 }
01436 if ( 0 == $wgArticle->getID() ) {
01437 return '';
01438 }
01439
01440 $s = '';
01441 if ( !$wgDisableCounters ) {
01442 $count = $wgLang->formatNum( $wgArticle->getCount() );
01443 if ( $count ) {
01444 $s = wfMsgExt( 'viewcount', array( 'parseinline' ), $count );
01445 }
01446 }
01447
01448 if( $wgMaxCredits != 0 ) {
01449 $s .= ' ' . Credits::getCredits( $wgArticle, $wgMaxCredits, $wgShowCreditsIfMax );
01450 } else {
01451 $s .= $this->lastModified();
01452 }
01453
01454 if( $wgPageShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' ) ) {
01455 $dbr = wfGetDB( DB_SLAVE );
01456 $res = $dbr->select(
01457 'watchlist',
01458 array( 'COUNT(*) AS n' ),
01459 array(
01460 'wl_title' => $dbr->strencode( $this->mTitle->getDBkey() ),
01461 'wl_namespace' => $this->mTitle->getNamespace()
01462 ),
01463 __METHOD__
01464 );
01465 $x = $dbr->fetchObject( $res );
01466
01467 $s .= ' ' . wfMsgExt( 'number_of_watching_users_pageview',
01468 array( 'parseinline' ), $wgLang->formatNum( $x->n )
01469 );
01470 }
01471
01472 return $s . ' ' . $this->getCopyright();
01473 }
01474
01475 function getCopyright( $type = 'detect' ) {
01476 global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest, $wgArticle;
01477
01478 if ( $type == 'detect' ) {
01479 $diff = $wgRequest->getVal( 'diff' );
01480 $isCur = $wgArticle && $wgArticle->isCurrent();
01481 if ( is_null( $diff ) && !$isCur && wfMsgForContent( 'history_copyright' ) !== '-' ) {
01482 $type = 'history';
01483 } else {
01484 $type = 'normal';
01485 }
01486 }
01487
01488 if ( $type == 'history' ) {
01489 $msg = 'history_copyright';
01490 } else {
01491 $msg = 'copyright';
01492 }
01493
01494 $out = '';
01495 if( $wgRightsPage ) {
01496 $title = Title::newFromText( $wgRightsPage );
01497 $link = $this->linkKnown( $title, $wgRightsText );
01498 } elseif( $wgRightsUrl ) {
01499 $link = $this->makeExternalLink( $wgRightsUrl, $wgRightsText );
01500 } elseif( $wgRightsText ) {
01501 $link = $wgRightsText;
01502 } else {
01503 # Give up now
01504 return $out;
01505 }
01506
01507 if( isset( $wgArticle ) ) {
01508 wfRunHooks( 'SkinCopyrightFooter', array( $wgArticle->getTitle(), $type, &$msg, &$link ) );
01509 }
01510
01511 $out .= wfMsgForContent( $msg, $link );
01512 return $out;
01513 }
01514
01515 function getCopyrightIcon() {
01516 global $wgRightsUrl, $wgRightsText, $wgRightsIcon, $wgCopyrightIcon;
01517 $out = '';
01518 if ( isset( $wgCopyrightIcon ) && $wgCopyrightIcon ) {
01519 $out = $wgCopyrightIcon;
01520 } elseif ( $wgRightsIcon ) {
01521 $icon = htmlspecialchars( $wgRightsIcon );
01522 if ( $wgRightsUrl ) {
01523 $url = htmlspecialchars( $wgRightsUrl );
01524 $out .= '<a href="'.$url.'">';
01525 }
01526 $text = htmlspecialchars( $wgRightsText );
01527 $out .= "<img src=\"$icon\" alt=\"$text\" width=\"88\" height=\"31\" />";
01528 if ( $wgRightsUrl ) {
01529 $out .= '</a>';
01530 }
01531 }
01532 return $out;
01533 }
01534
01539 function getPoweredBy() {
01540 global $wgStylePath;
01541 $url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
01542 $img = '<a href="http://www.mediawiki.org/"><img src="' . $url . '" height="31" width="88" alt="Powered by MediaWiki" /></a>';
01543 return $img;
01544 }
01545
01546 function lastModified() {
01547 global $wgLang, $wgArticle;
01548 if( $this->mRevisionId && $this->mRevisionId != $wgArticle->getLatest() ) {
01549 $timestamp = Revision::getTimestampFromId( $wgArticle->getTitle(), $this->mRevisionId );
01550 } else {
01551 $timestamp = $wgArticle->getTimestamp();
01552 }
01553 if ( $timestamp ) {
01554 $d = $wgLang->date( $timestamp, true );
01555 $t = $wgLang->time( $timestamp, true );
01556 $s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
01557 } else {
01558 $s = '';
01559 }
01560 if ( wfGetLB()->getLaggedSlaveMode() ) {
01561 $s .= ' <strong>' . wfMsg( 'laggedslavemode' ) . '</strong>';
01562 }
01563 return $s;
01564 }
01565
01566 function logoText( $align = '' ) {
01567 if ( $align != '' ) {
01568 $a = " align='{$align}'";
01569 } else {
01570 $a = '';
01571 }
01572
01573 $mp = wfMsg( 'mainpage' );
01574 $mptitle = Title::newMainPage();
01575 $url = ( is_object( $mptitle ) ? $mptitle->escapeLocalURL() : '' );
01576
01577 $logourl = $this->getLogo();
01578 $s = "<a href='{$url}'><img{$a} src='{$logourl}' alt='[{$mp}]' /></a>";
01579 return $s;
01580 }
01581
01585 function specialPagesList() {
01586 global $wgUser, $wgContLang, $wgServer, $wgRedirectScript;
01587 $pages = array_merge( SpecialPage::getRegularPages(), SpecialPage::getRestrictedPages() );
01588 foreach ( $pages as $name => $page ) {
01589 $pages[$name] = $page->getDescription();
01590 }
01591
01592 $go = wfMsg( 'go' );
01593 $sp = wfMsg( 'specialpages' );
01594 $spp = $wgContLang->specialPage( 'Specialpages' );
01595
01596 $s = '<form id="specialpages" method="get" ' .
01597 'action="' . htmlspecialchars( "{$wgServer}{$wgRedirectScript}" ) . "\">\n";
01598 $s .= "<select name=\"wpDropdown\">\n";
01599 $s .= "<option value=\"{$spp}\">{$sp}</option>\n";
01600
01601
01602 foreach ( $pages as $name => $desc ) {
01603 $p = $wgContLang->specialPage( $name );
01604 $s .= "<option value=\"{$p}\">{$desc}</option>\n";
01605 }
01606 $s .= "</select>\n";
01607 $s .= "<input type='submit' value=\"{$go}\" name='redirect' />\n";
01608 $s .= "</form>\n";
01609 return $s;
01610 }
01611
01616 function mainPageLink() {
01617 $s = $this->link(
01618 Title::newMainPage(),
01619 wfMsg( 'mainpage' ),
01620 array(),
01621 array(),
01622 array( 'known', 'noclasses' )
01623 );
01624 return $s;
01625 }
01626
01627 private function footerLink( $desc, $page ) {
01628
01629 if ( wfMsgForContent( $desc ) == '-') {
01630
01631 return '';
01632 } else {
01633
01634
01635
01636 $title = Title::newFromText( wfMsgForContent( $page ) );
01637 return $this->linkKnown(
01638 $title,
01639 wfMsgExt( $desc, array( 'parsemag', 'escapenoentities' ) )
01640 );
01641 }
01642 }
01643
01647 function privacyLink() {
01648 return $this->footerLink( 'privacy', 'privacypage' );
01649 }
01650
01654 function aboutLink() {
01655 return $this->footerLink( 'aboutsite', 'aboutpage' );
01656 }
01657
01661 function disclaimerLink() {
01662 return $this->footerLink( 'disclaimers', 'disclaimerpage' );
01663 }
01664
01665 function editThisPage() {
01666 global $wgOut;
01667
01668 if ( !$wgOut->isArticleRelated() ) {
01669 $s = wfMsg( 'protectedpage' );
01670 } else {
01671 if( $this->mTitle->quickUserCan( 'edit' ) && $this->mTitle->exists() ) {
01672 $t = wfMsg( 'editthispage' );
01673 } elseif( $this->mTitle->quickUserCan( 'create' ) && !$this->mTitle->exists() ) {
01674 $t = wfMsg( 'create-this-page' );
01675 } else {
01676 $t = wfMsg( 'viewsource' );
01677 }
01678
01679 $s = $this->link(
01680 $this->mTitle,
01681 $t,
01682 array(),
01683 $this->editUrlOptions(),
01684 array( 'known', 'noclasses' )
01685 );
01686 }
01687 return $s;
01688 }
01689
01697 function editUrlOptions() {
01698 global $wgArticle;
01699
01700 $options = array( 'action' => 'edit' );
01701
01702 if( $this->mRevisionId && ! $wgArticle->isCurrent() ) {
01703 $options['oldid'] = intval( $this->mRevisionId );
01704 }
01705
01706 return $options;
01707 }
01708
01709 function deleteThisPage() {
01710 global $wgUser, $wgRequest;
01711
01712 $diff = $wgRequest->getVal( 'diff' );
01713 if ( $this->mTitle->getArticleId() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
01714 $t = wfMsg( 'deletethispage' );
01715
01716 $s = $this->link(
01717 $this->mTitle,
01718 $t,
01719 array(),
01720 array( 'action' => 'delete' ),
01721 array( 'known', 'noclasses' )
01722 );
01723 } else {
01724 $s = '';
01725 }
01726 return $s;
01727 }
01728
01729 function protectThisPage() {
01730 global $wgUser, $wgRequest;
01731
01732 $diff = $wgRequest->getVal( 'diff' );
01733 if ( $this->mTitle->getArticleId() && ( ! $diff ) && $wgUser->isAllowed('protect') ) {
01734 if ( $this->mTitle->isProtected() ) {
01735 $text = wfMsg( 'unprotectthispage' );
01736 $query = array( 'action' => 'unprotect' );
01737 } else {
01738 $text = wfMsg( 'protectthispage' );
01739 $query = array( 'action' => 'protect' );
01740 }
01741
01742 $s = $this->link(
01743 $this->mTitle,
01744 $text,
01745 array(),
01746 $query,
01747 array( 'known', 'noclasses' )
01748 );
01749 } else {
01750 $s = '';
01751 }
01752 return $s;
01753 }
01754
01755 function watchThisPage() {
01756 global $wgOut;
01757 ++$this->mWatchLinkNum;
01758
01759 if ( $wgOut->isArticleRelated() ) {
01760 if ( $this->mTitle->userIsWatching() ) {
01761 $text = wfMsg( 'unwatchthispage' );
01762 $query = array( 'action' => 'unwatch' );
01763 $id = 'mw-unwatch-link' . $this->mWatchLinkNum;
01764 } else {
01765 $text = wfMsg( 'watchthispage' );
01766 $query = array( 'action' => 'watch' );
01767 $id = 'mw-watch-link' . $this->mWatchLinkNum;
01768 }
01769
01770 $s = $this->link(
01771 $this->mTitle,
01772 $text,
01773 array( 'id' => $id ),
01774 $query,
01775 array( 'known', 'noclasses' )
01776 );
01777 } else {
01778 $s = wfMsg( 'notanarticle' );
01779 }
01780 return $s;
01781 }
01782
01783 function moveThisPage() {
01784 if ( $this->mTitle->quickUserCan( 'move' ) ) {
01785 return $this->link(
01786 SpecialPage::getTitleFor( 'Movepage' ),
01787 wfMsg( 'movethispage' ),
01788 array(),
01789 array( 'target' => $this->mTitle->getPrefixedDBkey() ),
01790 array( 'known', 'noclasses' )
01791 );
01792 } else {
01793
01794 return '';
01795 }
01796 }
01797
01798 function historyLink() {
01799 return $this->link(
01800 $this->mTitle,
01801 wfMsgHtml( 'history' ),
01802 array( 'rel' => 'archives' ),
01803 array( 'action' => 'history' )
01804 );
01805 }
01806
01807 function whatLinksHere() {
01808 return $this->link(
01809 SpecialPage::getTitleFor( 'Whatlinkshere', $this->mTitle->getPrefixedDBkey() ),
01810 wfMsgHtml( 'whatlinkshere' ),
01811 array(),
01812 array(),
01813 array( 'known', 'noclasses' )
01814 );
01815 }
01816
01817 function userContribsLink() {
01818 return $this->link(
01819 SpecialPage::getTitleFor( 'Contributions', $this->mTitle->getDBkey() ),
01820 wfMsgHtml( 'contributions' ),
01821 array(),
01822 array(),
01823 array( 'known', 'noclasses' )
01824 );
01825 }
01826
01827 function showEmailUser( $id ) {
01828 global $wgUser;
01829 $targetUser = User::newFromId( $id );
01830 return $wgUser->canSendEmail() && # the sending user must have a confirmed email address
01831 $targetUser->canReceiveEmail(); # the target user must have a confirmed email address and allow emails from users
01832 }
01833
01834 function emailUserLink() {
01835 return $this->link(
01836 SpecialPage::getTitleFor( 'Emailuser', $this->mTitle->getDBkey() ),
01837 wfMsg( 'emailuser' ),
01838 array(),
01839 array(),
01840 array( 'known', 'noclasses' )
01841 );
01842 }
01843
01844 function watchPageLinksLink() {
01845 global $wgOut;
01846 if ( !$wgOut->isArticleRelated() ) {
01847 return '(' . wfMsg( 'notanarticle' ) . ')';
01848 } else {
01849 return $this->link(
01850 SpecialPage::getTitleFor( 'Recentchangeslinked', $this->mTitle->getPrefixedDBkey() ),
01851 wfMsg( 'recentchangeslinked-toolbox' ),
01852 array(),
01853 array(),
01854 array( 'known', 'noclasses' )
01855 );
01856 }
01857 }
01858
01859 function trackbackLink() {
01860 return '<a href="' . $this->mTitle->trackbackURL() . '">'
01861 . wfMsg( 'trackbacklink' ) . '</a>';
01862 }
01863
01864 function otherLanguages() {
01865 global $wgOut, $wgContLang, $wgHideInterlanguageLinks;
01866
01867 if ( $wgHideInterlanguageLinks ) {
01868 return '';
01869 }
01870
01871 $a = $wgOut->getLanguageLinks();
01872 if ( 0 == count( $a ) ) {
01873 return '';
01874 }
01875
01876 $s = wfMsg( 'otherlanguages' ) . wfMsg( 'colon-separator' );
01877 $first = true;
01878 if( $wgContLang->isRTL() ) {
01879 $s .= '<span dir="LTR">';
01880 }
01881 foreach( $a as $l ) {
01882 if ( !$first ) {
01883 $s .= wfMsgExt( 'pipe-separator', 'escapenoentities' );
01884 }
01885 $first = false;
01886
01887 $nt = Title::newFromText( $l );
01888 $url = $nt->escapeFullURL();
01889 $text = $wgContLang->getLanguageName( $nt->getInterwiki() );
01890
01891 if ( $text == '' ) {
01892 $text = $l;
01893 }
01894 $style = $this->getExternalLinkAttributes();
01895 $s .= "<a href=\"{$url}\"{$style}>{$text}</a>";
01896 }
01897 if( $wgContLang->isRTL() ) {
01898 $s .= '</span>';
01899 }
01900 return $s;
01901 }
01902
01903 function talkLink() {
01904 if ( NS_SPECIAL == $this->mTitle->getNamespace() ) {
01905 # No discussion links for special pages
01906 return '';
01907 }
01908
01909 $linkOptions = array();
01910
01911 if( $this->mTitle->isTalkPage() ) {
01912 $link = $this->mTitle->getSubjectPage();
01913 switch( $link->getNamespace() ) {
01914 case NS_MAIN:
01915 $text = wfMsg( 'articlepage' );
01916 break;
01917 case NS_USER:
01918 $text = wfMsg( 'userpage' );
01919 break;
01920 case NS_PROJECT:
01921 $text = wfMsg( 'projectpage' );
01922 break;
01923 case NS_FILE:
01924 $text = wfMsg( 'imagepage' );
01925 # Make link known if image exists, even if the desc. page doesn't.
01926 if( wfFindFile( $link ) )
01927 $linkOptions[] = 'known';
01928 break;
01929 case NS_MEDIAWIKI:
01930 $text = wfMsg( 'mediawikipage' );
01931 break;
01932 case NS_TEMPLATE:
01933 $text = wfMsg( 'templatepage' );
01934 break;
01935 case NS_HELP:
01936 $text = wfMsg( 'viewhelppage' );
01937 break;
01938 case NS_CATEGORY:
01939 $text = wfMsg( 'categorypage' );
01940 break;
01941 default:
01942 $text = wfMsg( 'articlepage' );
01943 }
01944 } else {
01945 $link = $this->mTitle->getTalkPage();
01946 $text = wfMsg( 'talkpage' );
01947 }
01948
01949 $s = $this->link( $link, $text, array(), array(), $linkOptions );
01950
01951 return $s;
01952 }
01953
01954 function commentLink() {
01955 global $wgOut;
01956
01957 if ( $this->mTitle->getNamespace() == NS_SPECIAL ) {
01958 return '';
01959 }
01960
01961 # __NEWSECTIONLINK___ changes behaviour here
01962 # If it is present, the link points to this page, otherwise
01963 # it points to the talk page
01964 if( $this->mTitle->isTalkPage() ) {
01965 $title = $this->mTitle;
01966 } elseif( $wgOut->showNewSectionLink() ) {
01967 $title = $this->mTitle;
01968 } else {
01969 $title = $this->mTitle->getTalkPage();
01970 }
01971
01972 return $this->link(
01973 $title,
01974 wfMsg( 'postcomment' ),
01975 array(),
01976 array(
01977 'action' => 'edit',
01978 'section' => 'new'
01979 ),
01980 array( 'known', 'noclasses' )
01981 );
01982 }
01983
01984
01985 static function makeMainPageUrl( $urlaction = '' ) {
01986 $title = Title::newMainPage();
01987 self::checkTitle( $title, '' );
01988 return $title->getLocalURL( $urlaction );
01989 }
01990
01991 static function makeSpecialUrl( $name, $urlaction = '' ) {
01992 $title = SpecialPage::getTitleFor( $name );
01993 return $title->getLocalURL( $urlaction );
01994 }
01995
01996 static function makeSpecialUrlSubpage( $name, $subpage, $urlaction = '' ) {
01997 $title = SpecialPage::getSafeTitleFor( $name, $subpage );
01998 return $title->getLocalURL( $urlaction );
01999 }
02000
02001 static function makeI18nUrl( $name, $urlaction = '' ) {
02002 $title = Title::newFromText( wfMsgForContent( $name ) );
02003 self::checkTitle( $title, $name );
02004 return $title->getLocalURL( $urlaction );
02005 }
02006
02007 static function makeUrl( $name, $urlaction = '' ) {
02008 $title = Title::newFromText( $name );
02009 self::checkTitle( $title, $name );
02010 return $title->getLocalURL( $urlaction );
02011 }
02012
02017 static function makeInternalOrExternalUrl( $name ) {
02018 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $name ) ) {
02019 return $name;
02020 } else {
02021 return self::makeUrl( $name );
02022 }
02023 }
02024
02025 # this can be passed the NS number as defined in Language.php
02026 static function makeNSUrl( $name, $urlaction = '', $namespace = NS_MAIN ) {
02027 $title = Title::makeTitleSafe( $namespace, $name );
02028 self::checkTitle( $title, $name );
02029 return $title->getLocalURL( $urlaction );
02030 }
02031
02032
02033 static function makeUrlDetails( $name, $urlaction = '' ) {
02034 $title = Title::newFromText( $name );
02035 self::checkTitle( $title, $name );
02036 return array(
02037 'href' => $title->getLocalURL( $urlaction ),
02038 'exists' => $title->getArticleID() != 0 ? true : false
02039 );
02040 }
02041
02045 static function makeKnownUrlDetails( $name, $urlaction = '' ) {
02046 $title = Title::newFromText( $name );
02047 self::checkTitle( $title, $name );
02048 return array(
02049 'href' => $title->getLocalURL( $urlaction ),
02050 'exists' => true
02051 );
02052 }
02053
02054 # make sure we have some title to operate on
02055 static function checkTitle( &$title, $name ) {
02056 if( !is_object( $title ) ) {
02057 $title = Title::newFromText( $name );
02058 if( !is_object( $title ) ) {
02059 $title = Title::newFromText( '--error: link target missing--' );
02060 }
02061 }
02062 }
02063
02069 function buildSidebar() {
02070 global $parserMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry;
02071 global $wgLang;
02072 wfProfileIn( __METHOD__ );
02073
02074 $key = wfMemcKey( 'sidebar', $wgLang->getCode() );
02075
02076 if ( $wgEnableSidebarCache ) {
02077 $cachedsidebar = $parserMemc->get( $key );
02078 if ( $cachedsidebar ) {
02079 wfProfileOut( __METHOD__ );
02080 return $cachedsidebar;
02081 }
02082 }
02083
02084 $bar = array();
02085 $this->addToSidebar( $bar, 'sidebar' );
02086
02087 wfRunHooks( 'SkinBuildSidebar', array( $this, &$bar ) );
02088 if ( $wgEnableSidebarCache ) {
02089 $parserMemc->set( $key, $bar, $wgSidebarCacheExpiry );
02090 }
02091 wfProfileOut( __METHOD__ );
02092 return $bar;
02093 }
02101 function addToSidebar( &$bar, $message ) {
02102 $lines = explode( "\n", wfMsgForContent( $message ) );
02103 $heading = '';
02104 foreach( $lines as $line ) {
02105 if( strpos( $line, '*' ) !== 0 ) {
02106 continue;
02107 }
02108 if( strpos( $line, '**') !== 0 ) {
02109 $heading = trim( $line, '* ' );
02110 if( !array_key_exists( $heading, $bar ) ) {
02111 $bar[$heading] = array();
02112 }
02113 } else {
02114 if( strpos( $line, '|' ) !== false ) {
02115 $line = array_map( 'trim', explode( '|', trim( $line, '* ' ), 2 ) );
02116 $link = wfMsgForContent( $line[0] );
02117 if( $link == '-' ) {
02118 continue;
02119 }
02120
02121 $text = wfMsgExt( $line[1], 'parsemag' );
02122 if( wfEmptyMsg( $line[1], $text ) ) {
02123 $text = $line[1];
02124 }
02125 if( wfEmptyMsg( $line[0], $link ) ) {
02126 $link = $line[0];
02127 }
02128
02129 if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
02130 $href = $link;
02131 } else {
02132 $title = Title::newFromText( $link );
02133 if ( $title ) {
02134 $title = $title->fixSpecialName();
02135 $href = $title->getLocalURL();
02136 } else {
02137 $href = 'INVALID-TITLE';
02138 }
02139 }
02140
02141 $bar[$heading][] = array(
02142 'text' => $text,
02143 'href' => $href,
02144 'id' => 'n-' . strtr( $line[1], ' ', '-' ),
02145 'active' => false
02146 );
02147 } else {
02148 continue;
02149 }
02150 }
02151 }
02152 }
02153
02162 public function commonPrintStylesheet() {
02163 return true;
02164 }
02165 }