* @return Boolean: true iff cache-ok headers was sent.
*/
public function checkLastModified( $timestamp ) {
- global $wgCachePages, $wgCacheEpoch, $wgRequest;
+ global $wgCachePages, $wgCacheEpoch;
if ( !$timestamp || $timestamp == '19700101000000' ) {
wfDebug( __METHOD__ . ": CACHE DISABLED, NO TIMESTAMP\n" );
# Give a 304 response code and disable body output
wfDebug( __METHOD__ . ": NOT MODIFIED, $info\n", false );
ini_set( 'zlib.output_compression', 0 );
- $wgRequest->response()->header( "HTTP/1.1 304 Not Modified" );
+ $this->getRequest()->response()->header( "HTTP/1.1 304 Not Modified" );
$this->sendCacheControl();
$this->disable();
return $this->mContext;
}
+ /**
+ * Get the WebRequest being used for this instance
+ *
+ * @return WebRequest
+ * @since 1.18
+ */
+ public function getRequest() {
+ return $this->getContext()->getRequest();
+ }
+
/**
* Set the Title object to use
*
* @return Boolean
*/
function uncacheableBecauseRequestVars() {
- global $wgRequest;
- return $wgRequest->getText( 'useskin', false ) === false
- && $wgRequest->getText( 'uselang', false ) === false;
+ $request = $this->getRequest();
+ return $request->getText( 'useskin', false ) === false
+ && $request->getText( 'uselang', false ) === false;
}
/**
* @return Boolean
*/
function haveCacheVaryCookies() {
- global $wgRequest;
- $cookieHeader = $wgRequest->getHeader( 'cookie' );
+ $cookieHeader = $this->getRequest()->getHeader( 'cookie' );
if ( $cookieHeader === false ) {
return false;
}
* /w/index.php?title=Main_page&variant=zh-cn should never be served.
*/
function addAcceptLanguage() {
- global $wgRequest, $wgContLang;
- if( !$wgRequest->getCheck( 'variant' ) && $wgContLang->hasVariants() ) {
+ global $wgContLang;
+ if( !$this->getRequest()->getCheck( 'variant' ) && $wgContLang->hasVariants() ) {
$variants = $wgContLang->getVariants();
$aloption = array();
foreach ( $variants as $variant ) {
* Send cache control HTTP headers
*/
public function sendCacheControl() {
- global $wgUseSquid, $wgUseESI, $wgUseETag, $wgSquidMaxage, $wgRequest, $wgUseXVO;
+ global $wgUseSquid, $wgUseESI, $wgUseETag, $wgSquidMaxage, $wgUseXVO;
- $response = $wgRequest->response();
+ $response = $this->getRequest()->response();
if ( $wgUseETag && $this->mETag ) {
$response->header( "ETag: $this->mETag" );
}
* the object, let's actually output it:
*/
public function output() {
- global $wgOutputEncoding, $wgRequest;
+ global $wgOutputEncoding;
global $wgLanguageCode, $wgDebugRedirects, $wgMimeType;
if( $this->mDoNothing ) {
wfProfileIn( __METHOD__ );
- $response = $wgRequest->response();
+ $response = $this->getRequest()->response();
if ( $this->mRedirect != '' ) {
# Standards require redirect URLs to be absolute
* @return nothing
*/
function blockedPage( $return = true ) {
- global $wgContLang, $wgLang;
+ global $wgContLang;
$this->setPageTitle( wfMsg( 'blockedtitle' ) );
$this->setRobotPolicy( 'noindex,nofollow' );
if( $reason == '' ) {
$reason = wfMsg( 'blockednoreason' );
}
- $blockTimestamp = $wgLang->timeanddate(
+ $blockTimestamp = $this->getContext()->getLang()->timeanddate(
wfTimestamp( TS_MW, $this->getUser()->mBlock->mTimestamp ), true
);
$ip = wfGetIP();
$blockid = $this->getUser()->mBlock->getId();
- $blockExpiry = $wgLang->formatExpiry( $this->getUser()->mBlock->mExpiry );
+ $blockExpiry = $this->getContext()->getLang()->formatExpiry( $this->getUser()->mBlock->mExpiry );
if ( $this->getUser()->mBlock->mAuto ) {
$msg = 'autoblockedtext';
* @param $permission String: key required
*/
public function permissionRequired( $permission ) {
- global $wgLang;
-
$this->setPageTitle( wfMsg( 'badaccess' ) );
$this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
$this->setRobotPolicy( 'noindex,nofollow' );
if( $groups ) {
$this->addWikiMsg(
'badaccess-groups',
- $wgLang->commaList( $groups ),
+ $this->getContext()->getLang()->commaList( $groups ),
count( $groups )
);
} else {
* @param $returntoquery String: query string for the return to link
*/
public function returnToMain( $unused = null, $returnto = null, $returntoquery = null ) {
- global $wgRequest;
-
if ( $returnto == null ) {
- $returnto = $wgRequest->getText( 'returnto' );
+ $returnto = $this->getRequest()->getText( 'returnto' );
}
if ( $returntoquery == null ) {
- $returntoquery = $wgRequest->getText( 'returntoquery' );
+ $returntoquery = $this->getRequest()->getText( 'returntoquery' );
}
if ( $returnto === '' ) {
public function headElement( Skin $sk, $includeStyle = true ) {
global $wgOutputEncoding, $wgMimeType;
global $wgUseTrackbacks, $wgHtml5;
- global $wgRequest, $wgLang;
if ( $sk->commonPrintStylesheet() ) {
$this->addModuleStyles( 'mediawiki.legacy.wikiprintable' );
$bodyAttrs = array();
# Crazy edit-on-double-click stuff
- $action = $wgRequest->getVal( 'action', 'view' );
+ $action = $this->getRequest()->getVal( 'action', 'view' );
if (
$this->getTitle()->getNamespace() != NS_SPECIAL &&
$dir = wfUILang()->getDir();
$bodyAttrs['class'] = "mediawiki $dir";
- if ( $wgLang->capitalizeAllNouns() ) {
+ if ( $this->getContext()->getLang()->capitalizeAllNouns() ) {
# A <body> class is probably not the best way to do this . . .
$bodyAttrs['class'] .= ' capitalize-all-nouns';
}
* @return string html <script> and <style> tags
*/
protected function makeResourceLoaderLink( Skin $skin, $modules, $only, $useESI = false ) {
- global $wgLang, $wgLoadScript, $wgResourceLoaderUseESI,
- $wgResourceLoaderInlinePrivateModules, $wgRequest;
+ global $wgLoadScript, $wgResourceLoaderUseESI,
+ $wgResourceLoaderInlinePrivateModules;
// Lazy-load ResourceLoader
// TODO: Should this be a static function of ResourceLoader instead?
// TODO: Divide off modules starting with "user", and add the user parameter to them
$baseQuery = array(
- 'lang' => $wgLang->getCode(),
+ 'lang' => $this->getContext()->getLang()->getCode(),
'debug' => ResourceLoader::inDebugMode() ? 'true' : 'false',
'skin' => $skin->getSkinName(),
'only' => $only,
if ( $this->isPrintable() ) {
$baseQuery['printable'] = 1;
}
- if ( $wgRequest->getBool( 'handheld' ) ) {
+ if ( $this->getRequest()->getBool( 'handheld' ) ) {
$baseQuery['handheld'] = 1;
}
* @return String: HTML fragment
*/
function getHeadScripts( Skin $sk ) {
- global $wgRequest, $wgUseSiteJs, $wgAllowUserJs;
+ global $wgUseSiteJs, $wgAllowUserJs;
// Startup - this will immediately load jquery and mediawiki modules
$scripts = $this->makeResourceLoaderLink( $sk, 'startup', ResourceLoaderModule::TYPE_SCRIPTS, true );
// Add user JS if enabled
if ( $wgAllowUserJs && $this->getUser()->isLoggedIn() ) {
- $action = $wgRequest->getVal( 'action', 'view' );
+ $action = $this->getRequest()->getVal( 'action', 'view' );
if( $this->getTitle() && $this->getTitle()->isJsSubpage() && $sk->userCanPreview( $action ) ) {
# XXX: additional security check/prompt?
- $scripts .= Html::inlineScript( "\n" . $wgRequest->getText( 'wpTextbox1' ) . "\n" ) . "\n";
+ $scripts .= Html::inlineScript( "\n" . $this->getRequest()->getText( 'wpTextbox1' ) . "\n" ) . "\n";
} else {
# FIXME: this means that User:Me/Common.js doesn't load when previewing
# User:Me/Vector.js, and vice versa (bug26283)
* have to be purged on configuration changes.
*/
protected function getJSVars() {
- global $wgRequest, $wgUseAjax, $wgEnableMWSuggest, $wgContLang;
+ global $wgUseAjax, $wgEnableMWSuggest, $wgContLang;
$title = $this->getTitle();
$ns = $title->getNamespace();
'wgCurRevisionId' => $title->getLatestRevID(),
'wgArticleId' => $title->getArticleId(),
'wgIsArticle' => $this->isArticle(),
- 'wgAction' => $wgRequest->getText( 'action', 'view' ),
+ 'wgAction' => $this->getRequest()->getText( 'action', 'view' ),
'wgUserName' => $this->getUser()->isAnon() ? null : $this->getUser()->getName(),
'wgUserGroups' => $this->getUser()->getEffectiveGroups(),
'wgCategories' => $this->getCategories(),
* @return String: modified value of the "media" attribute
*/
public static function transformCssMedia( $media ) {
- global $wgRequest, $wgHandheldForIPhone;
+ global $wgHandheldForIPhone;
// Switch in on-screen display for media testing
$switches = array(
'handheld' => 'handheld',
);
foreach( $switches as $switch => $targetMedia ) {
- if( $wgRequest->getBool( $switch ) ) {
+ if( $this->getRequest()->getBool( $switch ) ) {
if( $media == $targetMedia ) {
$media = '';
} elseif( $media == 'screen' ) {
* @param $lag Integer: slave lag
*/
public function showLagWarning( $lag ) {
- global $wgSlaveLagWarning, $wgSlaveLagCritical, $wgLang;
+ global $wgSlaveLagWarning, $wgSlaveLagCritical;
if( $lag >= $wgSlaveLagWarning ) {
$message = $lag < $wgSlaveLagCritical
? 'lag-warn-normal'
: 'lag-warn-high';
$wrap = Html::rawElement( 'div', array( 'class' => "mw-{$message}" ), "\n$1\n" );
- $this->wrapWikiMsg( "$wrap\n", array( $message, $wgLang->formatNum( $lag ) ) );
+ $this->wrapWikiMsg( "$wrap\n", array( $message, $this->getContext()->getLang()->formatNum( $lag ) ) );
}
}
* @return Skin
*/
public function getSkin() {
- // For now we'll just proxy to the user. In the future a saner location for
- // organizing what skin to use may be chosen
- return $this->getUser()->getSkin();
+ if ( !isset($this->skin) ) {
+ wfProfileIn( __METHOD__ . '-createskin' );
+
+ global $wgHiddenPrefs;
+ if( !in_array( 'skin', $wgHiddenPrefs ) ) {
+ # get the user skin
+ $userSkin = $this->getUser()->getOption( 'skin' );
+ $userSkin = $this->getRequest()->getVal( 'useskin', $userSkin );
+ } else {
+ # if we're not allowing users to override, then use the default
+ global $wgDefaultSkin;
+ $userSkin = $wgDefaultSkin;
+ }
+
+ $this->skin = Skin::newFromKey( $userSkin );
+ $this->skin->setContext( $this );
+ wfProfileOut( __METHOD__ . '-createskin' );
+ }
+ return $this->skin;
}
/** Helpful methods **/
/**#@-*/
protected $mRevisionId; // The revision ID we're looking at, null if not applicable.
protected $skinname = 'standard';
- /**
- * todo Fixme: should be protected :-\
- * @var Title
- */
- var $mTitle = null;
protected $mRelevantTitle = null;
protected $mRelevantUser = null;
* Preload the existence of three commonly-requested pages in a single query
*/
function preloadExistence() {
- global $wgUser;
-
+ $user = $this->getContext()->getUser();
+
// User/talk link
- $titles = array( $wgUser->getUserPage(), $wgUser->getTalkPage() );
+ $titles = array( $user->getUserPage(), $user->getTalkPage() );
// Other tab link
- if ( $this->mTitle->getNamespace() == NS_SPECIAL ) {
+ if ( $this->getTitle()->getNamespace() == NS_SPECIAL ) {
// nothing
- } elseif ( $this->mTitle->isTalkPage() ) {
- $titles[] = $this->mTitle->getSubjectPage();
+ } elseif ( $this->getTitle()->isTalkPage() ) {
+ $titles[] = $this->getTitle()->getSubjectPage();
} else {
- $titles[] = $this->mTitle->getTalkPage();
+ $titles[] = $this->getTitle()->getTalkPage();
}
$lb = new LinkBatch( $titles );
* Set some local variables
*/
protected function setMembers() {
- global $wgUser;
- $this->mUser = $wgUser;
- $this->userpage = $wgUser->getUserPage()->getPrefixedText();
+ $this->userpage = $this->getContext()->getUser()->getUserPage()->getPrefixedText();
$this->usercss = false;
}
* @return Boolean
*/
public function isRevisionCurrent() {
- return $this->mRevisionId == 0 || $this->mRevisionId == $this->mTitle->getLatestRevID();
+ return $this->mRevisionId == 0 || $this->mRevisionId == $this->getTitle()->getLatestRevID();
}
/**
- * Set the title
- * @param $t Title object to use
+ * Set the RequestContext used in this instance
+ *
+ * @param RequestContext $context
+ */
+ public function setContext( RequestContext $context ) {
+ $this->mContext = $context;
+ }
+
+ /**
+ * Get the RequestContext used in this instance
+ *
+ * @return RequestContext
*/
- public function setTitle( $t ) {
- $this->mTitle = $t;
+ public function getContext() {
+ if ( !isset($this->mContext) ) {
+ wfDebug( __METHOD__ . " called and \$mContext is null. Using RequestContext::getMain(); for sanity\n" );
+ $this->mContext = RequestContext::getMain();
+ }
+ return $this->mContext;
}
/** Get the title
* @return Title
*/
public function getTitle() {
- return $this->mTitle;
+ return $this->getContext()->getTitle();
}
/**
if ( isset($this->mRelevantTitle) ) {
return $this->mRelevantTitle;
}
- return $this->mTitle;
+ return $this->getTitle();
}
/**
* @return bool
*/
public function userCanPreview( $action ) {
- global $wgRequest, $wgUser;
-
if ( $action != 'submit' ) {
return false;
}
- if ( !$wgRequest->wasPosted() ) {
+ if ( !$this->getContext()->getRequest()->wasPosted() ) {
return false;
}
- if ( !$this->mTitle->userCanEditCssSubpage() ) {
+ if ( !$this->getTitle()->userCanEditCssSubpage() ) {
return false;
}
- if ( !$this->mTitle->userCanEditJsSubpage() ) {
+ if ( !$this->getTitle()->userCanEditJsSubpage() ) {
return false;
}
- return $wgUser->matchEditToken(
- $wgRequest->getVal( 'wpEditToken' ) );
+ return $this->getContext()->getUser()->matchEditToken(
+ $this->getContext()->getRequest()->getVal( 'wpEditToken' ) );
}
/**
* @private
*/
function setupUserCss( OutputPage $out ) {
- global $wgRequest, $wgUser;
global $wgUseSiteCss, $wgAllowUserCss, $wgAllowUserCssPrefs;
wfProfileIn( __METHOD__ );
// Per-site custom styles
if ( $wgUseSiteCss ) {
$out->addModuleStyles( array( 'site', 'noscript' ) );
- if( $wgUser->isLoggedIn() ){
+ if( $this->getContext()->getUser()->isLoggedIn() ){
$out->addModuleStyles( 'user.groups' );
}
}
// Per-user custom styles
if ( $wgAllowUserCss ) {
- if ( $this->mTitle->isCssSubpage() && $this->userCanPreview( $wgRequest->getVal( 'action' ) ) ) {
+ if ( $this->getTitle()->isCssSubpage() && $this->userCanPreview( $this->getContext()->getRequest()->getVal( 'action' ) ) ) {
// @FIXME: properly escape the cdata!
- $out->addInlineStyle( $wgRequest->getText( 'wpTextbox1' ) );
+ $out->addInlineStyle( $this->getContext()->getRequest()->getText( 'wpTextbox1' ) );
} else {
$out->addModuleStyles( 'user' );
}
* The format without an explicit $out argument is deprecated
*/
function getCategoryLinks( OutputPage $out=null ) {
- global $wgUseCategoryBrowser, $wgContLang, $wgUser;
-
- if ( is_null( $out ) ) {
- // Backwards compatibility for when there was no $out arg
- global $wgOut;
- $out = $wgOut;
- }
+ global $wgUseCategoryBrowser, $wgContLang;
if ( count( $out->mCategoryLinks ) == 0 ) {
return '';
# Hidden categories
if ( isset( $allCats['hidden'] ) ) {
- if ( $wgUser->getBoolOption( 'showhiddencats' ) ) {
+ if ( $this->getContext()->getUser()->getBoolOption( 'showhiddencats' ) ) {
$class = 'mw-hidden-cats-user-shown';
- } elseif ( $this->mTitle->getNamespace() == NS_CATEGORY ) {
+ } elseif ( $this->getTitle()->getNamespace() == NS_CATEGORY ) {
$class = 'mw-hidden-cats-ns-shown';
} else {
$class = 'mw-hidden-cats-hidden';
$s .= '<br /><hr />';
# get a big array of the parents tree
- $parenttree = $this->mTitle->getParentCategoryTree();
+ $parenttree = $this->getTitle()->getParentCategoryTree();
# Skin object passed by reference cause it can not be
# accessed under the method subfunction drawCategoryBrowser
$tempout = explode( "\n", $this->drawCategoryBrowser( $parenttree, $this ) );
* the ->getCategories( $out ) form with whatout OutputPage is on hand
*/
function getCategories( OutputPage $out=null ) {
- if ( is_null( $out ) ) {
- // Backwards compatibility for when there was no $out arg
- global $wgOut;
- $out = $wgOut;
- }
$catlinks = $this->getCategoryLinks( $out );
$classes = 'catlinks';
- global $wgUser;
-
// Check what we're showing
$allCats = $out->getCategoryLinks();
- $showHidden = $wgUser->getBoolOption( 'showhiddencats' ) ||
- $this->mTitle->getNamespace() == NS_CATEGORY;
+ $showHidden = $this->getContext()->getUser()->getBoolOption( 'showhiddencats' ) ||
+ $this->getTitle()->getNamespace() == NS_CATEGORY;
if ( empty( $allCats['normal'] ) && !( !empty( $allCats['hidden'] ) && $showHidden ) ) {
$classes .= ' catlinks-allhidden';
/** @return string Retrievied from HTML text */
function printSource() {
- $url = htmlspecialchars( $this->mTitle->getFullURL() );
+ $url = htmlspecialchars( $this->getTitle()->getFullURL() );
return wfMsg( 'retrievedfrom', '<a href="' . $url . '">' . $url . '</a>' );
}
function getUndeleteLink() {
- global $wgUser, $wgLang, $wgRequest;
-
- $action = $wgRequest->getVal( 'action', 'view' );
+ $action = $this->getContext()->getRequest()->getVal( 'action', 'view' );
- if ( $wgUser->isAllowed( 'deletedhistory' ) &&
- ( $this->mTitle->getArticleId() == 0 || $action == 'history' ) ) {
- $n = $this->mTitle->isDeleted();
+ if ( $this->getContext()->getUser()->isAllowed( 'deletedhistory' ) &&
+ ( $this->getTitle()->getArticleId() == 0 || $action == 'history' ) ) {
+ $n = $this->getTitle()->isDeleted();
if ( $n ) {
- if ( $wgUser->isAllowed( 'undelete' ) ) {
+ if ( $this->getContext()->getUser()->isAllowed( 'undelete' ) ) {
$msg = 'thisisdeleted';
} else {
$msg = 'viewdeleted';
return wfMsg(
$msg,
$this->link(
- SpecialPage::getTitleFor( 'Undelete', $this->mTitle->getPrefixedDBkey() ),
- wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $wgLang->formatNum( $n ) ),
+ SpecialPage::getTitleFor( 'Undelete', $this->getTitle()->getPrefixedDBkey() ),
+ wfMsgExt( 'restorelink', array( 'parsemag', 'escape' ), $this->getContext()->getLang()->formatNum( $n ) ),
array(),
array(),
array( 'known', 'noclasses' )
* The format without an explicit $out argument is deprecated
*/
function subPageSubtitle( OutputPage $out=null ) {
- if ( is_null( $out ) ) {
- // Backwards compatibility for when there was no $out arg
- global $wgOut;
- $out = $wgOut;
- }
-
+ $out = $this->getContext()->getOutput();
$subpages = '';
if ( !wfRunHooks( 'SkinSubPageSubtitle', array( &$subpages, $this, $out ) ) ) {
}
if ( $out->isArticle() && MWNamespace::hasSubpages( $out->getTitle()->getNamespace() ) ) {
- $ptext = $this->mTitle->getPrefixedText();
+ $ptext = $this->getTitle()->getPrefixedText();
if ( preg_match( '/\//', $ptext ) ) {
$links = explode( '/', $ptext );
array_pop( $links );
}
function getCopyright( $type = 'detect' ) {
- global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgRequest;
+ global $wgRightsPage, $wgRightsUrl, $wgRightsText;
if ( $type == 'detect' ) {
- $diff = $wgRequest->getVal( 'diff' );
+ $diff = $this->getContext()->getRequest()->getVal( 'diff' );
if ( is_null( $diff ) && !$this->isRevisionCurrent() && wfMsgForContent( 'history_copyright' ) !== '-' ) {
$type = 'history';
// Allow for site and per-namespace customization of copyright notice.
$forContent = true;
- wfRunHooks( 'SkinCopyrightFooter', array( $this->mTitle, $type, &$msg, &$link, &$forContent ) );
+ wfRunHooks( 'SkinCopyrightFooter', array( $this->getTitle(), $type, &$msg, &$link, &$forContent ) );
if ( $forContent ) {
$out .= wfMsgForContent( $msg, $link );
* @return String
*/
protected function lastModified( $article ) {
- global $wgLang;
-
if ( !$this->isRevisionCurrent() ) {
- $timestamp = Revision::getTimestampFromId( $this->mTitle, $this->mRevisionId );
+ $timestamp = Revision::getTimestampFromId( $this->getTitle(), $this->mRevisionId );
} else {
$timestamp = $article->getTimestamp();
}
if ( $timestamp ) {
- $d = $wgLang->date( $timestamp, true );
- $t = $wgLang->time( $timestamp, true );
+ $d = $this->getContext()->getLang()->date( $timestamp, true );
+ $t = $this->getContext()->getLang()->time( $timestamp, true );
$s = ' ' . wfMsg( 'lastmodifiedat', $d, $t );
} else {
$s = '';
}
function showEmailUser( $id ) {
- global $wgUser;
$targetUser = User::newFromId( $id );
- return $wgUser->canSendEmail() && # the sending user must have a confirmed email address
+ return $this->getContext()->getUser()->canSendEmail() && # the sending user must have a confirmed email address
$targetUser->canReceiveEmail(); # the target user must have a confirmed email address and allow emails from users
}
*/
function buildSidebar() {
global $parserMemc, $wgEnableSidebarCache, $wgSidebarCacheExpiry;
- global $wgLang;
wfProfileIn( __METHOD__ );
- $key = wfMemcKey( 'sidebar', $wgLang->getCode() );
+ $key = wfMemcKey( 'sidebar', $this->getContext()->getLang()->getCode() );
if ( $wgEnableSidebarCache ) {
$cachedsidebar = $parserMemc->get( $key );
$line = trim( $line, '* ' );
if ( strpos( $line, '|' ) !== false ) { // sanity check
- $line = MessageCache::singleton()->transform( $line, false, null, $this->mTitle );
+ $line = MessageCache::singleton()->transform( $line, false, null, $this->getTitle() );
$line = array_map( 'trim', explode( '|', $line, 2 ) );
$link = wfMsgForContent( $line[0] );
$options = new ParserOptions();
$options->setEditSection( false );
$options->setInterfaceMessage( true );
- $wikiBar[$heading] = $wgParser->parse( wfMsgForContentNoTrans( $line ) , $this->mTitle, $options )->getText();
+ $wikiBar[$heading] = $wgParser->parse( wfMsgForContentNoTrans( $line ) , $this->getTitle(), $options )->getText();
} else {
continue;
}
/**
* Gets new talk page messages for the current user.
* @return MediaWiki message or if no new talk page messages, nothing
- * The format without an explicit $out argument is deprecated
*/
- function getNewtalks( OutputPage $out=null ) {
- global $wgUser;
-
- if ( is_null( $out ) ) {
- // Backwards compatibility for when there was no $out arg
- global $wgOut;
- $out = $wgOut;
- }
+ function getNewtalks() {
+ $out = $this->getContext()->getOutput();
- $newtalks = $wgUser->getNewMessageLinks();
+ $newtalks = $this->getContext()->getUser()->getNewMessageLinks();
$ntl = '';
if ( count( $newtalks ) == 1 && $newtalks[0]['wiki'] === wfWikiID() ) {
* @return String: HTML fragment
*/
private function getCachedNotice( $name ) {
- global $wgOut, $wgRenderHashAppend, $parserMemc;
+ global $wgRenderHashAppend, $parserMemc;
wfProfileIn( __METHOD__ );
}
if ( $needParse ) {
- if( is_object( $wgOut ) ) {
- $parsed = $wgOut->parse( $notice );
- $parserMemc->set( $key, array( 'html' => $parsed, 'hash' => md5( $notice ) ), 600 );
- $notice = $parsed;
- } else {
- wfDebug( 'Skin::getCachedNotice called for ' . $name . ' with no $wgOut available' . "\n" );
- $notice = '';
- }
+ $parsed = $this->getContext()->getOutput()->parse( $notice );
+ $parserMemc->set( $key, array( 'html' => $parsed, 'hash' => md5( $notice ) ), 600 );
+ $notice = $parsed;
}
$notice = '<div id="localNotice">' .$notice . '</div>';
function getNamespaceNotice() {
wfProfileIn( __METHOD__ );
- $key = 'namespacenotice-' . $this->mTitle->getNsText();
+ $key = 'namespacenotice-' . $this->getTitle()->getNsText();
$namespaceNotice = $this->getCachedNotice( $key );
if ( $namespaceNotice && substr( $namespaceNotice, 0, 7 ) != '<p><' ) {
$namespaceNotice = '<div id="namespacebanner">' . $namespaceNotice . '</div>';
* @return String: HTML fragment
*/
function getSiteNotice() {
- global $wgUser;
-
wfProfileIn( __METHOD__ );
$siteNotice = '';
if ( wfRunHooks( 'SiteNoticeBefore', array( &$siteNotice, $this ) ) ) {
- if ( is_object( $wgUser ) && $wgUser->isLoggedIn() ) {
+ if ( is_object( $this->getContext()->getUser() ) && $this->getContext()->getUser()->isLoggedIn() ) {
$siteNotice = $this->getCachedNotice( 'sitenotice' );
} else {
$anonNotice = $this->getCachedNotice( 'anonnotice' );
wfProfileOut( __METHOD__ . '-init' );
wfProfileIn( __METHOD__ . '-stuff' );
- $this->thispage = $this->mTitle->getPrefixedDBkey();
- $this->thisurl = $this->mTitle->getPrefixedURL();
+ $this->thispage = $this->getTitle()->getPrefixedDBkey();
+ $this->thisurl = $this->getTitle()->getPrefixedURL();
$query = array();
if ( !$wgRequest->wasPosted() ) {
$query = $wgRequest->getValues();
}
$this->thisquery = wfUrlencode( wfArrayToCGI( $query ) );
$this->loggedin = $wgUser->isLoggedIn();
- $this->iscontent = ( $this->mTitle->getNamespace() != NS_SPECIAL );
+ $this->iscontent = ( $this->getTitle()->getNamespace() != NS_SPECIAL );
$this->iseditable = ( $this->iscontent and !( $action == 'edit' or $action == 'submit' ) );
$this->username = $wgUser->getName();
$this->userpageUrlDetails = self::makeKnownUrlDetails( $this->userpage );
}
- $this->titletxt = $this->mTitle->getPrefixedText();
+ $this->titletxt = $this->getTitle()->getPrefixedText();
wfProfileOut( __METHOD__ . '-stuff' );
wfProfileIn( __METHOD__ . '-stuff-head' );
$tpl->set( 'title', $out->getPageTitle() );
$tpl->set( 'pagetitle', $out->getHTMLTitle() );
$tpl->set( 'displaytitle', $out->mPageLinkTitle );
- $tpl->set( 'pageclass', $this->getPageClasses( $this->mTitle ) );
+ $tpl->set( 'pageclass', $this->getPageClasses( $this->getTitle() ) );
$tpl->set( 'skinnameclass', ( 'skin-' . Sanitizer::escapeClass( $this->getSkinName() ) ) );
- $nsname = MWNamespace::exists( $this->mTitle->getNamespace() ) ?
- MWNamespace::getCanonicalName( $this->mTitle->getNamespace() ) :
- $this->mTitle->getNsText();
+ $nsname = MWNamespace::exists( $this->getTitle()->getNamespace() ) ?
+ MWNamespace::getCanonicalName( $this->getTitle()->getNamespace() ) :
+ $this->getTitle()->getNsText();
$tpl->set( 'nscanonical', $nsname );
- $tpl->set( 'nsnumber', $this->mTitle->getNamespace() );
- $tpl->set( 'titleprefixeddbkey', $this->mTitle->getPrefixedDBKey() );
- $tpl->set( 'titletext', $this->mTitle->getText() );
- $tpl->set( 'articleid', $this->mTitle->getArticleId() );
- $tpl->set( 'currevisionid', $this->mTitle->getLatestRevID() );
+ $tpl->set( 'nsnumber', $this->getTitle()->getNamespace() );
+ $tpl->set( 'titleprefixeddbkey', $this->getTitle()->getPrefixedDBKey() );
+ $tpl->set( 'titletext', $this->getTitle()->getText() );
+ $tpl->set( 'articleid', $this->getTitle()->getArticleId() );
+ $tpl->set( 'currevisionid', $this->getTitle()->getLatestRevID() );
$tpl->set( 'isarticle', $out->isArticle() );
$tpl->set( 'printable', $out->isPrintable() );
$tpl->set( 'handheld', $wgRequest->getBool( 'handheld' ) );
$tpl->setRef( 'loggedin', $this->loggedin );
- $tpl->set( 'notspecialpage', $this->mTitle->getNamespace() != NS_SPECIAL );
+ $tpl->set( 'notspecialpage', $this->getTitle()->getNamespace() != NS_SPECIAL );
/* XXX currently unused, might get useful later
- $tpl->set( 'editable', ( $this->mTitle->getNamespace() != NS_SPECIAL ) );
- $tpl->set( 'exists', $this->mTitle->getArticleID() != 0 );
- $tpl->set( 'watch', $this->mTitle->userIsWatching() ? 'unwatch' : 'watch' );
- $tpl->set( 'protect', count( $this->mTitle->isProtected() ) ? 'unprotect' : 'protect' );
+ $tpl->set( 'editable', ( $this->getTitle()->getNamespace() != NS_SPECIAL ) );
+ $tpl->set( 'exists', $this->getTitle()->getArticleID() != 0 );
+ $tpl->set( 'watch', $this->getTitle()->userIsWatching() ? 'unwatch' : 'watch' );
+ $tpl->set( 'protect', count( $this->getTitle()->isProtected() ) ? 'unprotect' : 'protect' );
$tpl->set( 'helppage', wfMsg( 'helppage' ) );
*/
$tpl->set( 'searchaction', $this->escapeSearchLink() );
// The content of SpecialPages should be presented in the
// user's language. Content of regular pages should not be touched.
- if( $this->mTitle->isSpecialPage() ) {
+ if( $this->getTitle()->isSpecialPage() ) {
$tpl->set( 'specialpageattributes', $attrs );
}
}
$tpl->setRef( 'skin', $this );
$tpl->set( 'logo', $this->logoText() );
if ( $out->isArticle() && ( !isset( $oldid ) || isset( $diff ) ) &&
- $this->mTitle->exists() )
+ $this->getTitle()->exists() )
{
- $article = new Article( $this->mTitle, 0 );
+ $article = new Article( $this->getTitle(), 0 );
if ( !$wgDisableCounters ) {
$viewcount = $wgLang->formatNum( $article->getCount() );
if ( $viewcount ) {
$dbr = wfGetDB( DB_SLAVE );
$res = $dbr->select( 'watchlist',
array( 'COUNT(*) AS n' ),
- array( 'wl_title' => $dbr->strencode( $this->mTitle->getDBkey() ), 'wl_namespace' => $this->mTitle->getNamespace() ),
+ array( 'wl_title' => $dbr->strencode( $this->getTitle()->getDBkey() ), 'wl_namespace' => $this->getTitle()->getNamespace() ),
__METHOD__
);
$x = $dbr->fetchObject( $res );
wfProfileIn( __METHOD__ );
$title = $this->getRelevantTitle(); // Display tabs for the relevant title rather than always the title itself
- $onPage = $title->equals($this->mTitle);
+ $onPage = $title->equals($this->getTitle());
$content_navigation = array(
'namespaces' => array(),
if ( $title->quickUserCan( 'move' ) ) {
$moveTitle = SpecialPage::getTitleFor( 'Movepage', $title->getPrefixedDBkey() );
$content_navigation['actions']['move'] = array(
- 'class' => $this->mTitle->isSpecial( 'Movepage' ) ? 'selected' : false,
+ 'class' => $this->getTitle()->isSpecial( 'Movepage' ) ? 'selected' : false,
'text' => wfMessageFallback( "$skname-action-move", 'move' )->text(),
'href' => $moveTitle->getLocalURL()
);
// If the user can't undelete but can view deleted history show them a "View .. deleted" tab instead
$msgKey = $wgUser->isAllowed( 'undelete' ) ? 'undelete' : 'viewdeleted';
$content_navigation['actions']['undelete'] = array(
- 'class' => $this->mTitle->isSpecial( 'Undelete' ) ? 'selected' : false,
+ 'class' => $this->getTitle()->isSpecial( 'Undelete' ) ? 'selected' : false,
'text' => wfMessageFallback( "$skname-action-$msgKey", "{$msgKey}_short" )
->params( $wgLang->formatNum( $n ) )->text(),
'href' => $undelTitle->getLocalURL( array( 'target' => $title->getPrefixedDBkey() ) )
if ( !$out->isPrintable() ) {
$nav_urls['print'] = array(
'text' => wfMsg( 'printableversion' ),
- 'href' => $this->mTitle->getLocalURL( $wgRequest->appendQueryValue( 'printable', 'yes', true ) )
+ 'href' => $this->getTitle()->getLocalURL( $wgRequest->appendQueryValue( 'printable', 'yes', true ) )
);
}
wfRunHooks( 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink', array( &$this, &$nav_urls, &$revid, &$revid ) );
}
- if( $this->mTitle->getNamespace() != NS_SPECIAL ) {
+ if( $this->getTitle()->getNamespace() != NS_SPECIAL ) {
$wlhTitle = SpecialPage::getTitleFor( 'Whatlinkshere', $this->thispage );
$nav_urls['whatlinkshere'] = array(
'href' => $wlhTitle->getLocalUrl()
);
- if( $this->mTitle->getArticleId() ) {
+ if( $this->getTitle()->getArticleId() ) {
$rclTitle = SpecialPage::getTitleFor( 'Recentchangeslinked', $this->thispage );
$nav_urls['recentchangeslinked'] = array(
'href' => $rclTitle->getLocalUrl()
* @private
*/
function getNameSpaceKey() {
- return $this->mTitle->getNamespaceKey();
+ return $this->getTitle()->getNamespaceKey();
}
/**
$action = $wgRequest->getVal( 'action', 'view' );
if( $allowUserJs && $this->loggedin ) {
- if( $this->mTitle->isJsSubpage() and $this->userCanPreview( $action ) ) {
+ if( $this->getTitle()->isJsSubpage() and $this->userCanPreview( $action ) ) {
# XXX: additional security check/prompt?
$this->userjsprev = '/*<![CDATA[*/ ' . $wgRequest->getText( 'wpTextbox1' ) . ' /*]]>*/';
} else {
}
/**
- * Get the current skin, loading it if required, and setting a title
- * @param $t Title: the title to use in the skin
+ * Get the current skin, loading it if required
* @return Skin The current skin
* @todo: FIXME : need to check the old failback system [AV]
+ * @deprecated Use ->getSkin() in the most relevant outputting context you have
*/
- function getSkin( $t = null ) {
- if( !$this->mSkin ) {
- global $wgOut;
- $this->mSkin = $this->createSkinObject();
- $this->mSkin->setTitle( $wgOut->getTitle() );
- }
- if ( $t && ( !$this->mSkin->getTitle() || !$t->equals( $this->mSkin->getTitle() ) ) ) {
- $skin = $this->createSkinObject();
- $skin->setTitle( $t );
- return $skin;
- } else {
- return $this->mSkin;
- }
- }
-
- // Creates a Skin object, for getSkin()
- private function createSkinObject() {
- wfProfileIn( __METHOD__ );
-
- global $wgHiddenPrefs;
- if( !in_array( 'skin', $wgHiddenPrefs ) ) {
- global $wgRequest;
- # get the user skin
- $userSkin = $this->getOption( 'skin' );
- $userSkin = $wgRequest->getVal( 'useskin', $userSkin );
- } else {
- # if we're not allowing users to override, then use the default
- global $wgDefaultSkin;
- $userSkin = $wgDefaultSkin;
- }
-
- $skin = Skin::newFromKey( $userSkin );
- wfProfileOut( __METHOD__ );
-
- return $skin;
+ function getSkin() {
+ return RequestContext::getMain()->getSkin();
}
/**