2004-02-18 02:15:00 +00:00
|
|
|
<?php
|
2006-01-07 12:25:36 +00:00
|
|
|
if ( ! defined( 'MEDIAWIKI' ) )
|
2006-06-07 06:40:24 +00:00
|
|
|
die( 1 );
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
*/
|
2004-08-12 06:54:58 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
* @todo document
|
|
|
|
|
*/
|
2003-04-14 23:10:40 +00:00
|
|
|
class OutputPage {
|
2006-06-23 03:56:03 +00:00
|
|
|
var $mMetatags, $mKeywords;
|
2006-05-11 22:40:38 +00:00
|
|
|
var $mLinktags, $mPagetitle, $mBodytext, $mDebugtext;
|
|
|
|
|
var $mHTMLtitle, $mRobotpolicy, $mIsarticle, $mPrintable;
|
|
|
|
|
var $mSubtitle, $mRedirect, $mStatusCode;
|
|
|
|
|
var $mLastModified, $mETag, $mCategoryLinks;
|
|
|
|
|
var $mScripts, $mLinkColours, $mPageLinkTitle;
|
|
|
|
|
|
2007-05-08 20:48:02 +00:00
|
|
|
var $mAllowUserJs;
|
2006-05-11 22:40:38 +00:00
|
|
|
var $mSuppressQuickbar;
|
|
|
|
|
var $mOnloadHandler;
|
|
|
|
|
var $mDoNothing;
|
|
|
|
|
var $mContainsOldMagic, $mContainsNewMagic;
|
|
|
|
|
var $mIsArticleRelated;
|
2006-07-26 07:15:39 +00:00
|
|
|
protected $mParserOptions; // lazy initialised, use parserOptions()
|
2006-05-11 22:40:38 +00:00
|
|
|
var $mShowFeedLinks = false;
|
2007-12-08 12:46:18 +00:00
|
|
|
var $mFeedLinksAppendQuery = false;
|
2006-05-11 22:40:38 +00:00
|
|
|
var $mEnableClientCache = true;
|
|
|
|
|
var $mArticleBodyOnly = false;
|
|
|
|
|
|
|
|
|
|
var $mNewSectionLink = false;
|
2006-06-13 18:35:11 +00:00
|
|
|
var $mNoGallery = false;
|
2007-07-22 14:45:12 +00:00
|
|
|
var $mPageTitleActionText = '';
|
2007-12-10 06:02:29 +00:00
|
|
|
var $mParseWarnings = array();
|
2004-07-08 14:53:54 +00:00
|
|
|
|
2004-09-17 15:24:43 +00:00
|
|
|
/**
|
|
|
|
|
* Constructor
|
|
|
|
|
* Initialise private variables
|
|
|
|
|
*/
|
2007-01-20 13:34:31 +00:00
|
|
|
function __construct() {
|
2007-05-08 20:48:02 +00:00
|
|
|
global $wgAllowUserJs;
|
|
|
|
|
$this->mAllowUserJs = $wgAllowUserJs;
|
2006-06-23 03:56:03 +00:00
|
|
|
$this->mMetatags = $this->mKeywords = $this->mLinktags = array();
|
2003-04-14 23:10:40 +00:00
|
|
|
$this->mHTMLtitle = $this->mPagetitle = $this->mBodytext =
|
2004-02-26 13:37:26 +00:00
|
|
|
$this->mRedirect = $this->mLastModified =
|
2004-07-08 14:53:54 +00:00
|
|
|
$this->mSubtitle = $this->mDebugtext = $this->mRobotpolicy =
|
2006-04-11 10:16:27 +00:00
|
|
|
$this->mOnloadHandler = $this->mPageLinkTitle = '';
|
2004-01-17 09:49:43 +00:00
|
|
|
$this->mIsArticleRelated = $this->mIsarticle = $this->mPrintable = true;
|
2004-02-26 13:37:26 +00:00
|
|
|
$this->mSuppressQuickbar = $this->mPrintable = false;
|
2003-04-14 23:10:40 +00:00
|
|
|
$this->mLanguageLinks = array();
|
2006-04-11 10:16:27 +00:00
|
|
|
$this->mCategoryLinks = array();
|
2003-12-11 20:16:34 +00:00
|
|
|
$this->mDoNothing = false;
|
2004-01-07 02:51:47 +00:00
|
|
|
$this->mContainsOldMagic = $this->mContainsNewMagic = 0;
|
2006-07-26 07:15:39 +00:00
|
|
|
$this->mParserOptions = null;
|
2004-03-13 13:42:17 +00:00
|
|
|
$this->mSquidMaxage = 0;
|
2004-09-17 15:24:43 +00:00
|
|
|
$this->mScripts = '';
|
2007-04-03 21:58:18 +00:00
|
|
|
$this->mHeadItems = array();
|
2005-07-01 00:03:31 +00:00
|
|
|
$this->mETag = false;
|
2005-11-27 06:04:41 +00:00
|
|
|
$this->mRevisionId = null;
|
2006-05-01 20:35:08 +00:00
|
|
|
$this->mNewSectionLink = false;
|
2007-05-31 16:01:26 +00:00
|
|
|
$this->mTemplateIds = array();
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2006-06-23 03:56:03 +00:00
|
|
|
|
2006-11-07 05:37:31 +00:00
|
|
|
public function redirect( $url, $responsecode = '302' ) {
|
2006-06-23 03:56:03 +00:00
|
|
|
# Strip newlines as a paranoia check for header injection in PHP<5.1.2
|
|
|
|
|
$this->mRedirect = str_replace( "\n", '', $url );
|
|
|
|
|
$this->mRedirectCode = $responsecode;
|
|
|
|
|
}
|
2007-11-06 01:16:25 +00:00
|
|
|
|
|
|
|
|
public function getRedirect() {
|
|
|
|
|
return $this->mRedirect;
|
|
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2006-11-07 05:37:31 +00:00
|
|
|
/**
|
|
|
|
|
* Set the HTTP status code to send with the output.
|
|
|
|
|
*
|
|
|
|
|
* @param int $statusCode
|
|
|
|
|
* @return nothing
|
|
|
|
|
*/
|
2005-10-12 03:12:40 +00:00
|
|
|
function setStatusCode( $statusCode ) { $this->mStatusCode = $statusCode; }
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2003-04-14 23:10:40 +00:00
|
|
|
# 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 ); }
|
2007-01-21 16:46:36 +00:00
|
|
|
function addScript( $script ) { $this->mScripts .= "\t\t".$script; }
|
2007-05-16 17:57:00 +00:00
|
|
|
function addStyle( $style ) {
|
2007-05-16 19:54:58 +00:00
|
|
|
global $wgStylePath, $wgStyleVersion;
|
2007-05-16 17:57:00 +00:00
|
|
|
$this->addLink(
|
|
|
|
|
array(
|
|
|
|
|
'rel' => 'stylesheet',
|
2007-05-16 19:54:58 +00:00
|
|
|
'href' => $wgStylePath . '/' . $style . '?' . $wgStyleVersion ) );
|
2007-05-16 17:57:00 +00:00
|
|
|
}
|
2006-12-08 06:09:15 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add a self-contained script tag with the given contents
|
|
|
|
|
* @param string $script JavaScript text, no <script> tags
|
|
|
|
|
*/
|
|
|
|
|
function addInlineScript( $script ) {
|
|
|
|
|
global $wgJsMimeType;
|
2007-04-01 16:10:50 +00:00
|
|
|
$this->mScripts .= "<script type=\"$wgJsMimeType\">/*<![CDATA[*/\n$script\n/*]]>*/</script>";
|
2006-12-08 06:09:15 +00:00
|
|
|
}
|
|
|
|
|
|
2007-04-03 21:58:18 +00:00
|
|
|
function getScript() {
|
|
|
|
|
return $this->mScripts . $this->getHeadItems();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getHeadItems() {
|
|
|
|
|
$s = '';
|
|
|
|
|
foreach ( $this->mHeadItems as $item ) {
|
|
|
|
|
$s .= $item;
|
|
|
|
|
}
|
|
|
|
|
return $s;
|
|
|
|
|
}
|
|
|
|
|
|
2007-04-29 10:15:05 +00:00
|
|
|
function addHeadItem( $name, $value ) {
|
|
|
|
|
$this->mHeadItems[$name] = $value;
|
|
|
|
|
}
|
2004-07-08 14:53:54 +00:00
|
|
|
|
Basic integrated audio/video support, with Ogg implementation.
* JavaScript video player based loosely on Greg Maxwell's player
* Image page text snippet customisation
* Abstraction of transform parameters in the parser. Introduced Linker::makeImageLink2().
* Made canRender(), mustRender() depend on file, not just on handler. Moved width=0, height=0 checking to ImageHandler::canRender(), since audio streams have width=height=0 but should be rendered.
Also:
* Automatic upgrade for oldimage rows on image page view, allows media handler selection based on oi_*_mime
* oi_*_mime unconditionally referenced, REQUIRES SCHEMA UPGRADE
* Don't destroy file info for missing files on upgrade
* Simple, centralised extension message file handling
* Made MessageCache::loadAllMessages non-static, optimised for repeated-call case due to abuse in User.php
* Support for lightweight parser output hooks, with callback whitelist for security
* Moved Linker::formatSize() to Language, to join the new formatTimePeriod() and formatBitrate()
* Introduced MagicWordArray, regex capture trick requires that magic word IDs DO NOT CONTAIN HYPHENS.
2007-08-15 10:50:09 +00:00
|
|
|
function hasHeadItem( $name ) {
|
|
|
|
|
return isset( $this->mHeadItems[$name] );
|
|
|
|
|
}
|
|
|
|
|
|
2005-07-01 00:03:31 +00:00
|
|
|
function setETag($tag) { $this->mETag = $tag; }
|
2005-07-03 04:00:33 +00:00
|
|
|
function setArticleBodyOnly($only) { $this->mArticleBodyOnly = $only; }
|
2005-07-03 04:56:53 +00:00
|
|
|
function getArticleBodyOnly($only) { return $this->mArticleBodyOnly; }
|
2005-07-01 00:03:31 +00:00
|
|
|
|
2004-04-10 11:19:33 +00:00
|
|
|
function addLink( $linkarr ) {
|
|
|
|
|
# $linkarr should be an associative array of attributes. We'll escape on output.
|
|
|
|
|
array_push( $this->mLinktags, $linkarr );
|
|
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2004-04-10 11:19:33 +00:00
|
|
|
function addMetadataLink( $linkarr ) {
|
|
|
|
|
# note: buggy CC software only reads first "meta" link
|
2004-04-04 22:33:11 +00:00
|
|
|
static $haveMeta = false;
|
2004-08-22 17:24:50 +00:00
|
|
|
$linkarr['rel'] = ($haveMeta) ? 'alternate meta' : 'meta';
|
2004-04-10 11:19:33 +00:00
|
|
|
$this->addLink( $linkarr );
|
2004-04-04 22:33:11 +00:00
|
|
|
$haveMeta = true;
|
|
|
|
|
}
|
2004-04-04 21:58:05 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
* checkLastModified tells the client to use the client-cached page if
|
|
|
|
|
* possible. If sucessful, the OutputPage is disabled so that
|
2006-11-07 05:37:31 +00:00
|
|
|
* any future call to OutputPage->output() have no effect.
|
|
|
|
|
*
|
|
|
|
|
* @return bool True iff cache-ok headers was sent.
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2004-09-17 15:24:43 +00:00
|
|
|
function checkLastModified ( $timestamp ) {
|
2006-08-14 18:18:35 +00:00
|
|
|
global $wgCachePages, $wgCacheEpoch, $wgUser, $wgRequest;
|
2006-05-12 22:38:58 +00:00
|
|
|
$fname = 'OutputPage::checkLastModified';
|
|
|
|
|
|
2005-03-20 03:59:06 +00:00
|
|
|
if ( !$timestamp || $timestamp == '19700101000000' ) {
|
2006-05-12 22:38:58 +00:00
|
|
|
wfDebug( "$fname: CACHE DISABLED, NO TIMESTAMP\n" );
|
2005-03-20 03:59:06 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2003-07-10 04:55:41 +00:00
|
|
|
if( !$wgCachePages ) {
|
2006-05-12 22:38:58 +00:00
|
|
|
wfDebug( "$fname: CACHE DISABLED\n", false );
|
2003-07-10 04:55:41 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2004-08-22 17:24:50 +00:00
|
|
|
if( $wgUser->getOption( 'nocache' ) ) {
|
2006-05-12 22:38:58 +00:00
|
|
|
wfDebug( "$fname: USER DISABLED CACHE\n", false );
|
2003-04-14 23:10:40 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2004-03-20 15:03:26 +00:00
|
|
|
|
2005-03-20 03:59:06 +00:00
|
|
|
$timestamp=wfTimestamp(TS_MW,$timestamp);
|
2006-01-16 10:16:06 +00:00
|
|
|
$lastmod = wfTimestamp( TS_RFC2822, max( $timestamp, $wgUser->mTouched, $wgCacheEpoch ) );
|
2004-03-20 15:03:26 +00:00
|
|
|
|
2004-08-22 17:24:50 +00:00
|
|
|
if( !empty( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) {
|
2003-11-09 11:45:12 +00:00
|
|
|
# IE sends sizes after the date like this:
|
2003-08-20 07:45:18 +00:00
|
|
|
# Wed, 20 Aug 2003 06:51:19 GMT; length=5202
|
|
|
|
|
# this breaks strtotime().
|
|
|
|
|
$modsince = preg_replace( '/;.*$/', '', $_SERVER["HTTP_IF_MODIFIED_SINCE"] );
|
2007-06-20 18:49:54 +00:00
|
|
|
|
2007-06-20 22:25:39 +00:00
|
|
|
wfSuppressWarnings(); // E_STRICT system time bitching
|
2005-07-04 22:06:39 +00:00
|
|
|
$modsinceTime = strtotime( $modsince );
|
2007-06-20 22:25:39 +00:00
|
|
|
wfRestoreWarnings();
|
2007-06-20 18:49:54 +00:00
|
|
|
|
2005-07-04 22:06:39 +00:00
|
|
|
$ismodsince = wfTimestamp( TS_MW, $modsinceTime ? $modsinceTime : 1 );
|
2006-05-12 22:38:58 +00:00
|
|
|
wfDebug( "$fname: -- client send If-Modified-Since: " . $modsince . "\n", false );
|
|
|
|
|
wfDebug( "$fname: -- we might send Last-Modified : $lastmod\n", false );
|
2006-01-16 10:16:06 +00:00
|
|
|
if( ($ismodsince >= $timestamp ) && $wgUser->validateCache( $ismodsince ) && $ismodsince >= $wgCacheEpoch ) {
|
2003-04-14 23:10:40 +00:00
|
|
|
# Make sure you're in a place you can leave when you call us!
|
2006-08-14 18:18:35 +00:00
|
|
|
$wgRequest->response()->header( "HTTP/1.0 304 Not Modified" );
|
2004-02-02 04:33:48 +00:00
|
|
|
$this->mLastModified = $lastmod;
|
2004-02-02 04:10:46 +00:00
|
|
|
$this->sendCacheControl();
|
2006-05-12 22:38:58 +00:00
|
|
|
wfDebug( "$fname: CACHED client: $ismodsince ; user: $wgUser->mTouched ; page: $timestamp ; site $wgCacheEpoch\n", false );
|
2003-12-11 20:16:34 +00:00
|
|
|
$this->disable();
|
2006-12-11 01:51:21 +00:00
|
|
|
|
|
|
|
|
// Don't output a compressed blob when using ob_gzhandler;
|
|
|
|
|
// it's technically against HTTP spec and seems to confuse
|
|
|
|
|
// Firefox when the response gets split over two packets.
|
|
|
|
|
wfClearOutputBuffers();
|
|
|
|
|
|
2003-12-11 20:16:34 +00:00
|
|
|
return true;
|
2003-04-14 23:10:40 +00:00
|
|
|
} else {
|
2006-05-12 22:38:58 +00:00
|
|
|
wfDebug( "$fname: READY client: $ismodsince ; user: $wgUser->mTouched ; page: $timestamp ; site $wgCacheEpoch\n", false );
|
2003-04-14 23:10:40 +00:00
|
|
|
$this->mLastModified = $lastmod;
|
|
|
|
|
}
|
2003-07-10 04:55:41 +00:00
|
|
|
} else {
|
2006-05-12 22:38:58 +00:00
|
|
|
wfDebug( "$fname: client did not send If-Modified-Since header\n", false );
|
2003-07-10 04:55:41 +00:00
|
|
|
$this->mLastModified = $lastmod;
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-07-22 14:45:12 +00:00
|
|
|
function setPageTitleActionText( $text ) {
|
|
|
|
|
$this->mPageTitleActionText = $text;
|
|
|
|
|
}
|
|
|
|
|
|
2004-04-25 00:32:24 +00:00
|
|
|
function getPageTitleActionText () {
|
2007-07-22 14:45:12 +00:00
|
|
|
if ( isset( $this->mPageTitleActionText ) ) {
|
|
|
|
|
return $this->mPageTitleActionText;
|
2004-04-25 00:32:24 +00:00
|
|
|
}
|
|
|
|
|
}
|
2004-09-17 15:24:43 +00:00
|
|
|
|
2006-11-07 05:37:31 +00:00
|
|
|
public function setRobotpolicy( $str ) { $this->mRobotpolicy = $str; }
|
|
|
|
|
public function setHTMLTitle( $name ) {$this->mHTMLtitle = $name; }
|
|
|
|
|
public function setPageTitle( $name ) {
|
2004-10-08 04:27:07 +00:00
|
|
|
global $action, $wgContLang;
|
2004-10-19 18:03:58 +00:00
|
|
|
$name = $wgContLang->convert($name, true);
|
2004-04-25 00:32:24 +00:00
|
|
|
$this->mPagetitle = $name;
|
|
|
|
|
if(!empty($action)) {
|
|
|
|
|
$taction = $this->getPageTitleActionText();
|
|
|
|
|
if( !empty( $taction ) ) {
|
2004-08-22 17:24:50 +00:00
|
|
|
$name .= ' - '.$taction;
|
2004-04-25 00:32:24 +00:00
|
|
|
}
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-08-17 12:00:07 +00:00
|
|
|
$this->setHTMLTitle( wfMsg( 'pagetitle', $name ) );
|
2004-04-25 00:32:24 +00:00
|
|
|
}
|
2006-11-07 05:37:31 +00:00
|
|
|
public function getHTMLTitle() { return $this->mHTMLtitle; }
|
|
|
|
|
public function getPageTitle() { return $this->mPagetitle; }
|
|
|
|
|
public function setSubtitle( $str ) { $this->mSubtitle = /*$this->parse(*/$str/*)*/; } // @bug 2514
|
|
|
|
|
public function getSubtitle() { return $this->mSubtitle; }
|
|
|
|
|
public function isArticle() { return $this->mIsarticle; }
|
|
|
|
|
public function setPrintable() { $this->mPrintable = true; }
|
|
|
|
|
public function isPrintable() { return $this->mPrintable; }
|
|
|
|
|
public function setSyndicated( $show = true ) { $this->mShowFeedLinks = $show; }
|
|
|
|
|
public function isSyndicated() { return $this->mShowFeedLinks; }
|
2007-12-08 12:46:18 +00:00
|
|
|
public function setFeedAppendQuery( $val ) { $this->mFeedLinksAppendQuery = $val; }
|
|
|
|
|
public function getFeedAppendQuery() { return $this->mFeedLinksAppendQuery; }
|
2006-11-07 05:37:31 +00:00
|
|
|
public function setOnloadHandler( $js ) { $this->mOnloadHandler = $js; }
|
|
|
|
|
public function getOnloadHandler() { return $this->mOnloadHandler; }
|
|
|
|
|
public function disable() { $this->mDoNothing = true; }
|
|
|
|
|
|
|
|
|
|
public function setArticleRelated( $v ) {
|
2004-01-17 09:49:43 +00:00
|
|
|
$this->mIsArticleRelated = $v;
|
|
|
|
|
if ( !$v ) {
|
|
|
|
|
$this->mIsarticle = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2006-11-07 05:37:31 +00:00
|
|
|
public function setArticleFlag( $v ) {
|
2004-07-08 14:53:54 +00:00
|
|
|
$this->mIsarticle = $v;
|
2004-01-17 09:49:43 +00:00
|
|
|
if ( $v ) {
|
|
|
|
|
$this->mIsArticleRelated = $v;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-11-07 05:37:31 +00:00
|
|
|
public function isArticleRelated() { return $this->mIsArticleRelated; }
|
2004-07-08 14:53:54 +00:00
|
|
|
|
2006-11-07 05:37:31 +00:00
|
|
|
public function getLanguageLinks() { return $this->mLanguageLinks; }
|
|
|
|
|
public function addLanguageLinks($newLinkArray) {
|
2004-06-01 18:29:31 +00:00
|
|
|
$this->mLanguageLinks += $newLinkArray;
|
|
|
|
|
}
|
2006-11-07 05:37:31 +00:00
|
|
|
public function setLanguageLinks($newLinkArray) {
|
2004-06-01 18:29:31 +00:00
|
|
|
$this->mLanguageLinks = $newLinkArray;
|
|
|
|
|
}
|
2004-09-17 15:24:43 +00:00
|
|
|
|
2006-11-07 05:37:31 +00:00
|
|
|
public function getCategoryLinks() {
|
2004-06-19 06:46:54 +00:00
|
|
|
return $this->mCategoryLinks;
|
2004-07-08 14:53:54 +00:00
|
|
|
}
|
2005-12-30 09:33:11 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add an array of categories, with names in the keys
|
|
|
|
|
*/
|
2006-11-07 05:37:31 +00:00
|
|
|
public function addCategoryLinks($categories) {
|
2006-11-08 07:12:03 +00:00
|
|
|
global $wgUser, $wgContLang;
|
2005-12-30 09:33:11 +00:00
|
|
|
|
2006-04-02 03:59:07 +00:00
|
|
|
if ( !is_array( $categories ) ) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2005-12-30 09:33:11 +00:00
|
|
|
# Add the links to the link cache in a batch
|
|
|
|
|
$arr = array( NS_CATEGORY => $categories );
|
|
|
|
|
$lb = new LinkBatch;
|
|
|
|
|
$lb->setArray( $arr );
|
2006-01-05 02:05:53 +00:00
|
|
|
$lb->execute();
|
2005-12-30 09:33:11 +00:00
|
|
|
|
2007-01-22 23:50:42 +00:00
|
|
|
$sk = $wgUser->getSkin();
|
2006-11-25 17:11:58 +00:00
|
|
|
foreach ( $categories as $category => $unused ) {
|
2005-12-30 09:33:11 +00:00
|
|
|
$title = Title::makeTitleSafe( NS_CATEGORY, $category );
|
|
|
|
|
$text = $wgContLang->convertHtml( $title->getText() );
|
2006-11-08 07:12:03 +00:00
|
|
|
$this->mCategoryLinks[] = $sk->makeLinkObj( $title, $text );
|
2005-12-30 09:33:11 +00:00
|
|
|
}
|
2004-06-19 06:46:54 +00:00
|
|
|
}
|
2005-12-30 09:33:11 +00:00
|
|
|
|
2006-11-07 05:37:31 +00:00
|
|
|
public function setCategoryLinks($categories) {
|
2005-12-30 09:33:11 +00:00
|
|
|
$this->mCategoryLinks = array();
|
|
|
|
|
$this->addCategoryLinks($categories);
|
2004-06-19 06:46:54 +00:00
|
|
|
}
|
|
|
|
|
|
2006-11-07 05:37:31 +00:00
|
|
|
public function suppressQuickbar() { $this->mSuppressQuickbar = true; }
|
|
|
|
|
public function isQuickbarSuppressed() { return $this->mSuppressQuickbar; }
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2007-05-08 20:48:02 +00:00
|
|
|
public function disallowUserJs() { $this->mAllowUserJs = false; }
|
|
|
|
|
public function isUserJsAllowed() { return $this->mAllowUserJs; }
|
|
|
|
|
|
2006-11-07 05:37:31 +00:00
|
|
|
public function addHTML( $text ) { $this->mBodytext .= $text; }
|
|
|
|
|
public function clearHTML() { $this->mBodytext = ''; }
|
|
|
|
|
public function getHTML() { return $this->mBodytext; }
|
|
|
|
|
public function debug( $text ) { $this->mDebugtext .= $text; }
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2005-12-21 02:38:54 +00:00
|
|
|
/* @deprecated */
|
2006-11-07 05:37:31 +00:00
|
|
|
public function setParserOptions( $options ) {
|
2006-07-26 07:15:39 +00:00
|
|
|
return $this->parserOptions( $options );
|
2005-12-21 02:38:54 +00:00
|
|
|
}
|
|
|
|
|
|
2006-11-07 05:37:31 +00:00
|
|
|
public function parserOptions( $options = null ) {
|
2006-07-26 07:15:39 +00:00
|
|
|
if ( !$this->mParserOptions ) {
|
|
|
|
|
$this->mParserOptions = new ParserOptions;
|
|
|
|
|
}
|
2004-02-29 08:43:29 +00:00
|
|
|
return wfSetVar( $this->mParserOptions, $options );
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-11-27 06:04:41 +00:00
|
|
|
/**
|
|
|
|
|
* Set the revision ID which will be seen by the wiki text parser
|
|
|
|
|
* for things such as embedded {{REVISIONID}} variable use.
|
|
|
|
|
* @param mixed $revid an integer, or NULL
|
|
|
|
|
* @return mixed previous value
|
|
|
|
|
*/
|
2006-11-07 05:37:31 +00:00
|
|
|
public function setRevisionId( $revid ) {
|
2005-11-27 06:04:41 +00:00
|
|
|
$val = is_null( $revid ) ? null : intval( $revid );
|
|
|
|
|
return wfSetVar( $this->mRevisionId, $val );
|
|
|
|
|
}
|
2004-02-29 08:43:29 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
* Convert wikitext to HTML and add it to the buffer
|
2005-05-21 17:26:42 +00:00
|
|
|
* Default assumes that the current page title will
|
|
|
|
|
* be used.
|
2006-11-07 05:37:31 +00:00
|
|
|
*
|
|
|
|
|
* @param string $text
|
|
|
|
|
* @param bool $linestart
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2006-11-07 05:37:31 +00:00
|
|
|
public function addWikiText( $text, $linestart = true ) {
|
2005-05-21 17:26:42 +00:00
|
|
|
global $wgTitle;
|
2005-05-21 17:41:30 +00:00
|
|
|
$this->addWikiTextTitle($text, $wgTitle, $linestart);
|
2005-05-21 17:26:42 +00:00
|
|
|
}
|
|
|
|
|
|
2006-11-07 05:37:31 +00:00
|
|
|
public function addWikiTextWithTitle($text, &$title, $linestart = true) {
|
2005-05-21 17:41:30 +00:00
|
|
|
$this->addWikiTextTitle($text, $title, $linestart);
|
2005-05-21 17:26:42 +00:00
|
|
|
}
|
2005-07-01 00:03:31 +00:00
|
|
|
|
2007-01-10 23:32:38 +00:00
|
|
|
function addWikiTextTitleTidy($text, &$title, $linestart = true) {
|
2007-01-14 17:37:29 +00:00
|
|
|
$this->addWikiTextTitle( $text, $title, $linestart, true );
|
2007-01-10 23:32:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function addWikiTextTitle($text, &$title, $linestart, $tidy = false) {
|
2005-12-04 18:27:59 +00:00
|
|
|
global $wgParser;
|
2007-01-10 23:32:38 +00:00
|
|
|
|
2006-07-16 08:16:58 +00:00
|
|
|
$fname = 'OutputPage:addWikiTextTitle';
|
|
|
|
|
wfProfileIn($fname);
|
2007-01-10 23:32:38 +00:00
|
|
|
|
2006-07-15 19:36:06 +00:00
|
|
|
wfIncrStats('pcache_not_possible');
|
2007-01-10 23:32:38 +00:00
|
|
|
|
|
|
|
|
$popts = $this->parserOptions();
|
2007-09-11 18:22:37 +00:00
|
|
|
$oldTidy = $popts->setTidy($tidy);
|
2007-01-10 23:32:38 +00:00
|
|
|
|
|
|
|
|
$parserOutput = $wgParser->parse( $text, $title, $popts,
|
2005-11-27 06:04:41 +00:00
|
|
|
$linestart, true, $this->mRevisionId );
|
2007-09-11 18:22:37 +00:00
|
|
|
|
|
|
|
|
$popts->setTidy( $oldTidy );
|
2007-01-10 23:32:38 +00:00
|
|
|
|
2006-01-01 20:08:08 +00:00
|
|
|
$this->addParserOutput( $parserOutput );
|
2007-01-10 23:32:38 +00:00
|
|
|
|
2006-07-16 08:16:58 +00:00
|
|
|
wfProfileOut($fname);
|
2006-01-01 20:08:08 +00:00
|
|
|
}
|
|
|
|
|
|
2006-11-07 05:37:31 +00:00
|
|
|
/**
|
|
|
|
|
* @todo document
|
|
|
|
|
* @param ParserOutput object &$parserOutput
|
|
|
|
|
*/
|
|
|
|
|
public function addParserOutputNoText( &$parserOutput ) {
|
2004-08-21 14:56:07 +00:00
|
|
|
$this->mLanguageLinks += $parserOutput->getLanguageLinks();
|
2005-12-30 09:33:11 +00:00
|
|
|
$this->addCategoryLinks( $parserOutput->getCategories() );
|
2006-05-01 20:35:08 +00:00
|
|
|
$this->mNewSectionLink = $parserOutput->getNewSection();
|
2005-12-30 09:33:11 +00:00
|
|
|
$this->addKeywords( $parserOutput );
|
2007-12-10 06:02:29 +00:00
|
|
|
$this->mParseWarnings = $parserOutput->getWarnings();
|
2005-05-28 11:09:22 +00:00
|
|
|
if ( $parserOutput->getCacheTime() == -1 ) {
|
|
|
|
|
$this->enableClientCache( false );
|
|
|
|
|
}
|
2006-08-24 17:05:52 +00:00
|
|
|
$this->mNoGallery = $parserOutput->getNoGallery();
|
2007-04-06 19:21:35 +00:00
|
|
|
$this->mHeadItems = array_merge( $this->mHeadItems, (array)$parserOutput->mHeadItems );
|
2007-05-31 16:01:26 +00:00
|
|
|
// Versioning...
|
|
|
|
|
$this->mTemplateIds += (array)$parserOutput->mTemplateIds;
|
|
|
|
|
|
2007-06-25 15:51:09 +00:00
|
|
|
# Display title
|
2007-06-25 16:07:49 +00:00
|
|
|
if( ( $dt = $parserOutput->getDisplayTitle() ) !== false )
|
|
|
|
|
$this->setPageTitle( $dt );
|
Basic integrated audio/video support, with Ogg implementation.
* JavaScript video player based loosely on Greg Maxwell's player
* Image page text snippet customisation
* Abstraction of transform parameters in the parser. Introduced Linker::makeImageLink2().
* Made canRender(), mustRender() depend on file, not just on handler. Moved width=0, height=0 checking to ImageHandler::canRender(), since audio streams have width=height=0 but should be rendered.
Also:
* Automatic upgrade for oldimage rows on image page view, allows media handler selection based on oi_*_mime
* oi_*_mime unconditionally referenced, REQUIRES SCHEMA UPGRADE
* Don't destroy file info for missing files on upgrade
* Simple, centralised extension message file handling
* Made MessageCache::loadAllMessages non-static, optimised for repeated-call case due to abuse in User.php
* Support for lightweight parser output hooks, with callback whitelist for security
* Moved Linker::formatSize() to Language, to join the new formatTimePeriod() and formatBitrate()
* Introduced MagicWordArray, regex capture trick requires that magic word IDs DO NOT CONTAIN HYPHENS.
2007-08-15 10:50:09 +00:00
|
|
|
|
|
|
|
|
# Hooks registered in the object
|
|
|
|
|
global $wgParserOutputHooks;
|
|
|
|
|
foreach ( $parserOutput->getOutputHooks() as $hookInfo ) {
|
|
|
|
|
list( $hookName, $data ) = $hookInfo;
|
|
|
|
|
if ( isset( $wgParserOutputHooks[$hookName] ) ) {
|
|
|
|
|
call_user_func( $wgParserOutputHooks[$hookName], $this, $parserOutput, $data );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2006-08-24 17:05:52 +00:00
|
|
|
wfRunHooks( 'OutputPageParserOutput', array( &$this, $parserOutput ) );
|
2006-01-01 20:08:08 +00:00
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2006-11-07 05:37:31 +00:00
|
|
|
/**
|
|
|
|
|
* @todo document
|
|
|
|
|
* @param ParserOutput &$parserOutput
|
|
|
|
|
*/
|
2006-01-01 20:08:08 +00:00
|
|
|
function addParserOutput( &$parserOutput ) {
|
|
|
|
|
$this->addParserOutputNoText( $parserOutput );
|
2006-08-24 17:05:52 +00:00
|
|
|
$text = $parserOutput->getText();
|
|
|
|
|
wfRunHooks( 'OutputPageBeforeHTML',array( &$this, &$text ) );
|
|
|
|
|
$this->addHTML( $text );
|
2005-07-01 00:03:31 +00:00
|
|
|
}
|
|
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
* Add wikitext to the buffer, assuming that this is the primary text for a page view
|
2006-11-07 05:37:31 +00:00
|
|
|
* Saves the text into the parser cache if possible.
|
|
|
|
|
*
|
|
|
|
|
* @param string $text
|
|
|
|
|
* @param Article $article
|
|
|
|
|
* @param bool $cache
|
2007-01-10 23:32:38 +00:00
|
|
|
* @deprecated Use Article::outputWikitext
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2006-11-07 05:37:31 +00:00
|
|
|
public function addPrimaryWikiText( $text, $article, $cache = true ) {
|
2006-01-05 04:26:52 +00:00
|
|
|
global $wgParser, $wgUser;
|
2004-08-21 14:56:07 +00:00
|
|
|
|
2006-07-26 07:15:39 +00:00
|
|
|
$popts = $this->parserOptions();
|
|
|
|
|
$popts->setTidy(true);
|
2005-12-30 09:33:11 +00:00
|
|
|
$parserOutput = $wgParser->parse( $text, $article->mTitle,
|
2006-07-26 07:15:39 +00:00
|
|
|
$popts, true, true, $this->mRevisionId );
|
|
|
|
|
$popts->setTidy(false);
|
2006-01-14 23:56:01 +00:00
|
|
|
if ( $cache && $article && $parserOutput->getCacheTime() != -1 ) {
|
2006-01-05 04:26:52 +00:00
|
|
|
$parserCache =& ParserCache::singleton();
|
|
|
|
|
$parserCache->save( $parserOutput, $article, $wgUser );
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2004-07-08 14:53:54 +00:00
|
|
|
|
2006-08-24 17:05:52 +00:00
|
|
|
$this->addParserOutput( $parserOutput );
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2004-09-17 15:24:43 +00:00
|
|
|
|
2006-01-23 18:37:46 +00:00
|
|
|
/**
|
2007-01-14 17:37:29 +00:00
|
|
|
* @deprecated use addWikiTextTidy()
|
2006-01-23 18:37:46 +00:00
|
|
|
*/
|
2006-11-07 05:37:31 +00:00
|
|
|
public function addSecondaryWikiText( $text, $linestart = true ) {
|
2006-01-23 18:37:46 +00:00
|
|
|
global $wgTitle;
|
2007-01-14 17:37:29 +00:00
|
|
|
$this->addWikiTextTitleTidy($text, $wgTitle, $linestart);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add wikitext with tidy enabled
|
|
|
|
|
*/
|
|
|
|
|
public function addWikiTextTidy( $text, $linestart = true ) {
|
|
|
|
|
global $wgTitle;
|
|
|
|
|
$this->addWikiTextTitleTidy($text, $wgTitle, $linestart);
|
2006-01-23 18:37:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-11-25 06:04:16 +00:00
|
|
|
/**
|
|
|
|
|
* Add the output of a QuickTemplate to the output buffer
|
2006-11-07 05:37:31 +00:00
|
|
|
*
|
2004-11-25 06:04:16 +00:00
|
|
|
* @param QuickTemplate $template
|
|
|
|
|
*/
|
2006-11-07 05:37:31 +00:00
|
|
|
public function addTemplate( &$template ) {
|
2004-11-25 06:04:16 +00:00
|
|
|
ob_start();
|
|
|
|
|
$template->execute();
|
2005-12-30 09:33:11 +00:00
|
|
|
$this->addHTML( ob_get_contents() );
|
2004-11-25 06:04:16 +00:00
|
|
|
ob_end_clean();
|
|
|
|
|
}
|
2004-11-29 11:26:24 +00:00
|
|
|
|
|
|
|
|
/**
|
2006-04-29 13:15:19 +00:00
|
|
|
* Parse wikitext and return the HTML.
|
2006-11-07 05:37:31 +00:00
|
|
|
*
|
|
|
|
|
* @param string $text
|
|
|
|
|
* @param bool $linestart Is this the start of a line?
|
|
|
|
|
* @param bool $interface ??
|
2004-11-29 11:26:24 +00:00
|
|
|
*/
|
2006-11-07 05:37:31 +00:00
|
|
|
public function parse( $text, $linestart = true, $interface = false ) {
|
2004-11-29 11:26:24 +00:00
|
|
|
global $wgParser, $wgTitle;
|
2006-07-26 07:15:39 +00:00
|
|
|
$popts = $this->parserOptions();
|
|
|
|
|
if ( $interface) { $popts->setInterfaceMessage(true); }
|
|
|
|
|
$parserOutput = $wgParser->parse( $text, $wgTitle, $popts,
|
2005-12-01 08:24:49 +00:00
|
|
|
$linestart, true, $this->mRevisionId );
|
2006-07-26 07:15:39 +00:00
|
|
|
if ( $interface) { $popts->setInterfaceMessage(false); }
|
2004-11-29 11:26:24 +00:00
|
|
|
return $parserOutput->getText();
|
|
|
|
|
}
|
2005-07-01 00:03:31 +00:00
|
|
|
|
2004-09-17 15:24:43 +00:00
|
|
|
/**
|
2006-11-07 05:37:31 +00:00
|
|
|
* @param Article $article
|
|
|
|
|
* @param User $user
|
2005-04-15 18:37:39 +00:00
|
|
|
*
|
2006-11-07 05:37:31 +00:00
|
|
|
* @return bool True if successful, else false.
|
2004-09-17 15:24:43 +00:00
|
|
|
*/
|
2006-11-07 05:37:31 +00:00
|
|
|
public function tryParserCache( &$article, $user ) {
|
2006-01-05 04:26:52 +00:00
|
|
|
$parserCache =& ParserCache::singleton();
|
|
|
|
|
$parserOutput = $parserCache->get( $article, $user );
|
2004-06-04 10:40:44 +00:00
|
|
|
if ( $parserOutput !== false ) {
|
2006-08-24 17:05:52 +00:00
|
|
|
$this->addParserOutput( $parserOutput );
|
2004-06-04 10:40:44 +00:00
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-07-08 14:53:54 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2006-11-07 05:37:31 +00:00
|
|
|
* @param int $maxage Maximum cache time on the Squid, in seconds.
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2006-11-07 05:37:31 +00:00
|
|
|
public function setSquidMaxage( $maxage ) {
|
2004-03-13 13:42:17 +00:00
|
|
|
$this->mSquidMaxage = $maxage;
|
2004-02-08 21:12:07 +00:00
|
|
|
}
|
2004-07-08 14:53:54 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
* Use enableClientCache(false) to force it to send nocache headers
|
2006-11-07 05:37:31 +00:00
|
|
|
* @param $state ??
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2006-11-07 05:37:31 +00:00
|
|
|
public function enableClientCache( $state ) {
|
2004-03-23 10:19:31 +00:00
|
|
|
return wfSetVar( $this->mEnableClientCache, $state );
|
|
|
|
|
}
|
2004-07-08 14:53:54 +00:00
|
|
|
|
2005-07-24 06:55:45 +00:00
|
|
|
function uncacheableBecauseRequestvars() {
|
|
|
|
|
global $wgRequest;
|
|
|
|
|
return $wgRequest->getText('useskin', false) === false
|
|
|
|
|
&& $wgRequest->getText('uselang', false) === false;
|
|
|
|
|
}
|
|
|
|
|
|
2006-11-07 05:37:31 +00:00
|
|
|
public function sendCacheControl() {
|
2006-08-24 15:14:38 +00:00
|
|
|
global $wgUseSquid, $wgUseESI, $wgUseETag, $wgSquidMaxage, $wgRequest;
|
2006-05-12 22:45:52 +00:00
|
|
|
$fname = 'OutputPage::sendCacheControl';
|
2005-07-01 00:03:31 +00:00
|
|
|
|
2006-08-24 15:14:38 +00:00
|
|
|
if ($wgUseETag && $this->mETag)
|
2006-08-14 18:18:35 +00:00
|
|
|
$wgRequest->response()->header("ETag: $this->mETag");
|
2005-07-01 00:03:31 +00:00
|
|
|
|
2005-03-08 02:58:43 +00:00
|
|
|
# don't serve compressed data to clients who can't handle it
|
|
|
|
|
# maintain different caches for logged-in users and non-logged in ones
|
2006-08-14 18:18:35 +00:00
|
|
|
$wgRequest->response()->header( 'Vary: Accept-Encoding, Cookie' );
|
2005-07-24 06:55:45 +00:00
|
|
|
if( !$this->uncacheableBecauseRequestvars() && $this->mEnableClientCache ) {
|
2007-02-05 21:42:48 +00:00
|
|
|
if( $wgUseSquid && session_id() == '' &&
|
2004-07-08 14:53:54 +00:00
|
|
|
! $this->isPrintable() && $this->mSquidMaxage != 0 )
|
2004-02-04 00:45:48 +00:00
|
|
|
{
|
2004-01-31 12:45:09 +00:00
|
|
|
if ( $wgUseESI ) {
|
2004-02-02 01:40:03 +00:00
|
|
|
# We'll purge the proxy cache explicitly, but require end user agents
|
2004-01-31 12:45:09 +00:00
|
|
|
# to revalidate against the proxy on each visit.
|
|
|
|
|
# Surrogate-Control controls our Squid, Cache-Control downstream caches
|
2006-05-12 22:45:52 +00:00
|
|
|
wfDebug( "$fname: proxy caching with ESI; {$this->mLastModified} **\n", false );
|
2004-01-31 12:45:09 +00:00
|
|
|
# start with a shorter timeout for initial testing
|
|
|
|
|
# header( 'Surrogate-Control: max-age=2678400+2678400, content="ESI/1.0"');
|
2006-08-14 18:18:35 +00:00
|
|
|
$wgRequest->response()->header( 'Surrogate-Control: max-age='.$wgSquidMaxage.'+'.$this->mSquidMaxage.', content="ESI/1.0"');
|
|
|
|
|
$wgRequest->response()->header( 'Cache-Control: s-maxage=0, must-revalidate, max-age=0' );
|
2004-01-31 12:45:09 +00:00
|
|
|
} else {
|
|
|
|
|
# We'll purge the proxy cache for anons explicitly, but require end user agents
|
|
|
|
|
# to revalidate against the proxy on each visit.
|
2004-07-08 14:53:54 +00:00
|
|
|
# IMPORTANT! The Squid needs to replace the Cache-Control header with
|
2004-01-31 12:45:09 +00:00
|
|
|
# Cache-Control: s-maxage=0, must-revalidate, max-age=0
|
2006-05-12 22:45:52 +00:00
|
|
|
wfDebug( "$fname: local proxy caching; {$this->mLastModified} **\n", false );
|
2004-01-31 12:45:09 +00:00
|
|
|
# start with a shorter timeout for initial testing
|
|
|
|
|
# header( "Cache-Control: s-maxage=2678400, must-revalidate, max-age=0" );
|
2006-08-14 18:18:35 +00:00
|
|
|
$wgRequest->response()->header( 'Cache-Control: s-maxage='.$this->mSquidMaxage.', must-revalidate, max-age=0' );
|
2004-01-31 12:45:09 +00:00
|
|
|
}
|
2004-01-31 10:29:31 +00:00
|
|
|
} else {
|
|
|
|
|
# We do want clients to cache if they can, but they *must* check for updates
|
|
|
|
|
# on revisiting the page.
|
2006-05-12 22:45:52 +00:00
|
|
|
wfDebug( "$fname: private caching; {$this->mLastModified} **\n", false );
|
2006-08-14 18:18:35 +00:00
|
|
|
$wgRequest->response()->header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', 0 ) . ' GMT' );
|
|
|
|
|
$wgRequest->response()->header( "Cache-Control: private, must-revalidate, max-age=0" );
|
2004-01-31 10:29:31 +00:00
|
|
|
}
|
2006-08-14 18:18:35 +00:00
|
|
|
if($this->mLastModified) $wgRequest->response()->header( "Last-modified: {$this->mLastModified}" );
|
2003-07-03 10:18:07 +00:00
|
|
|
} else {
|
2006-05-12 22:45:52 +00:00
|
|
|
wfDebug( "$fname: no caching **\n", false );
|
2004-03-23 10:19:31 +00:00
|
|
|
|
|
|
|
|
# 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.
|
2006-08-14 18:18:35 +00:00
|
|
|
$wgRequest->response()->header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', 0 ) . ' GMT' );
|
|
|
|
|
$wgRequest->response()->header( 'Cache-Control: no-cache, no-store, max-age=0, must-revalidate' );
|
|
|
|
|
$wgRequest->response()->header( 'Pragma: no-cache' );
|
2003-07-03 10:18:07 +00:00
|
|
|
}
|
|
|
|
|
}
|
2004-07-08 14:53:54 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
* Finally, all the text has been munged and accumulated into
|
|
|
|
|
* the object, let's actually output it:
|
|
|
|
|
*/
|
2006-11-07 05:37:31 +00:00
|
|
|
public function output() {
|
2006-08-14 18:18:35 +00:00
|
|
|
global $wgUser, $wgOutputEncoding, $wgRequest;
|
2006-03-28 05:15:10 +00:00
|
|
|
global $wgContLanguageCode, $wgDebugRedirects, $wgMimeType;
|
2006-12-26 23:53:34 +00:00
|
|
|
global $wgJsMimeType, $wgStylePath, $wgUseAjax, $wgAjaxSearch, $wgAjaxWatch;
|
|
|
|
|
global $wgServer, $wgStyleVersion;
|
2004-10-08 04:27:07 +00:00
|
|
|
|
2003-12-11 20:16:34 +00:00
|
|
|
if( $this->mDoNothing ){
|
|
|
|
|
return;
|
|
|
|
|
}
|
2004-08-22 17:24:50 +00:00
|
|
|
$fname = 'OutputPage::output';
|
2003-10-25 08:01:33 +00:00
|
|
|
wfProfileIn( $fname );
|
2003-04-14 23:10:40 +00:00
|
|
|
$sk = $wgUser->getSkin();
|
|
|
|
|
|
2006-03-26 19:03:14 +00:00
|
|
|
if ( $wgUseAjax ) {
|
2006-12-27 01:17:55 +00:00
|
|
|
$this->addScript( "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/ajax.js?$wgStyleVersion\"></script>\n" );
|
2007-01-21 16:46:36 +00:00
|
|
|
|
|
|
|
|
wfRunHooks( 'AjaxAddScript', array( &$this ) );
|
|
|
|
|
|
2007-12-16 15:46:27 +00:00
|
|
|
if( $wgAjaxSearch && $wgUser->getBoolOption( 'ajaxsearch' ) ) {
|
2007-01-31 03:31:10 +00:00
|
|
|
$this->addScript( "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/ajaxsearch.js?$wgStyleVersion\"></script>\n" );
|
2006-12-26 23:53:34 +00:00
|
|
|
$this->addScript( "<script type=\"{$wgJsMimeType}\">hookEvent(\"load\", sajax_onload);</script>\n" );
|
|
|
|
|
}
|
2006-03-26 19:03:14 +00:00
|
|
|
|
2006-12-26 23:53:34 +00:00
|
|
|
if( $wgAjaxWatch && $wgUser->isLoggedIn() ) {
|
2007-01-31 03:31:10 +00:00
|
|
|
$this->addScript( "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/ajaxwatch.js?$wgStyleVersion\"></script>\n" );
|
2006-12-26 23:53:34 +00:00
|
|
|
}
|
2006-07-30 10:53:22 +00:00
|
|
|
}
|
|
|
|
|
|
2004-08-22 17:24:50 +00:00
|
|
|
if ( '' != $this->mRedirect ) {
|
|
|
|
|
if( substr( $this->mRedirect, 0, 4 ) != 'http' ) {
|
2003-12-22 10:21:18 +00:00
|
|
|
# Standards require redirect URLs to be absolute
|
|
|
|
|
global $wgServer;
|
|
|
|
|
$this->mRedirect = $wgServer . $this->mRedirect;
|
|
|
|
|
}
|
2004-03-05 03:18:31 +00:00
|
|
|
if( $this->mRedirectCode == '301') {
|
|
|
|
|
if( !$wgDebugRedirects ) {
|
2006-08-14 18:18:35 +00:00
|
|
|
$wgRequest->response()->header("HTTP/1.1 {$this->mRedirectCode} Moved Permanently");
|
2004-03-05 03:18:31 +00:00
|
|
|
}
|
2004-12-19 11:11:52 +00:00
|
|
|
$this->mLastModified = wfTimestamp( TS_RFC2822 );
|
2004-03-01 22:16:39 +00:00
|
|
|
}
|
2004-07-08 14:53:54 +00:00
|
|
|
|
2004-03-01 22:16:39 +00:00
|
|
|
$this->sendCacheControl();
|
2004-07-08 14:53:54 +00:00
|
|
|
|
2007-02-21 01:02:47 +00:00
|
|
|
$wgRequest->response()->header("Content-Type: text/html; charset=utf-8");
|
2004-03-05 03:18:31 +00:00
|
|
|
if( $wgDebugRedirects ) {
|
|
|
|
|
$url = htmlspecialchars( $this->mRedirect );
|
|
|
|
|
print "<html>\n<head>\n<title>Redirect</title>\n</head>\n<body>\n";
|
|
|
|
|
print "<p>Location: <a href=\"$url\">$url</a></p>\n";
|
|
|
|
|
print "</body>\n</html>\n";
|
|
|
|
|
} else {
|
2006-08-14 18:18:35 +00:00
|
|
|
$wgRequest->response()->header( 'Location: '.$this->mRedirect );
|
2004-03-05 03:18:31 +00:00
|
|
|
}
|
2005-07-25 07:00:20 +00:00
|
|
|
wfProfileOut( $fname );
|
2003-04-14 23:10:40 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2005-10-12 03:12:40 +00:00
|
|
|
elseif ( $this->mStatusCode )
|
|
|
|
|
{
|
|
|
|
|
$statusMessage = array(
|
|
|
|
|
100 => 'Continue',
|
|
|
|
|
101 => 'Switching Protocols',
|
|
|
|
|
102 => 'Processing',
|
|
|
|
|
200 => 'OK',
|
|
|
|
|
201 => 'Created',
|
|
|
|
|
202 => 'Accepted',
|
|
|
|
|
203 => 'Non-Authoritative Information',
|
|
|
|
|
204 => 'No Content',
|
|
|
|
|
205 => 'Reset Content',
|
|
|
|
|
206 => 'Partial Content',
|
|
|
|
|
207 => 'Multi-Status',
|
|
|
|
|
300 => 'Multiple Choices',
|
|
|
|
|
301 => 'Moved Permanently',
|
|
|
|
|
302 => 'Found',
|
|
|
|
|
303 => 'See Other',
|
|
|
|
|
304 => 'Not Modified',
|
|
|
|
|
305 => 'Use Proxy',
|
|
|
|
|
307 => 'Temporary Redirect',
|
|
|
|
|
400 => 'Bad Request',
|
|
|
|
|
401 => 'Unauthorized',
|
|
|
|
|
402 => 'Payment Required',
|
|
|
|
|
403 => 'Forbidden',
|
|
|
|
|
404 => 'Not Found',
|
|
|
|
|
405 => 'Method Not Allowed',
|
|
|
|
|
406 => 'Not Acceptable',
|
|
|
|
|
407 => 'Proxy Authentication Required',
|
|
|
|
|
408 => 'Request Timeout',
|
|
|
|
|
409 => 'Conflict',
|
|
|
|
|
410 => 'Gone',
|
|
|
|
|
411 => 'Length Required',
|
|
|
|
|
412 => 'Precondition Failed',
|
|
|
|
|
413 => 'Request Entity Too Large',
|
|
|
|
|
414 => 'Request-URI Too Large',
|
|
|
|
|
415 => 'Unsupported Media Type',
|
|
|
|
|
416 => 'Request Range Not Satisfiable',
|
|
|
|
|
417 => 'Expectation Failed',
|
|
|
|
|
422 => 'Unprocessable Entity',
|
|
|
|
|
423 => 'Locked',
|
|
|
|
|
424 => 'Failed Dependency',
|
|
|
|
|
500 => 'Internal Server Error',
|
|
|
|
|
501 => 'Not Implemented',
|
|
|
|
|
502 => 'Bad Gateway',
|
|
|
|
|
503 => 'Service Unavailable',
|
|
|
|
|
504 => 'Gateway Timeout',
|
|
|
|
|
505 => 'HTTP Version Not Supported',
|
|
|
|
|
507 => 'Insufficient Storage'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if ( $statusMessage[$this->mStatusCode] )
|
2006-08-14 18:18:35 +00:00
|
|
|
$wgRequest->response()->header( 'HTTP/1.1 ' . $this->mStatusCode . ' ' . $statusMessage[$this->mStatusCode] );
|
2005-10-12 03:12:40 +00:00
|
|
|
}
|
2004-07-08 14:53:54 +00:00
|
|
|
|
2004-11-12 09:34:11 +00:00
|
|
|
# Buffer output; final headers may depend on later processing
|
|
|
|
|
ob_start();
|
|
|
|
|
|
2006-11-08 07:12:03 +00:00
|
|
|
# Disable temporary placeholders, so that the skin produces HTML
|
|
|
|
|
$sk->postParseLinkColour( false );
|
|
|
|
|
|
2006-08-14 18:18:35 +00:00
|
|
|
$wgRequest->response()->header( "Content-type: $wgMimeType; charset={$wgOutputEncoding}" );
|
|
|
|
|
$wgRequest->response()->header( 'Content-language: '.$wgContLanguageCode );
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2005-07-03 04:00:33 +00:00
|
|
|
if ($this->mArticleBodyOnly) {
|
|
|
|
|
$this->out($this->mBodytext);
|
|
|
|
|
} else {
|
|
|
|
|
wfProfileIn( 'Output-skin' );
|
|
|
|
|
$sk->outputPage( $this );
|
|
|
|
|
wfProfileOut( 'Output-skin' );
|
|
|
|
|
}
|
2005-07-01 00:03:31 +00:00
|
|
|
|
2004-11-12 09:34:11 +00:00
|
|
|
$this->sendCacheControl();
|
|
|
|
|
ob_end_flush();
|
2005-07-25 07:00:20 +00:00
|
|
|
wfProfileOut( $fname );
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
2006-11-07 05:37:31 +00:00
|
|
|
/**
|
|
|
|
|
* @todo document
|
|
|
|
|
* @param string $ins
|
|
|
|
|
*/
|
|
|
|
|
public function out( $ins ) {
|
2004-09-24 13:14:52 +00:00
|
|
|
global $wgInputEncoding, $wgOutputEncoding, $wgContLang;
|
2003-04-14 23:10:40 +00:00
|
|
|
if ( 0 == strcmp( $wgInputEncoding, $wgOutputEncoding ) ) {
|
|
|
|
|
$outs = $ins;
|
|
|
|
|
} else {
|
2004-09-24 13:14:52 +00:00
|
|
|
$outs = $wgContLang->iconv( $wgInputEncoding, $wgOutputEncoding, $ins );
|
2003-04-14 23:10:40 +00:00
|
|
|
if ( false === $outs ) { $outs = $ins; }
|
|
|
|
|
}
|
|
|
|
|
print $outs;
|
|
|
|
|
}
|
|
|
|
|
|
2006-11-07 05:37:31 +00:00
|
|
|
/**
|
|
|
|
|
* @todo document
|
|
|
|
|
*/
|
2006-11-29 05:45:03 +00:00
|
|
|
public static function setEncodings() {
|
2003-11-18 02:39:38 +00:00
|
|
|
global $wgInputEncoding, $wgOutputEncoding;
|
2004-09-24 13:14:52 +00:00
|
|
|
global $wgUser, $wgContLang;
|
2003-04-14 23:10:40 +00:00
|
|
|
|
|
|
|
|
$wgInputEncoding = strtolower( $wgInputEncoding );
|
2004-07-08 14:53:54 +00:00
|
|
|
|
2003-11-15 23:06:59 +00:00
|
|
|
if ( empty( $_SERVER['HTTP_ACCEPT_CHARSET'] ) ) {
|
2003-04-14 23:10:40 +00:00
|
|
|
$wgOutputEncoding = strtolower( $wgOutputEncoding );
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
$wgOutputEncoding = $wgInputEncoding;
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2006-11-07 05:37:31 +00:00
|
|
|
* Deprecated, use wfReportTime() instead.
|
2005-04-04 19:31:58 +00:00
|
|
|
* @return string
|
2005-09-24 13:37:26 +00:00
|
|
|
* @deprecated
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2006-11-07 05:37:31 +00:00
|
|
|
public function reportTime() {
|
2005-09-24 13:37:26 +00:00
|
|
|
$time = wfReportTime();
|
|
|
|
|
return $time;
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2006-01-06 23:09:37 +00:00
|
|
|
/**
|
2006-11-07 05:37:31 +00:00
|
|
|
* Produce a "user is blocked" page.
|
|
|
|
|
*
|
|
|
|
|
* @param bool $return Whether to have a "return to $wgTitle" message or not.
|
|
|
|
|
* @return nothing
|
2006-01-06 23:09:37 +00:00
|
|
|
*/
|
2006-06-24 20:58:10 +00:00
|
|
|
function blockedPage( $return = true ) {
|
2007-05-03 15:40:38 +00:00
|
|
|
global $wgUser, $wgContLang, $wgTitle, $wgLang;
|
2006-01-06 23:09:37 +00:00
|
|
|
|
|
|
|
|
$this->setPageTitle( wfMsg( 'blockedtitle' ) );
|
|
|
|
|
$this->setRobotpolicy( 'noindex,nofollow' );
|
|
|
|
|
$this->setArticleRelated( false );
|
|
|
|
|
|
2007-08-01 20:11:29 +00:00
|
|
|
$name = User::whoIs( $wgUser->blockedBy() );
|
2006-01-06 23:09:37 +00:00
|
|
|
$reason = $wgUser->blockedFor();
|
2007-11-15 14:42:20 +00:00
|
|
|
if( $reason == '' ) {
|
|
|
|
|
$reason = wfMsg( 'blockednoreason' );
|
|
|
|
|
}
|
2007-07-31 13:59:29 +00:00
|
|
|
$blockTimestamp = $wgLang->timeanddate( wfTimestamp( TS_MW, $wgUser->mBlock->mTimestamp ), true );
|
2006-06-01 08:19:02 +00:00
|
|
|
$ip = wfGetIP();
|
2006-01-06 23:09:37 +00:00
|
|
|
|
|
|
|
|
$link = '[[' . $wgContLang->getNsText( NS_USER ) . ":{$name}|{$name}]]";
|
|
|
|
|
|
2006-12-13 05:44:46 +00:00
|
|
|
$blockid = $wgUser->mBlock->mId;
|
|
|
|
|
|
2007-05-03 15:40:38 +00:00
|
|
|
$blockExpiry = $wgUser->mBlock->mExpiry;
|
|
|
|
|
if ( $blockExpiry == 'infinity' ) {
|
2007-05-04 05:46:44 +00:00
|
|
|
// Entry in database (table ipblocks) is 'infinity' but 'ipboptions' uses 'infinite' or 'indefinite'
|
2007-05-03 15:40:38 +00:00
|
|
|
// Search for localization in 'ipboptions'
|
|
|
|
|
$scBlockExpiryOptions = wfMsg( 'ipboptions' );
|
|
|
|
|
foreach ( explode( ',', $scBlockExpiryOptions ) as $option ) {
|
|
|
|
|
if ( strpos( $option, ":" ) === false )
|
|
|
|
|
continue;
|
|
|
|
|
list( $show, $value ) = explode( ":", $option );
|
2007-05-04 05:46:44 +00:00
|
|
|
if ( $value == 'infinite' || $value == 'indefinite' ) {
|
2007-05-03 15:40:38 +00:00
|
|
|
$blockExpiry = $show;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$blockExpiry = $wgLang->timeanddate( wfTimestamp( TS_MW, $blockExpiry ), true );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $wgUser->mBlock->mAuto ) {
|
|
|
|
|
$msg = 'autoblockedtext';
|
|
|
|
|
} else {
|
|
|
|
|
$msg = 'blockedtext';
|
|
|
|
|
}
|
|
|
|
|
|
2007-06-02 00:03:22 +00:00
|
|
|
/* $ip returns who *is* being blocked, $intended contains who was meant to be blocked.
|
|
|
|
|
* This could be a username, an ip range, or a single ip. */
|
|
|
|
|
$intended = $wgUser->mBlock->mAddress;
|
2007-06-01 07:57:17 +00:00
|
|
|
|
2007-07-31 13:59:29 +00:00
|
|
|
$this->addWikiText( wfMsg( $msg, $link, $reason, $ip, $name, $blockid, $blockExpiry, $intended, $blockTimestamp ) );
|
|
|
|
|
|
2006-04-29 23:30:46 +00:00
|
|
|
# Don't auto-return to special pages
|
2006-06-24 20:58:10 +00:00
|
|
|
if( $return ) {
|
|
|
|
|
$return = $wgTitle->getNamespace() > -1 ? $wgTitle->getPrefixedText() : NULL;
|
|
|
|
|
$this->returnToMain( false, $return );
|
|
|
|
|
}
|
2006-01-06 23:09:37 +00:00
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2007-05-18 20:46:42 +00:00
|
|
|
* Output a standard error page
|
2006-11-07 05:37:31 +00:00
|
|
|
*
|
2007-05-18 20:46:42 +00:00
|
|
|
* @param string $title Message key for page title
|
|
|
|
|
* @param string $msg Message key for page text
|
|
|
|
|
* @param array $params Message parameters
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2007-05-18 20:46:42 +00:00
|
|
|
public function showErrorPage( $title, $msg, $params = array() ) {
|
2003-04-14 23:10:40 +00:00
|
|
|
global $wgTitle;
|
|
|
|
|
|
2004-08-22 17:24:50 +00:00
|
|
|
$this->mDebugtext .= 'Original title: ' .
|
2003-04-14 23:10:40 +00:00
|
|
|
$wgTitle->getPrefixedText() . "\n";
|
|
|
|
|
$this->setPageTitle( wfMsg( $title ) );
|
2004-08-22 17:24:50 +00:00
|
|
|
$this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
|
|
|
|
|
$this->setRobotpolicy( 'noindex,nofollow' );
|
2004-01-17 09:49:43 +00:00
|
|
|
$this->setArticleRelated( false );
|
2004-03-23 10:19:31 +00:00
|
|
|
$this->enableClientCache( false );
|
2004-08-22 17:24:50 +00:00
|
|
|
$this->mRedirect = '';
|
|
|
|
|
$this->mBodytext = '';
|
2007-05-18 20:46:42 +00:00
|
|
|
|
2007-08-22 06:41:50 +00:00
|
|
|
array_unshift( $params, 'parse' );
|
2007-05-18 20:46:42 +00:00
|
|
|
array_unshift( $params, $msg );
|
2007-08-22 06:41:50 +00:00
|
|
|
$this->addHtml( call_user_func_array( 'wfMsgExt', $params ) );
|
2007-05-18 20:46:42 +00:00
|
|
|
|
2003-04-14 23:10:40 +00:00
|
|
|
$this->returnToMain( false );
|
|
|
|
|
}
|
|
|
|
|
|
2007-08-06 11:30:40 +00:00
|
|
|
/**
|
|
|
|
|
* Output a standard permission error page
|
|
|
|
|
*
|
|
|
|
|
* @param array $errors Error message keys
|
|
|
|
|
*/
|
|
|
|
|
public function showPermissionsErrorPage( $errors )
|
2007-08-01 10:19:26 +00:00
|
|
|
{
|
|
|
|
|
global $wgTitle;
|
|
|
|
|
|
|
|
|
|
$this->mDebugtext .= 'Original title: ' .
|
|
|
|
|
$wgTitle->getPrefixedText() . "\n";
|
|
|
|
|
$this->setPageTitle( wfMsg( 'permissionserrors' ) );
|
|
|
|
|
$this->setHTMLTitle( wfMsg( 'permissionserrors' ) );
|
|
|
|
|
$this->setRobotpolicy( 'noindex,nofollow' );
|
|
|
|
|
$this->setArticleRelated( false );
|
|
|
|
|
$this->enableClientCache( false );
|
|
|
|
|
$this->mRedirect = '';
|
|
|
|
|
$this->mBodytext = '';
|
2007-08-31 21:33:44 +00:00
|
|
|
$this->addWikiText( $this->formatPermissionsErrorMessage( $errors ) );
|
2007-08-01 10:19:26 +00:00
|
|
|
}
|
|
|
|
|
|
2007-04-04 05:22:37 +00:00
|
|
|
/** @deprecated */
|
2006-11-07 05:37:31 +00:00
|
|
|
public function errorpage( $title, $msg ) {
|
2006-06-07 06:40:24 +00:00
|
|
|
throw new ErrorPageError( $title, $msg );
|
|
|
|
|
}
|
|
|
|
|
|
2005-06-26 06:49:56 +00:00
|
|
|
/**
|
|
|
|
|
* Display an error page indicating that a given version of MediaWiki is
|
|
|
|
|
* required to use it
|
|
|
|
|
*
|
|
|
|
|
* @param mixed $version The version of MediaWiki needed to use the page
|
|
|
|
|
*/
|
2006-11-07 05:37:31 +00:00
|
|
|
public function versionRequired( $version ) {
|
2005-06-26 06:49:56 +00:00
|
|
|
$this->setPageTitle( wfMsg( 'versionrequired', $version ) );
|
|
|
|
|
$this->setHTMLTitle( wfMsg( 'versionrequired', $version ) );
|
|
|
|
|
$this->setRobotpolicy( 'noindex,nofollow' );
|
|
|
|
|
$this->setArticleRelated( false );
|
|
|
|
|
$this->mBodytext = '';
|
|
|
|
|
|
|
|
|
|
$this->addWikiText( wfMsg( 'versionrequiredtext', $version ) );
|
|
|
|
|
$this->returnToMain();
|
|
|
|
|
}
|
2005-07-01 00:03:31 +00:00
|
|
|
|
2005-06-19 06:25:53 +00:00
|
|
|
/**
|
|
|
|
|
* Display an error page noting that a given permission bit is required.
|
2006-11-07 05:37:31 +00:00
|
|
|
*
|
2005-06-19 06:25:53 +00:00
|
|
|
* @param string $permission key required
|
|
|
|
|
*/
|
2006-11-07 05:37:31 +00:00
|
|
|
public function permissionRequired( $permission ) {
|
2007-08-27 21:05:19 +00:00
|
|
|
global $wgGroupPermissions, $wgUser;
|
2005-06-19 06:25:53 +00:00
|
|
|
|
|
|
|
|
$this->setPageTitle( wfMsg( 'badaccess' ) );
|
|
|
|
|
$this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
|
|
|
|
|
$this->setRobotpolicy( 'noindex,nofollow' );
|
|
|
|
|
$this->setArticleRelated( false );
|
|
|
|
|
$this->mBodytext = '';
|
|
|
|
|
|
2007-08-26 09:49:28 +00:00
|
|
|
$groups = array();
|
|
|
|
|
foreach( $wgGroupPermissions as $key => $value ) {
|
|
|
|
|
if( isset( $value[$permission] ) && $value[$permission] == true ) {
|
|
|
|
|
$groupName = User::getGroupName( $key );
|
|
|
|
|
$groupPage = User::getGroupPage( $key );
|
|
|
|
|
if( $groupPage ) {
|
|
|
|
|
$skin = $wgUser->getSkin();
|
|
|
|
|
$groups[] = $skin->makeLinkObj( $groupPage, $groupName );
|
|
|
|
|
} else {
|
|
|
|
|
$groups[] = $groupName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-08-27 21:05:19 +00:00
|
|
|
$n = count( $groups );
|
|
|
|
|
$groups = implode( ', ', $groups );
|
|
|
|
|
switch( $n ) {
|
|
|
|
|
case 0:
|
|
|
|
|
case 1:
|
|
|
|
|
case 2:
|
2007-08-31 20:34:41 +00:00
|
|
|
$message = wfMsgHtml( "badaccess-group$n", $groups );
|
2007-08-27 21:05:19 +00:00
|
|
|
break;
|
|
|
|
|
default:
|
2007-08-31 20:34:41 +00:00
|
|
|
$message = wfMsgHtml( 'badaccess-groups', $groups );
|
2007-08-27 21:05:19 +00:00
|
|
|
}
|
2007-08-31 20:47:04 +00:00
|
|
|
$this->addHtml( $message );
|
2007-08-27 21:05:19 +00:00
|
|
|
$this->returnToMain( false );
|
2007-08-26 09:49:28 +00:00
|
|
|
}
|
2005-07-01 00:03:31 +00:00
|
|
|
|
2005-06-19 06:25:53 +00:00
|
|
|
/**
|
2006-11-07 05:37:31 +00:00
|
|
|
* Use permissionRequired.
|
2005-06-19 06:25:53 +00:00
|
|
|
* @deprecated
|
|
|
|
|
*/
|
2006-11-07 05:37:31 +00:00
|
|
|
public function sysopRequired() {
|
2006-08-08 13:58:25 +00:00
|
|
|
throw new MWException( "Call to deprecated OutputPage::sysopRequired() method\n" );
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
2005-06-19 06:25:53 +00:00
|
|
|
/**
|
2006-11-07 05:37:31 +00:00
|
|
|
* Use permissionRequired.
|
2005-06-19 06:25:53 +00:00
|
|
|
* @deprecated
|
|
|
|
|
*/
|
2006-11-07 05:37:31 +00:00
|
|
|
public function developerRequired() {
|
2006-08-08 13:58:25 +00:00
|
|
|
throw new MWException( "Call to deprecated OutputPage::developerRequired() method\n" );
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
2006-05-02 15:37:06 +00:00
|
|
|
/**
|
|
|
|
|
* Produce the stock "please login to use the wiki" page
|
|
|
|
|
*/
|
2006-11-07 05:37:31 +00:00
|
|
|
public function loginToUse() {
|
2004-09-24 13:14:52 +00:00
|
|
|
global $wgUser, $wgTitle, $wgContLang;
|
2006-09-06 17:19:43 +00:00
|
|
|
|
|
|
|
|
if( $wgUser->isLoggedIn() ) {
|
|
|
|
|
$this->permissionRequired( 'read' );
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2006-11-08 07:12:03 +00:00
|
|
|
$skin = $wgUser->getSkin();
|
|
|
|
|
|
2004-08-22 17:24:50 +00:00
|
|
|
$this->setPageTitle( wfMsg( 'loginreqtitle' ) );
|
2006-05-02 15:37:06 +00:00
|
|
|
$this->setHtmlTitle( wfMsg( 'errorpagetitle' ) );
|
|
|
|
|
$this->setRobotPolicy( 'noindex,nofollow' );
|
2004-03-05 13:19:19 +00:00
|
|
|
$this->setArticleFlag( false );
|
2006-05-02 15:37:06 +00:00
|
|
|
|
2006-10-30 06:25:31 +00:00
|
|
|
$loginTitle = SpecialPage::getTitleFor( 'Userlogin' );
|
2006-11-08 07:12:03 +00:00
|
|
|
$loginLink = $skin->makeKnownLinkObj( $loginTitle, wfMsgHtml( 'loginreqlink' ), 'returnto=' . $wgTitle->getPrefixedUrl() );
|
2006-06-20 18:20:58 +00:00
|
|
|
$this->addHtml( wfMsgWikiHtml( 'loginreqpagetext', $loginLink ) );
|
2006-05-02 15:37:06 +00:00
|
|
|
$this->addHtml( "\n<!--" . $wgTitle->getPrefixedUrl() . "-->" );
|
|
|
|
|
|
2006-08-31 17:15:30 +00:00
|
|
|
# Don't return to the main page if the user can't read it
|
|
|
|
|
# otherwise we'll end up in a pointless loop
|
2006-12-03 00:22:14 +00:00
|
|
|
$mainPage = Title::newMainPage();
|
2006-08-31 17:15:30 +00:00
|
|
|
if( $mainPage->userCanRead() )
|
|
|
|
|
$this->returnToMain( true, $mainPage );
|
2004-03-05 13:19:19 +00:00
|
|
|
}
|
|
|
|
|
|
2007-04-04 05:22:37 +00:00
|
|
|
/** @deprecated */
|
2006-11-07 05:37:31 +00:00
|
|
|
public function databaseError( $fname, $sql, $error, $errno ) {
|
2006-06-07 06:40:24 +00:00
|
|
|
throw new MWException( "OutputPage::databaseError is obsolete\n" );
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
2007-08-03 09:27:28 +00:00
|
|
|
/**
|
2007-08-16 07:05:38 +00:00
|
|
|
* @param array $errors An array of arrays returned by Title::getUserPermissionsErrors
|
2008-01-02 01:16:44 +00:00
|
|
|
* @return string The error-messages, formatted into a list.
|
2007-08-03 09:27:28 +00:00
|
|
|
*/
|
|
|
|
|
public function formatPermissionsErrorMessage( $errors ) {
|
2008-01-02 01:16:44 +00:00
|
|
|
$text = '';
|
|
|
|
|
|
|
|
|
|
if (sizeof( $errors ) > 1) {
|
2007-08-03 09:27:28 +00:00
|
|
|
|
2008-01-02 01:16:44 +00:00
|
|
|
$text .= wfMsgExt( 'permissionserrorstext', array( 'parse' ), count( $errors ) ) . "\n";
|
2007-08-16 07:05:38 +00:00
|
|
|
$text .= '<ul class="permissions-errors">' . "\n";
|
|
|
|
|
|
|
|
|
|
foreach( $errors as $error )
|
|
|
|
|
{
|
|
|
|
|
$text .= '<li>';
|
2007-08-16 07:23:40 +00:00
|
|
|
$text .= call_user_func_array( 'wfMsg', $error );
|
2007-08-16 07:05:38 +00:00
|
|
|
$text .= "</li>\n";
|
|
|
|
|
}
|
|
|
|
|
$text .= '</ul>';
|
|
|
|
|
} else {
|
2008-01-02 01:16:44 +00:00
|
|
|
$text .= call_user_func_array( 'wfMsg', $errors[0]);
|
2007-08-03 09:27:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $text;
|
|
|
|
|
}
|
|
|
|
|
|
2006-11-07 05:37:31 +00:00
|
|
|
/**
|
2007-12-09 00:16:59 +00:00
|
|
|
* Display a page stating that the Wiki is in read-only mode,
|
|
|
|
|
* and optionally show the source of the page that the user
|
|
|
|
|
* was trying to edit. Should only be called (for this
|
|
|
|
|
* purpose) after wfReadOnly() has returned true.
|
|
|
|
|
*
|
|
|
|
|
* For historical reasons, this function is _also_ used to
|
|
|
|
|
* show the error message when a user tries to edit a page
|
|
|
|
|
* they are not allowed to edit. (Unless it's because they're
|
|
|
|
|
* blocked, then we show blockedPage() instead.) In this
|
|
|
|
|
* case, the second parameter should be set to true and a list
|
|
|
|
|
* of reasons supplied as the third parameter.
|
|
|
|
|
*
|
|
|
|
|
* @todo Needs to be split into multiple functions.
|
|
|
|
|
*
|
|
|
|
|
* @param string $source Source code to show (or null).
|
|
|
|
|
* @param bool $protected Is this a permissions error?
|
|
|
|
|
* @param array $reasons List of reasons for this error, as returned by Title::getUserPermissionsErrors().
|
2006-11-07 05:37:31 +00:00
|
|
|
*/
|
2007-08-03 09:27:28 +00:00
|
|
|
public function readOnlyPage( $source = null, $protected = false, $reasons = array() ) {
|
2006-04-04 15:51:35 +00:00
|
|
|
global $wgUser, $wgReadOnlyFile, $wgReadOnly, $wgTitle;
|
2007-12-09 16:16:33 +00:00
|
|
|
$skin = $wgUser->getSkin();
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2004-08-22 17:24:50 +00:00
|
|
|
$this->setRobotpolicy( 'noindex,nofollow' );
|
2004-01-17 09:49:43 +00:00
|
|
|
$this->setArticleRelated( false );
|
2007-08-31 20:34:41 +00:00
|
|
|
|
2007-12-09 00:16:59 +00:00
|
|
|
// If no reason is given, just supply a default "I can't let you do
|
|
|
|
|
// that, Dave" message. Should only occur if called by legacy code.
|
|
|
|
|
if ( $protected && empty($reasons) ) {
|
|
|
|
|
$reasons[] = array( 'badaccess-group0' );
|
|
|
|
|
}
|
|
|
|
|
|
2007-08-31 20:34:41 +00:00
|
|
|
if ( !empty($reasons) ) {
|
2007-12-09 00:16:59 +00:00
|
|
|
// Permissions error
|
2007-08-03 09:27:28 +00:00
|
|
|
$this->setPageTitle( wfMsg( 'viewsource' ) );
|
|
|
|
|
$this->setSubtitle( wfMsg( 'viewsourcefor', $skin->makeKnownLinkObj( $wgTitle ) ) );
|
2007-08-31 21:33:44 +00:00
|
|
|
$this->addWikiText( $this->formatPermissionsErrorMessage( $reasons ) );
|
2003-11-09 11:45:12 +00:00
|
|
|
} else {
|
2007-12-09 00:16:59 +00:00
|
|
|
// Wiki is read only
|
2004-08-22 17:24:50 +00:00
|
|
|
$this->setPageTitle( wfMsg( 'readonly' ) );
|
2005-06-01 06:18:49 +00:00
|
|
|
if ( $wgReadOnly ) {
|
|
|
|
|
$reason = $wgReadOnly;
|
|
|
|
|
} else {
|
2007-12-09 00:16:59 +00:00
|
|
|
// Should not happen, user should have called wfReadOnly() first
|
2005-06-01 06:18:49 +00:00
|
|
|
$reason = file_get_contents( $wgReadOnlyFile );
|
|
|
|
|
}
|
2004-08-22 17:24:50 +00:00
|
|
|
$this->addWikiText( wfMsg( 'readonlytext', $reason ) );
|
2003-11-09 11:45:12 +00:00
|
|
|
}
|
2004-07-08 14:53:54 +00:00
|
|
|
|
2007-12-09 00:16:59 +00:00
|
|
|
// Show source, if supplied
|
2004-04-30 07:18:38 +00:00
|
|
|
if( is_string( $source ) ) {
|
2006-12-18 18:26:57 +00:00
|
|
|
$this->addWikiText( wfMsg( 'viewsourcetext' ) );
|
2007-12-09 00:16:59 +00:00
|
|
|
$text = wfOpenElement( 'textarea',
|
|
|
|
|
array( 'id' => 'wpTextbox1',
|
|
|
|
|
'name' => 'wpTextbox1',
|
|
|
|
|
'cols' => $wgUser->getOption( 'cols' ),
|
|
|
|
|
'rows' => $wgUser->getOption( 'rows' ),
|
|
|
|
|
'readonly' => 'readonly' ) );
|
|
|
|
|
$text .= htmlspecialchars( $source );
|
|
|
|
|
$text .= wfCloseElement( 'textarea' );
|
2003-11-09 11:45:12 +00:00
|
|
|
$this->addHTML( $text );
|
2007-12-09 00:16:59 +00:00
|
|
|
|
|
|
|
|
// Show templates used by this article
|
|
|
|
|
$skin = $wgUser->getSkin();
|
|
|
|
|
$article = new Article( $wgTitle );
|
|
|
|
|
$this->addHTML( $skin->formatTemplates( $article->getUsedTemplates() ) );
|
2003-09-09 05:46:22 +00:00
|
|
|
}
|
2004-07-08 14:53:54 +00:00
|
|
|
|
2007-09-14 20:53:19 +00:00
|
|
|
$this->returnToMain( false, $wgTitle );
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
2007-04-04 05:22:37 +00:00
|
|
|
/** @deprecated */
|
2006-11-07 05:37:31 +00:00
|
|
|
public function fatalError( $message ) {
|
2006-06-07 06:40:24 +00:00
|
|
|
throw new FatalError( $message );
|
|
|
|
|
}
|
|
|
|
|
|
2007-04-04 05:22:37 +00:00
|
|
|
/** @deprecated */
|
2006-11-07 05:37:31 +00:00
|
|
|
public function unexpectedValueError( $name, $val ) {
|
2006-06-07 06:40:24 +00:00
|
|
|
throw new FatalError( wfMsg( 'unexpected', $name, $val ) );
|
|
|
|
|
}
|
|
|
|
|
|
2007-04-04 05:22:37 +00:00
|
|
|
/** @deprecated */
|
2006-11-07 05:37:31 +00:00
|
|
|
public function fileCopyError( $old, $new ) {
|
2006-06-07 06:40:24 +00:00
|
|
|
throw new FatalError( wfMsg( 'filecopyerror', $old, $new ) );
|
|
|
|
|
}
|
|
|
|
|
|
2007-04-04 05:22:37 +00:00
|
|
|
/** @deprecated */
|
2006-11-07 05:37:31 +00:00
|
|
|
public function fileRenameError( $old, $new ) {
|
2006-06-07 06:40:24 +00:00
|
|
|
throw new FatalError( wfMsg( 'filerenameerror', $old, $new ) );
|
|
|
|
|
}
|
|
|
|
|
|
2007-04-04 05:22:37 +00:00
|
|
|
/** @deprecated */
|
2006-11-07 05:37:31 +00:00
|
|
|
public function fileDeleteError( $name ) {
|
2006-06-07 06:40:24 +00:00
|
|
|
throw new FatalError( wfMsg( 'filedeleteerror', $name ) );
|
|
|
|
|
}
|
|
|
|
|
|
2007-04-04 05:22:37 +00:00
|
|
|
/** @deprecated */
|
2006-11-07 05:37:31 +00:00
|
|
|
public function fileNotFoundError( $name ) {
|
2006-06-07 06:40:24 +00:00
|
|
|
throw new FatalError( wfMsg( 'filenotfound', $name ) );
|
|
|
|
|
}
|
|
|
|
|
|
2006-11-07 05:37:31 +00:00
|
|
|
public function showFatalError( $message ) {
|
2003-04-14 23:10:40 +00:00
|
|
|
$this->setPageTitle( wfMsg( "internalerror" ) );
|
|
|
|
|
$this->setRobotpolicy( "noindex,nofollow" );
|
2004-01-17 09:49:43 +00:00
|
|
|
$this->setArticleRelated( false );
|
2004-03-23 10:19:31 +00:00
|
|
|
$this->enableClientCache( false );
|
2004-08-22 17:24:50 +00:00
|
|
|
$this->mRedirect = '';
|
2003-04-14 23:10:40 +00:00
|
|
|
$this->mBodytext = $message;
|
|
|
|
|
}
|
|
|
|
|
|
2006-11-07 05:37:31 +00:00
|
|
|
public function showUnexpectedValueError( $name, $val ) {
|
2006-06-07 06:40:24 +00:00
|
|
|
$this->showFatalError( wfMsg( 'unexpected', $name, $val ) );
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
2006-11-07 05:37:31 +00:00
|
|
|
public function showFileCopyError( $old, $new ) {
|
2006-06-07 06:40:24 +00:00
|
|
|
$this->showFatalError( wfMsg( 'filecopyerror', $old, $new ) );
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
2006-11-07 05:37:31 +00:00
|
|
|
public function showFileRenameError( $old, $new ) {
|
2006-06-07 06:40:24 +00:00
|
|
|
$this->showFatalError( wfMsg( 'filerenameerror', $old, $new ) );
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
2006-11-07 05:37:31 +00:00
|
|
|
public function showFileDeleteError( $name ) {
|
2006-06-07 06:40:24 +00:00
|
|
|
$this->showFatalError( wfMsg( 'filedeleteerror', $name ) );
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
2006-11-07 05:37:31 +00:00
|
|
|
public function showFileNotFoundError( $name ) {
|
2006-06-07 06:40:24 +00:00
|
|
|
$this->showFatalError( wfMsg( 'filenotfound', $name ) );
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2007-07-29 23:53:45 +00:00
|
|
|
* Add a "return to" link pointing to a specified title
|
|
|
|
|
*
|
|
|
|
|
* @param Title $title Title to link
|
|
|
|
|
*/
|
|
|
|
|
public function addReturnTo( $title ) {
|
|
|
|
|
global $wgUser;
|
|
|
|
|
$link = wfMsg( 'returnto', $wgUser->getSkin()->makeLinkObj( $title ) );
|
|
|
|
|
$this->addHtml( "<p>{$link}</p>\n" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add a "return to" link pointing to a specified title,
|
|
|
|
|
* or the title indicated in the request, or else the main page
|
|
|
|
|
*
|
|
|
|
|
* @param null $unused No longer used
|
|
|
|
|
* @param Title $returnto Title to return to
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2007-07-10 21:47:36 +00:00
|
|
|
public function returnToMain( $unused = null, $returnto = NULL ) {
|
2007-07-29 23:53:45 +00:00
|
|
|
global $wgRequest;
|
2006-06-21 16:28:04 +00:00
|
|
|
|
2004-04-01 12:44:54 +00:00
|
|
|
if ( $returnto == NULL ) {
|
|
|
|
|
$returnto = $wgRequest->getText( 'returnto' );
|
|
|
|
|
}
|
2006-06-21 16:28:04 +00:00
|
|
|
|
|
|
|
|
if ( '' === $returnto ) {
|
2006-12-03 00:22:14 +00:00
|
|
|
$returnto = Title::newMainPage();
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2006-06-21 16:28:04 +00:00
|
|
|
|
|
|
|
|
if ( is_object( $returnto ) ) {
|
|
|
|
|
$titleObj = $returnto;
|
|
|
|
|
} else {
|
|
|
|
|
$titleObj = Title::newFromText( $returnto );
|
|
|
|
|
}
|
2006-06-23 06:53:05 +00:00
|
|
|
if ( !is_object( $titleObj ) ) {
|
|
|
|
|
$titleObj = Title::newMainPage();
|
|
|
|
|
}
|
2006-06-21 16:28:04 +00:00
|
|
|
|
2007-07-29 23:53:45 +00:00
|
|
|
$this->addReturnTo( $titleObj );
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2005-07-12 21:23:28 +00:00
|
|
|
* This function takes the title (first item of mGoodLinks), categories, existing and broken links for the page
|
2004-09-02 23:28:24 +00:00
|
|
|
* and uses the first 10 of them for META keywords
|
2006-11-07 05:37:31 +00:00
|
|
|
*
|
|
|
|
|
* @param ParserOutput &$parserOutput
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2006-11-07 05:37:31 +00:00
|
|
|
private function addKeywords( &$parserOutput ) {
|
2005-12-30 09:33:11 +00:00
|
|
|
global $wgTitle;
|
|
|
|
|
$this->addKeyword( $wgTitle->getPrefixedText() );
|
|
|
|
|
$count = 1;
|
|
|
|
|
$links2d =& $parserOutput->getLinks();
|
2006-04-02 03:59:07 +00:00
|
|
|
if ( !is_array( $links2d ) ) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2006-11-23 08:25:56 +00:00
|
|
|
foreach ( $links2d as $dbkeys ) {
|
2006-11-25 17:11:58 +00:00
|
|
|
foreach( $dbkeys as $dbkey => $unused ) {
|
2005-12-30 09:33:11 +00:00
|
|
|
$this->addKeyword( $dbkey );
|
|
|
|
|
if ( ++$count > 10 ) {
|
|
|
|
|
break 2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-03-20 13:27:08 +00:00
|
|
|
}
|
|
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2006-11-07 05:37:31 +00:00
|
|
|
* @return string The doctype, opening <html>, and head element.
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2006-11-07 05:37:31 +00:00
|
|
|
public function headElement() {
|
2004-09-24 13:14:52 +00:00
|
|
|
global $wgDocType, $wgDTD, $wgContLanguageCode, $wgOutputEncoding, $wgMimeType;
|
2007-01-07 22:31:07 +00:00
|
|
|
global $wgXhtmlDefaultNamespace, $wgXhtmlNamespaces;
|
2006-10-13 21:48:19 +00:00
|
|
|
global $wgUser, $wgContLang, $wgUseTrackbacks, $wgTitle, $wgStyleVersion;
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2005-02-07 14:11:59 +00:00
|
|
|
if( $wgMimeType == 'text/xml' || $wgMimeType == 'application/xhtml+xml' || $wgMimeType == 'application/xml' ) {
|
2005-04-15 18:37:39 +00:00
|
|
|
$ret = "<?xml version=\"1.0\" encoding=\"$wgOutputEncoding\" ?>\n";
|
2004-04-03 10:01:08 +00:00
|
|
|
} else {
|
2004-08-22 17:24:50 +00:00
|
|
|
$ret = '';
|
2004-04-03 10:01:08 +00:00
|
|
|
}
|
2004-07-08 14:53:54 +00:00
|
|
|
|
2004-04-09 10:15:08 +00:00
|
|
|
$ret .= "<!DOCTYPE html PUBLIC \"$wgDocType\"\n \"$wgDTD\">\n";
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2005-08-17 12:00:07 +00:00
|
|
|
if ( '' == $this->getHTMLTitle() ) {
|
|
|
|
|
$this->setHTMLTitle( wfMsg( 'pagetitle', $this->getPageTitle() ));
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2005-02-07 14:11:59 +00:00
|
|
|
|
2006-05-31 20:39:14 +00:00
|
|
|
$rtl = $wgContLang->isRTL() ? " dir='RTL'" : '';
|
2007-01-07 22:31:07 +00:00
|
|
|
$ret .= "<html xmlns=\"{$wgXhtmlDefaultNamespace}\" ";
|
|
|
|
|
foreach($wgXhtmlNamespaces as $tag => $ns) {
|
|
|
|
|
$ret .= "xmlns:{$tag}=\"{$ns}\" ";
|
|
|
|
|
}
|
|
|
|
|
$ret .= "xml:lang=\"$wgContLanguageCode\" lang=\"$wgContLanguageCode\" $rtl>\n";
|
2005-08-17 12:00:07 +00:00
|
|
|
$ret .= "<head>\n<title>" . htmlspecialchars( $this->getHTMLTitle() ) . "</title>\n";
|
2004-04-03 10:01:08 +00:00
|
|
|
array_push( $this->mMetatags, array( "http:Content-type", "$wgMimeType; charset={$wgOutputEncoding}" ) );
|
2004-07-08 14:53:54 +00:00
|
|
|
|
2004-04-09 04:53:52 +00:00
|
|
|
$ret .= $this->getHeadLinks();
|
2004-04-27 12:18:48 +00:00
|
|
|
global $wgStylePath;
|
2004-04-09 04:53:52 +00:00
|
|
|
if( $this->isPrintable() ) {
|
2004-08-22 17:24:50 +00:00
|
|
|
$media = '';
|
2004-04-09 04:53:52 +00:00
|
|
|
} else {
|
|
|
|
|
$media = "media='print'";
|
|
|
|
|
}
|
2006-10-13 21:48:19 +00:00
|
|
|
$printsheet = htmlspecialchars( "$wgStylePath/common/wikiprintable.css?$wgStyleVersion" );
|
2004-04-09 04:53:52 +00:00
|
|
|
$ret .= "<link rel='stylesheet' type='text/css' $media href='$printsheet' />\n";
|
|
|
|
|
|
|
|
|
|
$sk = $wgUser->getSkin();
|
2007-05-08 20:48:02 +00:00
|
|
|
$ret .= $sk->getHeadScripts( $this->mAllowUserJs );
|
2004-05-17 23:18:37 +00:00
|
|
|
$ret .= $this->mScripts;
|
2004-04-09 04:53:52 +00:00
|
|
|
$ret .= $sk->getUserStyles();
|
2007-04-03 21:58:18 +00:00
|
|
|
$ret .= $this->getHeadItems();
|
2004-04-09 04:53:52 +00:00
|
|
|
|
2005-07-23 05:47:25 +00:00
|
|
|
if ($wgUseTrackbacks && $this->isArticleRelated())
|
|
|
|
|
$ret .= $wgTitle->trackbackRDF();
|
|
|
|
|
|
2004-04-09 04:53:52 +00:00
|
|
|
$ret .= "</head>\n";
|
|
|
|
|
return $ret;
|
|
|
|
|
}
|
2004-07-08 14:53:54 +00:00
|
|
|
|
2006-11-07 05:37:31 +00:00
|
|
|
/**
|
|
|
|
|
* @return string HTML tag links to be put in the header.
|
|
|
|
|
*/
|
|
|
|
|
public function getHeadLinks() {
|
2006-03-07 01:10:39 +00:00
|
|
|
global $wgRequest;
|
2004-08-22 17:24:50 +00:00
|
|
|
$ret = '';
|
2003-04-14 23:10:40 +00:00
|
|
|
foreach ( $this->mMetatags as $tag ) {
|
2004-08-22 17:24:50 +00:00
|
|
|
if ( 0 == strcasecmp( 'http:', substr( $tag[0], 0, 5 ) ) ) {
|
|
|
|
|
$a = 'http-equiv';
|
2003-04-14 23:10:40 +00:00
|
|
|
$tag[0] = substr( $tag[0], 5 );
|
|
|
|
|
} else {
|
2004-08-22 17:24:50 +00:00
|
|
|
$a = 'name';
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2004-04-03 10:01:08 +00:00
|
|
|
$ret .= "<meta $a=\"{$tag[0]}\" content=\"{$tag[1]}\" />\n";
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2003-04-14 23:10:40 +00:00
|
|
|
$p = $this->mRobotpolicy;
|
2005-12-08 02:38:46 +00:00
|
|
|
if( $p !== '' && $p != 'index,follow' ) {
|
|
|
|
|
// http://www.robotstxt.org/wc/meta-user.html
|
|
|
|
|
// Only show if it's different from the default robots policy
|
|
|
|
|
$ret .= "<meta name=\"robots\" content=\"$p\" />\n";
|
|
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
|
|
|
|
|
if ( count( $this->mKeywords ) > 0 ) {
|
2004-04-15 12:27:31 +00:00
|
|
|
$strip = array(
|
2005-05-15 18:39:18 +00:00
|
|
|
"/<.*?>/" => '',
|
|
|
|
|
"/_/" => ' '
|
2004-04-15 12:27:31 +00:00
|
|
|
);
|
2007-01-21 16:01:50 +00:00
|
|
|
$ret .= "\t\t<meta name=\"keywords\" content=\"" .
|
2004-04-15 12:27:31 +00:00
|
|
|
htmlspecialchars(preg_replace(array_keys($strip), array_values($strip),implode( ",", $this->mKeywords ))) . "\" />\n";
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
foreach ( $this->mLinktags as $tag ) {
|
2007-01-21 16:01:50 +00:00
|
|
|
$ret .= "\t\t<link";
|
2004-04-10 11:19:33 +00:00
|
|
|
foreach( $tag as $attr => $val ) {
|
|
|
|
|
$ret .= " $attr=\"" . htmlspecialchars( $val ) . "\"";
|
|
|
|
|
}
|
|
|
|
|
$ret .= " />\n";
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2007-09-24 04:43:23 +00:00
|
|
|
|
2004-03-19 08:05:36 +00:00
|
|
|
if( $this->isSyndicated() ) {
|
2007-09-24 04:43:23 +00:00
|
|
|
# Use the page name for the title (accessed through $wgTitle since
|
|
|
|
|
# there's no other way). In principle, this could lead to issues
|
|
|
|
|
# with having the same name for different feeds corresponding to
|
|
|
|
|
# the same page, but we can't avoid that at this low a level.
|
2007-12-08 12:46:18 +00:00
|
|
|
global $wgTitle, $wgFeedClasses;
|
|
|
|
|
|
|
|
|
|
if( is_string( $this->getFeedAppendQuery() ) ) {
|
|
|
|
|
$appendQuery = "&" . $this->getFeedAppendQuery();
|
|
|
|
|
} else {
|
|
|
|
|
$appendQuery = "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach( $wgFeedClasses as $format => $class ) {
|
|
|
|
|
$ret .= $this->feedLink(
|
|
|
|
|
$format,
|
2007-12-19 01:42:51 +00:00
|
|
|
$wgRequest->appendQuery( "feed=$format{$appendQuery}" ),
|
2007-12-08 12:46:18 +00:00
|
|
|
wfMsg( "page-{$format}-feed", $wgTitle->getPrefixedText() ) );
|
|
|
|
|
}
|
2004-03-19 08:05:36 +00:00
|
|
|
}
|
2005-01-18 00:05:35 +00:00
|
|
|
|
2007-09-24 18:25:56 +00:00
|
|
|
# Recent changes feed should appear on every page
|
|
|
|
|
# Put it after the per-page feed to avoid changing existing behavior.
|
|
|
|
|
# It's still available, probably via a menu in your browser.
|
|
|
|
|
global $wgSitename;
|
|
|
|
|
$rctitle = SpecialPage::getTitleFor( 'Recentchanges' );
|
|
|
|
|
$ret .= $this->feedLink(
|
|
|
|
|
'rss',
|
|
|
|
|
$rctitle->getFullURL( 'feed=rss' ),
|
|
|
|
|
wfMsg( 'site-rss-feed', $wgSitename ) );
|
|
|
|
|
$ret .= $this->feedLink(
|
|
|
|
|
'atom',
|
|
|
|
|
$rctitle->getFullURL( 'feed=atom' ),
|
|
|
|
|
wfMsg( 'site-atom-feed', $wgSitename ) );
|
|
|
|
|
|
2003-04-14 23:10:40 +00:00
|
|
|
return $ret;
|
|
|
|
|
}
|
2007-09-24 18:25:56 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Generate a <link rel/> for an RSS feed.
|
|
|
|
|
*/
|
|
|
|
|
private function feedLink( $type, $url, $text ) {
|
|
|
|
|
return Xml::element( 'link', array(
|
|
|
|
|
'rel' => 'alternate',
|
|
|
|
|
'type' => "application/$type+xml",
|
|
|
|
|
'title' => $text,
|
|
|
|
|
'href' => $url ) ) . "\n";
|
|
|
|
|
}
|
2005-07-01 00:03:31 +00:00
|
|
|
|
2005-05-27 11:03:37 +00:00
|
|
|
/**
|
|
|
|
|
* Turn off regular page output and return an error reponse
|
|
|
|
|
* for when rate limiting has triggered.
|
|
|
|
|
*/
|
2006-11-07 05:37:31 +00:00
|
|
|
public function rateLimited() {
|
Find and fix places where globals were being used without declaring them.
All the places were found using a script, reproduced below, in case
anyone wants to reuse it.
But beware: The script produces a lot of false positives, because it
doesn't fully parse PHP and is fooled e.g. by javascript functions
inside of <<<HERE documents.
#!/usr/bin/perl -0777 -n
#
# find functions where variables starting with $wg are used without declaring them as globals
# should be given a list of files on the command line
#
# first remove all comments
# Warning: this may remove too much, e.g. if /* is inside a string
s,/\*.*?\*/,,sg; # remove multiline comments
s,#.*,,g; # remove single line comments starting with #
s,//.*,,g; # and the ones starting with //
s,(?<!\\)'.*?(?<!\\)',,g; # remove 'single quoted single-line strings'; may again remove too much
# now process each function one by one
# does not deal correctly with javascript functions embedded in <<HERE documents, unfortunately
#
while (/(^\s*)(?:(?:private|public|protected|static)\s+)*function\s+(\w+)\s*\((.*?)\)\s*\{(.*?)\1\}/msg) {
$fname = $2; $farg = $3; $fbody = $4;
%globals = ();
while ($farg =~ /(\$\w+)/g) { # treat arguments to functions as globals here
$globals{$1} = 1;
}
while ($fbody =~ /^\s*global\s+([^;]+?)\s*;/msg) { # find all global vars
for (split /\s*,\s*/, $1) {
$globals{$_} = 1;
}
}
while ($fbody =~ /(?<!\\)(\$wg\w+)\b/g) { # search for all variables starting with $wg and see if they are declared as globals
if (not $globals{$1}) {
print "Global $1 not declared in function $fname, file $ARGV\n";
$globals{$1} = 1; # warn only once
}
}
}
2007-12-17 12:24:16 +00:00
|
|
|
global $wgOut, $wgTitle;
|
2007-11-20 08:34:59 +00:00
|
|
|
|
|
|
|
|
$this->setPageTitle(wfMsg('actionthrottled'));
|
2007-11-20 17:32:43 +00:00
|
|
|
$this->setRobotPolicy( 'noindex,follow' );
|
2007-11-20 08:34:59 +00:00
|
|
|
$this->setArticleRelated( false );
|
|
|
|
|
$this->enableClientCache( false );
|
|
|
|
|
$this->mRedirect = '';
|
|
|
|
|
$this->clearHTML();
|
|
|
|
|
$this->setStatusCode(503);
|
|
|
|
|
$this->addWikiText( wfMsg('actionthrottledtext') );
|
|
|
|
|
|
|
|
|
|
$this->returnToMain( false, $wgTitle );
|
2005-05-27 11:03:37 +00:00
|
|
|
}
|
2006-05-01 20:35:08 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Show an "add new section" link?
|
|
|
|
|
*
|
2007-08-11 17:18:20 +00:00
|
|
|
* @return bool
|
2006-05-01 20:35:08 +00:00
|
|
|
*/
|
2006-11-07 05:37:31 +00:00
|
|
|
public function showNewSectionLink() {
|
2006-05-01 20:35:08 +00:00
|
|
|
return $this->mNewSectionLink;
|
|
|
|
|
}
|
2007-05-18 20:17:53 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Show a warning about slave lag
|
|
|
|
|
*
|
2007-08-11 17:18:20 +00:00
|
|
|
* If the lag is higher than $wgSlaveLagCritical seconds,
|
|
|
|
|
* then the warning is a bit more obvious. If the lag is
|
|
|
|
|
* lower than $wgSlaveLagWarning, then no warning is shown.
|
2007-05-18 20:17:53 +00:00
|
|
|
*
|
|
|
|
|
* @param int $lag Slave lag
|
|
|
|
|
*/
|
|
|
|
|
public function showLagWarning( $lag ) {
|
2007-05-24 18:06:21 +00:00
|
|
|
global $wgSlaveLagWarning, $wgSlaveLagCritical;
|
2007-08-11 17:18:20 +00:00
|
|
|
if( $lag >= $wgSlaveLagWarning ) {
|
|
|
|
|
$message = $lag < $wgSlaveLagCritical
|
|
|
|
|
? 'lag-warn-normal'
|
|
|
|
|
: 'lag-warn-high';
|
|
|
|
|
$warning = wfMsgExt( $message, 'parse', $lag );
|
|
|
|
|
$this->addHtml( "<div class=\"mw-{$message}\">\n{$warning}\n</div>\n" );
|
|
|
|
|
}
|
2007-05-18 20:17:53 +00:00
|
|
|
}
|
2007-12-10 06:02:29 +00:00
|
|
|
|
2007-08-16 07:05:38 +00:00
|
|
|
}
|