var $mIsArticleRelated;
var $mParserOptions;
var $mShowFeedLinks = false;
-
+ var $mEnableClientCache = true;
+
function OutputPage()
{
$this->mHeaders = $this->mCookies = $this->mMetatags =
# To add an http-equiv meta tag, precede the name with "http:"
function addMeta( $name, $val ) { array_push( $this->mMetatags, array( $name, $val ) ); }
function addKeyword( $text ) { array_push( $this->mKeywords, $text ); }
- function addLink( $rel, $rev, $target, $type="" ) { array_push( $this->mLinktags, array( $rel, $rev, $target, $type ) ); }
+ function addLink( $rel, $rev, $target, $type="", $media="" ) { array_push( $this->mLinktags, array( $rel, $rev, $target, $type, $media ) ); }
# checkLastModified tells the client to use the client-cached page if
# possible. If sucessful, the OutputPage is disabled so that
wfDebug( "USER DISABLED CACHE\n", false );
return;
}
-
- $lastmod = gmdate( "D, j M Y H:i:s", wfTimestamp2Unix(
- max( $timestamp, $wgUser->mTouched ) ) ) . " GMT";
-
- if( !empty( $_SERVER["HTTP_IF_MODIFIED_SINCE"] ) ) {
+
+ $lastmod = gmdate( "D, j M Y H:i:s", wfTimestamp2Unix(
+ max( $timestamp, $wgUser->mTouched ) ) ) . " GMT";
+
+ if( !empty( $_SERVER["HTTP_IF_MODIFIED_SINCE"] ) ) {
# IE sends sizes after the date like this:
# Wed, 20 Aug 2003 06:51:19 GMT; length=5202
# this breaks strtotime().
$this->mSquidMaxage = $maxage;
}
+ # Use enableClientCache(false) to force it to send nocache headers
+ function enableClientCache( $state ) {
+ return wfSetVar( $this->mEnableClientCache, $state );
+ }
+
function sendCacheControl() {
global $wgUseSquid, $wgUseESI;
# FIXME: This header may cause trouble with some versions of Internet Explorer
header( "Vary: Accept-Encoding, Cookie" );
- if( $this->mLastModified != "" ) {
+ if( $this->mEnableClientCache && $this->mLastModified != "" ) {
if( $wgUseSquid && ! isset( $_COOKIE[ini_get( "session.name") ] ) &&
! $this->isPrintable() )
{
header( "Last-modified: {$this->mLastModified}" );
} else {
wfDebug( "** no caching **\n", false );
+
+ # In general, the absence of a last modified header should be enough to prevent
+ # the client from using its cache. We send a few other things just to make sure.
header( "Expires: -1" );
- header( "Cache-Control: no-cache" );
+ header( "Cache-Control: no-cache, no-store, max-age=0, must-revalidate" );
header( "Pragma: no-cache" );
- header( "Last-modified: " . gmdate( "D, j M Y H:i:s" ) . " GMT" );
}
}
{
global $wgUser, $wgLang, $wgDebugComments, $wgCookieExpiration;
global $wgInputEncoding, $wgOutputEncoding, $wgLanguageCode;
- global $wgDebugRedirects;
+ global $wgDebugRedirects, $wgMimeType;
if( $this->mDoNothing ){
return;
}
$this->sendCacheControl();
- header( "Content-type: text/html; charset={$wgOutputEncoding}" );
+ header( "Content-type: $wgMimeType; charset={$wgOutputEncoding}" );
header( "Content-language: {$wgLanguageCode}" );
$exp = time() + $wgCookieExpiration;
$this->setPageTitle( wfMsg( $title ) );
$this->setRobotpolicy( "noindex,nofollow" );
$this->setArticleRelated( false );
+ $this->enableClientCache( false );
$this->mBodytext = "";
$this->addHTML( "<p>" . wfMsg( $msg ) . "\n" );
$this->setPageTitle( wfMsgNoDB( "databaseerror" ) );
$this->setRobotpolicy( "noindex,nofollow" );
$this->setArticleRelated( false );
+ $this->enableClientCache( false );
if ( $wgCommandLineMode ) {
$msg = wfMsgNoDB( "dberrortextcl" );
$this->setPageTitle( wfMsg( "internalerror" ) );
$this->setRobotpolicy( "noindex,nofollow" );
$this->setArticleRelated( false );
+ $this->enableClientCache( false );
$this->mBodytext = $message;
$this->output();
$this->fatalError( wfMsg( "filenotfound", $name ) );
}
- function returnToMain( $auto = true )
+ function returnToMain( $auto = true, $returnto = NULL )
{
- global $wgUser, $wgOut, $returnto;
+ global $wgUser, $wgOut, $wgRequest;
+
+ if ( $returnto == NULL ) {
+ $returnto = $wgRequest->getText( 'returnto' );
+ }
$sk = $wgUser->getSkin();
if ( "" == $returnto ) {
$titleObj = Title::newFromText( $returnto );
$wgOut->addMeta( "http:Refresh", "10;url=" . $titleObj->escapeFullURL() );
}
- $wgOut->addHTML( "\n<p>$r\n" );
+ $wgOut->addHTML( "\n<p>$r</p>\n" );
+ }
+
+ # This function takes the existing and broken links for the page
+ # and uses the first 10 of them for META keywords
+ function addMetaTags ()
+ {
+ global $wgLinkCache , $wgOut ;
+ $good = array_keys ( $wgLinkCache->mGoodLinks ) ;
+ $bad = array_keys ( $wgLinkCache->mBadLinks ) ;
+ $a = array_merge ( $good , $bad ) ;
+ $a = array_slice ( $a , 0 , 10 ) ; # 10 keywords max
+ $a = implode ( "," , $a ) ;
+ $wgOut->addMeta ( "KEYWORDS" , $a ) ;
}
/* private */ function headElement()
{
- global $wgDocType, $wgDTD, $wgUser, $wgLanguageCode, $wgOutputEncoding, $wgLang, $wgRequest;
+ global $wgDocType, $wgDTD, $wgLanguageCode, $wgOutputEncoding, $wgMimeType;
+ global $wgUser, $wgLang, $wgRequest;
- $ret = "<!DOCTYPE HTML PUBLIC \"$wgDocType\"\n \"$wgDTD\">\n";
+ $xml = ($wgMimeType == 'text/xml');
+ if( $xml ) {
+ $ret = "<" . "?xml version=\"1.0\" encoding=\"$wgOutputEncoding\" ?" . ">\n";
+ } else {
+ $ret = "";
+ }
+
+ $ret .= "<!DOCTYPE HTML PUBLIC \"$wgDocType\"\n \"$wgDTD\">\n";
if ( "" == $this->mHTMLtitle ) {
$this->mHTMLtitle = $this->mPagetitle;
}
+ if( $xml ) {
+ $xmlbits = "xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\"";
+ } else {
+ $xmlbits = "";
+ }
$rtl = $wgLang->isRTL() ? " dir='RTL'" : "";
- $ret .= "<html lang=\"$wgLanguageCode\"$rtl><head><title>{$this->mHTMLtitle}</title>\n";
- array_push( $this->mMetatags, array( "http:Content-type", "text/html; charset={$wgOutputEncoding}" ) );
+ $ret .= "<html $xmlbits lang=\"$wgLanguageCode\" $rtl>\n";
+ $ret .= "<head>\n<title>{$this->mHTMLtitle}</title>\n";
+ array_push( $this->mMetatags, array( "http:Content-type", "$wgMimeType; charset={$wgOutputEncoding}" ) );
foreach ( $this->mMetatags as $tag ) {
if ( 0 == strcasecmp( "http:", substr( $tag[0], 0, 5 ) ) ) {
$a = "http-equiv";
} else {
$a = "name";
}
- $ret .= "<meta $a=\"{$tag[0]}\" content=\"{$tag[1]}\">\n";
+ $ret .= "<meta $a=\"{$tag[0]}\" content=\"{$tag[1]}\" />\n";
}
$p = $this->mRobotpolicy;
if ( "" == $p ) { $p = "index,follow"; }
- $ret .= "<meta name=\"robots\" content=\"$p\">\n";
+ $ret .= "<meta name=\"robots\" content=\"$p\" />\n";
if ( count( $this->mKeywords ) > 0 ) {
$ret .= "<meta name=\"keywords\" content=\"" .
- implode( ",", $this->mKeywords ) . "\">\n";
+ implode( ",", $this->mKeywords ) . "\" />\n";
}
foreach ( $this->mLinktags as $tag ) {
$ret .= "<link ";
if ( "" != $tag[0] ) { $ret .= "rel=\"{$tag[0]}\" "; }
if ( "" != $tag[1] ) { $ret .= "rev=\"{$tag[1]}\" "; }
if ( !empty( $tag[3] ) ) { $ret .= "type=\"{$tag[3]}\" "; }
- $ret .= "href=\"{$tag[2]}\">\n";
+ if ( !empty( $tag[4] ) ) { $ret .= "media=\"{$tag[4]}\" "; }
+ $ret .= "href=\"{$tag[2]}\" />\n";
}
if( $this->isSyndicated() ) {
$link = $wgRequest->escapeAppendQuery( "feed=rss" );
- $ret .= "<link rel='alternate' type='application/rss+xml' title='RSS' href='$link'>\n";
+ $ret .= "<link rel='alternate' type='application/rss+xml' title='RSS' href='$link' />\n";
}
+ global $wgStyleSheetPath;
+ if( $this->isPrintable() ) {
+ $media = "";
+ } else {
+ $media = "media='print'";
+ }
+ $printsheet = htmlspecialchars( "$wgStyleSheetPath/wikiprintable.css" );
+ $ret .= "<link rel='stylesheet' type='text/css' $media href='$printsheet' />\n";
+
$sk = $wgUser->getSkin();
$ret .= $sk->getHeadScripts();
$ret .= $sk->getUserStyles();