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-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 {
|
2008-07-25 01:27:51 +00:00
|
|
|
var $mMetatags = array(), $mKeywords = array(), $mLinktags = array();
|
2008-08-10 07:14:08 +00:00
|
|
|
var $mExtStyles = array();
|
2008-07-25 01:27:51 +00:00
|
|
|
var $mPagetitle = '', $mBodytext = '', $mDebugtext = '';
|
|
|
|
|
var $mHTMLtitle = '', $mIsarticle = true, $mPrintable = false;
|
|
|
|
|
var $mSubtitle = '', $mRedirect = '', $mStatusCode;
|
|
|
|
|
var $mLastModified = '', $mETag = false;
|
|
|
|
|
var $mCategoryLinks = array(), $mLanguageLinks = array();
|
|
|
|
|
var $mScripts = '', $mLinkColours, $mPageLinkTitle = '', $mHeadItems = array();
|
|
|
|
|
var $mTemplateIds = array();
|
2006-05-11 22:40:38 +00:00
|
|
|
|
2007-05-08 20:48:02 +00:00
|
|
|
var $mAllowUserJs;
|
2008-07-25 01:27:51 +00:00
|
|
|
var $mSuppressQuickbar = false;
|
|
|
|
|
var $mOnloadHandler = '';
|
|
|
|
|
var $mDoNothing = false;
|
|
|
|
|
var $mContainsOldMagic = 0, $mContainsNewMagic = 0;
|
|
|
|
|
var $mIsArticleRelated = true;
|
|
|
|
|
protected $mParserOptions = null; // 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;
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2006-05-11 22:40:38 +00:00
|
|
|
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();
|
2008-07-25 01:27:51 +00:00
|
|
|
var $mSquidMaxage = 0;
|
|
|
|
|
var $mRevisionId = null;
|
2004-07-08 14:53:54 +00:00
|
|
|
|
2008-08-21 14:09:57 +00:00
|
|
|
/**
|
|
|
|
|
* An array of stylesheet filenames (relative from skins path), with options
|
|
|
|
|
* for CSS media, IE conditions, and RTL/LTR direction.
|
|
|
|
|
* For internal use; add settings in the skin via $this->addStyle()
|
|
|
|
|
*/
|
|
|
|
|
var $styles = array();
|
|
|
|
|
|
2008-07-23 19:05:43 +00:00
|
|
|
private $mIndexPolicy = 'index';
|
|
|
|
|
private $mFollowPolicy = 'follow';
|
|
|
|
|
|
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;
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +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;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
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
|
|
|
|
2008-08-21 14:09:57 +00:00
|
|
|
/**
|
|
|
|
|
* Add a new <meta> tag
|
|
|
|
|
* To add an http-equiv meta tag, precede the name with "http:"
|
|
|
|
|
*
|
|
|
|
|
* @param $name tag name
|
|
|
|
|
* @param $val tag value
|
|
|
|
|
*/
|
|
|
|
|
function addMeta( $name, $val ) {
|
|
|
|
|
array_push( $this->mMetatags, array( $name, $val ) );
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-14 23:10:40 +00:00
|
|
|
function addKeyword( $text ) { array_push( $this->mKeywords, $text ); }
|
2007-01-21 16:46:36 +00:00
|
|
|
function addScript( $script ) { $this->mScripts .= "\t\t".$script; }
|
2008-08-10 07:14:08 +00:00
|
|
|
|
|
|
|
|
function addExtensionStyle( $url ) {
|
|
|
|
|
$linkarr = array( 'rel' => 'stylesheet', 'href' => $url, 'type' => 'text/css' );
|
|
|
|
|
array_push( $this->mExtStyles, $linkarr );
|
|
|
|
|
}
|
2006-12-08 06:09:15 +00:00
|
|
|
|
2008-05-09 20:18:35 +00:00
|
|
|
/**
|
|
|
|
|
* Add a JavaScript file out of skins/common, or a given relative path.
|
|
|
|
|
* @param string $file filename in skins/common or complete on-server path (/foo/bar.js)
|
|
|
|
|
*/
|
|
|
|
|
function addScriptFile( $file ) {
|
|
|
|
|
global $wgStylePath, $wgStyleVersion, $wgJsMimeType;
|
|
|
|
|
if( substr( $file, 0, 1 ) == '/' ) {
|
|
|
|
|
$path = $file;
|
|
|
|
|
} else {
|
|
|
|
|
$path = "{$wgStylePath}/common/{$file}";
|
|
|
|
|
}
|
|
|
|
|
$this->addScript( "<script type=\"{$wgJsMimeType}\" src=\"$path?$wgStyleVersion\"></script>\n" );
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2008-04-14 07:45:50 +00:00
|
|
|
function getScript() {
|
|
|
|
|
return $this->mScripts . $this->getHeadItems();
|
2007-04-03 21:58:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 );
|
|
|
|
|
}
|
2008-08-10 07:14:08 +00:00
|
|
|
|
|
|
|
|
# Get all links added by extensions
|
|
|
|
|
function getExtStyle() {
|
|
|
|
|
return $this->mExtStyles;
|
|
|
|
|
}
|
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.
|
|
|
|
|
*
|
2008-08-29 08:40:13 +00:00
|
|
|
* Side effect: sets mLastModified for Last-Modified header
|
|
|
|
|
*
|
2006-11-07 05:37:31 +00:00
|
|
|
* @return bool True iff cache-ok headers was sent.
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2008-12-23 19:39:00 +00:00
|
|
|
function checkLastModified ( $timestamp ) {
|
2006-08-14 18:18:35 +00:00
|
|
|
global $wgCachePages, $wgCacheEpoch, $wgUser, $wgRequest;
|
2008-08-29 08:40:13 +00:00
|
|
|
|
2005-03-20 03:59:06 +00:00
|
|
|
if ( !$timestamp || $timestamp == '19700101000000' ) {
|
2008-04-16 13:46:16 +00:00
|
|
|
wfDebug( __METHOD__ . ": CACHE DISABLED, NO TIMESTAMP\n" );
|
2008-08-29 08:40:13 +00:00
|
|
|
return false;
|
2005-03-20 03:59:06 +00:00
|
|
|
}
|
2003-07-10 04:55:41 +00:00
|
|
|
if( !$wgCachePages ) {
|
2008-04-16 13:46:16 +00:00
|
|
|
wfDebug( __METHOD__ . ": CACHE DISABLED\n", false );
|
2008-08-29 08:40:13 +00:00
|
|
|
return false;
|
2003-07-10 04:55:41 +00:00
|
|
|
}
|
2004-08-22 17:24:50 +00:00
|
|
|
if( $wgUser->getOption( 'nocache' ) ) {
|
2008-04-16 13:46:16 +00:00
|
|
|
wfDebug( __METHOD__ . ": USER DISABLED CACHE\n", false );
|
2008-08-29 08:40:13 +00:00
|
|
|
return false;
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2004-03-20 15:03:26 +00:00
|
|
|
|
2008-08-29 08:40:13 +00:00
|
|
|
$timestamp = wfTimestamp( TS_MW, $timestamp );
|
|
|
|
|
$modifiedTimes = array(
|
|
|
|
|
'page' => $timestamp,
|
|
|
|
|
'user' => $wgUser->getTouched(),
|
|
|
|
|
'epoch' => $wgCacheEpoch
|
|
|
|
|
);
|
|
|
|
|
wfRunHooks( 'OutputPageCheckLastModified', array( &$modifiedTimes ) );
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-08-29 08:40:13 +00:00
|
|
|
$maxModified = max( $modifiedTimes );
|
|
|
|
|
$this->mLastModified = wfTimestamp( TS_RFC2822, $maxModified );
|
|
|
|
|
|
|
|
|
|
if( empty( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) {
|
2008-04-16 13:46:16 +00:00
|
|
|
wfDebug( __METHOD__ . ": client did not send If-Modified-Since header\n", false );
|
2008-08-29 08:40:13 +00:00
|
|
|
return false;
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2008-08-29 08:40:13 +00:00
|
|
|
|
|
|
|
|
# Make debug info
|
|
|
|
|
$info = '';
|
2008-12-23 19:39:00 +00:00
|
|
|
foreach ( $modifiedTimes as $name => $value ) {
|
|
|
|
|
if ( $info !== '' ) {
|
2008-08-29 08:40:13 +00:00
|
|
|
$info .= ', ';
|
|
|
|
|
}
|
|
|
|
|
$info .= "$name=" . wfTimestamp( TS_ISO_8601, $value );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# IE sends sizes after the date like this:
|
|
|
|
|
# Wed, 20 Aug 2003 06:51:19 GMT; length=5202
|
|
|
|
|
# this breaks strtotime().
|
|
|
|
|
$clientHeader = preg_replace( '/;.*$/', '', $_SERVER["HTTP_IF_MODIFIED_SINCE"] );
|
|
|
|
|
|
2008-12-23 19:39:00 +00:00
|
|
|
wfSuppressWarnings(); // E_STRICT system time bitching
|
|
|
|
|
$clientHeaderTime = strtotime( $clientHeader );
|
|
|
|
|
wfRestoreWarnings();
|
|
|
|
|
if ( !$clientHeaderTime ) {
|
2008-08-29 08:40:13 +00:00
|
|
|
wfDebug( __METHOD__ . ": unable to parse the client's If-Modified-Since header: $clientHeader\n" );
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
$clientHeaderTime = wfTimestamp( TS_MW, $clientHeaderTime );
|
|
|
|
|
|
|
|
|
|
wfDebug( __METHOD__ . ": client sent If-Modified-Since: " .
|
|
|
|
|
wfTimestamp( TS_ISO_8601, $clientHeaderTime ) . "\n", false );
|
|
|
|
|
wfDebug( __METHOD__ . ": effective Last-Modified: " .
|
|
|
|
|
wfTimestamp( TS_ISO_8601, $maxModified ) . "\n", false );
|
|
|
|
|
if( $clientHeaderTime < $maxModified ) {
|
|
|
|
|
wfDebug( __METHOD__ . ": STALE, $info\n", false );
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-23 19:39:00 +00:00
|
|
|
# Not modified
|
2008-08-29 08:40:13 +00:00
|
|
|
# Give a 304 response code and disable body output
|
2008-12-23 19:39:00 +00:00
|
|
|
wfDebug( __METHOD__ . ": NOT MODIFIED, $info\n", false );
|
2008-08-29 08:40:13 +00:00
|
|
|
$wgRequest->response()->header( "HTTP/1.1 304 Not Modified" );
|
|
|
|
|
$this->sendCacheControl();
|
|
|
|
|
$this->disable();
|
|
|
|
|
|
|
|
|
|
// 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();
|
|
|
|
|
|
|
|
|
|
return true;
|
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
|
|
|
|
2008-07-23 19:05:43 +00:00
|
|
|
/**
|
|
|
|
|
* Set the robot policy for the page: <http://www.robotstxt.org/meta.html>
|
|
|
|
|
*
|
|
|
|
|
* @param $policy string The literal string to output as the contents of
|
|
|
|
|
* the meta tag. Will be parsed according to the spec and output in
|
|
|
|
|
* standardized form.
|
|
|
|
|
* @return null
|
|
|
|
|
*/
|
|
|
|
|
public function setRobotPolicy( $policy ) {
|
|
|
|
|
$policy = explode( ',', $policy );
|
|
|
|
|
$policy = array_map( 'trim', $policy );
|
|
|
|
|
|
|
|
|
|
# The default policy is follow, so if nothing is said explicitly, we
|
|
|
|
|
# do that.
|
|
|
|
|
if( in_array( 'nofollow', $policy ) ) {
|
|
|
|
|
$this->mFollowPolicy = 'nofollow';
|
|
|
|
|
} else {
|
|
|
|
|
$this->mFollowPolicy = 'follow';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( in_array( 'noindex', $policy ) ) {
|
|
|
|
|
$this->mIndexPolicy = 'noindex';
|
|
|
|
|
} else {
|
|
|
|
|
$this->mIndexPolicy = 'index';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the index policy for the page, but leave the follow policy un-
|
|
|
|
|
* touched.
|
|
|
|
|
*
|
|
|
|
|
* @param $policy string Either 'index' or 'noindex'.
|
|
|
|
|
* @return null
|
|
|
|
|
*/
|
|
|
|
|
public function setIndexPolicy( $policy ) {
|
|
|
|
|
$policy = trim( $policy );
|
|
|
|
|
if( in_array( $policy, array( 'index', 'noindex' ) ) ) {
|
|
|
|
|
$this->mIndexPolicy = $policy;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the follow policy for the page, but leave the index policy un-
|
|
|
|
|
* touched.
|
|
|
|
|
*
|
|
|
|
|
* @param $policy string Either 'follow' or 'nofollow'.
|
|
|
|
|
* @return null
|
|
|
|
|
*/
|
|
|
|
|
public function setFollowPolicy( $policy ) {
|
|
|
|
|
$policy = trim( $policy );
|
|
|
|
|
if( in_array( $policy, array( 'follow', 'nofollow' ) ) ) {
|
|
|
|
|
$this->mFollowPolicy = $policy;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-02-04 19:43:30 +00:00
|
|
|
public function setHTMLTitle( $name ) { $this->mHTMLtitle = $name; }
|
2006-11-07 05:37:31 +00:00
|
|
|
public function setPageTitle( $name ) {
|
2009-02-04 19:43:30 +00:00
|
|
|
global $wgContLang;
|
|
|
|
|
$name = $wgContLang->convert( $name, true );
|
2004-04-25 00:32:24 +00:00
|
|
|
$this->mPagetitle = $name;
|
2009-02-04 19:43:30 +00:00
|
|
|
|
|
|
|
|
$taction = $this->getPageTitleActionText();
|
|
|
|
|
if( !empty( $taction ) ) {
|
|
|
|
|
$name .= ' - '.$taction;
|
2004-04-25 00:32:24 +00:00
|
|
|
}
|
2008-12-31 16:49:38 +00:00
|
|
|
|
2005-08-17 12:00:07 +00:00
|
|
|
$this->setHTMLTitle( wfMsg( 'pagetitle', $name ) );
|
2004-04-25 00:32:24 +00:00
|
|
|
}
|
2009-02-04 19:43:30 +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
|
2008-05-03 03:52:33 +00:00
|
|
|
public function appendSubtitle( $str ) { $this->mSubtitle .= /*$this->parse(*/$str/*)*/; } // @bug 2514
|
2006-11-07 05:37:31 +00:00
|
|
|
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
|
|
|
|
|
*/
|
2008-02-20 08:53:12 +00:00
|
|
|
public function addCategoryLinks( $categories ) {
|
2008-02-25 16:38:25 +00:00
|
|
|
global $wgUser, $wgContLang;
|
2005-12-30 09:33:11 +00:00
|
|
|
|
2008-02-25 16:38:25 +00:00
|
|
|
if ( !is_array( $categories ) || count( $categories ) == 0 ) {
|
2008-02-20 08:53:12 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2008-02-25 16:38:25 +00:00
|
|
|
|
2008-02-20 08:53:12 +00:00
|
|
|
# Add the links to a LinkBatch
|
2005-12-30 09:33:11 +00:00
|
|
|
$arr = array( NS_CATEGORY => $categories );
|
|
|
|
|
$lb = new LinkBatch;
|
|
|
|
|
$lb->setArray( $arr );
|
|
|
|
|
|
2008-02-20 08:53:12 +00:00
|
|
|
# Fetch existence plus the hiddencat property
|
|
|
|
|
$dbr = wfGetDB( DB_SLAVE );
|
|
|
|
|
$pageTable = $dbr->tableName( 'page' );
|
|
|
|
|
$where = $lb->constructSet( 'page', $dbr );
|
2008-02-25 16:38:25 +00:00
|
|
|
$propsTable = $dbr->tableName( 'page_props' );
|
2008-04-09 13:02:34 +00:00
|
|
|
$sql = "SELECT page_id, page_namespace, page_title, page_len, page_is_redirect, pp_value
|
|
|
|
|
FROM $pageTable LEFT JOIN $propsTable ON pp_propname='hiddencat' AND pp_page=page_id WHERE $where";
|
2008-02-20 08:53:12 +00:00
|
|
|
$res = $dbr->query( $sql, __METHOD__ );
|
|
|
|
|
|
|
|
|
|
# Add the results to the link cache
|
|
|
|
|
$lb->addResultToCache( LinkCache::singleton(), $res );
|
|
|
|
|
|
2008-02-25 16:38:25 +00:00
|
|
|
# Set all the values to 'normal'. This can be done with array_fill_keys in PHP 5.2.0+
|
|
|
|
|
$categories = array_combine( array_keys( $categories ),
|
|
|
|
|
array_fill( 0, count( $categories ), 'normal' ) );
|
|
|
|
|
|
|
|
|
|
# Mark hidden categories
|
2008-02-20 08:53:12 +00:00
|
|
|
foreach ( $res as $row ) {
|
2008-02-25 16:38:25 +00:00
|
|
|
if ( isset( $row->pp_value ) ) {
|
|
|
|
|
$categories[$row->page_title] = 'hidden';
|
2008-02-20 08:53:12 +00:00
|
|
|
}
|
|
|
|
|
}
|
2008-02-25 16:38:25 +00:00
|
|
|
|
2008-02-20 08:53:12 +00:00
|
|
|
# Add the remaining categories to the skin
|
2008-07-02 20:02:51 +00:00
|
|
|
if ( wfRunHooks( 'OutputPageMakeCategoryLinks', array( &$this, $categories, &$this->mCategoryLinks ) ) ) {
|
|
|
|
|
$sk = $wgUser->getSkin();
|
|
|
|
|
foreach ( $categories as $category => $type ) {
|
2009-02-02 07:54:43 +00:00
|
|
|
$origcategory = $category;
|
2008-07-02 20:02:51 +00:00
|
|
|
$title = Title::makeTitleSafe( NS_CATEGORY, $category );
|
2009-02-02 07:54:43 +00:00
|
|
|
$wgContLang->findVariantLink( $category, $title, true );
|
|
|
|
|
if ( $category != $origcategory )
|
|
|
|
|
if ( array_key_exists( $category, $categories ) )
|
|
|
|
|
continue;
|
2008-07-02 20:02:51 +00:00
|
|
|
$text = $wgContLang->convertHtml( $title->getText() );
|
|
|
|
|
$this->mCategoryLinks[$type][] = $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; }
|
|
|
|
|
|
2008-08-11 14:20:37 +00:00
|
|
|
public function prependHTML( $text ) { $this->mBodytext = $text . $this->mBodytext; }
|
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 ) {
|
2008-04-16 13:46:16 +00:00
|
|
|
wfDeprecated( __METHOD__ );
|
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 );
|
|
|
|
|
}
|
2008-08-11 13:23:45 +00:00
|
|
|
|
|
|
|
|
public function getRevisionId() {
|
|
|
|
|
return $this->mRevisionId;
|
|
|
|
|
}
|
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
|
|
|
|
2008-04-16 13:46:16 +00:00
|
|
|
wfProfileIn( __METHOD__ );
|
2007-01-10 23:32:38 +00:00
|
|
|
|
2008-04-16 13:46:16 +00:00
|
|
|
wfIncrStats( 'pcache_not_possible' );
|
2007-01-10 23:32:38 +00:00
|
|
|
|
|
|
|
|
$popts = $this->parserOptions();
|
2008-04-16 13:46:16 +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 );
|
2008-04-14 07:45:50 +00:00
|
|
|
|
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
|
|
|
|
2008-04-16 13:46:16 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
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 ) {
|
2008-07-24 18:02:20 +00:00
|
|
|
global $wgTitle, $wgExemptFromUserRobotsControl, $wgContentNamespaces;
|
2008-07-24 17:40:16 +00:00
|
|
|
|
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();
|
2008-07-24 18:02:20 +00:00
|
|
|
|
|
|
|
|
if( is_null( $wgExemptFromUserRobotsControl ) ) {
|
|
|
|
|
$bannedNamespaces = $wgContentNamespaces;
|
|
|
|
|
} else {
|
|
|
|
|
$bannedNamespaces = $wgExemptFromUserRobotsControl;
|
|
|
|
|
}
|
|
|
|
|
if( !in_array( $wgTitle->getNamespace(), $bannedNamespaces ) ) {
|
|
|
|
|
# FIXME (bug 14900): This overrides $wgArticleRobotPolicies, and it
|
|
|
|
|
# shouldn't
|
2008-07-24 17:40:16 +00:00
|
|
|
$this->setIndexPolicy( $parserOutput->getIndexPolicy() );
|
|
|
|
|
}
|
2008-07-24 18:02:20 +00:00
|
|
|
|
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...
|
2008-11-01 23:20:25 +00:00
|
|
|
foreach ( (array)$parserOutput->mTemplateIds as $ns => $dbks ) {
|
|
|
|
|
if ( isset( $this->mTemplateIds[$ns] ) ) {
|
|
|
|
|
$this->mTemplateIds[$ns] = $dbks + $this->mTemplateIds[$ns];
|
|
|
|
|
} else {
|
|
|
|
|
$this->mTemplateIds[$ns] = $dbks;
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-01-10 19:41:11 +00:00
|
|
|
// Page title
|
2008-12-31 16:49:38 +00:00
|
|
|
if( ( $dt = $parserOutput->getDisplayTitle() ) !== false )
|
|
|
|
|
$this->setPageTitle( $dt );
|
2009-01-10 19:41:11 +00:00
|
|
|
else if ( ( $title = $parserOutput->getTitleText() ) != '' )
|
|
|
|
|
$this->setPageTitle( $title );
|
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
|
|
|
|
2008-02-20 08:53:12 +00:00
|
|
|
// Hooks registered in the object
|
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
|
|
|
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
|
|
|
|
2008-04-16 13:46:16 +00:00
|
|
|
wfDeprecated( __METHOD__ );
|
|
|
|
|
|
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 ) {
|
2008-04-09 18:23:34 +00:00
|
|
|
$parserCache = ParserCache::singleton();
|
2006-01-05 04:26:52 +00:00
|
|
|
$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;
|
2008-04-16 13:46:16 +00:00
|
|
|
wfDeprecated( __METHOD__ );
|
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;
|
2008-11-24 01:58:15 +00:00
|
|
|
if( is_null( $wgTitle ) ) {
|
|
|
|
|
throw new MWException( 'Empty $wgTitle in ' . __METHOD__ );
|
|
|
|
|
}
|
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
|
|
|
|
2009-01-31 01:59:13 +00:00
|
|
|
/** Parse wikitext, strip paragraphs, and return the HTML. */
|
|
|
|
|
public function parseInline( $text, $linestart = true, $interface = false ) {
|
|
|
|
|
$parsed = $this->parse( $text, $linestart, $interface );
|
|
|
|
|
|
|
|
|
|
$m = array();
|
|
|
|
|
if ( preg_match( '/^<p>(.*)\n?<\/p>\n?/sU', $parsed, $m ) ) {
|
|
|
|
|
$parsed = $m[1];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $parsed;
|
|
|
|
|
}
|
|
|
|
|
|
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 ) {
|
2008-04-09 18:23:34 +00:00
|
|
|
$parserCache = ParserCache::singleton();
|
2006-01-05 04:26:52 +00:00
|
|
|
$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
|
|
|
|
2008-02-20 04:13:24 +00:00
|
|
|
function getCacheVaryCookies() {
|
2008-04-10 08:42:36 +00:00
|
|
|
global $wgCookiePrefix, $wgCacheVaryCookies;
|
|
|
|
|
static $cookies;
|
|
|
|
|
if ( $cookies === null ) {
|
2008-04-14 07:45:50 +00:00
|
|
|
$cookies = array_merge(
|
2008-04-10 08:42:36 +00:00
|
|
|
array(
|
|
|
|
|
"{$wgCookiePrefix}Token",
|
|
|
|
|
"{$wgCookiePrefix}LoggedOut",
|
|
|
|
|
session_name()
|
|
|
|
|
),
|
|
|
|
|
$wgCacheVaryCookies
|
|
|
|
|
);
|
|
|
|
|
wfRunHooks('GetCacheVaryCookies', array( $this, &$cookies ) );
|
|
|
|
|
}
|
|
|
|
|
return $cookies;
|
2008-02-20 04:13:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function uncacheableBecauseRequestVars() {
|
2005-07-24 06:55:45 +00:00
|
|
|
global $wgRequest;
|
|
|
|
|
return $wgRequest->getText('useskin', false) === false
|
|
|
|
|
&& $wgRequest->getText('uselang', false) === false;
|
|
|
|
|
}
|
|
|
|
|
|
2008-02-20 04:13:24 +00:00
|
|
|
/**
|
|
|
|
|
* Check if the request has a cache-varying cookie header
|
|
|
|
|
* If it does, it's very important that we don't allow public caching
|
|
|
|
|
*/
|
|
|
|
|
function haveCacheVaryCookies() {
|
2008-11-18 21:37:11 +00:00
|
|
|
global $wgRequest;
|
2008-02-20 04:13:24 +00:00
|
|
|
$cookieHeader = $wgRequest->getHeader( 'cookie' );
|
|
|
|
|
if ( $cookieHeader === false ) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
$cvCookies = $this->getCacheVaryCookies();
|
|
|
|
|
foreach ( $cvCookies as $cookieName ) {
|
|
|
|
|
# Check for a simple string match, like the way squid does it
|
|
|
|
|
if ( strpos( $cookieHeader, $cookieName ) ) {
|
|
|
|
|
wfDebug( __METHOD__.": found $cookieName\n" );
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
wfDebug( __METHOD__.": no cache-varying cookies found\n" );
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2008-02-08 07:12:38 +00:00
|
|
|
/** Get a complete X-Vary-Options header */
|
|
|
|
|
public function getXVO() {
|
2008-02-20 04:13:24 +00:00
|
|
|
$cvCookies = $this->getCacheVaryCookies();
|
|
|
|
|
$xvo = 'X-Vary-Options: Accept-Encoding;list-contains=gzip,Cookie;';
|
2008-02-22 07:42:07 +00:00
|
|
|
$first = true;
|
2008-02-20 04:13:24 +00:00
|
|
|
foreach ( $cvCookies as $cookieName ) {
|
2008-02-22 07:42:07 +00:00
|
|
|
if ( $first ) {
|
|
|
|
|
$first = false;
|
|
|
|
|
} else {
|
|
|
|
|
$xvo .= ';';
|
|
|
|
|
}
|
2008-02-20 04:13:24 +00:00
|
|
|
$xvo .= 'string-contains=' . $cookieName;
|
|
|
|
|
}
|
|
|
|
|
return $xvo;
|
2008-02-08 07:12:38 +00:00
|
|
|
}
|
|
|
|
|
|
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;
|
2005-07-01 00:03:31 +00:00
|
|
|
|
2008-02-08 07:12:38 +00:00
|
|
|
$response = $wgRequest->response();
|
2008-12-23 19:39:00 +00:00
|
|
|
if ($wgUseETag && $this->mETag)
|
2008-02-08 07:12:38 +00:00
|
|
|
$response->header("ETag: $this->mETag");
|
2008-12-23 19:39:00 +00:00
|
|
|
|
|
|
|
|
# don't serve compressed data to clients who can't handle it
|
2005-03-08 02:58:43 +00:00
|
|
|
# maintain different caches for logged-in users and non-logged in ones
|
2008-02-08 07:12:38 +00:00
|
|
|
$response->header( 'Vary: Accept-Encoding, Cookie' );
|
|
|
|
|
|
|
|
|
|
# Add an X-Vary-Options header for Squid with Wikimedia patches
|
|
|
|
|
$response->header( $this->getXVO() );
|
|
|
|
|
|
2008-02-20 04:13:24 +00:00
|
|
|
if( !$this->uncacheableBecauseRequestVars() && $this->mEnableClientCache ) {
|
2008-12-23 19:39:00 +00:00
|
|
|
if( $wgUseSquid && session_id() == '' &&
|
|
|
|
|
! $this->isPrintable() && $this->mSquidMaxage != 0 && !$this->haveCacheVaryCookies() )
|
2004-02-04 00:45:48 +00:00
|
|
|
{
|
2008-12-23 19:39:00 +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
|
2008-04-16 13:46:16 +00:00
|
|
|
wfDebug( __METHOD__ . ": 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"');
|
2008-02-08 07:12:38 +00:00
|
|
|
$response->header( 'Surrogate-Control: max-age='.$wgSquidMaxage.'+'.$this->mSquidMaxage.', content="ESI/1.0"');
|
|
|
|
|
$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
|
2008-04-16 13:46:16 +00:00
|
|
|
wfDebug( __METHOD__ . ": 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" );
|
2008-02-08 07:12:38 +00:00
|
|
|
$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.
|
2008-04-16 13:46:16 +00:00
|
|
|
wfDebug( __METHOD__ . ": private caching; {$this->mLastModified} **\n", false );
|
2008-02-08 07:12:38 +00:00
|
|
|
$response->header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', 0 ) . ' GMT' );
|
|
|
|
|
$response->header( "Cache-Control: private, must-revalidate, max-age=0" );
|
2004-01-31 10:29:31 +00:00
|
|
|
}
|
2008-12-23 19:39:00 +00:00
|
|
|
if($this->mLastModified) {
|
2008-08-29 08:40:13 +00:00
|
|
|
$response->header( "Last-Modified: {$this->mLastModified}" );
|
|
|
|
|
}
|
2003-07-03 10:18:07 +00:00
|
|
|
} else {
|
2008-04-16 13:46:16 +00:00
|
|
|
wfDebug( __METHOD__ . ": 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.
|
2008-02-08 07:12:38 +00:00
|
|
|
$response->header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', 0 ) . ' GMT' );
|
|
|
|
|
$response->header( 'Cache-Control: no-cache, no-store, max-age=0, must-revalidate' );
|
|
|
|
|
$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;
|
2008-08-22 02:01:31 +00:00
|
|
|
global $wgJsMimeType, $wgUseAjax, $wgAjaxWatch;
|
2008-10-10 01:15:11 +00:00
|
|
|
global $wgEnableMWSuggest, $wgUniversalEditButton;
|
|
|
|
|
global $wgArticle, $wgTitle;
|
2004-10-08 04:27:07 +00:00
|
|
|
|
2008-12-31 17:56:04 +00:00
|
|
|
if( $this->mDoNothing ){
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2008-04-16 13:46:16 +00:00
|
|
|
wfProfileIn( __METHOD__ );
|
2006-07-30 10:53:22 +00:00
|
|
|
|
2004-08-22 17:24:50 +00:00
|
|
|
if ( '' != $this->mRedirect ) {
|
2008-02-13 05:59:14 +00:00
|
|
|
# Standards require redirect URLs to be absolute
|
|
|
|
|
$this->mRedirect = wfExpandUrl( $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
|
|
|
}
|
2008-04-16 13:46:16 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
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
|
|
|
|
2008-01-14 10:23:48 +00:00
|
|
|
$sk = $wgUser->getSkin();
|
|
|
|
|
|
|
|
|
|
if ( $wgUseAjax ) {
|
2008-05-09 20:18:35 +00:00
|
|
|
$this->addScriptFile( 'ajax.js' );
|
2008-01-14 10:23:48 +00:00
|
|
|
|
|
|
|
|
wfRunHooks( 'AjaxAddScript', array( &$this ) );
|
|
|
|
|
|
|
|
|
|
if( $wgAjaxWatch && $wgUser->isLoggedIn() ) {
|
2008-05-09 20:18:35 +00:00
|
|
|
$this->addScriptFile( 'ajaxwatch.js' );
|
2008-01-14 10:23:48 +00:00
|
|
|
}
|
2008-04-15 23:06:28 +00:00
|
|
|
|
|
|
|
|
if ( $wgEnableMWSuggest && !$wgUser->getOption( 'disablesuggest', false ) ){
|
2008-05-09 20:18:35 +00:00
|
|
|
$this->addScriptFile( 'mwsuggest.js' );
|
2008-04-15 23:06:28 +00:00
|
|
|
}
|
2008-01-14 10:23:48 +00:00
|
|
|
}
|
2008-05-12 23:37:51 +00:00
|
|
|
|
|
|
|
|
if( $wgUser->getBoolOption( 'editsectiononrightclick' ) ) {
|
|
|
|
|
$this->addScriptFile( 'rightclickedit.js' );
|
|
|
|
|
}
|
2008-01-14 10:23:48 +00:00
|
|
|
|
2008-10-10 01:15:11 +00:00
|
|
|
if( $wgUniversalEditButton ) {
|
|
|
|
|
if( isset( $wgArticle ) && isset( $wgTitle ) && $wgTitle->quickUserCan( 'edit' )
|
|
|
|
|
&& ( $wgTitle->exists() || $wgTitle->quickUserCan( 'create' ) ) ) {
|
2008-10-22 18:07:15 +00:00
|
|
|
// Original UniversalEditButton
|
2008-10-10 01:15:11 +00:00
|
|
|
$this->addLink( array(
|
|
|
|
|
'rel' => 'alternate',
|
|
|
|
|
'type' => 'application/x-wiki',
|
|
|
|
|
'title' => wfMsg( 'edit' ),
|
|
|
|
|
'href' => $wgTitle->getFullURL( 'action=edit' )
|
|
|
|
|
) );
|
2008-10-22 18:07:15 +00:00
|
|
|
// Alternate edit link
|
|
|
|
|
$this->addLink( array(
|
|
|
|
|
'rel' => 'edit',
|
|
|
|
|
'title' => wfMsg( 'edit' ),
|
|
|
|
|
'href' => $wgTitle->getFullURL( 'action=edit' )
|
|
|
|
|
) );
|
2008-10-10 01:15:11 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-11-12 09:34:11 +00:00
|
|
|
# Buffer output; final headers may depend on later processing
|
2008-09-15 01:27:22 +00:00
|
|
|
ob_start();
|
2004-11-12 09:34:11 +00:00
|
|
|
|
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 {
|
2008-04-06 20:25:45 +00:00
|
|
|
// Hook that allows last minute changes to the output page, e.g.
|
|
|
|
|
// adding of CSS or Javascript by extensions.
|
2008-04-07 17:53:31 +00:00
|
|
|
wfRunHooks( 'BeforePageDisplay', array( &$this, &$sk ) );
|
2008-04-06 20:25:45 +00:00
|
|
|
|
2005-07-03 04:00:33 +00:00
|
|
|
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();
|
2008-04-16 13:46:16 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
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;
|
2008-12-23 19:39:00 +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() {
|
2008-04-16 13:46:16 +00:00
|
|
|
wfDeprecated( __METHOD__ );
|
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' ) );
|
2008-07-23 19:05:43 +00:00
|
|
|
$this->setRobotPolicy( 'noindex,nofollow' );
|
2006-01-06 23:09:37 +00:00
|
|
|
$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
|
|
|
|
2008-02-18 07:25:35 +00:00
|
|
|
$this->addWikiMsg( $msg, $link, $reason, $ip, $name, $blockid, $blockExpiry, $intended, $blockTimestamp );
|
2007-07-31 13:59:29 +00:00
|
|
|
|
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 ) {
|
2008-04-16 13:46:16 +00:00
|
|
|
$return = $wgTitle->getNamespace() > -1 ? $wgTitle : NULL;
|
|
|
|
|
$this->returnToMain( null, $return );
|
2006-06-24 20:58:10 +00:00
|
|
|
}
|
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;
|
2008-01-13 12:29:43 +00:00
|
|
|
if ( isset($wgTitle) ) {
|
|
|
|
|
$this->mDebugtext .= 'Original title: ' . $wgTitle->getPrefixedText() . "\n";
|
|
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
$this->setPageTitle( wfMsg( $title ) );
|
2004-08-22 17:24:50 +00:00
|
|
|
$this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
|
2008-07-23 19:05:43 +00:00
|
|
|
$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 = '';
|
2008-04-14 07:45:50 +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 );
|
2008-11-06 22:20:29 +00:00
|
|
|
$this->addHTML( call_user_func_array( 'wfMsgExt', $params ) );
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-04-16 13:46:16 +00:00
|
|
|
$this->returnToMain();
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
2007-08-06 11:30:40 +00:00
|
|
|
/**
|
|
|
|
|
* Output a standard permission error page
|
|
|
|
|
*
|
|
|
|
|
* @param array $errors Error message keys
|
|
|
|
|
*/
|
2008-05-23 10:34:11 +00:00
|
|
|
public function showPermissionsErrorPage( $errors, $action = null )
|
2007-08-01 10:19:26 +00:00
|
|
|
{
|
|
|
|
|
global $wgTitle;
|
|
|
|
|
|
|
|
|
|
$this->mDebugtext .= 'Original title: ' .
|
2008-01-02 02:01:09 +00:00
|
|
|
$wgTitle->getPrefixedText() . "\n";
|
2007-08-01 10:19:26 +00:00
|
|
|
$this->setPageTitle( wfMsg( 'permissionserrors' ) );
|
|
|
|
|
$this->setHTMLTitle( wfMsg( 'permissionserrors' ) );
|
2008-07-23 19:05:43 +00:00
|
|
|
$this->setRobotPolicy( 'noindex,nofollow' );
|
2007-08-01 10:19:26 +00:00
|
|
|
$this->setArticleRelated( false );
|
|
|
|
|
$this->enableClientCache( false );
|
|
|
|
|
$this->mRedirect = '';
|
|
|
|
|
$this->mBodytext = '';
|
2008-05-23 10:34:11 +00:00
|
|
|
$this->addWikiText( $this->formatPermissionsErrorMessage( $errors, $action ) );
|
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 ) {
|
2008-04-16 13:46:16 +00:00
|
|
|
wfDeprecated( __METHOD__ );
|
2006-06-07 06:40:24 +00:00
|
|
|
throw new ErrorPageError( $title, $msg );
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
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 ) );
|
2008-07-23 19:05:43 +00:00
|
|
|
$this->setRobotPolicy( 'noindex,nofollow' );
|
2005-06-26 06:49:56 +00:00
|
|
|
$this->setArticleRelated( false );
|
|
|
|
|
$this->mBodytext = '';
|
|
|
|
|
|
2008-02-18 07:25:35 +00:00
|
|
|
$this->addWikiMsg( 'versionrequiredtext', $version );
|
2005-06-26 06:49:56 +00:00
|
|
|
$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 ) {
|
2008-08-05 17:48:24 +00:00
|
|
|
global $wgUser;
|
2005-06-19 06:25:53 +00:00
|
|
|
|
|
|
|
|
$this->setPageTitle( wfMsg( 'badaccess' ) );
|
|
|
|
|
$this->setHTMLTitle( wfMsg( 'errorpagetitle' ) );
|
2008-07-23 19:05:43 +00:00
|
|
|
$this->setRobotPolicy( 'noindex,nofollow' );
|
2005-06-19 06:25:53 +00:00
|
|
|
$this->setArticleRelated( false );
|
|
|
|
|
$this->mBodytext = '';
|
|
|
|
|
|
2008-08-05 05:32:30 +00:00
|
|
|
$groups = array_map( array( 'User', 'makeGroupLinkWiki' ),
|
|
|
|
|
User::getGroupsWithPermission( $permission ) );
|
|
|
|
|
if( $groups ) {
|
|
|
|
|
$this->addWikiMsg( 'badaccess-groups',
|
|
|
|
|
implode( ', ', $groups ),
|
|
|
|
|
count( $groups) );
|
|
|
|
|
} else {
|
|
|
|
|
$this->addWikiMsg( 'badaccess-group0' );
|
2007-08-27 21:05:19 +00:00
|
|
|
}
|
2008-04-16 13:46:16 +00:00
|
|
|
$this->returnToMain();
|
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();
|
2008-04-14 07:45:50 +00:00
|
|
|
|
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 );
|
2008-04-14 07:45:50 +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() );
|
2008-11-06 22:20:29 +00:00
|
|
|
$this->addHTML( wfMsgWikiHtml( 'loginreqpagetext', $loginLink ) );
|
|
|
|
|
$this->addHTML( "\n<!--" . $wgTitle->getPrefixedUrl() . "-->" );
|
2008-04-14 07:45:50 +00:00
|
|
|
|
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() )
|
2008-04-16 13:46:16 +00:00
|
|
|
$this->returnToMain( null, $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 02:01:09 +00:00
|
|
|
* @return string The wikitext error-messages, formatted into a list.
|
2007-08-03 09:27:28 +00:00
|
|
|
*/
|
2008-05-23 10:34:11 +00:00
|
|
|
public function formatPermissionsErrorMessage( $errors, $action = null ) {
|
|
|
|
|
if ($action == null) {
|
|
|
|
|
$text = wfMsgNoTrans( 'permissionserrorstext', count($errors)). "\n\n";
|
|
|
|
|
} else {
|
2008-08-26 18:51:27 +00:00
|
|
|
global $wgLang;
|
2008-10-06 09:16:20 +00:00
|
|
|
$action_desc = wfMsg( "action-$action" );
|
2008-05-23 10:34:11 +00:00
|
|
|
$text = wfMsgNoTrans( 'permissionserrorstext-withaction', count($errors), $action_desc ) . "\n\n";
|
|
|
|
|
}
|
2008-01-02 01:16:44 +00:00
|
|
|
|
2008-01-02 02:01:09 +00:00
|
|
|
if (count( $errors ) > 1) {
|
2007-08-16 07:05:38 +00:00
|
|
|
$text .= '<ul class="permissions-errors">' . "\n";
|
|
|
|
|
|
|
|
|
|
foreach( $errors as $error )
|
|
|
|
|
{
|
|
|
|
|
$text .= '<li>';
|
2008-02-18 07:25:35 +00:00
|
|
|
$text .= call_user_func_array( 'wfMsgNoTrans', $error );
|
2007-08-16 07:05:38 +00:00
|
|
|
$text .= "</li>\n";
|
|
|
|
|
}
|
|
|
|
|
$text .= '</ul>';
|
|
|
|
|
} else {
|
2008-02-21 09:32:59 +00:00
|
|
|
$text .= '<div class="permissions-errors">' . call_user_func_array( 'wfMsgNoTrans', reset( $errors ) ) . '</div>';
|
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
|
|
|
*/
|
2008-05-23 10:34:11 +00:00
|
|
|
public function readOnlyPage( $source = null, $protected = false, $reasons = array(), $action = null ) {
|
2008-02-24 03:50:05 +00:00
|
|
|
global $wgUser, $wgTitle;
|
2007-12-09 16:16:33 +00:00
|
|
|
$skin = $wgUser->getSkin();
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2008-07-23 19:05:43 +00:00
|
|
|
$this->setRobotPolicy( 'noindex,nofollow' );
|
2004-01-17 09:49:43 +00:00
|
|
|
$this->setArticleRelated( false );
|
2008-01-24 01:59:35 +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
|
2008-01-02 02:49:31 +00:00
|
|
|
if( $source ) {
|
|
|
|
|
$this->setPageTitle( wfMsg( 'viewsource' ) );
|
|
|
|
|
$this->setSubtitle( wfMsg( 'viewsourcefor', $skin->makeKnownLinkObj( $wgTitle ) ) );
|
|
|
|
|
} else {
|
|
|
|
|
$this->setPageTitle( wfMsg( 'badaccess' ) );
|
|
|
|
|
}
|
2008-05-23 10:34:11 +00:00
|
|
|
$this->addWikiText( $this->formatPermissionsErrorMessage( $reasons, $action ) );
|
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' ) );
|
2008-02-24 03:50:05 +00:00
|
|
|
$reason = wfReadOnlyReason();
|
2008-09-12 22:24:15 +00:00
|
|
|
$this->wrapWikiMsg( '<div class="mw-readonly-error">$1</div>', array( '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 ) ) {
|
2008-02-18 07:25:35 +00:00
|
|
|
$this->addWikiMsg( 'viewsourcetext' );
|
2008-04-16 13:46:16 +00:00
|
|
|
$text = Xml::openElement( 'textarea',
|
2007-12-09 00:16:59 +00:00
|
|
|
array( 'id' => 'wpTextbox1',
|
|
|
|
|
'name' => 'wpTextbox1',
|
|
|
|
|
'cols' => $wgUser->getOption( 'cols' ),
|
|
|
|
|
'rows' => $wgUser->getOption( 'rows' ),
|
|
|
|
|
'readonly' => 'readonly' ) );
|
|
|
|
|
$text .= htmlspecialchars( $source );
|
2008-04-16 13:46:16 +00:00
|
|
|
$text .= Xml::closeElement( '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 );
|
2008-08-08 12:23:17 +00:00
|
|
|
$this->addHTML( "<div class='templatesUsed'>
|
|
|
|
|
{$skin->formatTemplates( $article->getUsedTemplates() )}
|
|
|
|
|
</div>
|
|
|
|
|
" );
|
2003-09-09 05:46:22 +00:00
|
|
|
}
|
2004-07-08 14:53:54 +00:00
|
|
|
|
2008-01-02 02:49:31 +00:00
|
|
|
# If the title doesn't exist, it's fairly pointless to print a return
|
|
|
|
|
# link to it. After all, you just tried editing it and couldn't, so
|
|
|
|
|
# what's there to do there?
|
|
|
|
|
if( $wgTitle->exists() ) {
|
2008-04-16 13:46:16 +00:00
|
|
|
$this->returnToMain( null, $wgTitle );
|
2008-01-02 02:49:31 +00:00
|
|
|
}
|
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 ) {
|
2008-04-16 13:46:16 +00:00
|
|
|
wfDeprecated( __METHOD__ );
|
2008-04-14 07:45:50 +00:00
|
|
|
throw new FatalError( $message );
|
2006-06-07 06:40:24 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2007-04-04 05:22:37 +00:00
|
|
|
/** @deprecated */
|
2006-11-07 05:37:31 +00:00
|
|
|
public function unexpectedValueError( $name, $val ) {
|
2008-04-16 13:46:16 +00:00
|
|
|
wfDeprecated( __METHOD__ );
|
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 ) {
|
2008-04-16 13:46:16 +00:00
|
|
|
wfDeprecated( __METHOD__ );
|
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 ) {
|
2008-04-16 13:46:16 +00:00
|
|
|
wfDeprecated( __METHOD__ );
|
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 ) {
|
2008-04-16 13:46:16 +00:00
|
|
|
wfDeprecated( __METHOD__ );
|
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 ) {
|
2008-04-16 13:46:16 +00:00
|
|
|
wfDeprecated( __METHOD__ );
|
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" ) );
|
2008-07-23 19:05:43 +00:00
|
|
|
$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;
|
2008-12-24 19:08:18 +00:00
|
|
|
$this->addLink( array( 'rel' => 'next', 'href' => $title->getFullUrl() ) );
|
2007-07-29 23:53:45 +00:00
|
|
|
$link = wfMsg( 'returnto', $wgUser->getSkin()->makeLinkObj( $title ) );
|
2008-11-06 22:20:29 +00:00
|
|
|
$this->addHTML( "<p>{$link}</p>\n" );
|
2007-07-29 23:53:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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;
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2004-04-01 12:44:54 +00:00
|
|
|
if ( $returnto == NULL ) {
|
|
|
|
|
$returnto = $wgRequest->getText( 'returnto' );
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
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
|
|
|
*/
|
2008-08-21 14:09:57 +00:00
|
|
|
public function headElement( Skin $sk ) {
|
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;
|
2008-06-30 01:34:07 +00:00
|
|
|
global $wgUser, $wgContLang, $wgUseTrackbacks, $wgTitle, $wgStyleVersion;
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2008-08-21 14:09:57 +00:00
|
|
|
$this->addMeta( "http:Content-type", "$wgMimeType; charset={$wgOutputEncoding}" );
|
|
|
|
|
$this->addStyle( 'common/wikiprintable.css', 'print' );
|
|
|
|
|
$sk->setupUserCss( $this );
|
|
|
|
|
|
|
|
|
|
$ret = '';
|
|
|
|
|
|
2005-02-07 14:11:59 +00:00
|
|
|
if( $wgMimeType == 'text/xml' || $wgMimeType == 'application/xhtml+xml' || $wgMimeType == 'application/xml' ) {
|
2008-08-21 14:09:57 +00:00
|
|
|
$ret .= "<?xml version=\"1.0\" encoding=\"$wgOutputEncoding\" ?>\n";
|
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";
|
2008-08-21 14:09:57 +00:00
|
|
|
$ret .= "<head>\n<title>" . htmlspecialchars( $this->getHTMLTitle() ) . "</title>\n\t\t";
|
|
|
|
|
$ret .= implode( "\t\t", array(
|
|
|
|
|
$this->getHeadLinks(),
|
|
|
|
|
$this->buildCssLinks(),
|
|
|
|
|
$sk->getHeadScripts( $this->mAllowUserJs ),
|
|
|
|
|
$this->mScripts,
|
|
|
|
|
$this->getHeadItems(),
|
|
|
|
|
));
|
|
|
|
|
if( $sk->usercss ){
|
|
|
|
|
$ret .= "<style type='text/css'>{$sk->usercss}</style>";
|
2008-08-10 07:14:08 +00:00
|
|
|
}
|
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;
|
|
|
|
|
}
|
2008-07-02 22:52:22 +00:00
|
|
|
|
|
|
|
|
protected function addDefaultMeta() {
|
|
|
|
|
global $wgVersion;
|
2008-11-08 15:06:50 +00:00
|
|
|
$this->addMeta( 'http:Content-Style-Type', 'text/css' ); //bug 15835
|
|
|
|
|
$this->addMeta( 'generator', "MediaWiki $wgVersion" );
|
2008-07-02 22:52:22 +00:00
|
|
|
|
2008-07-23 19:05:43 +00:00
|
|
|
$p = "{$this->mIndexPolicy},{$this->mFollowPolicy}";
|
|
|
|
|
if( $p !== 'index,follow' ) {
|
2008-07-02 22:52:22 +00:00
|
|
|
// http://www.robotstxt.org/wc/meta-user.html
|
|
|
|
|
// Only show if it's different from the default robots policy
|
|
|
|
|
$this->addMeta( 'robots', $p );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( count( $this->mKeywords ) > 0 ) {
|
|
|
|
|
$strip = array(
|
|
|
|
|
"/<.*?>/" => '',
|
|
|
|
|
"/_/" => ' '
|
|
|
|
|
);
|
|
|
|
|
$this->addMeta( 'keywords', preg_replace(array_keys($strip), array_values($strip),implode( ",", $this->mKeywords ) ) );
|
|
|
|
|
}
|
|
|
|
|
}
|
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() {
|
2008-07-02 22:52:22 +00:00
|
|
|
global $wgRequest, $wgFeed;
|
|
|
|
|
|
|
|
|
|
// Ideally this should happen earlier, somewhere. :P
|
|
|
|
|
$this->addDefaultMeta();
|
|
|
|
|
|
|
|
|
|
$tags = array();
|
|
|
|
|
|
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
|
|
|
}
|
2008-07-02 22:52:22 +00:00
|
|
|
$tags[] = Xml::element( 'meta',
|
|
|
|
|
array(
|
|
|
|
|
$a => $tag[0],
|
|
|
|
|
'content' => $tag[1] ) );
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
foreach ( $this->mLinktags as $tag ) {
|
2008-07-02 22:52:22 +00:00
|
|
|
$tags[] = Xml::element( 'link', $tag );
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-02-22 12:33:51 +00:00
|
|
|
if( $wgFeed ) {
|
2008-06-12 00:51:04 +00:00
|
|
|
global $wgTitle;
|
2008-02-22 12:33:51 +00:00
|
|
|
foreach( $this->getSyndicationLinks() as $format => $link ) {
|
|
|
|
|
# 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.
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-07-02 22:52:22 +00:00
|
|
|
$tags[] = $this->feedLink(
|
2008-02-22 12:33:51 +00:00
|
|
|
$format,
|
|
|
|
|
$link,
|
|
|
|
|
wfMsg( "page-{$format}-feed", $wgTitle->getPrefixedText() ) ); # Used messages: 'page-rss-feed' and 'page-atom-feed' (for an easier grep)
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-06-12 00:51:04 +00:00
|
|
|
# Recent changes feed should appear on every page (except recentchanges,
|
|
|
|
|
# that would be redundant). Put it after the per-page feed to avoid
|
|
|
|
|
# changing existing behavior. It's still available, probably via a
|
2008-08-08 01:41:14 +00:00
|
|
|
# menu in your browser. Some sites might have a different feed they'd
|
|
|
|
|
# like to promote instead of the RC feed (maybe like a "Recent New Articles"
|
|
|
|
|
# or "Breaking news" one). For this, we see if $wgOverrideSiteFeed is defined.
|
|
|
|
|
# If so, use it instead.
|
|
|
|
|
|
2008-09-16 03:58:18 +00:00
|
|
|
global $wgOverrideSiteFeed, $wgSitename, $wgFeedClasses;
|
2008-02-22 12:33:51 +00:00
|
|
|
$rctitle = SpecialPage::getTitleFor( 'Recentchanges' );
|
2008-08-08 01:41:14 +00:00
|
|
|
|
2008-08-08 21:02:52 +00:00
|
|
|
if ( $wgOverrideSiteFeed ) {
|
2008-08-08 01:41:14 +00:00
|
|
|
foreach ( $wgOverrideSiteFeed as $type => $feedUrl ) {
|
|
|
|
|
$tags[] = $this->feedLink (
|
|
|
|
|
$type,
|
|
|
|
|
htmlspecialchars( $feedUrl ),
|
|
|
|
|
wfMsg( "site-{$type}-feed", $wgSitename ) );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if ( $wgTitle->getPrefixedText() != $rctitle->getPrefixedText() ) {
|
2008-09-16 03:58:18 +00:00
|
|
|
foreach( $wgFeedClasses as $format => $class ) {
|
|
|
|
|
$tags[] = $this->feedLink(
|
|
|
|
|
$format,
|
|
|
|
|
$rctitle->getFullURL( "feed={$format}" ),
|
|
|
|
|
wfMsg( "site-{$format}-feed", $wgSitename ) ); # For grep: 'site-rss-feed', 'site-atom-feed'.
|
|
|
|
|
}
|
2008-06-12 00:51:04 +00:00
|
|
|
}
|
2004-03-19 08:05:36 +00:00
|
|
|
}
|
2005-01-18 00:05:35 +00:00
|
|
|
|
2008-07-02 22:52:22 +00:00
|
|
|
return implode( "\n\t\t", $tags ) . "\n";
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-01-12 00:13:53 +00:00
|
|
|
/**
|
|
|
|
|
* Return URLs for each supported syndication format for this page.
|
|
|
|
|
* @return array associating format keys with URLs
|
|
|
|
|
*/
|
|
|
|
|
public function getSyndicationLinks() {
|
|
|
|
|
global $wgTitle, $wgFeedClasses;
|
|
|
|
|
$links = array();
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-01-12 00:13:53 +00:00
|
|
|
if( $this->isSyndicated() ) {
|
|
|
|
|
if( is_string( $this->getFeedAppendQuery() ) ) {
|
|
|
|
|
$appendQuery = "&" . $this->getFeedAppendQuery();
|
|
|
|
|
} else {
|
|
|
|
|
$appendQuery = "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach( $wgFeedClasses as $format => $class ) {
|
|
|
|
|
$links[$format] = $wgTitle->getLocalUrl( "feed=$format{$appendQuery}" );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $links;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
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,
|
2008-07-02 22:52:22 +00:00
|
|
|
'href' => $url ) );
|
2007-09-24 18:25:56 +00:00
|
|
|
}
|
2005-07-01 00:03:31 +00:00
|
|
|
|
2008-08-21 14:09:57 +00:00
|
|
|
/**
|
|
|
|
|
* Add a local or specified stylesheet, with the given media options.
|
|
|
|
|
* Meant primarily for internal use...
|
|
|
|
|
*
|
|
|
|
|
* @param $media -- to specify a media type, 'screen', 'printable', 'handheld' or any.
|
|
|
|
|
* @param $conditional -- for IE conditional comments, specifying an IE version
|
|
|
|
|
* @param $dir -- set to 'rtl' or 'ltr' for direction-specific sheets
|
|
|
|
|
*/
|
|
|
|
|
public function addStyle( $style, $media='', $condition='', $dir='' ) {
|
|
|
|
|
$options = array();
|
|
|
|
|
if( $media )
|
|
|
|
|
$options['media'] = $media;
|
|
|
|
|
if( $condition )
|
|
|
|
|
$options['condition'] = $condition;
|
|
|
|
|
if( $dir )
|
|
|
|
|
$options['dir'] = $dir;
|
|
|
|
|
$this->styles[$style] = $options;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Build a set of <link>s for the stylesheets specified in the $this->styles array.
|
|
|
|
|
* These will be applied to various media & IE conditionals.
|
|
|
|
|
*/
|
|
|
|
|
public function buildCssLinks() {
|
|
|
|
|
$links = array();
|
|
|
|
|
foreach( $this->styles as $file => $options ) {
|
|
|
|
|
$link = $this->styleLink( $file, $options );
|
|
|
|
|
if( $link )
|
|
|
|
|
$links[] = $link;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return implode( "\n\t\t", $links );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function styleLink( $style, $options ) {
|
|
|
|
|
global $wgRequest;
|
|
|
|
|
|
|
|
|
|
if( isset( $options['dir'] ) ) {
|
|
|
|
|
global $wgContLang;
|
|
|
|
|
$siteDir = $wgContLang->isRTL() ? 'rtl' : 'ltr';
|
|
|
|
|
if( $siteDir != $options['dir'] )
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( isset( $options['media'] ) ) {
|
|
|
|
|
$media = $this->transformCssMedia( $options['media'] );
|
|
|
|
|
if( is_null( $media ) ) {
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$media = '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( substr( $style, 0, 1 ) == '/' ||
|
|
|
|
|
substr( $style, 0, 5 ) == 'http:' ||
|
|
|
|
|
substr( $style, 0, 6 ) == 'https:' ) {
|
|
|
|
|
$url = $style;
|
|
|
|
|
} else {
|
|
|
|
|
global $wgStylePath, $wgStyleVersion;
|
|
|
|
|
$url = $wgStylePath . '/' . $style . '?' . $wgStyleVersion;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$attribs = array(
|
|
|
|
|
'rel' => 'stylesheet',
|
|
|
|
|
'href' => $url,
|
|
|
|
|
'type' => 'text/css' );
|
|
|
|
|
if( $media ) {
|
|
|
|
|
$attribs['media'] = $media;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$link = Xml::element( 'link', $attribs );
|
|
|
|
|
|
|
|
|
|
if( isset( $options['condition'] ) ) {
|
|
|
|
|
$condition = htmlspecialchars( $options['condition'] );
|
|
|
|
|
$link = "<!--[if $condition]>$link<![endif]-->";
|
|
|
|
|
}
|
|
|
|
|
return $link;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function transformCssMedia( $media ) {
|
|
|
|
|
global $wgRequest, $wgHandheldForIPhone;
|
|
|
|
|
|
|
|
|
|
// Switch in on-screen display for media testing
|
|
|
|
|
$switches = array(
|
|
|
|
|
'printable' => 'print',
|
|
|
|
|
'handheld' => 'handheld',
|
|
|
|
|
);
|
|
|
|
|
foreach( $switches as $switch => $targetMedia ) {
|
|
|
|
|
if( $wgRequest->getBool( $switch ) ) {
|
|
|
|
|
if( $media == $targetMedia ) {
|
|
|
|
|
$media = '';
|
|
|
|
|
} elseif( $media == 'screen' ) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Expand longer media queries as iPhone doesn't grok 'handheld'
|
|
|
|
|
if( $wgHandheldForIPhone ) {
|
|
|
|
|
$mediaAliases = array(
|
|
|
|
|
'screen' => 'screen and (min-device-width: 481px)',
|
|
|
|
|
'handheld' => 'handheld, only screen and (max-device-width: 480px)',
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if( isset( $mediaAliases[$media] ) ) {
|
|
|
|
|
$media = $mediaAliases[$media];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $media;
|
|
|
|
|
}
|
|
|
|
|
|
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() {
|
2008-04-16 13:46:16 +00:00
|
|
|
global $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);
|
2008-02-18 07:25:35 +00:00
|
|
|
$this->addWikiMsg( 'actionthrottledtext' );
|
2007-11-20 08:34:59 +00:00
|
|
|
|
2008-04-16 13:46:16 +00:00
|
|
|
$this->returnToMain( null, $wgTitle );
|
2005-05-27 11:03:37 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +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;
|
|
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
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 );
|
2008-11-06 22:20:29 +00:00
|
|
|
$this->addHTML( "<div class=\"mw-{$message}\">\n{$warning}\n</div>\n" );
|
2007-08-11 17:18:20 +00:00
|
|
|
}
|
2007-05-18 20:17:53 +00:00
|
|
|
}
|
2007-12-10 06:02:29 +00:00
|
|
|
|
2008-02-18 07:25:35 +00:00
|
|
|
/**
|
|
|
|
|
* Add a wikitext-formatted message to the output.
|
|
|
|
|
* This is equivalent to:
|
|
|
|
|
*
|
|
|
|
|
* $wgOut->addWikiText( wfMsgNoTrans( ... ) )
|
|
|
|
|
*/
|
|
|
|
|
public function addWikiMsg( /*...*/ ) {
|
|
|
|
|
$args = func_get_args();
|
|
|
|
|
$name = array_shift( $args );
|
|
|
|
|
$this->addWikiMsgArray( $name, $args );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add a wikitext-formatted message to the output.
|
|
|
|
|
* Like addWikiMsg() except the parameters are taken as an array
|
|
|
|
|
* instead of a variable argument list.
|
|
|
|
|
*
|
|
|
|
|
* $options is passed through to wfMsgExt(), see that function for details.
|
|
|
|
|
*/
|
|
|
|
|
public function addWikiMsgArray( $name, $args, $options = array() ) {
|
|
|
|
|
$options[] = 'parse';
|
|
|
|
|
$text = wfMsgExt( $name, $options, $args );
|
|
|
|
|
$this->addHTML( $text );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2008-04-14 07:45:50 +00:00
|
|
|
* This function takes a number of message/argument specifications, wraps them in
|
2008-02-18 07:25:35 +00:00
|
|
|
* some overall structure, and then parses the result and adds it to the output.
|
|
|
|
|
*
|
2008-04-14 07:45:50 +00:00
|
|
|
* In the $wrap, $1 is replaced with the first message, $2 with the second, and so
|
|
|
|
|
* on. The subsequent arguments may either be strings, in which case they are the
|
2008-02-18 07:25:35 +00:00
|
|
|
* message names, or an arrays, in which case the first element is the message name,
|
|
|
|
|
* and subsequent elements are the parameters to that message.
|
|
|
|
|
*
|
|
|
|
|
* The special named parameter 'options' in a message specification array is passed
|
2008-04-14 07:45:50 +00:00
|
|
|
* through to the $options parameter of wfMsgExt().
|
2008-02-18 07:25:35 +00:00
|
|
|
*
|
2008-04-18 06:31:37 +00:00
|
|
|
* Don't use this for messages that are not in users interface language.
|
|
|
|
|
*
|
2008-02-18 07:25:35 +00:00
|
|
|
* For example:
|
|
|
|
|
*
|
|
|
|
|
* $wgOut->wrapWikiMsg( '<div class="error">$1</div>', 'some-error' );
|
2008-04-14 07:45:50 +00:00
|
|
|
*
|
2008-02-18 07:25:35 +00:00
|
|
|
* Is equivalent to:
|
|
|
|
|
*
|
|
|
|
|
* $wgOut->addWikiText( '<div class="error">' . wfMsgNoTrans( 'some-error' ) . '</div>' );
|
|
|
|
|
*/
|
|
|
|
|
public function wrapWikiMsg( $wrap /*, ...*/ ) {
|
|
|
|
|
$msgSpecs = func_get_args();
|
|
|
|
|
array_shift( $msgSpecs );
|
|
|
|
|
$msgSpecs = array_values( $msgSpecs );
|
|
|
|
|
$s = $wrap;
|
|
|
|
|
foreach ( $msgSpecs as $n => $spec ) {
|
|
|
|
|
$options = array();
|
|
|
|
|
if ( is_array( $spec ) ) {
|
|
|
|
|
$args = $spec;
|
|
|
|
|
$name = array_shift( $args );
|
|
|
|
|
if ( isset( $args['options'] ) ) {
|
|
|
|
|
$options = $args['options'];
|
|
|
|
|
unset( $args['options'] );
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$args = array();
|
|
|
|
|
$name = $spec;
|
|
|
|
|
}
|
2009-01-30 16:45:09 +00:00
|
|
|
$s = str_replace( '$' . ( $n + 1 ), wfMsgExt( $name, $options, $args ), $s );
|
2008-02-18 07:25:35 +00:00
|
|
|
}
|
2008-04-18 06:31:37 +00:00
|
|
|
$this->addHTML( $this->parse( $s, /*linestart*/true, /*uilang*/true ) );
|
2008-02-18 07:25:35 +00:00
|
|
|
}
|
2007-08-16 07:05:38 +00:00
|
|
|
}
|