summaryrefslogtreecommitdiff
path: root/includes/RawPage.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2009-02-22 13:37:51 +0100
committerPierre Schmitz <pierre@archlinux.de>2009-02-22 13:37:51 +0100
commitb9b85843572bf283f48285001e276ba7e61b63f6 (patch)
tree4c6f4571552ada9ccfb4030481dcf77308f8b254 /includes/RawPage.php
parentd9a20acc4e789cca747ad360d87ee3f3e7aa58c1 (diff)
updated to MediaWiki 1.14.0
Diffstat (limited to 'includes/RawPage.php')
-rw-r--r--includes/RawPage.php62
1 files changed, 38 insertions, 24 deletions
diff --git a/includes/RawPage.php b/includes/RawPage.php
index b1e2539a..7093367f 100644
--- a/includes/RawPage.php
+++ b/includes/RawPage.php
@@ -21,20 +21,20 @@ class RawPage {
var $mContentType, $mExpandTemplates;
function __construct( &$article, $request = false ) {
- global $wgRequest, $wgInputEncoding, $wgSquidMaxage, $wgJsMimeType, $wgForcedRawSMaxage, $wgGroupPermissions;
+ global $wgRequest, $wgInputEncoding, $wgSquidMaxage, $wgJsMimeType, $wgGroupPermissions;
$allowedCTypes = array('text/x-wiki', $wgJsMimeType, 'text/css', 'application/x-zope-edit');
$this->mArticle =& $article;
$this->mTitle =& $article->mTitle;
- if ( $request === false ) {
+ if( $request === false ) {
$this->mRequest =& $wgRequest;
} else {
$this->mRequest = $request;
}
$ctype = $this->mRequest->getVal( 'ctype' );
- $smaxage = $this->mRequest->getIntOrNull( 'smaxage', $wgSquidMaxage );
+ $smaxage = $this->mRequest->getIntOrNull( 'smaxage' );
$maxage = $this->mRequest->getInt( 'maxage', $wgSquidMaxage );
$this->mExpandTemplates = $this->mRequest->getVal( 'templates' ) === 'expand';
@@ -44,17 +44,17 @@ class RawPage {
$oldid = $this->mRequest->getInt( 'oldid' );
- switch ( $wgRequest->getText( 'direction' ) ) {
+ switch( $wgRequest->getText( 'direction' ) ) {
case 'next':
# output next revision, or nothing if there isn't one
- if ( $oldid ) {
+ if( $oldid ) {
$oldid = $this->mTitle->getNextRevisionId( $oldid );
}
$oldid = $oldid ? $oldid : -1;
break;
case 'prev':
# output previous revision, or nothing if there isn't one
- if ( ! $oldid ) {
+ if( ! $oldid ) {
# get the current revision so we can get the penultimate one
$this->mArticle->getTouched();
$oldid = $this->mArticle->mLatest;
@@ -71,11 +71,11 @@ class RawPage {
# special case for 'generated' raw things: user css/js
$gen = $this->mRequest->getVal( 'gen' );
- if($gen == 'css') {
+ if( $gen == 'css' ) {
$this->mGen = $gen;
if( is_null( $smaxage ) ) $smaxage = $wgSquidMaxage;
if($ctype == '') $ctype = 'text/css';
- } elseif ($gen == 'js') {
+ } elseif( $gen == 'js' ) {
$this->mGen = $gen;
if( is_null( $smaxage ) ) $smaxage = $wgSquidMaxage;
if($ctype == '') $ctype = $wgJsMimeType;
@@ -85,7 +85,8 @@ class RawPage {
$this->mCharset = $wgInputEncoding;
# Force caching for CSS and JS raw content, default: 5 minutes
- if (is_null($smaxage) and ($ctype=='text/css' or $ctype==$wgJsMimeType)) {
+ if( is_null($smaxage) and ($ctype=='text/css' or $ctype==$wgJsMimeType) ) {
+ global $wgForcedRawSMaxage;
$this->mSmaxage = intval($wgForcedRawSMaxage);
} else {
$this->mSmaxage = intval( $smaxage );
@@ -94,14 +95,13 @@ class RawPage {
# Output may contain user-specific data;
# vary generated content for open sessions and private wikis
- if ($this->mGen or !$wgGroupPermissions['*']['read']) {
- $this->mPrivateCache = ( $this->mSmaxage == 0 ) ||
- ( session_id() != '' );
+ if( $this->mGen or !$wgGroupPermissions['*']['read'] ) {
+ $this->mPrivateCache = $this->mSmaxage == 0 || session_id() != '';
} else {
$this->mPrivateCache = false;
}
- if ( $ctype == '' or ! in_array( $ctype, $allowedCTypes ) ) {
+ if( $ctype == '' or ! in_array( $ctype, $allowedCTypes ) ) {
$this->mContentType = 'text/x-wiki';
} else {
$this->mContentType = $ctype;
@@ -149,6 +149,18 @@ class RawPage {
# allow the client to cache this for 24 hours
$mode = $this->mPrivateCache ? 'private' : 'public';
header( 'Cache-Control: '.$mode.', s-maxage='.$this->mSmaxage.', max-age='.$this->mMaxage );
+
+ if( HTMLFileCache::useFileCache() ) {
+ $cache = new HTMLFileCache( $this->mTitle, 'raw' );
+ if( $cache->isFileCacheGood( /* Assume up to date */ ) ) {
+ $cache->loadFromFileCache();
+ $wgOut->disable();
+ return;
+ } else {
+ ob_start( array(&$cache, 'saveToFileCache' ) );
+ }
+ }
+
$text = $this->getRawText();
if( !wfRunHooks( 'RawPageViewBeforeOutput', array( &$this, &$text ) ) ) {
@@ -161,13 +173,15 @@ class RawPage {
function getRawText() {
global $wgUser, $wgOut, $wgRequest;
- if($this->mGen) {
+ if( $this->mGen ) {
$sk = $wgUser->getSkin();
- $sk->initPage($wgOut);
- if($this->mGen == 'css') {
- return $sk->getUserStylesheet();
- } else if($this->mGen == 'js') {
- return $sk->getUserJs();
+ if( !StubObject::isRealObject( $wgOut ) )
+ $wgOut->_unstub( 2 );
+ $sk->initPage( $wgOut );
+ if( $this->mGen == 'css' ) {
+ return $sk->generateUserStylesheet();
+ } else if( $this->mGen == 'js' ) {
+ return $sk->generateUserJs();
}
} else {
return $this->getArticleText();
@@ -179,7 +193,7 @@ class RawPage {
$text = '';
if( $this->mTitle ) {
// If it's a MediaWiki message we can just hit the message cache
- if ( $this->mUseMessageCache && $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
+ if( $this->mUseMessageCache && $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
$key = $this->mTitle->getDBkey();
$text = wfMsgForContentNoTrans( $key );
# If the message doesn't exist, return a blank
@@ -189,11 +203,11 @@ class RawPage {
} else {
// Get it from the DB
$rev = Revision::newFromTitle( $this->mTitle, $this->mOldId );
- if ( $rev ) {
+ if( $rev ) {
$lastmod = wfTimestamp( TS_RFC2822, $rev->getTimestamp() );
header( "Last-modified: $lastmod" );
- if ( !is_null($this->mSection ) ) {
+ if( !is_null($this->mSection ) ) {
global $wgParser;
$text = $wgParser->getSection ( $rev->getText(), $this->mSection );
} else
@@ -230,10 +244,10 @@ class RawPage {
}
function parseArticleText( $text ) {
- if ( $text === '' )
+ if( $text === '' )
return '';
else
- if ( $this->mExpandTemplates ) {
+ if( $this->mExpandTemplates ) {
global $wgParser;
return $wgParser->preprocess( $text, $this->mTitle, new ParserOptions() );
} else