From b185adf24ffd48b63435c678089fdbad3e6fe395 Mon Sep 17 00:00:00 2001 From: Daniel Friesen Date: Sun, 3 Apr 2011 12:46:36 +0000 Subject: [PATCH] Continue with r85240; Move getSkin from User to RequestContext, do it without globals, strip out the non-functional $title related stuff, and update Skin to use a RequestContext. --- includes/OutputPage.php | 82 +++++++++-------- includes/RequestContext.php | 22 ++++- includes/Skin.php | 178 +++++++++++++++--------------------- includes/SkinTemplate.php | 60 ++++++------ includes/User.php | 41 +-------- 5 files changed, 168 insertions(+), 215 deletions(-) diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 60057b5fe7..1d821552ff 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -552,7 +552,7 @@ class OutputPage { * @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" ); @@ -619,7 +619,7 @@ class OutputPage { # 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(); @@ -773,6 +773,16 @@ class OutputPage { 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 * @@ -1546,9 +1556,9 @@ class OutputPage { * @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; } /** @@ -1558,8 +1568,7 @@ class OutputPage { * @return Boolean */ function haveCacheVaryCookies() { - global $wgRequest; - $cookieHeader = $wgRequest->getHeader( 'cookie' ); + $cookieHeader = $this->getRequest()->getHeader( 'cookie' ); if ( $cookieHeader === false ) { return false; } @@ -1632,8 +1641,8 @@ class OutputPage { * /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 ) { @@ -1696,9 +1705,9 @@ class OutputPage { * 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" ); } @@ -1824,7 +1833,7 @@ class OutputPage { * the object, let's actually output it: */ public function output() { - global $wgOutputEncoding, $wgRequest; + global $wgOutputEncoding; global $wgLanguageCode, $wgDebugRedirects, $wgMimeType; if( $this->mDoNothing ) { @@ -1833,7 +1842,7 @@ class OutputPage { wfProfileIn( __METHOD__ ); - $response = $wgRequest->response(); + $response = $this->getRequest()->response(); if ( $this->mRedirect != '' ) { # Standards require redirect URLs to be absolute @@ -1924,7 +1933,7 @@ class OutputPage { * @return nothing */ function blockedPage( $return = true ) { - global $wgContLang, $wgLang; + global $wgContLang; $this->setPageTitle( wfMsg( 'blockedtitle' ) ); $this->setRobotPolicy( 'noindex,nofollow' ); @@ -1935,7 +1944,7 @@ class OutputPage { if( $reason == '' ) { $reason = wfMsg( 'blockednoreason' ); } - $blockTimestamp = $wgLang->timeanddate( + $blockTimestamp = $this->getContext()->getLang()->timeanddate( wfTimestamp( TS_MW, $this->getUser()->mBlock->mTimestamp ), true ); $ip = wfGetIP(); @@ -1944,7 +1953,7 @@ class OutputPage { $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'; @@ -2034,8 +2043,6 @@ class OutputPage { * @param $permission String: key required */ public function permissionRequired( $permission ) { - global $wgLang; - $this->setPageTitle( wfMsg( 'badaccess' ) ); $this->setHTMLTitle( wfMsg( 'errorpagetitle' ) ); $this->setRobotPolicy( 'noindex,nofollow' ); @@ -2047,7 +2054,7 @@ class OutputPage { if( $groups ) { $this->addWikiMsg( 'badaccess-groups', - $wgLang->commaList( $groups ), + $this->getContext()->getLang()->commaList( $groups ), count( $groups ) ); } else { @@ -2279,14 +2286,12 @@ class OutputPage { * @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 === '' ) { @@ -2313,7 +2318,6 @@ class OutputPage { public function headElement( Skin $sk, $includeStyle = true ) { global $wgOutputEncoding, $wgMimeType; global $wgUseTrackbacks, $wgHtml5; - global $wgRequest, $wgLang; if ( $sk->commonPrintStylesheet() ) { $this->addModuleStyles( 'mediawiki.legacy.wikiprintable' ); @@ -2353,7 +2357,7 @@ class OutputPage { $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 && @@ -2368,7 +2372,7 @@ class OutputPage { $dir = wfUILang()->getDir(); $bodyAttrs['class'] = "mediawiki $dir"; - if ( $wgLang->capitalizeAllNouns() ) { + if ( $this->getContext()->getLang()->capitalizeAllNouns() ) { # A class is probably not the best way to do this . . . $bodyAttrs['class'] .= ' capitalize-all-nouns'; } @@ -2437,13 +2441,13 @@ class OutputPage { * @return string html