<?php
+if ( ! defined( 'MEDIAWIKI' ) )
+ die( -1 );
/**
* @package MediaWiki
*/
-/**
- * This is not a valid entry point, perform no further processing unless MEDIAWIKI is defined
- */
-if( defined( 'MEDIAWIKI' ) ) {
-
-# See design.txt
-
-if($wgUseTeX) require_once( 'Math.php' );
+if ( $wgUseTeX )
+ require_once 'Math.php';
/**
* @todo document
function addHeader( $name, $val ) { array_push( $this->mHeaders, $name.': '.$val ) ; }
function redirect( $url, $responsecode = '302' ) { $this->mRedirect = $url; $this->mRedirectCode = $responsecode; }
function setStatusCode( $statusCode ) { $this->mStatusCode = $statusCode; }
-
+
# 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 ); }
* returns true iff cache-ok headers was sent.
*/
function checkLastModified ( $timestamp ) {
- global $wgCachePages, $wgUser;
+ global $wgCachePages, $wgCacheEpoch, $wgUser;
if ( !$timestamp || $timestamp == '19700101000000' ) {
wfDebug( "CACHE DISABLED, NO TIMESTAMP\n" );
return;
}
$timestamp=wfTimestamp(TS_MW,$timestamp);
- $lastmod = wfTimestamp( TS_RFC2822, max( $timestamp, $wgUser->mTouched ) );
+ $lastmod = wfTimestamp( TS_RFC2822, max( $timestamp, $wgUser->mTouched, $wgCacheEpoch ) );
if( !empty( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) {
# IE sends sizes after the date like this:
$ismodsince = wfTimestamp( TS_MW, $modsinceTime ? $modsinceTime : 1 );
wfDebug( "-- client send If-Modified-Since: " . $modsince . "\n", false );
wfDebug( "-- we might send Last-Modified : $lastmod\n", false );
- if( ($ismodsince >= $timestamp ) && $wgUser->validateCache( $ismodsince ) ) {
+ if( ($ismodsince >= $timestamp ) && $wgUser->validateCache( $ismodsince ) && $ismodsince >= $wgCacheEpoch ) {
# 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->sendCacheControl();
- wfDebug( "CACHED client: $ismodsince ; user: $wgUser->mTouched ; page: $timestamp\n", false );
+ wfDebug( "CACHED client: $ismodsince ; user: $wgUser->mTouched ; page: $timestamp ; site $wgCacheEpoch\n", false );
$this->disable();
@ob_end_clean(); // Don't output compressed blob
return true;
} else {
- wfDebug( "READY client: $ismodsince ; user: $wgUser->mTouched ; page: $timestamp\n", false );
+ wfDebug( "READY client: $ismodsince ; user: $wgUser->mTouched ; page: $timestamp ; site $wgCacheEpoch\n", false );
$this->mLastModified = $lastmod;
}
} else {
$name .= ' - '.$taction;
}
}
-
+
$this->setHTMLTitle( wfMsg( 'pagetitle', $name ) );
}
function getHTMLTitle() { return $this->mHTMLtitle; }
function ParserOptions( $options = null ) {
return wfSetVar( $this->mParserOptions, $options );
}
-
+
/**
* Set the revision ID which will be seen by the wiki text parser
* for things such as embedded {{REVISIONID}} variable use.
$this->enableClientCache( false );
}
}
-
+
function addParserOutput( &$parserOutput ) {
$this->addParserOutputNoText( $parserOutput );
$this->addHTML( $parserOutput->getText() );
function addPrimaryWikiText( $text, $article, $cache = true ) {
global $wgParser, $wgUser;
+ $this->mParserOptions->setTidy(true);
$parserOutput = $wgParser->parse( $text, $article->mTitle,
$this->mParserOptions, true, true, $this->mRevisionId );
-
- if ( $article && $parserOutput->getCacheTime() != -1 ) {
+ $this->mParserOptions->setTidy(false);
+ if ( $cache && $article && $parserOutput->getCacheTime() != -1 ) {
$parserCache =& ParserCache::singleton();
$parserCache->save( $parserOutput, $article, $wgUser );
}
- $this->addParserOutput( $parserOutput );
+ $this->addParserOutputNoText( $parserOutput );
+ $text = $parserOutput->getText();
+ wfRunHooks( 'OutputPageBeforeHTML',array( &$this, &$text ) );
+ $parserOutput->setText( $text );
+ $this->addHTML( $parserOutput->getText() );
}
+ /**
+ * For anything that isn't primary text or interface message
+ */
+ function addSecondaryWikiText( $text, $linestart = true ) {
+ global $wgTitle;
+ $this->mParserOptions->setTidy(true);
+ $this->addWikiTextTitle($text, $wgTitle, $linestart);
+ $this->mParserOptions->setTidy(false);
+ }
+
+
/**
* Add the output of a QuickTemplate to the output buffer
* @param QuickTemplate $template
$this->mLanguageLinks += $parserOutput->getLanguageLinks();
$this->addCategoryLinks( $parserOutput->getCategories() );
$this->addKeywords( $parserOutput );
- $this->addHTML( $parserOutput->getText() );
+ $text = $parserOutput->getText();
+ wfRunHooks( 'OutputPageBeforeHTML', array( &$this, &$text ) );
+ $this->addHTML( $text );
$t = $parserOutput->getTitleText();
if( !empty( $t ) ) {
$this->setPageTitle( $t );
}
function sendCacheControl() {
- global $wgUseSquid, $wgUseESI;
+ global $wgUseSquid, $wgUseESI, $wgSquidMaxage;
if ($this->mETag)
header("ETag: $this->mETag");
return $time;
}
+ /**
+ * Produce a "user is blocked" page
+ */
+ function blockedPage() {
+ global $wgUser, $wgContLang;
+
+ $this->setPageTitle( wfMsg( 'blockedtitle' ) );
+ $this->setRobotpolicy( 'noindex,nofollow' );
+ $this->setArticleRelated( false );
+
+ $id = $wgUser->blockedBy();
+ $reason = $wgUser->blockedFor();
+ $ip = wfGetIP();
+
+ if ( is_numeric( $id ) ) {
+ $name = User::whoIs( $id );
+ } else {
+ $name = $id;
+ }
+ $link = '[[' . $wgContLang->getNsText( NS_USER ) . ":{$name}|{$name}]]";
+
+ $this->addWikiText( wfMsg( 'blockedtext', $link, $reason, $ip, $name ) );
+ $this->returnToMain( false );
+ }
+
/**
* Note: these arguments are keys into wfMsg(), not text!
*/
$this->mBodytext = '';
$loginpage = Title::makeTitle(NS_SPECIAL, 'Userlogin');
$sk = $wgUser->getSkin();
- $loginlink = $sk->makeKnownLinkObj($loginpage, wfMsg('loginreqlink'),
+ $loginlink = $sk->makeKnownLinkObj($loginpage, wfMsg('loginreqlink'),
'returnto=' . htmlspecialchars($wgTitle->getPrefixedDBkey()));
$this->addHTML( wfMsgHtml( 'loginreqpagetext', $loginlink ) );
if ( '' == $returnto ) {
$returnto = wfMsgForContent( 'mainpage' );
}
- $link = $sk->makeKnownLink( $returnto, '' );
+ $link = $sk->makeLinkObj( Title::newFromText( $returnto ), '' );
$r = wfMsg( 'returnto', $link );
if ( $auto ) {
}
/**
- * @private
+ * @access private
* @return string
*/
function headElement() {
}
$ret .= "<meta $a=\"{$tag[0]}\" content=\"{$tag[1]}\" />\n";
}
-
+
$p = $this->mRobotpolicy;
if( $p !== '' && $p != 'index,follow' ) {
// http://www.robotstxt.org/wc/meta-user.html
}
}
-
-} // MediaWiki
-
?>