diff options
author | nobody <nobody@localhost> | 2004-06-27 00:05:32 +0000 |
---|---|---|
committer | nobody <nobody@localhost> | 2004-06-27 00:05:32 +0000 |
commit | 0c1d741ff4792d486258b390cf50cf3f9e229511 (patch) | |
tree | 55961c46b433ade0739763bee2ba3c4843d13751 /includes/RawPage.php | |
parent | d5c8171a3157337557bc54ecb730d7dd35778ca3 (diff) | |
parent | 1aaed5fd7c7f4d7ea7abbfc7915bab5954d60a30 (diff) | |
download | mediawikicore-1.3.0beta4a.tar.gz mediawikicore-1.3.0beta4a.zip |
This commit was manufactured by cvs2svn to create tag1.3.0beta4a
'REL1_3_0beta4a'.
Diffstat (limited to 'includes/RawPage.php')
-rw-r--r-- | includes/RawPage.php | 56 |
1 files changed, 47 insertions, 9 deletions
diff --git a/includes/RawPage.php b/includes/RawPage.php index b218612a9637..4116f005667c 100644 --- a/includes/RawPage.php +++ b/includes/RawPage.php @@ -8,36 +8,74 @@ class RawPage { function RawPage( $article ) { - global $wgRequest, $wgInputEncoding; + global $wgRequest, $wgInputEncoding, $wgSquidMaxage; $allowedCTypes = array('text/x-wiki', 'text/javascript', 'text/css', 'application/x-zope-edit'); $this->mArticle =& $article; $this->mTitle =& $article->mTitle; + $ctype = $wgRequest->getText( 'ctype' ); + $charset = $wgRequest->getText( 'charset' ); + $smaxage = $wgRequest->getText( 'smaxage' ); + $maxage = $wgRequest->getText( 'maxage' ); + $this->mOldId = $wgRequest->getInt( 'oldid' ); + # special case for 'generated' raw things: user css/js + $gen = $wgRequest->getText( 'gen' ); + if($gen == 'css') { + $this->mGen = $gen; + if($smaxage == '') $smaxage = $wgSquidMaxage; + if($ctype == '') $ctype = 'text/css'; + } else if ($gen == 'js') { + $this->mGen = $gen; + if($smaxage == '') $smaxage = $wgSquidMaxage; + if($ctype == '') $ctype = 'text/javascript'; + } else { + $this->mGen = false; + } + $this->mCharset = !empty($charset) ? $charset : $wgInputEncoding; + $this->mSmaxage = ($smaxage != '') ? $smaxage : 0; + $this->mMaxage = ($maxage != '') ? $maxage : 86400; if(empty($ctype) or !in_array($ctype, $allowedCTypes)) { $this->mContentType = 'text/x-wiki'; } else { $this->mContentType = $ctype; } - - $charset = $wgRequest->getText( 'charset' ); - $this->mCharset = !empty($charset) ? $charset : $wgInputEncoding; - $this->mOldId = $wgRequest->getInt( 'oldid' ); } function view() { + global $wgUser, $wgOut; header( "Content-type: ".$this->mContentType.'; charset='.$this->mCharset ); # allow the client to cache this for 24 hours - header( 'Cache-Control: s-maxage=0, max-age=86400' ); - echo $this->getrawtext(); + header( 'Cache-Control: s-maxage='.$this->mSmaxage.', max-age='.$this->mMaxage ); + if($this->mGen) { + $sk = $wgUser->getSkin(); + $sk->initPage($wgOut); + if($this->mGen == 'css') { + echo $sk->getUserStylesheet(); + } else if($this->mGen == 'js') { + echo $sk->getUserJs(); + } + } else { + echo $this->getrawtext(); + } wfAbruptExit(); } function getrawtext () { - global $wgInputEncoding, $wgLang; + global $wgInputEncoding, $wgLang, $wgIsPg; if( !$this->mTitle ) return ''; $t = wfStrencode( $this->mTitle->getDBKey() ); $ns = $this->mTitle->getNamespace(); + # special case + if($ns == NS_MEDIAWIKI) { + $rawtext = wfMsg($t); + if($wgInputEncoding != $this->mCharset) + $rawtext = $wgLang->iconv( $wgInputEncoding, $this->mCharset, $rawtext ); + return $rawtext; + } + # else get it from the DB if(!empty($this->mOldId)) { - $sql = "SELECT old_text as text,old_timestamp as timestamp,old_user as user,old_flags as flags FROM old " . + $oldtable=$wgIsPg?'"old"':'old'; + $sql = "SELECT old_text AS text,old_timestamp AS timestamp,". + "old_user AS user,old_flags AS flags FROM $oldtable " . "WHERE old_id={$this->mOldId}"; } else { $sql = "SELECT cur_id as id,cur_timestamp as timestamp,cur_user as user,cur_user_text as user_text," . |