<?php
/**
- * @version $Id$
* @package MediaWiki
*/
*/
function checkLastModified ( $timestamp ) {
global $wgLang, $wgCachePages, $wgUser;
- $timestamp=wfTimestamp(TS_MW,$timestamp);
- if( !$wgCachePages ) {
- wfDebug( "CACHE DISABLED\n", false );
+ if ( !$timestamp || $timestamp == '19700101000000' ) {
+ wfDebug( "CACHE DISABLED, NO TIMESTAMP\n" );
return;
}
- if( preg_match( '/MSIE ([1-4]|5\.0)/', $_SERVER["HTTP_USER_AGENT"] ) ) {
- # IE 5.0 has probs with our caching
- wfDebug( "-- bad client, not caching\n", false );
+ if( !$wgCachePages ) {
+ wfDebug( "CACHE DISABLED\n", false );
return;
}
if( $wgUser->getOption( 'nocache' ) ) {
return;
}
- $lastmod = gmdate( 'D, j M Y H:i:s', wfTimestamp(TS_UNIX, max( $timestamp, $wgUser->mTouched ) ) ) . ' GMT';
+ $timestamp=wfTimestamp(TS_MW,$timestamp);
+ $lastmod = wfTimestamp( TS_RFC2822, max( $timestamp, $wgUser->mTouched ) );
if( !empty( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) {
# IE sends sizes after the date like this:
$ismodsince = wfTimestamp( TS_MW, strtotime( $modsince ) );
wfDebug( "-- client send If-Modified-Since: " . $modsince . "\n", false );
wfDebug( "-- we might send Last-Modified : $lastmod\n", false );
- if( ($ismodsince >= $timestamp ) and $wgUser->validateCache( $ismodsince ) ) {
+ if( ($ismodsince >= $timestamp ) && $wgUser->validateCache( $ismodsince ) ) {
# Make sure you're in a place you can leave when you call us!
header( "HTTP/1.0 304 Not Modified" );
$this->mLastModified = $lastmod;
$this->mLastModified = $lastmod;
}
} else {
- wfDebug( "We're confused.\n", false );
+ wfDebug( "client did not send If-Modified-Since header\n", false );
$this->mLastModified = $lastmod;
}
}
$this->addHTML( $text );
}
+ /**
+ * Add the output of a QuickTemplate to the output buffer
+ * @param QuickTemplate $template
+ */
+ function addTemplate( &$template ) {
+ ob_start();
+ $template->execute();
+ $this->addHtml( ob_get_contents() );
+ ob_end_clean();
+ }
+
+ /**
+ * Parse wikitext and return the HTML. This is for special pages that add the text later
+ */
+ function parse( $text, $linestart = true ) {
+ global $wgParser, $wgTitle;
+ $parserOutput = $wgParser->parse( $text, $wgTitle, $this->mParserOptions, $linestart );
+ return $parserOutput->getText();
+ }
+
/**
* @param $article
* @param $user
function sendCacheControl() {
global $wgUseSquid, $wgUseESI;
- # FIXME: This header may cause trouble with some versions of Internet Explorer
+ # don't serve compressed data to clients who can't handle it
+ # maintain different caches for logged-in users and non-logged in ones
header( 'Vary: Accept-Encoding, Cookie' );
if( $this->mEnableClientCache ) {
if( $wgUseSquid && ! isset( $_COOKIE[ini_get( 'session.name') ] ) &&
if( !$wgDebugRedirects ) {
header("HTTP/1.1 {$this->mRedirectCode} Moved Permanently");
}
- $this->mLastModified = gmdate( 'D, j M Y H:i:s' ) . ' GMT';
+ $this->mLastModified = wfTimestamp( TS_RFC2822 );
}
$this->sendCacheControl();
}
- $this->sendCacheControl();
+ # Buffer output; final headers may depend on later processing
+ ob_start();
+
$this->transformBuffer();
# Disable temporary placeholders, so that the skin produces HTML
setcookie( $name, $val, $exp, '/' );
}
+ wfProfileIn( 'Output-skin' );
$sk->outputPage( $this );
- # flush();
+ wfProfileOut( 'Output-skin' );
+
+ $this->sendCacheControl();
+ ob_end_flush();
}
function out( $ins ) {
$this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
$this->setRobotpolicy( 'noindex,nofollow' );
$this->setArticleRelated( false );
- $this->suppressQuickbar();
-
$this->enableClientCache( false );
$this->mRedirect = '';
}
function databaseError( $fname, $sql, $error, $errno ) {
- global $wgUser, $wgCommandLineMode;
+ global $wgUser, $wgCommandLineMode, $wgShowSQLErrors;
$this->setPageTitle( wfMsgNoDB( 'databaseerror' ) );
$this->setRobotpolicy( 'noindex,nofollow' );
$this->enableClientCache( false );
$this->mRedirect = '';
- if ( $wgCommandLineMode ) {
- $msg = wfMsgNoDB( 'dberrortextcl', htmlspecialchars( $sql ),
- htmlspecialchars( $fname ), $errno, htmlspecialchars( $error ) );
+ if( $wgShowSQLErrors ) {
+ if ( $wgCommandLineMode ) {
+ $msg = wfMsgNoDB( 'dberrortextcl', htmlspecialchars( $sql ),
+ htmlspecialchars( $fname ), $errno, htmlspecialchars( $error ) );
+ } else {
+ $msg = wfMsgNoDB( 'dberrortext', htmlspecialchars( $sql ),
+ htmlspecialchars( $fname ), $errno, htmlspecialchars( $error ) );
+ }
} else {
- $msg = wfMsgNoDB( 'dberrortext', htmlspecialchars( $sql ),
- htmlspecialchars( $fname ), $errno, htmlspecialchars( $error ) );
+ if( $wgCommandLineMode ) {
+ $msg = wfMsg( 'internalerror' );
+ } else {
+ $msg = htmlspecialchars( wfMsg( 'internalerror' ) );
+ }
}
if ( $wgCommandLineMode || !is_object( $wgUser )) {
global $wgDocType, $wgDTD, $wgContLanguageCode, $wgOutputEncoding, $wgMimeType;
global $wgUser, $wgContLang, $wgRequest;
- $xml = ($wgMimeType == 'text/xml');
- if( $xml ) {
+ if( $wgMimeType == 'text/xml' || $wgMimeType == 'application/xhtml+xml' || $wgMimeType == 'application/xml' ) {
$ret = "<" . "?xml version=\"1.0\" encoding=\"$wgOutputEncoding\" ?" . ">\n";
} else {
$ret = '';
if ( "" == $this->mHTMLtitle ) {
$this->mHTMLtitle = wfMsg( "pagetitle", $this->mPagetitle );
}
- if( $xml ) {
- $xmlbits = "xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\"";
- } else {
- $xmlbits = '';
- }
+
$rtl = $wgContLang->isRTL() ? " dir='RTL'" : '';
- $ret .= "<html $xmlbits lang=\"$wgContLanguageCode\" $rtl>\n";
+ $ret .= "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"$wgContLanguageCode\" lang=\"$wgContLanguageCode\" $rtl>\n";
$ret .= "<head>\n<title>" . htmlspecialchars( $this->mHTMLtitle ) . "</title>\n";
array_push( $this->mMetatags, array( "http:Content-type", "$wgMimeType; charset={$wgOutputEncoding}" ) );
$link = $wgRequest->escapeAppendQuery( 'feed=atom' );
$ret .= "<link rel='alternate' type='application/rss+atom' title='Atom 0.3' href='$link' />\n";
}
- # FIXME: get these working
- # $fix = htmlspecialchars( $wgStylePath . "/ie-png-fix.js" );
- # $ret .= "<!--[if gte IE 5.5000]><script type='text/javascript' src='$fix'>< /script><![endif]-->";
+
return $ret;
}
function transformBuffer( $options = 0 ) {
}
+
}
}