2004-02-18 02:15:00 +00:00
|
|
|
<?php
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
* File for articles
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @file
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2003-08-02 20:43:11 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2011-06-29 22:09:51 +00:00
|
|
|
* Class for viewing MediaWiki article and history.
|
|
|
|
|
*
|
|
|
|
|
* This maintains WikiPage functions for backwards compatibility.
|
|
|
|
|
*
|
|
|
|
|
* @TODO: move and rewrite code to an Action class
|
2004-09-02 23:28:24 +00:00
|
|
|
*
|
2005-04-12 02:07:16 +00:00
|
|
|
* See design.txt for an overview.
|
2004-09-02 23:28:24 +00:00
|
|
|
* Note: edit user interface and cache support functions have been
|
2006-10-11 08:25:26 +00:00
|
|
|
* moved to separate EditPage and HTMLFileCache classes.
|
2004-09-03 00:20:26 +00:00
|
|
|
*
|
2010-03-15 23:22:50 +00:00
|
|
|
* @internal documentation reviewed 15 Mar 2010
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2011-06-29 22:09:51 +00:00
|
|
|
class Article extends Page {
|
2007-03-28 14:16:43 +00:00
|
|
|
/**@{{
|
2006-04-19 15:46:24 +00:00
|
|
|
* @private
|
|
|
|
|
*/
|
2011-04-25 11:59:31 +00:00
|
|
|
|
|
|
|
|
/**
|
2011-09-15 15:19:49 +00:00
|
|
|
* @var IContextSource
|
2011-04-25 11:59:31 +00:00
|
|
|
*/
|
|
|
|
|
protected $mContext;
|
2011-04-12 23:00:49 +00:00
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
/**
|
|
|
|
|
* @var WikiPage
|
|
|
|
|
*/
|
|
|
|
|
protected $mPage;
|
|
|
|
|
|
2011-09-29 17:54:19 +00:00
|
|
|
/**
|
|
|
|
|
* @var ParserOptions: ParserOptions object for $wgUser articles
|
|
|
|
|
*/
|
|
|
|
|
public $mParserOptions;
|
|
|
|
|
|
2010-02-14 22:07:30 +00:00
|
|
|
var $mContent; // !<
|
|
|
|
|
var $mContentLoaded = false; // !<
|
|
|
|
|
var $mOldId; // !<
|
2011-04-25 11:59:31 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var Title
|
|
|
|
|
*/
|
|
|
|
|
var $mRedirectedFrom = null;
|
|
|
|
|
|
|
|
|
|
/**
|
2011-06-14 21:10:33 +00:00
|
|
|
* @var mixed: boolean false or URL string
|
2011-04-25 11:59:31 +00:00
|
|
|
*/
|
2010-02-14 22:07:30 +00:00
|
|
|
var $mRedirectUrl = false; // !<
|
|
|
|
|
var $mRevIdFetched = 0; // !<
|
2011-04-25 11:59:31 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var Revision
|
|
|
|
|
*/
|
|
|
|
|
var $mRevision = null;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var ParserOutput
|
|
|
|
|
*/
|
|
|
|
|
var $mParserOutput;
|
|
|
|
|
|
2007-03-28 14:16:43 +00:00
|
|
|
/**@}}*/
|
2004-09-02 23:28:24 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Constructor and clear the article
|
2011-05-28 18:58:51 +00:00
|
|
|
* @param $title Title Reference to a Title object.
|
2006-04-19 15:46:24 +00:00
|
|
|
* @param $oldId Integer revision ID, null to fetch from request, zero for current
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2008-11-28 14:29:25 +00:00
|
|
|
public function __construct( Title $title, $oldId = null ) {
|
2005-12-30 09:33:11 +00:00
|
|
|
$this->mOldId = $oldId;
|
2011-06-29 22:09:51 +00:00
|
|
|
$this->mPage = $this->newPage( $title );
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-05 13:43:32 +00:00
|
|
|
/**
|
|
|
|
|
* @param $title Title
|
|
|
|
|
* @return WikiPage
|
|
|
|
|
*/
|
2011-06-29 22:09:51 +00:00
|
|
|
protected function newPage( Title $title ) {
|
|
|
|
|
return new WikiPage( $title );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Constructor from a page id
|
|
|
|
|
* @param $id Int article ID to load
|
2011-10-29 01:17:26 +00:00
|
|
|
* @return Article|null
|
2011-06-29 22:09:51 +00:00
|
|
|
*/
|
|
|
|
|
public static function newFromID( $id ) {
|
|
|
|
|
$t = Title::newFromID( $id );
|
|
|
|
|
# @todo FIXME: Doesn't inherit right
|
|
|
|
|
return $t == null ? null : new self( $t );
|
|
|
|
|
# return $t == null ? null : new static( $t ); // PHP 5.3
|
2003-09-01 08:30:14 +00:00
|
|
|
}
|
2008-08-21 00:45:13 +00:00
|
|
|
|
2011-05-22 18:38:04 +00:00
|
|
|
/**
|
|
|
|
|
* Create an Article object of the appropriate class for the given page.
|
|
|
|
|
*
|
|
|
|
|
* @param $title Title
|
2011-09-15 15:19:49 +00:00
|
|
|
* @param $context IContextSource
|
2011-05-22 18:38:04 +00:00
|
|
|
* @return Article object
|
|
|
|
|
*/
|
2011-09-15 15:19:49 +00:00
|
|
|
public static function newFromTitle( $title, IContextSource $context ) {
|
2011-05-22 18:38:04 +00:00
|
|
|
if ( NS_MEDIA == $title->getNamespace() ) {
|
|
|
|
|
// FIXME: where should this go?
|
|
|
|
|
$title = Title::makeTitle( NS_FILE, $title->getDBkey() );
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-28 03:51:00 +00:00
|
|
|
$page = null;
|
|
|
|
|
wfRunHooks( 'ArticleFromTitle', array( &$title, &$page ) );
|
|
|
|
|
if ( !$page ) {
|
|
|
|
|
switch( $title->getNamespace() ) {
|
|
|
|
|
case NS_FILE:
|
|
|
|
|
$page = new ImagePage( $title );
|
|
|
|
|
break;
|
|
|
|
|
case NS_CATEGORY:
|
|
|
|
|
$page = new CategoryPage( $title );
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
$page = new Article( $title );
|
|
|
|
|
}
|
2011-05-22 18:38:04 +00:00
|
|
|
}
|
|
|
|
|
$page->setContext( $context );
|
2011-06-28 03:51:00 +00:00
|
|
|
|
2011-05-22 18:38:04 +00:00
|
|
|
return $page;
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-15 19:41:32 +00:00
|
|
|
/**
|
|
|
|
|
* Create an Article object of the appropriate class for the given page.
|
|
|
|
|
*
|
|
|
|
|
* @param $page WikiPage
|
|
|
|
|
* @param $context IContextSource
|
|
|
|
|
* @return Article object
|
|
|
|
|
*/
|
|
|
|
|
public static function newFromWikiPage( WikiPage $page, IContextSource $context ) {
|
|
|
|
|
$article = self::newFromTitle( $page->getTitle(), $context );
|
|
|
|
|
$article->mPage = $page; // override to keep process cached vars
|
|
|
|
|
return $article;
|
|
|
|
|
}
|
|
|
|
|
|
2006-01-13 00:29:20 +00:00
|
|
|
/**
|
|
|
|
|
* Tell the page view functions that this view was redirected
|
|
|
|
|
* from another page on the wiki.
|
2006-04-19 15:46:24 +00:00
|
|
|
* @param $from Title object.
|
2006-01-13 00:29:20 +00:00
|
|
|
*/
|
2010-03-14 23:20:40 +00:00
|
|
|
public function setRedirectedFrom( Title $from ) {
|
2006-01-13 00:29:20 +00:00
|
|
|
$this->mRedirectedFrom = $from;
|
|
|
|
|
}
|
2007-01-17 22:32:40 +00:00
|
|
|
|
2004-12-29 01:07:43 +00:00
|
|
|
/**
|
2010-06-28 07:17:16 +00:00
|
|
|
* Get the title object of the article
|
2012-01-06 20:00:04 +00:00
|
|
|
*
|
2010-06-28 07:17:16 +00:00
|
|
|
* @return Title object of this page
|
2004-12-29 01:07:43 +00:00
|
|
|
*/
|
2008-11-28 14:29:25 +00:00
|
|
|
public function getTitle() {
|
2011-06-29 22:09:51 +00:00
|
|
|
return $this->mPage->getTitle();
|
2004-12-29 01:07:43 +00:00
|
|
|
}
|
|
|
|
|
|
2012-01-06 20:00:04 +00:00
|
|
|
/**
|
|
|
|
|
* Get the WikiPage object of this instance
|
|
|
|
|
*
|
|
|
|
|
* @since 1.19
|
|
|
|
|
* @return WikiPage
|
|
|
|
|
*/
|
|
|
|
|
public function getPage() {
|
|
|
|
|
return $this->mPage;
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2008-11-30 10:10:15 +00:00
|
|
|
* Clear the object
|
|
|
|
|
*/
|
2008-11-28 14:29:25 +00:00
|
|
|
public function clear() {
|
2003-04-14 23:10:40 +00:00
|
|
|
$this->mContentLoaded = false;
|
2005-07-01 00:03:31 +00:00
|
|
|
|
2006-01-13 00:29:20 +00:00
|
|
|
$this->mRedirectedFrom = null; # Title object if set
|
2005-03-29 16:38:30 +00:00
|
|
|
$this->mRevIdFetched = 0;
|
2005-12-30 09:33:11 +00:00
|
|
|
$this->mRedirectUrl = false;
|
2011-06-29 22:09:51 +00:00
|
|
|
|
|
|
|
|
$this->mPage->clear();
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2006-01-13 00:29:20 +00:00
|
|
|
* Note that getContent/loadContent do not follow redirects anymore.
|
|
|
|
|
* If you need to fetch redirectable content easily, try
|
2012-01-08 17:34:28 +00:00
|
|
|
* the shortcut in WikiPage::getRedirectTarget()
|
2004-09-02 23:28:24 +00:00
|
|
|
*
|
2010-06-28 07:17:16 +00:00
|
|
|
* This function has side effects! Do not use this function if you
|
|
|
|
|
* only want the real revision text if any.
|
|
|
|
|
*
|
2012-02-09 18:01:54 +00:00
|
|
|
* @return string Return the text of this revision
|
2009-12-26 20:03:33 +00:00
|
|
|
*/
|
2008-11-28 14:29:25 +00:00
|
|
|
public function getContent() {
|
2011-02-03 15:31:38 +00:00
|
|
|
global $wgUser;
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2006-06-20 09:50:57 +00:00
|
|
|
wfProfileIn( __METHOD__ );
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
if ( $this->mPage->getID() === 0 ) {
|
2008-11-28 14:29:25 +00:00
|
|
|
# If this is a MediaWiki:x message, then load the messages
|
|
|
|
|
# and return the message value for x.
|
2011-06-29 22:09:51 +00:00
|
|
|
if ( $this->getTitle()->getNamespace() == NS_MEDIAWIKI ) {
|
|
|
|
|
$text = $this->getTitle()->getDefaultMessageText();
|
2011-02-03 15:29:13 +00:00
|
|
|
if ( $text === false ) {
|
2008-11-28 18:37:31 +00:00
|
|
|
$text = '';
|
2011-02-03 15:29:13 +00:00
|
|
|
}
|
2005-12-28 14:47:30 +00:00
|
|
|
} else {
|
2009-01-12 08:11:22 +00:00
|
|
|
$text = wfMsgExt( $wgUser->isLoggedIn() ? 'noarticletext' : 'noarticletextanon', 'parsemag' );
|
2005-12-28 14:47:30 +00:00
|
|
|
}
|
2008-11-28 14:29:25 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2008-11-28 14:29:25 +00:00
|
|
|
return $text;
|
2005-07-03 04:00:33 +00:00
|
|
|
} else {
|
2011-11-14 18:05:55 +00:00
|
|
|
$this->fetchContent();
|
2006-06-20 09:50:57 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2006-04-11 08:27:35 +00:00
|
|
|
return $this->mContent;
|
2004-05-13 12:20:59 +00:00
|
|
|
}
|
|
|
|
|
}
|
2009-06-18 02:50:16 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2006-01-07 12:10:04 +00:00
|
|
|
* @return int The oldid of the article that is to be shown, 0 for the
|
|
|
|
|
* current revision
|
2004-11-13 08:40:34 +00:00
|
|
|
*/
|
2008-11-28 14:29:25 +00:00
|
|
|
public function getOldID() {
|
2010-02-14 22:07:30 +00:00
|
|
|
if ( is_null( $this->mOldId ) ) {
|
2005-12-30 09:33:11 +00:00
|
|
|
$this->mOldId = $this->getOldIDFromRequest();
|
2004-11-13 08:40:34 +00:00
|
|
|
}
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2005-12-30 09:33:11 +00:00
|
|
|
return $this->mOldId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets $this->mRedirectUrl to a correct URL if the query parameters are incorrect
|
2006-01-07 12:10:04 +00:00
|
|
|
*
|
|
|
|
|
* @return int The old id for the request
|
2005-12-30 09:33:11 +00:00
|
|
|
*/
|
2008-08-26 00:32:55 +00:00
|
|
|
public function getOldIDFromRequest() {
|
2005-12-30 09:33:11 +00:00
|
|
|
global $wgRequest;
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2005-12-30 09:33:11 +00:00
|
|
|
$this->mRedirectUrl = false;
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2011-11-14 18:05:55 +00:00
|
|
|
$oldid = $wgRequest->getIntOrNull( 'oldid' );
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2011-11-14 18:05:55 +00:00
|
|
|
if ( $oldid === null ) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $oldid !== 0 ) {
|
|
|
|
|
# Load the given revision and check whether the page is another one.
|
|
|
|
|
# In that case, update this instance to reflect the change.
|
2012-03-09 14:50:39 +00:00
|
|
|
if ( $oldid === $this->mPage->getLatest() ) {
|
|
|
|
|
$this->mRevision = $this->mPage->getRevision();
|
|
|
|
|
} else {
|
|
|
|
|
$this->mRevision = Revision::newFromId( $oldid );
|
|
|
|
|
if ( $this->mRevision !== null ) {
|
|
|
|
|
// Revision title doesn't match the page title given?
|
|
|
|
|
if ( $this->mPage->getID() != $this->mRevision->getPage() ) {
|
|
|
|
|
$function = array( get_class( $this->mPage ), 'newFromID' );
|
|
|
|
|
$this->mPage = call_user_func( $function, $this->mRevision->getPage() );
|
|
|
|
|
}
|
2004-10-02 21:36:36 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2011-11-14 18:05:55 +00:00
|
|
|
if ( $wgRequest->getVal( 'direction' ) == 'next' ) {
|
|
|
|
|
$nextid = $this->getTitle()->getNextRevisionID( $oldid );
|
|
|
|
|
if ( $nextid ) {
|
|
|
|
|
$oldid = $nextid;
|
2012-01-29 19:05:04 +00:00
|
|
|
$this->mRevision = null;
|
2011-11-14 18:05:55 +00:00
|
|
|
} else {
|
|
|
|
|
$this->mRedirectUrl = $this->getTitle()->getFullURL( 'redirect=no' );
|
|
|
|
|
}
|
|
|
|
|
} elseif ( $wgRequest->getVal( 'direction' ) == 'prev' ) {
|
|
|
|
|
$previd = $this->getTitle()->getPreviousRevisionID( $oldid );
|
|
|
|
|
if ( $previd ) {
|
|
|
|
|
$oldid = $previd;
|
2012-01-29 19:05:04 +00:00
|
|
|
$this->mRevision = null;
|
2011-11-14 18:05:55 +00:00
|
|
|
}
|
2005-12-30 09:33:11 +00:00
|
|
|
}
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2005-12-30 09:33:11 +00:00
|
|
|
return $oldid;
|
2004-11-13 08:40:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2005-12-30 09:33:11 +00:00
|
|
|
* Load the revision (including text) into this object
|
2011-11-14 18:05:55 +00:00
|
|
|
*
|
|
|
|
|
* @deprecated in 1.19; use fetchContent()
|
2004-12-19 08:00:50 +00:00
|
|
|
*/
|
2006-01-13 00:29:20 +00:00
|
|
|
function loadContent() {
|
2011-12-13 05:19:05 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.19' );
|
2011-11-14 18:05:55 +00:00
|
|
|
$this->fetchContent();
|
2004-12-19 08:00:50 +00:00
|
|
|
}
|
2005-07-01 00:03:31 +00:00
|
|
|
|
2004-12-19 08:00:50 +00:00
|
|
|
/**
|
2005-01-11 01:28:18 +00:00
|
|
|
* Get text of an article from database
|
2006-01-13 00:29:20 +00:00
|
|
|
* Does *NOT* follow redirects.
|
2010-05-30 14:28:54 +00:00
|
|
|
*
|
2010-03-14 23:20:40 +00:00
|
|
|
* @return mixed string containing article contents, or false if null
|
2004-12-19 08:00:50 +00:00
|
|
|
*/
|
2011-11-14 18:05:55 +00:00
|
|
|
function fetchContent() {
|
2010-02-14 22:07:30 +00:00
|
|
|
if ( $this->mContentLoaded ) {
|
2004-12-19 08:00:50 +00:00
|
|
|
return $this->mContent;
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2011-11-14 18:05:55 +00:00
|
|
|
wfProfileIn( __METHOD__ );
|
|
|
|
|
|
|
|
|
|
$this->mContentLoaded = true;
|
|
|
|
|
|
|
|
|
|
$oldid = $this->getOldID();
|
|
|
|
|
|
2004-12-19 08:00:50 +00:00
|
|
|
# Pre-fill content with error message so that if something
|
|
|
|
|
# fails we'll have something telling us what we intended.
|
2011-06-29 22:09:51 +00:00
|
|
|
$t = $this->getTitle()->getPrefixedText();
|
2008-06-05 17:33:31 +00:00
|
|
|
$d = $oldid ? wfMsgExt( 'missingarticle-rev', array( 'escape' ), $oldid ) : '';
|
2009-09-22 11:13:41 +00:00
|
|
|
$this->mContent = wfMsgNoTrans( 'missing-article', $t, $d ) ;
|
2004-07-08 14:53:54 +00:00
|
|
|
|
2010-02-14 22:07:30 +00:00
|
|
|
if ( $oldid ) {
|
2011-11-14 18:05:55 +00:00
|
|
|
# $this->mRevision might already be fetched by getOldIDFromRequest()
|
|
|
|
|
if ( !$this->mRevision ) {
|
|
|
|
|
$this->mRevision = Revision::newFromId( $oldid );
|
|
|
|
|
if ( !$this->mRevision ) {
|
|
|
|
|
wfDebug( __METHOD__ . " failed to retrieve specified revision, id $oldid\n" );
|
2011-11-15 16:35:52 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
2005-03-18 08:37:50 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
2005-03-18 05:38:49 +00:00
|
|
|
}
|
2011-01-03 19:50:01 +00:00
|
|
|
} else {
|
2011-07-01 23:33:34 +00:00
|
|
|
if ( !$this->mPage->getLatest() ) {
|
2011-06-29 22:09:51 +00:00
|
|
|
wfDebug( __METHOD__ . " failed to find page data for title " . $this->getTitle()->getPrefixedText() . "\n" );
|
2011-11-15 16:35:52 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
2011-01-03 19:50:01 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-14 18:05:55 +00:00
|
|
|
$this->mRevision = $this->mPage->getRevision();
|
|
|
|
|
if ( !$this->mRevision ) {
|
2011-06-29 22:09:51 +00:00
|
|
|
wfDebug( __METHOD__ . " failed to retrieve current page, rev_id " . $this->mPage->getLatest() . "\n" );
|
2011-11-15 16:35:52 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
2005-03-18 05:38:49 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
2004-12-19 08:00:50 +00:00
|
|
|
}
|
2004-08-07 03:50:46 +00:00
|
|
|
|
2011-05-17 22:03:20 +00:00
|
|
|
// @todo FIXME: Horrible, horrible! This content-loading interface just plain sucks.
|
2006-03-16 19:04:25 +00:00
|
|
|
// We should instead work with the Revision object when we need it...
|
2011-11-14 18:05:55 +00:00
|
|
|
$this->mContent = $this->mRevision->getText( Revision::FOR_THIS_USER ); // Loads if user is allowed
|
|
|
|
|
$this->mRevIdFetched = $this->mRevision->getId();
|
2005-07-01 00:03:31 +00:00
|
|
|
|
2010-06-30 07:42:07 +00:00
|
|
|
wfRunHooks( 'ArticleAfterFetchContent', array( &$this, &$this->mContent ) );
|
2005-12-21 12:02:18 +00:00
|
|
|
|
2011-11-14 18:05:55 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
|
|
|
|
|
2004-03-23 10:11:24 +00:00
|
|
|
return $this->mContent;
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2011-05-10 22:54:59 +00:00
|
|
|
* No-op
|
2011-05-06 20:59:58 +00:00
|
|
|
* @deprecated since 1.18
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2011-05-10 22:54:59 +00:00
|
|
|
public function forUpdate() {
|
2011-12-13 05:19:05 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.18' );
|
2004-08-20 14:59:49 +00:00
|
|
|
}
|
2004-09-01 02:57:26 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2011-06-29 22:09:51 +00:00
|
|
|
* Returns true if the currently-referenced revision is the current edit
|
|
|
|
|
* to this page (and it exists).
|
|
|
|
|
* @return bool
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2011-06-29 22:09:51 +00:00
|
|
|
public function isCurrent() {
|
|
|
|
|
# If no oldid, this is the current version.
|
|
|
|
|
if ( $this->getOldID() == 0 ) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2005-07-01 20:36:04 +00:00
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
return $this->mPage->exists() && $this->mRevision && $this->mRevision->isCurrent();
|
2005-06-29 23:44:03 +00:00
|
|
|
}
|
2009-06-18 02:50:16 +00:00
|
|
|
|
2011-12-30 16:12:46 +00:00
|
|
|
/**
|
|
|
|
|
* Get the fetched Revision object depending on request parameters or null
|
|
|
|
|
* on failure.
|
|
|
|
|
*
|
2012-01-05 19:05:02 +00:00
|
|
|
* @since 1.19
|
2011-12-30 16:12:46 +00:00
|
|
|
* @return Revision|null
|
|
|
|
|
*/
|
|
|
|
|
public function getRevisionFetched() {
|
|
|
|
|
$this->fetchContent();
|
|
|
|
|
|
|
|
|
|
return $this->mRevision;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-22 23:38:58 +00:00
|
|
|
/**
|
2011-06-29 22:09:51 +00:00
|
|
|
* Use this to fetch the rev ID used on page views
|
2008-12-22 23:38:58 +00:00
|
|
|
*
|
2011-06-29 22:09:51 +00:00
|
|
|
* @return int revision ID of last article revision
|
2008-12-22 23:38:58 +00:00
|
|
|
*/
|
2011-06-29 22:09:51 +00:00
|
|
|
public function getRevIdFetched() {
|
|
|
|
|
if ( $this->mRevIdFetched ) {
|
|
|
|
|
return $this->mRevIdFetched;
|
|
|
|
|
} else {
|
|
|
|
|
return $this->mPage->getLatest();
|
|
|
|
|
}
|
2008-12-22 23:38:58 +00:00
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2004-09-11 11:39:24 +00:00
|
|
|
/**
|
2011-06-29 22:09:51 +00:00
|
|
|
* This is the default action of the index.php entry point: just view the
|
|
|
|
|
* page of the given title.
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2011-06-29 22:09:51 +00:00
|
|
|
public function view() {
|
|
|
|
|
global $wgUser, $wgOut, $wgRequest, $wgParser;
|
2011-12-04 18:29:57 +00:00
|
|
|
global $wgUseFileCache, $wgUseETag, $wgDebugToolbar;
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
wfProfileIn( __METHOD__ );
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
# Get variables from query string
|
2011-11-14 18:05:55 +00:00
|
|
|
# As side effect this will load the revision and update the title
|
|
|
|
|
# in a revision ID is passed in the request, so this should remain
|
|
|
|
|
# the first call of this method even if $oldid is used way below.
|
2011-06-29 22:09:51 +00:00
|
|
|
$oldid = $this->getOldID();
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2011-11-14 18:05:55 +00:00
|
|
|
# Another whitelist check in case getOldID() is altering the title
|
|
|
|
|
$permErrors = $this->getTitle()->getUserPermissionsErrors( 'read', $wgUser );
|
|
|
|
|
if ( count( $permErrors ) ) {
|
|
|
|
|
wfDebug( __METHOD__ . ": denied on secondary read check\n" );
|
|
|
|
|
wfProfileOut( __METHOD__ );
|
|
|
|
|
throw new PermissionsError( 'read', $permErrors );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# getOldID() may as well want us to redirect somewhere else
|
2011-06-29 22:09:51 +00:00
|
|
|
if ( $this->mRedirectUrl ) {
|
|
|
|
|
$wgOut->redirect( $this->mRedirectUrl );
|
|
|
|
|
wfDebug( __METHOD__ . ": redirecting due to oldid\n" );
|
|
|
|
|
wfProfileOut( __METHOD__ );
|
2011-05-14 17:11:32 +00:00
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
return;
|
2011-05-14 17:11:32 +00:00
|
|
|
}
|
|
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
# If we got diff in the query, we want to see a diff page instead of the article.
|
|
|
|
|
if ( $wgRequest->getCheck( 'diff' ) ) {
|
|
|
|
|
wfDebug( __METHOD__ . ": showing diff page\n" );
|
|
|
|
|
$this->showDiffPage();
|
|
|
|
|
wfProfileOut( __METHOD__ );
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
return;
|
2011-05-14 17:11:32 +00:00
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2011-11-14 18:05:55 +00:00
|
|
|
# Set page title (may be overridden by DISPLAYTITLE)
|
|
|
|
|
$wgOut->setPageTitle( $this->getTitle()->getPrefixedText() );
|
|
|
|
|
|
2011-07-27 13:14:28 +00:00
|
|
|
$wgOut->setArticleFlag( true );
|
2011-06-29 22:09:51 +00:00
|
|
|
# Allow frames by default
|
|
|
|
|
$wgOut->allowClickjacking();
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
$parserCache = ParserCache::singleton();
|
2004-09-11 11:39:24 +00:00
|
|
|
|
2011-09-29 17:51:27 +00:00
|
|
|
$parserOptions = $this->getParserOptions();
|
2011-06-29 22:09:51 +00:00
|
|
|
# Render printable version, use printable version cache
|
|
|
|
|
if ( $wgOut->isPrintable() ) {
|
|
|
|
|
$parserOptions->setIsPrintable( true );
|
|
|
|
|
$parserOptions->setEditSection( false );
|
2011-11-14 18:05:55 +00:00
|
|
|
} elseif ( !$this->getTitle()->quickUserCan( 'edit' ) ) {
|
2011-06-29 22:09:51 +00:00
|
|
|
$parserOptions->setEditSection( false );
|
2008-11-28 14:29:25 +00:00
|
|
|
}
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
# Try client and file cache
|
2011-12-04 18:29:57 +00:00
|
|
|
if ( !$wgDebugToolbar && $oldid === 0 && $this->mPage->checkTouched() ) {
|
2011-06-29 22:09:51 +00:00
|
|
|
if ( $wgUseETag ) {
|
|
|
|
|
$wgOut->setETag( $parserCache->getETag( $this, $parserOptions ) );
|
|
|
|
|
}
|
2005-07-01 20:36:04 +00:00
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
# Is it client cached?
|
|
|
|
|
if ( $wgOut->checkLastModified( $this->mPage->getTouched() ) ) {
|
|
|
|
|
wfDebug( __METHOD__ . ": done 304\n" );
|
|
|
|
|
wfProfileOut( __METHOD__ );
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
return;
|
|
|
|
|
# Try file cache
|
|
|
|
|
} elseif ( $wgUseFileCache && $this->tryFileCache() ) {
|
|
|
|
|
wfDebug( __METHOD__ . ": done file cache\n" );
|
|
|
|
|
# tell wgOut that output is taken care of
|
|
|
|
|
$wgOut->disable();
|
2012-01-02 17:16:10 +00:00
|
|
|
$this->mPage->doViewUpdates( $wgUser );
|
2011-06-29 22:09:51 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
2005-02-06 07:28:21 +00:00
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2010-05-30 14:28:54 +00:00
|
|
|
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
# Should the parser cache be used?
|
2011-11-17 20:21:54 +00:00
|
|
|
$useParserCache = $this->mPage->isParserCacheUsed( $parserOptions, $oldid );
|
2010-02-14 22:07:30 +00:00
|
|
|
wfDebug( 'Article::view using parser cache: ' . ( $useParserCache ? 'yes' : 'no' ) . "\n" );
|
2010-08-03 22:32:09 +00:00
|
|
|
if ( $wgUser->getStubThreshold() ) {
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
wfIncrStats( 'pcache_miss_stub' );
|
2006-06-04 00:25:53 +00:00
|
|
|
}
|
|
|
|
|
|
2011-11-08 18:01:22 +00:00
|
|
|
$this->showRedirectedFromHeader();
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
$this->showNamespaceHeader();
|
2007-01-17 22:32:40 +00:00
|
|
|
|
2009-08-31 19:19:12 +00:00
|
|
|
# Iterate through the possible ways of constructing the output text.
|
|
|
|
|
# Keep going until $outputDone is set, or we run out of things to do.
|
|
|
|
|
$pass = 0;
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
$outputDone = false;
|
2010-04-10 23:52:07 +00:00
|
|
|
$this->mParserOutput = false;
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2010-02-14 22:07:30 +00:00
|
|
|
while ( !$outputDone && ++$pass ) {
|
|
|
|
|
switch( $pass ) {
|
2009-08-31 19:19:12 +00:00
|
|
|
case 1:
|
|
|
|
|
wfRunHooks( 'ArticleViewHeader', array( &$this, &$outputDone, &$useParserCache ) );
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
2011-11-14 18:05:55 +00:00
|
|
|
# Early abort if the page doesn't exist
|
|
|
|
|
if ( !$this->mPage->exists() ) {
|
|
|
|
|
wfDebug( __METHOD__ . ": showing missing article\n" );
|
|
|
|
|
$this->showMissingArticle();
|
|
|
|
|
wfProfileOut( __METHOD__ );
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-31 19:19:12 +00:00
|
|
|
# Try the parser cache
|
2010-02-14 22:07:30 +00:00
|
|
|
if ( $useParserCache ) {
|
2009-08-31 19:19:12 +00:00
|
|
|
$this->mParserOutput = $parserCache->get( $this, $parserOptions );
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2009-08-31 19:19:12 +00:00
|
|
|
if ( $this->mParserOutput !== false ) {
|
2011-11-14 18:05:55 +00:00
|
|
|
if ( $oldid ) {
|
|
|
|
|
wfDebug( __METHOD__ . ": showing parser cache contents for current rev permalink\n" );
|
|
|
|
|
$this->setOldSubtitle( $oldid );
|
|
|
|
|
} else {
|
|
|
|
|
wfDebug( __METHOD__ . ": showing parser cache contents\n" );
|
|
|
|
|
}
|
2009-08-31 19:19:12 +00:00
|
|
|
$wgOut->addParserOutput( $this->mParserOutput );
|
|
|
|
|
# Ensure that UI elements requiring revision ID have
|
|
|
|
|
# the correct version information.
|
2011-06-29 22:09:51 +00:00
|
|
|
$wgOut->setRevisionId( $this->mPage->getLatest() );
|
|
|
|
|
# Preload timestamp to avoid a DB hit
|
2011-12-16 20:55:54 +00:00
|
|
|
$cachedTimestamp = $this->mParserOutput->getTimestamp();
|
|
|
|
|
if ( $cachedTimestamp !== null ) {
|
|
|
|
|
$wgOut->setRevisionTimestamp( $cachedTimestamp );
|
|
|
|
|
$this->mPage->setTimestamp( $cachedTimestamp );
|
|
|
|
|
}
|
2011-12-10 16:30:40 +00:00
|
|
|
$outputDone = true;
|
2009-08-31 19:19:12 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
2011-11-14 18:05:55 +00:00
|
|
|
# This will set $this->mRevision if needed
|
|
|
|
|
$this->fetchContent();
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
|
2009-08-31 19:19:12 +00:00
|
|
|
# Are we looking at an old revision
|
2011-11-14 18:05:55 +00:00
|
|
|
if ( $oldid && $this->mRevision ) {
|
2009-08-31 19:19:12 +00:00
|
|
|
$this->setOldSubtitle( $oldid );
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2009-08-31 19:19:12 +00:00
|
|
|
if ( !$this->showDeletedRevisionHeader() ) {
|
2010-02-14 22:07:30 +00:00
|
|
|
wfDebug( __METHOD__ . ": cannot view deleted revision\n" );
|
2009-08-31 19:19:12 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
|
2009-08-31 19:19:12 +00:00
|
|
|
# Ensure that UI elements requiring revision ID have
|
|
|
|
|
# the correct version information.
|
|
|
|
|
$wgOut->setRevisionId( $this->getRevIdFetched() );
|
2011-12-10 16:30:40 +00:00
|
|
|
# Preload timestamp to avoid a DB hit
|
|
|
|
|
$wgOut->setRevisionTimestamp( $this->getTimestamp() );
|
2009-08-31 19:19:12 +00:00
|
|
|
|
|
|
|
|
# Pages containing custom CSS or JavaScript get special treatment
|
2011-06-29 22:09:51 +00:00
|
|
|
if ( $this->getTitle()->isCssOrJsPage() || $this->getTitle()->isCssJsSubpage() ) {
|
2010-02-14 22:07:30 +00:00
|
|
|
wfDebug( __METHOD__ . ": showing CSS/JS source\n" );
|
2009-08-31 19:19:12 +00:00
|
|
|
$this->showCssOrJsPage();
|
|
|
|
|
$outputDone = true;
|
2011-08-11 17:21:31 +00:00
|
|
|
} elseif( !wfRunHooks( 'ArticleViewCustom', array( $this->mContent, $this->getTitle(), $wgOut ) ) ) {
|
|
|
|
|
# Allow extensions do their own custom view for certain pages
|
|
|
|
|
$outputDone = true;
|
2010-11-01 00:07:17 +00:00
|
|
|
} else {
|
2011-11-14 18:05:55 +00:00
|
|
|
$text = $this->getContent();
|
2010-11-01 00:07:17 +00:00
|
|
|
$rt = Title::newFromRedirectArray( $text );
|
|
|
|
|
if ( $rt ) {
|
|
|
|
|
wfDebug( __METHOD__ . ": showing redirect=no page\n" );
|
|
|
|
|
# Viewing a redirect page (e.g. with parameter redirect=no)
|
2011-11-08 18:01:22 +00:00
|
|
|
$wgOut->addHTML( $this->viewRedirect( $rt ) );
|
2010-11-01 00:07:17 +00:00
|
|
|
# Parse just to get categories, displaytitle, etc.
|
2011-06-29 22:09:51 +00:00
|
|
|
$this->mParserOutput = $wgParser->parse( $text, $this->getTitle(), $parserOptions );
|
2010-11-01 00:07:17 +00:00
|
|
|
$wgOut->addParserOutputNoText( $this->mParserOutput );
|
|
|
|
|
$outputDone = true;
|
|
|
|
|
}
|
2009-08-31 19:19:12 +00:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
# Run the parse, protected by a pool counter
|
2010-02-14 22:07:30 +00:00
|
|
|
wfDebug( __METHOD__ . ": doing uncached parse\n" );
|
2010-08-09 21:53:21 +00:00
|
|
|
|
2011-11-17 20:21:54 +00:00
|
|
|
$poolArticleView = new PoolWorkArticleView( $this, $parserOptions,
|
|
|
|
|
$this->getRevIdFetched(), $useParserCache, $this->getContent() );
|
2010-12-13 19:47:34 +00:00
|
|
|
|
2010-08-27 20:57:32 +00:00
|
|
|
if ( !$poolArticleView->execute() ) {
|
2011-11-17 20:21:54 +00:00
|
|
|
$error = $poolArticleView->getError();
|
|
|
|
|
if ( $error ) {
|
|
|
|
|
$wgOut->clearHTML(); // for release() errors
|
|
|
|
|
$wgOut->enableClientCache( false );
|
|
|
|
|
$wgOut->setRobotPolicy( 'noindex,nofollow' );
|
|
|
|
|
|
|
|
|
|
$errortext = $error->getWikiText( false, 'view-pool-error' );
|
|
|
|
|
$wgOut->addWikiText( '<div class="errorbox">' . $errortext . '</div>' );
|
|
|
|
|
}
|
2009-08-31 19:19:12 +00:00
|
|
|
# Connection or timeout error
|
|
|
|
|
wfProfileOut( __METHOD__ );
|
|
|
|
|
return;
|
|
|
|
|
}
|
2011-11-17 20:21:54 +00:00
|
|
|
|
|
|
|
|
$this->mParserOutput = $poolArticleView->getParserOutput();
|
|
|
|
|
$wgOut->addParserOutput( $this->mParserOutput );
|
|
|
|
|
|
|
|
|
|
# Don't cache a dirty ParserOutput object
|
|
|
|
|
if ( $poolArticleView->getIsDirty() ) {
|
|
|
|
|
$wgOut->setSquidMaxage( 0 );
|
|
|
|
|
$wgOut->addHTML( "<!-- parser cache is expired, sending anyway due to pool overload-->\n" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$outputDone = true;
|
2009-08-31 19:19:12 +00:00
|
|
|
break;
|
|
|
|
|
# Should be unreachable, but just in case...
|
|
|
|
|
default:
|
|
|
|
|
break 2;
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-24 21:12:26 +00:00
|
|
|
# Get the ParserOutput actually *displayed* here.
|
|
|
|
|
# Note that $this->mParserOutput is the *current* version output.
|
|
|
|
|
$pOutput = ( $outputDone instanceof ParserOutput )
|
|
|
|
|
? $outputDone // object fetched by hook
|
|
|
|
|
: $this->mParserOutput;
|
|
|
|
|
|
|
|
|
|
# Adjust title for main page & pages with displaytitle
|
|
|
|
|
if ( $pOutput ) {
|
|
|
|
|
$this->adjustDisplayTitle( $pOutput );
|
2010-04-10 13:38:50 +00:00
|
|
|
}
|
|
|
|
|
|
2010-04-11 13:04:58 +00:00
|
|
|
# For the main page, overwrite the <title> element with the con-
|
|
|
|
|
# tents of 'pagetitle-view-mainpage' instead of the default (if
|
|
|
|
|
# that's not empty).
|
2010-06-28 07:17:16 +00:00
|
|
|
# This message always exists because it is in the i18n files
|
2011-09-12 21:26:08 +00:00
|
|
|
if ( $this->getTitle()->isMainPage() ) {
|
2011-02-17 17:06:06 +00:00
|
|
|
$msg = wfMessage( 'pagetitle-view-mainpage' )->inContentLanguage();
|
|
|
|
|
if ( !$msg->isDisabled() ) {
|
2011-06-29 22:09:51 +00:00
|
|
|
$wgOut->setHTMLTitle( $msg->title( $this->getTitle() )->text() );
|
2011-02-17 17:06:06 +00:00
|
|
|
}
|
2010-04-11 13:04:58 +00:00
|
|
|
}
|
|
|
|
|
|
2011-09-24 21:12:26 +00:00
|
|
|
# Check for any __NOINDEX__ tags on the page using $pOutput
|
|
|
|
|
$policy = $this->getRobotPolicy( 'view', $pOutput );
|
2009-08-31 19:19:12 +00:00
|
|
|
$wgOut->setIndexPolicy( $policy['index'] );
|
|
|
|
|
$wgOut->setFollowPolicy( $policy['follow'] );
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
|
|
|
|
|
$this->showViewFooter();
|
2012-01-02 17:16:10 +00:00
|
|
|
$this->mPage->doViewUpdates( $wgUser );
|
2011-09-24 21:12:26 +00:00
|
|
|
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-26 03:44:47 +00:00
|
|
|
/**
|
2011-09-24 21:12:26 +00:00
|
|
|
* Adjust title for pages with displaytitle, -{T|}- or language conversion
|
|
|
|
|
* @param $pOutput ParserOutput
|
|
|
|
|
*/
|
|
|
|
|
public function adjustDisplayTitle( ParserOutput $pOutput ) {
|
|
|
|
|
global $wgOut;
|
|
|
|
|
# Adjust the title if it was set by displaytitle, -{T|}- or language conversion
|
|
|
|
|
$titleText = $pOutput->getTitleText();
|
|
|
|
|
if ( strval( $titleText ) !== '' ) {
|
|
|
|
|
$wgOut->setPageTitle( $titleText );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
/**
|
|
|
|
|
* Show a diff page according to current request variables. For use within
|
|
|
|
|
* Article::view() only, other callers should use the DifferenceEngine class.
|
|
|
|
|
*/
|
|
|
|
|
public function showDiffPage() {
|
2010-07-24 19:11:34 +00:00
|
|
|
global $wgRequest, $wgUser;
|
2009-12-26 20:03:33 +00:00
|
|
|
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
$diff = $wgRequest->getVal( 'diff' );
|
|
|
|
|
$rcid = $wgRequest->getVal( 'rcid' );
|
|
|
|
|
$diffOnly = $wgRequest->getBool( 'diffonly', $wgUser->getOption( 'diffonly' ) );
|
|
|
|
|
$purge = $wgRequest->getVal( 'action' ) == 'purge';
|
2010-02-14 22:07:30 +00:00
|
|
|
$unhide = $wgRequest->getInt( 'unhide' ) == 1;
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
$oldid = $this->getOldID();
|
|
|
|
|
|
2011-11-10 13:06:52 +00:00
|
|
|
$de = new DifferenceEngine( $this->getContext(), $oldid, $diff, $rcid, $purge, $unhide );
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
// DifferenceEngine directly fetched the revision:
|
|
|
|
|
$this->mRevIdFetched = $de->mNewid;
|
|
|
|
|
$de->showDiffPage( $diffOnly );
|
|
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
if ( $diff == 0 || $diff == $this->mPage->getLatest() ) {
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
# Run view updates for current revision only
|
2012-01-02 17:16:10 +00:00
|
|
|
$this->mPage->doViewUpdates( $wgUser );
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2009-12-26 20:03:33 +00:00
|
|
|
* Show a page view for a page formatted as CSS or JavaScript. To be called by
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
* Article::view() only.
|
|
|
|
|
*
|
2009-12-26 20:03:33 +00:00
|
|
|
* This is hooked by SyntaxHighlight_GeSHi to do syntax highlighting of these
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
* page views.
|
|
|
|
|
*/
|
2010-08-07 22:17:00 +00:00
|
|
|
protected function showCssOrJsPage() {
|
2011-07-20 22:31:47 +00:00
|
|
|
global $wgOut;
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2011-11-21 16:13:21 +00:00
|
|
|
$dir = $this->getContext()->getLanguage()->getDir();
|
|
|
|
|
$lang = $this->getContext()->getLanguage()->getCode();
|
2011-07-07 16:15:27 +00:00
|
|
|
|
|
|
|
|
$wgOut->wrapWikiMsg( "<div id='mw-clearyourcache' lang='$lang' dir='$dir' class='mw-content-$dir'>\n$1\n</div>",
|
|
|
|
|
'clearyourcache' );
|
2010-05-30 14:28:54 +00:00
|
|
|
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
// Give hooks a chance to customise the output
|
2011-06-29 22:09:51 +00:00
|
|
|
if ( wfRunHooks( 'ShowRawCssJs', array( $this->mContent, $this->getTitle(), $wgOut ) ) ) {
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
// Wrap the whole lot in a <pre> and don't parse
|
|
|
|
|
$m = array();
|
2011-06-29 22:09:51 +00:00
|
|
|
preg_match( '!\.(css|js)$!u', $this->getTitle()->getText(), $m );
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
$wgOut->addHTML( "<pre class=\"mw-code mw-{$m[1]}\" dir=\"ltr\">\n" );
|
|
|
|
|
$wgOut->addHTML( htmlspecialchars( $this->mContent ) );
|
|
|
|
|
$wgOut->addHTML( "\n</pre>\n" );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-31 19:19:12 +00:00
|
|
|
/**
|
|
|
|
|
* Get the robot policy to be used for the current view
|
|
|
|
|
* @param $action String the action= GET parameter
|
2011-09-24 21:12:26 +00:00
|
|
|
* @param $pOutput ParserOutput
|
2009-08-31 19:19:12 +00:00
|
|
|
* @return Array the policy that should be set
|
|
|
|
|
* TODO: actions other than 'view'
|
|
|
|
|
*/
|
2011-09-24 21:12:26 +00:00
|
|
|
public function getRobotPolicy( $action, $pOutput ) {
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
global $wgOut, $wgArticleRobotPolicies, $wgNamespaceRobotPolicies;
|
|
|
|
|
global $wgDefaultRobotPolicy, $wgRequest;
|
|
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
$ns = $this->getTitle()->getNamespace();
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2010-02-14 22:07:30 +00:00
|
|
|
if ( $ns == NS_USER || $ns == NS_USER_TALK ) {
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
# Don't index user and user talk pages for blocked users (bug 11443)
|
2011-06-29 22:09:51 +00:00
|
|
|
if ( !$this->getTitle()->isSubpage() ) {
|
|
|
|
|
if ( Block::newFromTarget( null, $this->getTitle()->getText() ) instanceof Block ) {
|
2010-05-30 14:28:54 +00:00
|
|
|
return array(
|
|
|
|
|
'index' => 'noindex',
|
|
|
|
|
'follow' => 'nofollow'
|
|
|
|
|
);
|
2009-01-14 23:42:57 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-01-17 22:32:40 +00:00
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
if ( $this->mPage->getID() === 0 || $this->getOldID() ) {
|
2009-08-31 19:19:12 +00:00
|
|
|
# Non-articles (special pages etc), and old revisions
|
2010-05-30 14:28:54 +00:00
|
|
|
return array(
|
|
|
|
|
'index' => 'noindex',
|
|
|
|
|
'follow' => 'nofollow'
|
|
|
|
|
);
|
2010-02-14 22:07:30 +00:00
|
|
|
} elseif ( $wgOut->isPrintable() ) {
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
# Discourage indexing of printable versions, but encourage following
|
2010-05-30 14:28:54 +00:00
|
|
|
return array(
|
|
|
|
|
'index' => 'noindex',
|
|
|
|
|
'follow' => 'follow'
|
|
|
|
|
);
|
2010-02-14 22:07:30 +00:00
|
|
|
} elseif ( $wgRequest->getInt( 'curid' ) ) {
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
# For ?curid=x urls, disallow indexing
|
2010-05-30 14:28:54 +00:00
|
|
|
return array(
|
|
|
|
|
'index' => 'noindex',
|
|
|
|
|
'follow' => 'follow'
|
|
|
|
|
);
|
2009-08-31 19:19:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Otherwise, construct the policy based on the various config variables.
|
|
|
|
|
$policy = self::formatRobotPolicy( $wgDefaultRobotPolicy );
|
|
|
|
|
|
2010-02-14 22:07:30 +00:00
|
|
|
if ( isset( $wgNamespaceRobotPolicies[$ns] ) ) {
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
# Honour customised robot policies for this namespace
|
2010-05-30 14:28:54 +00:00
|
|
|
$policy = array_merge(
|
|
|
|
|
$policy,
|
|
|
|
|
self::formatRobotPolicy( $wgNamespaceRobotPolicies[$ns] )
|
|
|
|
|
);
|
2009-08-31 19:19:12 +00:00
|
|
|
}
|
2011-09-24 21:12:26 +00:00
|
|
|
if ( $this->getTitle()->canUseNoindex() && is_object( $pOutput ) && $pOutput->getIndexPolicy() ) {
|
2009-09-01 14:11:29 +00:00
|
|
|
# __INDEX__ and __NOINDEX__ magic words, if allowed. Incorporates
|
|
|
|
|
# a final sanity check that we have really got the parser output.
|
2010-05-30 14:28:54 +00:00
|
|
|
$policy = array_merge(
|
|
|
|
|
$policy,
|
2011-09-24 21:12:26 +00:00
|
|
|
array( 'index' => $pOutput->getIndexPolicy() )
|
2010-05-30 14:28:54 +00:00
|
|
|
);
|
2005-12-26 13:01:18 +00:00
|
|
|
}
|
2009-08-31 19:19:12 +00:00
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
if ( isset( $wgArticleRobotPolicies[$this->getTitle()->getPrefixedText()] ) ) {
|
2009-08-31 19:19:12 +00:00
|
|
|
# (bug 14900) site config can override user-defined __INDEX__ or __NOINDEX__
|
2010-05-30 14:28:54 +00:00
|
|
|
$policy = array_merge(
|
|
|
|
|
$policy,
|
2011-06-29 22:09:51 +00:00
|
|
|
self::formatRobotPolicy( $wgArticleRobotPolicies[$this->getTitle()->getPrefixedText()] )
|
2010-05-30 14:28:54 +00:00
|
|
|
);
|
2009-08-31 19:19:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $policy;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Converts a String robot policy into an associative array, to allow
|
|
|
|
|
* merging of several policies using array_merge().
|
|
|
|
|
* @param $policy Mixed, returns empty array on null/false/'', transparent
|
|
|
|
|
* to already-converted arrays, converts String.
|
2011-01-06 15:55:56 +00:00
|
|
|
* @return Array: 'index' => <indexpolicy>, 'follow' => <followpolicy>
|
2009-08-31 19:19:12 +00:00
|
|
|
*/
|
2010-02-14 22:07:30 +00:00
|
|
|
public static function formatRobotPolicy( $policy ) {
|
|
|
|
|
if ( is_array( $policy ) ) {
|
2009-08-31 19:19:12 +00:00
|
|
|
return $policy;
|
2010-02-14 22:07:30 +00:00
|
|
|
} elseif ( !$policy ) {
|
2009-08-31 19:19:12 +00:00
|
|
|
return array();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$policy = explode( ',', $policy );
|
|
|
|
|
$policy = array_map( 'trim', $policy );
|
|
|
|
|
|
|
|
|
|
$arr = array();
|
2010-02-14 22:07:30 +00:00
|
|
|
foreach ( $policy as $var ) {
|
|
|
|
|
if ( in_array( $var, array( 'index', 'noindex' ) ) ) {
|
2009-08-31 19:19:12 +00:00
|
|
|
$arr['index'] = $var;
|
2010-02-14 22:07:30 +00:00
|
|
|
} elseif ( in_array( $var, array( 'follow', 'nofollow' ) ) ) {
|
2009-08-31 19:19:12 +00:00
|
|
|
$arr['follow'] = $var;
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2009-08-31 19:19:12 +00:00
|
|
|
return $arr;
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
}
|
2004-07-08 14:53:54 +00:00
|
|
|
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
/**
|
2009-12-26 20:03:33 +00:00
|
|
|
* If this request is a redirect view, send "redirected from" subtitle to
|
|
|
|
|
* $wgOut. Returns true if the header was needed, false if this is not a
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
* redirect view. Handles both local and remote redirects.
|
2010-03-15 01:08:07 +00:00
|
|
|
*
|
|
|
|
|
* @return boolean
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
*/
|
|
|
|
|
public function showRedirectedFromHeader() {
|
2011-04-25 11:59:31 +00:00
|
|
|
global $wgOut, $wgRequest, $wgRedirectSources;
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
|
|
|
|
|
$rdfrom = $wgRequest->getVal( 'rdfrom' );
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2010-02-14 22:07:30 +00:00
|
|
|
if ( isset( $this->mRedirectedFrom ) ) {
|
2006-01-13 00:29:20 +00:00
|
|
|
// This is an internally redirected page view.
|
|
|
|
|
// We'll need a backlink to the source page for navigation.
|
2010-02-14 22:07:30 +00:00
|
|
|
if ( wfRunHooks( 'ArticleViewRedirect', array( &$this ) ) ) {
|
2011-11-08 18:01:22 +00:00
|
|
|
$redir = Linker::linkKnown(
|
2009-06-06 22:42:48 +00:00
|
|
|
$this->mRedirectedFrom,
|
|
|
|
|
null,
|
|
|
|
|
array(),
|
2011-11-08 18:01:22 +00:00
|
|
|
array( 'redirect' => 'no' )
|
2009-06-06 22:42:48 +00:00
|
|
|
);
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2011-11-08 18:01:22 +00:00
|
|
|
$wgOut->addSubtitle( wfMessage( 'redirectedfrom' )->rawParams( $redir ) );
|
2006-12-08 06:09:15 +00:00
|
|
|
|
|
|
|
|
// Set the fragment if one was specified in the redirect
|
2011-06-29 22:09:51 +00:00
|
|
|
if ( strval( $this->getTitle()->getFragment() ) != '' ) {
|
|
|
|
|
$fragment = Xml::escapeJsString( $this->getTitle()->getFragmentForURL() );
|
2006-12-08 06:09:15 +00:00
|
|
|
$wgOut->addInlineScript( "redirectToFragment(\"$fragment\");" );
|
|
|
|
|
}
|
2009-02-13 16:17:39 +00:00
|
|
|
|
|
|
|
|
// Add a <link rel="canonical"> tag
|
|
|
|
|
$wgOut->addLink( array( 'rel' => 'canonical',
|
2011-06-29 22:09:51 +00:00
|
|
|
'href' => $this->getTitle()->getLocalURL() )
|
2009-02-13 16:17:39 +00:00
|
|
|
);
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2011-11-30 12:43:10 +00:00
|
|
|
// Tell $wgOut the user arrived at this article through a redirect
|
|
|
|
|
$wgOut->setRedirectedFrom( $this->mRedirectedFrom );
|
|
|
|
|
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
return true;
|
2006-01-13 00:29:20 +00:00
|
|
|
}
|
2010-02-14 22:07:30 +00:00
|
|
|
} elseif ( $rdfrom ) {
|
2006-01-13 00:29:20 +00:00
|
|
|
// This is an externally redirected view, from some other wiki.
|
|
|
|
|
// If it was reported from a trusted site, supply a backlink.
|
2010-02-14 22:07:30 +00:00
|
|
|
if ( $wgRedirectSources && preg_match( $wgRedirectSources, $rdfrom ) ) {
|
2011-04-25 11:59:31 +00:00
|
|
|
$redir = Linker::makeExternalLink( $rdfrom, $rdfrom );
|
2011-11-08 18:01:22 +00:00
|
|
|
$wgOut->addSubtitle( wfMessage( 'redirectedfrom' )->rawParams( $redir ) );
|
2010-05-30 14:28:54 +00:00
|
|
|
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
return true;
|
2006-01-13 00:29:20 +00:00
|
|
|
}
|
|
|
|
|
}
|
2010-05-30 14:28:54 +00:00
|
|
|
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
2007-01-17 22:32:40 +00:00
|
|
|
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
/**
|
2009-12-26 20:03:33 +00:00
|
|
|
* Show a header specific to the namespace currently being viewed, like
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
* [[MediaWiki:Talkpagetext]]. For Article::view().
|
|
|
|
|
*/
|
|
|
|
|
public function showNamespaceHeader() {
|
|
|
|
|
global $wgOut;
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
if ( $this->getTitle()->isTalkPage() ) {
|
2011-01-14 10:51:05 +00:00
|
|
|
if ( !wfMessage( 'talkpageheader' )->isDisabled() ) {
|
2010-05-28 21:22:45 +00:00
|
|
|
$wgOut->wrapWikiMsg( "<div class=\"mw-talkpageheader\">\n$1\n</div>", array( 'talkpageheader' ) );
|
2009-03-27 20:22:52 +00:00
|
|
|
}
|
|
|
|
|
}
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
}
|
2009-03-27 20:22:52 +00:00
|
|
|
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
/**
|
|
|
|
|
* Show the footer section of an ordinary page view
|
|
|
|
|
*/
|
|
|
|
|
public function showViewFooter() {
|
2011-11-23 17:14:03 +00:00
|
|
|
global $wgOut;
|
2010-05-30 14:28:54 +00:00
|
|
|
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
# check if we're displaying a [[User talk:x.x.x.x]] anonymous talk page
|
2011-06-29 22:09:51 +00:00
|
|
|
if ( $this->getTitle()->getNamespace() == NS_USER_TALK && IP::isValid( $this->getTitle()->getText() ) ) {
|
2010-02-14 22:07:30 +00:00
|
|
|
$wgOut->addWikiMsg( 'anontalkpagetext' );
|
2004-06-04 10:40:44 +00:00
|
|
|
}
|
2009-06-18 02:50:16 +00:00
|
|
|
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
# If we have been passed an &rcid= parameter, we want to give the user a
|
|
|
|
|
# chance to mark this new article as patrolled.
|
|
|
|
|
$this->showPatrolFooter();
|
2004-07-08 14:53:54 +00:00
|
|
|
|
2011-01-14 21:54:29 +00:00
|
|
|
wfRunHooks( 'ArticleViewFooter', array( $this ) );
|
|
|
|
|
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
}
|
2008-12-22 23:38:58 +00:00
|
|
|
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
/**
|
2009-12-26 20:03:33 +00:00
|
|
|
* If patrol is possible, output a patrol UI box. This is called from the
|
|
|
|
|
* footer section of ordinary page views. If patrol is not possible or not
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
* desired, does nothing.
|
|
|
|
|
*/
|
|
|
|
|
public function showPatrolFooter() {
|
2009-07-15 09:48:25 +00:00
|
|
|
global $wgOut, $wgRequest, $wgUser;
|
2010-05-30 14:28:54 +00:00
|
|
|
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
$rcid = $wgRequest->getVal( 'rcid' );
|
2009-06-18 02:50:16 +00:00
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
if ( !$rcid || !$this->getTitle()->quickUserCan( 'patrol' ) ) {
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2004-07-08 14:53:54 +00:00
|
|
|
|
2011-11-16 04:37:17 +00:00
|
|
|
$token = $wgUser->getEditToken( $rcid );
|
2011-01-04 06:12:33 +00:00
|
|
|
$wgOut->preventClickjacking();
|
2009-07-15 09:48:25 +00:00
|
|
|
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
$wgOut->addHTML(
|
|
|
|
|
"<div class='patrollink'>" .
|
|
|
|
|
wfMsgHtml(
|
|
|
|
|
'markaspatrolledlink',
|
2011-04-25 11:59:31 +00:00
|
|
|
Linker::link(
|
2011-06-29 22:09:51 +00:00
|
|
|
$this->getTitle(),
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
wfMsgHtml( 'markaspatrolledtext' ),
|
|
|
|
|
array(),
|
|
|
|
|
array(
|
|
|
|
|
'action' => 'markpatrolled',
|
2010-08-01 15:50:30 +00:00
|
|
|
'rcid' => $rcid,
|
|
|
|
|
'token' => $token,
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
),
|
|
|
|
|
array( 'known', 'noclasses' )
|
|
|
|
|
)
|
|
|
|
|
) .
|
|
|
|
|
'</div>'
|
|
|
|
|
);
|
2009-12-26 20:03:33 +00:00
|
|
|
}
|
2008-08-08 00:01:53 +00:00
|
|
|
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
/**
|
2009-12-26 20:03:33 +00:00
|
|
|
* Show the error text for a missing article. For articles in the MediaWiki
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
* namespace, show the default message text. To be called from Article::view().
|
|
|
|
|
*/
|
|
|
|
|
public function showMissingArticle() {
|
2011-12-09 04:31:10 +00:00
|
|
|
global $wgOut, $wgRequest, $wgUser, $wgSend404Code;
|
2009-09-13 02:07:21 +00:00
|
|
|
|
2010-02-10 13:08:24 +00:00
|
|
|
# Show info in user (talk) namespace. Does the user exist? Is he blocked?
|
2011-06-29 22:09:51 +00:00
|
|
|
if ( $this->getTitle()->getNamespace() == NS_USER || $this->getTitle()->getNamespace() == NS_USER_TALK ) {
|
|
|
|
|
$parts = explode( '/', $this->getTitle()->getText() );
|
2009-10-10 09:29:44 +00:00
|
|
|
$rootPart = $parts[0];
|
2010-02-19 10:37:20 +00:00
|
|
|
$user = User::newFromName( $rootPart, false /* allow IP users*/ );
|
2009-10-10 09:29:44 +00:00
|
|
|
$ip = User::isIP( $rootPart );
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2011-11-20 10:55:58 +00:00
|
|
|
if ( !($user && $user->isLoggedIn()) && !$ip ) { # User does not exist
|
2010-05-28 21:22:45 +00:00
|
|
|
$wgOut->wrapWikiMsg( "<div class=\"mw-userpage-userdoesnotexist error\">\n\$1\n</div>",
|
2011-06-20 19:45:35 +00:00
|
|
|
array( 'userpage-userdoesnotexist-view', wfEscapeWikiText( $rootPart ) ) );
|
2011-06-17 16:03:52 +00:00
|
|
|
} elseif ( $user->isBlocked() ) { # Show log extract if the user is currently blocked
|
2010-02-10 13:08:24 +00:00
|
|
|
LogEventsList::showLogExtract(
|
|
|
|
|
$wgOut,
|
|
|
|
|
'block',
|
2010-02-19 10:37:20 +00:00
|
|
|
$user->getUserPage()->getPrefixedText(),
|
2010-02-10 13:08:24 +00:00
|
|
|
'',
|
|
|
|
|
array(
|
|
|
|
|
'lim' => 1,
|
|
|
|
|
'showIfEmpty' => false,
|
|
|
|
|
'msgKey' => array(
|
2010-02-19 10:37:20 +00:00
|
|
|
'blocked-notice-logextract',
|
|
|
|
|
$user->getName() # Support GENDER in notice
|
2010-02-10 13:08:24 +00:00
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
);
|
2009-09-13 02:07:21 +00:00
|
|
|
}
|
|
|
|
|
}
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2009-09-14 18:10:13 +00:00
|
|
|
wfRunHooks( 'ShowMissingArticle', array( $this ) );
|
2010-05-30 14:28:54 +00:00
|
|
|
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
# Show delete and move logs
|
2011-06-29 22:09:51 +00:00
|
|
|
LogEventsList::showLogExtract( $wgOut, array( 'delete', 'move' ), $this->getTitle()->getPrefixedText(), '',
|
2009-09-16 17:17:16 +00:00
|
|
|
array( 'lim' => 10,
|
|
|
|
|
'conds' => array( "log_action != 'revision'" ),
|
|
|
|
|
'showIfEmpty' => false,
|
2009-12-26 20:03:33 +00:00
|
|
|
'msgKey' => array( 'moveddeleted-notice' ) )
|
2009-09-15 12:41:15 +00:00
|
|
|
);
|
2005-07-01 20:36:04 +00:00
|
|
|
|
2012-02-13 22:32:44 +00:00
|
|
|
if ( !$this->mPage->hasViewableContent() && $wgSend404Code ) {
|
|
|
|
|
// If there's no backing content, send a 404 Not Found
|
|
|
|
|
// for better machine handling of broken links.
|
|
|
|
|
$wgRequest->response()->header( "HTTP/1.1 404 Not Found" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$hookResult = wfRunHooks( 'BeforeDisplayNoArticleText', array( $this ) );
|
|
|
|
|
|
|
|
|
|
if ( ! $hookResult ) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
# Show error message
|
|
|
|
|
$oldid = $this->getOldID();
|
2010-02-14 22:07:30 +00:00
|
|
|
if ( $oldid ) {
|
2009-12-26 20:03:33 +00:00
|
|
|
$text = wfMsgNoTrans( 'missing-article',
|
2011-06-29 22:09:51 +00:00
|
|
|
$this->getTitle()->getPrefixedText(),
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
wfMsgNoTrans( 'missingarticle-rev', $oldid ) );
|
2011-06-29 22:09:51 +00:00
|
|
|
} elseif ( $this->getTitle()->getNamespace() === NS_MEDIAWIKI ) {
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
// Use the default message text
|
2011-06-29 22:09:51 +00:00
|
|
|
$text = $this->getTitle()->getDefaultMessageText();
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
} else {
|
2011-06-29 22:09:51 +00:00
|
|
|
$createErrors = $this->getTitle()->getUserPermissionsErrors( 'create', $wgUser );
|
|
|
|
|
$editErrors = $this->getTitle()->getUserPermissionsErrors( 'edit', $wgUser );
|
2009-09-08 19:39:04 +00:00
|
|
|
$errors = array_merge( $createErrors, $editErrors );
|
2009-12-26 20:03:33 +00:00
|
|
|
|
2010-05-30 14:28:54 +00:00
|
|
|
if ( !count( $errors ) ) {
|
2010-03-07 18:29:22 +00:00
|
|
|
$text = wfMsgNoTrans( 'noarticletext' );
|
2010-05-30 14:28:54 +00:00
|
|
|
} else {
|
2010-03-07 18:29:22 +00:00
|
|
|
$text = wfMsgNoTrans( 'noarticletext-nopermission' );
|
2010-05-30 14:28:54 +00:00
|
|
|
}
|
2004-02-27 02:24:14 +00:00
|
|
|
}
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
$text = "<div class='noarticletext'>\n$text\n</div>";
|
2010-05-30 14:28:54 +00:00
|
|
|
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
$wgOut->addWikiText( $text );
|
|
|
|
|
}
|
2006-06-13 11:37:09 +00:00
|
|
|
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
/**
|
2009-12-26 20:03:33 +00:00
|
|
|
* If the revision requested for view is deleted, check permissions.
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
* Send either an error message or a warning header to $wgOut.
|
2010-05-30 14:28:54 +00:00
|
|
|
*
|
2010-03-15 01:08:07 +00:00
|
|
|
* @return boolean true if the view is allowed, false if not.
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
*/
|
|
|
|
|
public function showDeletedRevisionHeader() {
|
|
|
|
|
global $wgOut, $wgRequest;
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2010-02-14 22:07:30 +00:00
|
|
|
if ( !$this->mRevision->isDeleted( Revision::DELETED_TEXT ) ) {
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
// Not deleted
|
|
|
|
|
return true;
|
2004-08-09 05:38:11 +00:00
|
|
|
}
|
2010-05-30 14:28:54 +00:00
|
|
|
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
// If the user is not allowed to see it...
|
2010-02-14 22:07:30 +00:00
|
|
|
if ( !$this->mRevision->userCan( Revision::DELETED_TEXT ) ) {
|
2010-05-28 21:22:45 +00:00
|
|
|
$wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
'rev-deleted-text-permission' );
|
2010-05-30 14:28:54 +00:00
|
|
|
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
return false;
|
|
|
|
|
// If the user needs to confirm that they want to see it...
|
2011-06-17 16:03:52 +00:00
|
|
|
} elseif ( $wgRequest->getInt( 'unhide' ) != 1 ) {
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
# Give explanation and add a link to view the revision...
|
|
|
|
|
$oldid = intval( $this->getOldID() );
|
2011-06-29 22:09:51 +00:00
|
|
|
$link = $this->getTitle()->getFullUrl( "oldid={$oldid}&unhide=1" );
|
2009-07-30 18:01:41 +00:00
|
|
|
$msg = $this->mRevision->isDeleted( Revision::DELETED_RESTRICTED ) ?
|
|
|
|
|
'rev-suppressed-text-unhide' : 'rev-deleted-text-unhide';
|
2010-05-28 21:22:45 +00:00
|
|
|
$wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
|
2010-02-14 22:07:30 +00:00
|
|
|
array( $msg, $link ) );
|
2010-05-30 14:28:54 +00:00
|
|
|
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
return false;
|
|
|
|
|
// We are allowed to see...
|
|
|
|
|
} else {
|
2009-07-30 18:01:41 +00:00
|
|
|
$msg = $this->mRevision->isDeleted( Revision::DELETED_RESTRICTED ) ?
|
|
|
|
|
'rev-suppressed-text-view' : 'rev-deleted-text-view';
|
2010-05-28 21:22:45 +00:00
|
|
|
$wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n", $msg );
|
2010-05-30 14:28:54 +00:00
|
|
|
|
Implemented the PoolCounter feature and did some general refactoring in the areas that it touched.
* Renamed Article::outputFromWikitext() to Article::getOutputFromWikitext()
* Factored out cascade protection updates
* Removed recently-added Article::tryParserCache(): misnamed, can be done in one line of code in the caller. Deprecated OutputPage::tryParserCache().
* Made some functions public instead of protected when they could be useful from hooks.
* In ParserCache, removed PHP 4-style ampersands
In Article::view():
* Factored out robot policy logic, "redirected from" header, patrol footer, diff page, revdelete header, CSS/JS formatting, footer, namespace header, missing article error
* Removed some variables, renamed some others, fixed incorrect use of empty()
* Used the refactored footer section to do a couple of early returns and unindent a massive if(!$outputDone) block
* Removed fantasy interpretation of $this->getContent()===false in comment
* Don't try the parser cache when ArticleViewHeader specified $outputDone=true
* Move timing hack to getOutputFromWikitext()
* Stop using $wgOut->parserOptions() with save/restore nonsense every time you want to change something in it. This is meant to be OOP.
* Don't overwrite the article text with an error message and then pretend to write it to the cache, that's confusing
2009-07-08 08:12:35 +00:00
|
|
|
return true;
|
2008-11-28 14:29:25 +00:00
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2009-06-18 02:50:16 +00:00
|
|
|
|
2011-11-11 15:58:17 +00:00
|
|
|
/**
|
|
|
|
|
* Generate the navigation links when browsing through an article revisions
|
|
|
|
|
* It shows the information as:
|
|
|
|
|
* Revision as of \<date\>; view current revision
|
|
|
|
|
* \<- Previous version | Next Version -\>
|
|
|
|
|
*
|
|
|
|
|
* @param $oldid String: revision ID of this article revision
|
|
|
|
|
*/
|
|
|
|
|
public function setOldSubtitle( $oldid = 0 ) {
|
|
|
|
|
global $wgLang, $wgOut, $wgUser, $wgRequest;
|
|
|
|
|
|
|
|
|
|
if ( !wfRunHooks( 'DisplayOldSubtitle', array( &$this, &$oldid ) ) ) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$unhide = $wgRequest->getInt( 'unhide' ) == 1;
|
|
|
|
|
|
|
|
|
|
# Cascade unhide param in links for easy deletion browsing
|
|
|
|
|
$extraParams = array();
|
|
|
|
|
if ( $wgRequest->getVal( 'unhide' ) ) {
|
|
|
|
|
$extraParams['unhide'] = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$revision = Revision::newFromId( $oldid );
|
|
|
|
|
$timestamp = $revision->getTimestamp();
|
|
|
|
|
|
|
|
|
|
$current = ( $oldid == $this->mPage->getLatest() );
|
|
|
|
|
$td = $wgLang->timeanddate( $timestamp, true );
|
|
|
|
|
$tddate = $wgLang->date( $timestamp, true );
|
|
|
|
|
$tdtime = $wgLang->time( $timestamp, true );
|
|
|
|
|
|
|
|
|
|
# Show user links if allowed to see them. If hidden, then show them only if requested...
|
|
|
|
|
$userlinks = Linker::revUserTools( $revision, !$unhide );
|
|
|
|
|
|
|
|
|
|
$infomsg = $current && !wfMessage( 'revision-info-current' )->isDisabled()
|
|
|
|
|
? 'revision-info-current'
|
|
|
|
|
: 'revision-info';
|
|
|
|
|
|
|
|
|
|
$wgOut->addSubtitle( "<div id=\"mw-{$infomsg}\">" . wfMessage( $infomsg,
|
|
|
|
|
$td )->rawParams( $userlinks )->params( $revision->getID(), $tddate,
|
|
|
|
|
$tdtime, $revision->getUser() )->parse() . "</div>" );
|
|
|
|
|
|
|
|
|
|
$lnk = $current
|
|
|
|
|
? wfMsgHtml( 'currentrevisionlink' )
|
|
|
|
|
: Linker::link(
|
|
|
|
|
$this->getTitle(),
|
|
|
|
|
wfMsgHtml( 'currentrevisionlink' ),
|
|
|
|
|
array(),
|
|
|
|
|
$extraParams,
|
|
|
|
|
array( 'known', 'noclasses' )
|
|
|
|
|
);
|
|
|
|
|
$curdiff = $current
|
|
|
|
|
? wfMsgHtml( 'diff' )
|
|
|
|
|
: Linker::link(
|
|
|
|
|
$this->getTitle(),
|
|
|
|
|
wfMsgHtml( 'diff' ),
|
|
|
|
|
array(),
|
|
|
|
|
array(
|
|
|
|
|
'diff' => 'cur',
|
|
|
|
|
'oldid' => $oldid
|
|
|
|
|
) + $extraParams,
|
|
|
|
|
array( 'known', 'noclasses' )
|
|
|
|
|
);
|
|
|
|
|
$prev = $this->getTitle()->getPreviousRevisionID( $oldid ) ;
|
|
|
|
|
$prevlink = $prev
|
|
|
|
|
? Linker::link(
|
|
|
|
|
$this->getTitle(),
|
|
|
|
|
wfMsgHtml( 'previousrevision' ),
|
|
|
|
|
array(),
|
|
|
|
|
array(
|
|
|
|
|
'direction' => 'prev',
|
|
|
|
|
'oldid' => $oldid
|
|
|
|
|
) + $extraParams,
|
|
|
|
|
array( 'known', 'noclasses' )
|
|
|
|
|
)
|
|
|
|
|
: wfMsgHtml( 'previousrevision' );
|
|
|
|
|
$prevdiff = $prev
|
|
|
|
|
? Linker::link(
|
|
|
|
|
$this->getTitle(),
|
|
|
|
|
wfMsgHtml( 'diff' ),
|
|
|
|
|
array(),
|
|
|
|
|
array(
|
|
|
|
|
'diff' => 'prev',
|
|
|
|
|
'oldid' => $oldid
|
|
|
|
|
) + $extraParams,
|
|
|
|
|
array( 'known', 'noclasses' )
|
|
|
|
|
)
|
|
|
|
|
: wfMsgHtml( 'diff' );
|
|
|
|
|
$nextlink = $current
|
|
|
|
|
? wfMsgHtml( 'nextrevision' )
|
|
|
|
|
: Linker::link(
|
|
|
|
|
$this->getTitle(),
|
|
|
|
|
wfMsgHtml( 'nextrevision' ),
|
|
|
|
|
array(),
|
|
|
|
|
array(
|
|
|
|
|
'direction' => 'next',
|
|
|
|
|
'oldid' => $oldid
|
|
|
|
|
) + $extraParams,
|
|
|
|
|
array( 'known', 'noclasses' )
|
|
|
|
|
);
|
|
|
|
|
$nextdiff = $current
|
|
|
|
|
? wfMsgHtml( 'diff' )
|
|
|
|
|
: Linker::link(
|
|
|
|
|
$this->getTitle(),
|
|
|
|
|
wfMsgHtml( 'diff' ),
|
|
|
|
|
array(),
|
|
|
|
|
array(
|
|
|
|
|
'diff' => 'next',
|
|
|
|
|
'oldid' => $oldid
|
|
|
|
|
) + $extraParams,
|
|
|
|
|
array( 'known', 'noclasses' )
|
|
|
|
|
);
|
|
|
|
|
|
2011-12-28 18:41:36 +00:00
|
|
|
$cdel = Linker::getRevDeleteLink( $wgUser, $revision, $this->getTitle() );
|
|
|
|
|
if ( $cdel !== '' ) {
|
2011-11-11 15:58:17 +00:00
|
|
|
$cdel .= ' ';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$wgOut->addSubtitle( "<div id=\"mw-revision-nav\">" . $cdel .
|
|
|
|
|
wfMsgExt( 'revision-nav', array( 'escapenoentities', 'parsemag', 'replaceafter' ),
|
|
|
|
|
$prevdiff, $prevlink, $lnk, $curdiff, $nextlink, $nextdiff ) . "</div>" );
|
|
|
|
|
}
|
|
|
|
|
|
2008-08-02 02:39:09 +00:00
|
|
|
/**
|
|
|
|
|
* View redirect
|
2010-05-30 14:28:54 +00:00
|
|
|
*
|
2011-01-06 15:55:56 +00:00
|
|
|
* @param $target Title|Array of destination(s) to redirect
|
2008-11-30 10:10:15 +00:00
|
|
|
* @param $appendSubtitle Boolean [optional]
|
|
|
|
|
* @param $forceKnown Boolean: should the image be shown as a bluelink regardless of existence?
|
2010-03-15 01:08:07 +00:00
|
|
|
* @return string containing HMTL with redirect link
|
2008-08-02 02:39:09 +00:00
|
|
|
*/
|
|
|
|
|
public function viewRedirect( $target, $appendSubtitle = true, $forceKnown = false ) {
|
2011-09-20 15:55:08 +00:00
|
|
|
global $wgOut, $wgStylePath;
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2010-02-14 22:07:30 +00:00
|
|
|
if ( !is_array( $target ) ) {
|
2009-01-21 20:42:32 +00:00
|
|
|
$target = array( $target );
|
|
|
|
|
}
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2011-09-20 15:55:08 +00:00
|
|
|
$lang = $this->getTitle()->getPageLanguage();
|
|
|
|
|
$imageDir = $lang->getDir();
|
2009-06-18 02:50:16 +00:00
|
|
|
|
2010-02-14 22:07:30 +00:00
|
|
|
if ( $appendSubtitle ) {
|
2008-07-02 10:33:42 +00:00
|
|
|
$wgOut->appendSubtitle( wfMsgHtml( 'redirectpagesub' ) );
|
2008-05-11 19:49:08 +00:00
|
|
|
}
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2009-01-21 20:42:32 +00:00
|
|
|
// the loop prepends the arrow image before the link, so the first case needs to be outside
|
2011-10-29 01:53:28 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var $title Title
|
|
|
|
|
*/
|
2009-01-21 20:42:32 +00:00
|
|
|
$title = array_shift( $target );
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2010-02-14 22:07:30 +00:00
|
|
|
if ( $forceKnown ) {
|
2011-04-25 11:59:31 +00:00
|
|
|
$link = Linker::linkKnown( $title, htmlspecialchars( $title->getFullText() ) );
|
2008-11-28 14:29:25 +00:00
|
|
|
} else {
|
2011-04-25 11:59:31 +00:00
|
|
|
$link = Linker::link( $title, htmlspecialchars( $title->getFullText() ) );
|
2009-01-21 20:42:32 +00:00
|
|
|
}
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2010-06-28 07:17:16 +00:00
|
|
|
$nextRedirect = $wgStylePath . '/common/images/nextredirect' . $imageDir . '.png';
|
2011-09-20 15:55:08 +00:00
|
|
|
$alt = $lang->isRTL() ? '←' : '→';
|
2010-05-30 14:28:54 +00:00
|
|
|
// Automatically append redirect=no to each link, since most of them are redirect pages themselves.
|
2010-02-14 22:07:30 +00:00
|
|
|
foreach ( $target as $rt ) {
|
2010-06-28 07:17:16 +00:00
|
|
|
$link .= Html::element( 'img', array( 'src' => $nextRedirect, 'alt' => $alt ) );
|
2010-02-14 22:07:30 +00:00
|
|
|
if ( $forceKnown ) {
|
2011-04-25 11:59:31 +00:00
|
|
|
$link .= Linker::linkKnown( $rt, htmlspecialchars( $rt->getFullText(), array(), array( 'redirect' => 'no' ) ) );
|
2009-01-21 20:42:32 +00:00
|
|
|
} else {
|
2011-04-25 11:59:31 +00:00
|
|
|
$link .= Linker::link( $rt, htmlspecialchars( $rt->getFullText() ), array(), array( 'redirect' => 'no' ) );
|
2009-01-21 20:42:32 +00:00
|
|
|
}
|
2008-11-28 14:29:25 +00:00
|
|
|
}
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2010-12-13 19:47:34 +00:00
|
|
|
$imageUrl = $wgStylePath . '/common/images/redirect' . $imageDir . '.png';
|
2010-11-19 21:23:50 +00:00
|
|
|
return '<div class="redirectMsg">' .
|
|
|
|
|
Html::element( 'img', array( 'src' => $imageUrl, 'alt' => '#REDIRECT' ) ) .
|
|
|
|
|
'<span class="redirectText">' . $link . '</span></div>';
|
2008-05-11 19:49:08 +00:00
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2010-03-15 01:08:07 +00:00
|
|
|
/**
|
|
|
|
|
* Handle action=render
|
|
|
|
|
*/
|
2008-11-28 14:29:25 +00:00
|
|
|
public function render() {
|
2005-07-03 04:00:33 +00:00
|
|
|
global $wgOut;
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2010-02-14 22:07:30 +00:00
|
|
|
$wgOut->setArticleBodyOnly( true );
|
2005-07-03 04:00:33 +00:00
|
|
|
$this->view();
|
|
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
/**
|
|
|
|
|
* action=protect handler
|
|
|
|
|
*/
|
|
|
|
|
public function protect() {
|
|
|
|
|
$form = new ProtectionForm( $this );
|
|
|
|
|
$form->execute();
|
|
|
|
|
}
|
2007-01-17 22:32:40 +00:00
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
/**
|
|
|
|
|
* action=unprotect handler (alias)
|
|
|
|
|
*/
|
|
|
|
|
public function unprotect() {
|
|
|
|
|
$this->protect();
|
2004-04-21 16:17:49 +00:00
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2011-05-21 19:35:16 +00:00
|
|
|
/**
|
2004-09-02 23:28:24 +00:00
|
|
|
* UI entry point for page deletion
|
|
|
|
|
*/
|
2008-11-28 14:29:25 +00:00
|
|
|
public function delete() {
|
2011-11-03 08:55:04 +00:00
|
|
|
global $wgOut, $wgRequest, $wgLang;
|
2011-04-13 23:36:27 +00:00
|
|
|
|
2011-11-02 15:30:55 +00:00
|
|
|
# This code desperately needs to be totally rewritten
|
|
|
|
|
|
2011-11-03 08:55:04 +00:00
|
|
|
$title = $this->getTitle();
|
|
|
|
|
$user = $this->getContext()->getUser();
|
|
|
|
|
|
2011-11-02 15:30:55 +00:00
|
|
|
# Check permissions
|
2011-11-03 08:55:04 +00:00
|
|
|
$permission_errors = $title->getUserPermissionsErrors( 'delete', $user );
|
2011-11-02 15:30:55 +00:00
|
|
|
if ( count( $permission_errors ) ) {
|
|
|
|
|
throw new PermissionsError( 'delete', $permission_errors );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Read-only check...
|
|
|
|
|
if ( wfReadOnly() ) {
|
|
|
|
|
throw new ReadOnlyError;
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-13 23:36:27 +00:00
|
|
|
# Better double-check that it hasn't been deleted yet!
|
|
|
|
|
$dbw = wfGetDB( DB_MASTER );
|
2011-11-03 08:55:04 +00:00
|
|
|
$conds = $title->pageCond();
|
2011-04-13 23:36:27 +00:00
|
|
|
$latest = $dbw->selectField( 'page', 'page_latest', $conds, __METHOD__ );
|
|
|
|
|
if ( $latest === false ) {
|
2011-11-03 08:55:04 +00:00
|
|
|
$wgOut->setPageTitle( wfMessage( 'cannotdelete-title', $title->getPrefixedText() ) );
|
|
|
|
|
$wgOut->wrapWikiMsg( "<div class=\"error mw-error-cannotdelete\">\n$1\n</div>",
|
|
|
|
|
array( 'cannotdelete', wfEscapeWikiText( $title->getPrefixedText() ) )
|
|
|
|
|
);
|
2011-12-13 21:34:16 +00:00
|
|
|
$wgOut->addHTML( Xml::element( 'h2', null, LogPage::logName( 'delete' ) ) );
|
2011-04-13 23:36:27 +00:00
|
|
|
LogEventsList::showLogExtract(
|
|
|
|
|
$wgOut,
|
|
|
|
|
'delete',
|
2011-11-03 08:55:04 +00:00
|
|
|
$title->getPrefixedText()
|
2011-04-13 23:36:27 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-03 08:55:04 +00:00
|
|
|
$deleteReasonList = $wgRequest->getText( 'wpDeleteReasonList', 'other' );
|
|
|
|
|
$deleteReason = $wgRequest->getText( 'wpReason' );
|
|
|
|
|
|
|
|
|
|
if ( $deleteReasonList == 'other' ) {
|
|
|
|
|
$reason = $deleteReason;
|
|
|
|
|
} elseif ( $deleteReason != '' ) {
|
|
|
|
|
// Entry from drop down menu + additional comment
|
|
|
|
|
$reason = $deleteReasonList . wfMsgForContent( 'colon-separator' ) . $deleteReason;
|
|
|
|
|
} else {
|
|
|
|
|
$reason = $deleteReasonList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $wgRequest->wasPosted() && $user->matchEditToken( $wgRequest->getVal( 'wpEditToken' ),
|
|
|
|
|
array( 'delete', $this->getTitle()->getPrefixedText() ) ) )
|
|
|
|
|
{
|
|
|
|
|
# Flag to hide all contents of the archived revisions
|
|
|
|
|
$suppress = $wgRequest->getVal( 'wpSuppress' ) && $user->isAllowed( 'suppressrevision' );
|
|
|
|
|
|
2011-04-13 23:36:27 +00:00
|
|
|
$this->doDelete( $reason, $suppress );
|
|
|
|
|
|
2011-11-03 08:55:04 +00:00
|
|
|
if ( $wgRequest->getCheck( 'wpWatch' ) && $user->isLoggedIn() ) {
|
2011-04-13 23:36:27 +00:00
|
|
|
$this->doWatch();
|
2011-11-03 08:55:04 +00:00
|
|
|
} elseif ( $title->userIsWatching() ) {
|
2011-04-13 23:36:27 +00:00
|
|
|
$this->doUnwatch();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Generate deletion reason
|
|
|
|
|
$hasHistory = false;
|
|
|
|
|
if ( !$reason ) {
|
|
|
|
|
$reason = $this->generateReason( $hasHistory );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If the page has a history, insert a warning
|
2011-11-03 08:55:04 +00:00
|
|
|
if ( $hasHistory ) {
|
2011-12-27 15:29:44 +00:00
|
|
|
$revisions = $this->mTitle->estimateRevisionCount();
|
2011-05-17 22:03:20 +00:00
|
|
|
// @todo FIXME: i18n issue/patchwork message
|
2011-04-13 23:36:27 +00:00
|
|
|
$wgOut->addHTML( '<strong class="mw-delete-warning-revisions">' .
|
|
|
|
|
wfMsgExt( 'historywarning', array( 'parseinline' ), $wgLang->formatNum( $revisions ) ) .
|
2011-11-03 08:55:04 +00:00
|
|
|
wfMsgHtml( 'word-separator' ) . Linker::link( $title,
|
2011-04-13 23:36:27 +00:00
|
|
|
wfMsgHtml( 'history' ),
|
|
|
|
|
array( 'rel' => 'archives' ),
|
|
|
|
|
array( 'action' => 'history' ) ) .
|
|
|
|
|
'</strong>'
|
|
|
|
|
);
|
|
|
|
|
|
2011-12-27 21:16:20 +00:00
|
|
|
if ( $this->mTitle->isBigDeletion() ) {
|
2011-04-13 23:36:27 +00:00
|
|
|
global $wgDeleteRevisionsLimit;
|
|
|
|
|
$wgOut->wrapWikiMsg( "<div class='error'>\n$1\n</div>\n",
|
|
|
|
|
array( 'delete-warning-toobig', $wgLang->formatNum( $wgDeleteRevisionsLimit ) ) );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $this->confirmDelete( $reason );
|
2003-09-01 09:59:53 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2011-04-13 23:36:27 +00:00
|
|
|
/**
|
|
|
|
|
* Output deletion confirmation dialog
|
2011-05-17 22:03:20 +00:00
|
|
|
* @todo FIXME: Move to another file?
|
2011-04-13 23:36:27 +00:00
|
|
|
* @param $reason String: prefilled reason
|
|
|
|
|
*/
|
|
|
|
|
public function confirmDelete( $reason ) {
|
|
|
|
|
global $wgOut;
|
|
|
|
|
|
|
|
|
|
wfDebug( "Article::confirmDelete\n" );
|
|
|
|
|
|
2011-11-03 08:55:04 +00:00
|
|
|
$wgOut->setPageTitle( wfMessage( 'delete-confirm', $this->getTitle()->getPrefixedText() ) );
|
2011-11-08 18:01:22 +00:00
|
|
|
$wgOut->addBacklinkSubtitle( $this->getTitle() );
|
2011-04-13 23:36:27 +00:00
|
|
|
$wgOut->setRobotPolicy( 'noindex,nofollow' );
|
|
|
|
|
$wgOut->addWikiMsg( 'confirmdeletetext' );
|
|
|
|
|
|
|
|
|
|
wfRunHooks( 'ArticleConfirmDelete', array( $this, $wgOut, &$reason ) );
|
|
|
|
|
|
2011-11-03 08:55:04 +00:00
|
|
|
$user = $this->getContext()->getUser();
|
|
|
|
|
|
|
|
|
|
if ( $user->isAllowed( 'suppressrevision' ) ) {
|
2011-04-13 23:36:27 +00:00
|
|
|
$suppress = "<tr id=\"wpDeleteSuppressRow\">
|
|
|
|
|
<td></td>
|
|
|
|
|
<td class='mw-input'><strong>" .
|
|
|
|
|
Xml::checkLabel( wfMsg( 'revdelete-suppress' ),
|
|
|
|
|
'wpSuppress', 'wpSuppress', false, array( 'tabindex' => '4' ) ) .
|
|
|
|
|
"</strong></td>
|
|
|
|
|
</tr>";
|
|
|
|
|
} else {
|
|
|
|
|
$suppress = '';
|
|
|
|
|
}
|
2011-11-03 08:55:04 +00:00
|
|
|
$checkWatch = $user->getBoolOption( 'watchdeletion' ) || $this->getTitle()->userIsWatching();
|
2011-04-13 23:36:27 +00:00
|
|
|
|
|
|
|
|
$form = Xml::openElement( 'form', array( 'method' => 'post',
|
2011-06-29 22:09:51 +00:00
|
|
|
'action' => $this->getTitle()->getLocalURL( 'action=delete' ), 'id' => 'deleteconfirm' ) ) .
|
2011-04-13 23:36:27 +00:00
|
|
|
Xml::openElement( 'fieldset', array( 'id' => 'mw-delete-table' ) ) .
|
|
|
|
|
Xml::tags( 'legend', null, wfMsgExt( 'delete-legend', array( 'parsemag', 'escapenoentities' ) ) ) .
|
|
|
|
|
Xml::openElement( 'table', array( 'id' => 'mw-deleteconfirm-table' ) ) .
|
|
|
|
|
"<tr id=\"wpDeleteReasonListRow\">
|
|
|
|
|
<td class='mw-label'>" .
|
|
|
|
|
Xml::label( wfMsg( 'deletecomment' ), 'wpDeleteReasonList' ) .
|
|
|
|
|
"</td>
|
|
|
|
|
<td class='mw-input'>" .
|
|
|
|
|
Xml::listDropDown( 'wpDeleteReasonList',
|
|
|
|
|
wfMsgForContent( 'deletereason-dropdown' ),
|
|
|
|
|
wfMsgForContent( 'deletereasonotherlist' ), '', 'wpReasonDropDown', 1 ) .
|
|
|
|
|
"</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr id=\"wpDeleteReasonRow\">
|
|
|
|
|
<td class='mw-label'>" .
|
|
|
|
|
Xml::label( wfMsg( 'deleteotherreason' ), 'wpReason' ) .
|
|
|
|
|
"</td>
|
|
|
|
|
<td class='mw-input'>" .
|
|
|
|
|
Html::input( 'wpReason', $reason, 'text', array(
|
|
|
|
|
'size' => '60',
|
|
|
|
|
'maxlength' => '255',
|
|
|
|
|
'tabindex' => '2',
|
|
|
|
|
'id' => 'wpReason',
|
|
|
|
|
'autofocus'
|
|
|
|
|
) ) .
|
|
|
|
|
"</td>
|
|
|
|
|
</tr>";
|
|
|
|
|
|
|
|
|
|
# Disallow watching if user is not logged in
|
2011-11-03 08:55:04 +00:00
|
|
|
if ( $user->isLoggedIn() ) {
|
2011-04-13 23:36:27 +00:00
|
|
|
$form .= "
|
|
|
|
|
<tr>
|
|
|
|
|
<td></td>
|
|
|
|
|
<td class='mw-input'>" .
|
|
|
|
|
Xml::checkLabel( wfMsg( 'watchthis' ),
|
|
|
|
|
'wpWatch', 'wpWatch', $checkWatch, array( 'tabindex' => '3' ) ) .
|
|
|
|
|
"</td>
|
|
|
|
|
</tr>";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$form .= "
|
|
|
|
|
$suppress
|
|
|
|
|
<tr>
|
|
|
|
|
<td></td>
|
|
|
|
|
<td class='mw-submit'>" .
|
|
|
|
|
Xml::submitButton( wfMsg( 'deletepage' ),
|
|
|
|
|
array( 'name' => 'wpConfirmB', 'id' => 'wpConfirmB', 'tabindex' => '5' ) ) .
|
|
|
|
|
"</td>
|
|
|
|
|
</tr>" .
|
|
|
|
|
Xml::closeElement( 'table' ) .
|
|
|
|
|
Xml::closeElement( 'fieldset' ) .
|
2011-11-16 04:37:17 +00:00
|
|
|
Html::hidden( 'wpEditToken', $user->getEditToken( array( 'delete', $this->getTitle()->getPrefixedText() ) ) ) .
|
2011-04-13 23:36:27 +00:00
|
|
|
Xml::closeElement( 'form' );
|
|
|
|
|
|
2011-11-03 08:55:04 +00:00
|
|
|
if ( $user->isAllowed( 'editinterface' ) ) {
|
2011-04-13 23:36:27 +00:00
|
|
|
$title = Title::makeTitle( NS_MEDIAWIKI, 'Deletereason-dropdown' );
|
2011-04-25 11:59:31 +00:00
|
|
|
$link = Linker::link(
|
2011-04-13 23:36:27 +00:00
|
|
|
$title,
|
|
|
|
|
wfMsgHtml( 'delete-edit-reasonlist' ),
|
|
|
|
|
array(),
|
|
|
|
|
array( 'action' => 'edit' )
|
|
|
|
|
);
|
|
|
|
|
$form .= '<p class="mw-delete-editreasons">' . $link . '</p>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$wgOut->addHTML( $form );
|
2011-12-13 21:34:16 +00:00
|
|
|
$wgOut->addHTML( Xml::element( 'h2', null, LogPage::logName( 'delete' ) ) );
|
2011-04-13 23:36:27 +00:00
|
|
|
LogEventsList::showLogExtract( $wgOut, 'delete',
|
2011-06-29 22:09:51 +00:00
|
|
|
$this->getTitle()->getPrefixedText()
|
2011-04-13 23:36:27 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
* Perform a deletion and output success or failure messages
|
2011-10-29 01:53:28 +00:00
|
|
|
* @param $reason
|
|
|
|
|
* @param $suppress bool
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2008-11-28 14:29:25 +00:00
|
|
|
public function doDelete( $reason, $suppress = false ) {
|
2011-04-13 23:36:27 +00:00
|
|
|
global $wgOut;
|
|
|
|
|
|
|
|
|
|
$error = '';
|
2012-01-01 14:16:09 +00:00
|
|
|
if ( $this->mPage->doDeleteArticle( $reason, $suppress, 0, true, $error ) ) {
|
2011-06-29 22:09:51 +00:00
|
|
|
$deleted = $this->getTitle()->getPrefixedText();
|
2011-04-13 23:36:27 +00:00
|
|
|
|
2011-10-27 20:23:16 +00:00
|
|
|
$wgOut->setPageTitle( wfMessage( 'actioncomplete' ) );
|
2011-04-13 23:36:27 +00:00
|
|
|
$wgOut->setRobotPolicy( 'noindex,nofollow' );
|
|
|
|
|
|
|
|
|
|
$loglink = '[[Special:Log/delete|' . wfMsgNoTrans( 'deletionlog' ) . ']]';
|
|
|
|
|
|
2011-06-20 19:45:35 +00:00
|
|
|
$wgOut->addWikiMsg( 'deletedtext', wfEscapeWikiText( $deleted ), $loglink );
|
2011-04-13 23:36:27 +00:00
|
|
|
$wgOut->returnToMain( false );
|
|
|
|
|
} else {
|
2011-11-03 08:55:04 +00:00
|
|
|
$wgOut->setPageTitle( wfMessage( 'cannotdelete-title', $this->getTitle()->getPrefixedText() ) );
|
2011-04-13 23:36:27 +00:00
|
|
|
if ( $error == '' ) {
|
2011-11-03 08:55:04 +00:00
|
|
|
$wgOut->wrapWikiMsg( "<div class=\"error mw-error-cannotdelete\">\n$1\n</div>",
|
|
|
|
|
array( 'cannotdelete', wfEscapeWikiText( $this->getTitle()->getPrefixedText() ) )
|
2011-04-13 23:36:27 +00:00
|
|
|
);
|
2011-12-13 21:34:16 +00:00
|
|
|
$wgOut->addHTML( Xml::element( 'h2', null, LogPage::logName( 'delete' ) ) );
|
2011-04-13 23:36:27 +00:00
|
|
|
|
|
|
|
|
LogEventsList::showLogExtract(
|
|
|
|
|
$wgOut,
|
|
|
|
|
'delete',
|
2011-06-29 22:09:51 +00:00
|
|
|
$this->getTitle()->getPrefixedText()
|
2011-04-13 23:36:27 +00:00
|
|
|
);
|
|
|
|
|
} else {
|
2011-11-03 08:55:04 +00:00
|
|
|
$wgOut->addHTML( $error );
|
2011-04-13 23:36:27 +00:00
|
|
|
}
|
|
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
2003-05-16 13:39:22 +00:00
|
|
|
/* Caching functions */
|
2003-12-11 20:16:34 +00:00
|
|
|
|
2004-09-03 00:20:26 +00:00
|
|
|
/**
|
|
|
|
|
* checkLastModified returns true if it has taken care of all
|
|
|
|
|
* output to the client that is necessary for this request.
|
|
|
|
|
* (that is, it has sent a cached version of the page)
|
2010-03-15 12:04:24 +00:00
|
|
|
*
|
|
|
|
|
* @return boolean true if cached version send, false otherwise
|
2004-09-03 00:20:26 +00:00
|
|
|
*/
|
2008-11-28 14:29:25 +00:00
|
|
|
protected function tryFileCache() {
|
2003-11-24 08:41:40 +00:00
|
|
|
static $called = false;
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2010-02-14 22:07:30 +00:00
|
|
|
if ( $called ) {
|
2006-07-03 16:45:51 +00:00
|
|
|
wfDebug( "Article::tryFileCache(): called twice!?\n" );
|
2008-09-25 23:02:35 +00:00
|
|
|
return false;
|
2003-11-24 08:41:40 +00:00
|
|
|
}
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2003-11-24 08:41:40 +00:00
|
|
|
$called = true;
|
2010-02-14 22:07:30 +00:00
|
|
|
if ( $this->isFileCacheable() ) {
|
2011-09-29 08:18:20 +00:00
|
|
|
$cache = HTMLFileCache::newFromTitle( $this->getTitle(), 'view' );
|
|
|
|
|
if ( $cache->isCacheGood( $this->mPage->getTouched() ) ) {
|
2006-07-03 16:45:51 +00:00
|
|
|
wfDebug( "Article::tryFileCache(): about to load file\n" );
|
2011-09-29 08:18:20 +00:00
|
|
|
$cache->loadFromFileCache( $this->getContext() );
|
2003-12-11 20:16:34 +00:00
|
|
|
return true;
|
2003-05-16 13:39:22 +00:00
|
|
|
} else {
|
2006-07-03 16:45:51 +00:00
|
|
|
wfDebug( "Article::tryFileCache(): starting buffer\n" );
|
2010-02-14 22:07:30 +00:00
|
|
|
ob_start( array( &$cache, 'saveToFileCache' ) );
|
2003-05-16 13:39:22 +00:00
|
|
|
}
|
|
|
|
|
} else {
|
2006-07-03 16:45:51 +00:00
|
|
|
wfDebug( "Article::tryFileCache(): not cacheable\n" );
|
2003-05-16 13:39:22 +00:00
|
|
|
}
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2008-09-25 23:02:35 +00:00
|
|
|
return false;
|
2003-05-16 13:39:22 +00:00
|
|
|
}
|
2005-07-01 00:03:31 +00:00
|
|
|
|
2004-09-03 00:20:26 +00:00
|
|
|
/**
|
|
|
|
|
* Check if the page can be cached
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
2008-11-28 14:29:25 +00:00
|
|
|
public function isFileCacheable() {
|
2008-12-11 14:29:16 +00:00
|
|
|
$cacheable = false;
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2011-09-29 08:18:20 +00:00
|
|
|
if ( HTMLFileCache::useFileCache( $this->getContext() ) ) {
|
|
|
|
|
$cacheable = $this->mPage->getID()
|
|
|
|
|
&& !$this->mRedirectedFrom && !$this->getTitle()->isRedirect();
|
2008-12-11 14:29:16 +00:00
|
|
|
// Extension may have reason to disable file caching on some pages.
|
2010-02-14 22:07:30 +00:00
|
|
|
if ( $cacheable ) {
|
2008-12-11 14:29:16 +00:00
|
|
|
$cacheable = wfRunHooks( 'IsFileCacheable', array( &$this ) );
|
2008-09-25 23:02:35 +00:00
|
|
|
}
|
|
|
|
|
}
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2007-04-25 13:07:29 +00:00
|
|
|
return $cacheable;
|
2003-05-16 13:39:22 +00:00
|
|
|
}
|
2004-07-08 14:53:54 +00:00
|
|
|
|
2004-09-03 00:20:26 +00:00
|
|
|
/**#@-*/
|
2004-08-12 14:27:38 +00:00
|
|
|
|
2011-06-30 07:52:59 +00:00
|
|
|
/**
|
|
|
|
|
* Lightweight method to get the parser output for a page, checking the parser cache
|
|
|
|
|
* and so on. Doesn't consider most of the stuff that WikiPage::view is forced to
|
|
|
|
|
* consider, so it's not appropriate to use there.
|
|
|
|
|
*
|
|
|
|
|
* @since 1.16 (r52326) for LiquidThreads
|
|
|
|
|
*
|
|
|
|
|
* @param $oldid mixed integer Revision ID or null
|
|
|
|
|
* @param $user User The relevant user
|
|
|
|
|
* @return ParserOutput or false if the given revsion ID is not found
|
|
|
|
|
*/
|
|
|
|
|
public function getParserOutput( $oldid = null, User $user = null ) {
|
2011-11-17 20:21:54 +00:00
|
|
|
global $wgUser;
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2011-11-17 20:21:54 +00:00
|
|
|
$user = is_null( $user ) ? $wgUser : $user;
|
|
|
|
|
$parserOptions = $this->mPage->makeParserOptions( $user );
|
2007-01-10 23:32:38 +00:00
|
|
|
|
2011-11-17 20:21:54 +00:00
|
|
|
return $this->mPage->getParserOutput( $parserOptions, $oldid );
|
2007-01-10 23:32:38 +00:00
|
|
|
}
|
|
|
|
|
|
2011-09-29 17:51:27 +00:00
|
|
|
/**
|
|
|
|
|
* Get parser options suitable for rendering the primary article wikitext
|
2012-02-10 15:37:33 +00:00
|
|
|
* @return ParserOptions
|
2011-09-29 17:51:27 +00:00
|
|
|
*/
|
|
|
|
|
public function getParserOptions() {
|
|
|
|
|
global $wgUser;
|
|
|
|
|
if ( !$this->mParserOptions ) {
|
|
|
|
|
$this->mParserOptions = $this->mPage->makeParserOptions( $wgUser );
|
|
|
|
|
}
|
|
|
|
|
// Clone to allow modifications of the return value without affecting cache
|
|
|
|
|
return clone $this->mParserOptions;
|
|
|
|
|
}
|
|
|
|
|
|
This is a schema change. It's only a table creation, but the table must be created on Wikimedia servers before this revision goes live. The maintenance script populateCategory.php should be run when convenient. If it's not run, there's only one substantial case where display will be harmed: the page of a category with more than 200 net pages added since the patch goes live will give an erroneously low count. In other cases category pages will just be better-worded, and it will recognize the count in the table is bogus.
* Adds Category and CategoryList classes to represent categories themselves.
* Adds a category table, giving each category a name, ID, and counts of all members, subcats only, and files.
* Adds a maintenance script to populate the category table efficiently. This script is careful to wait for slaves and should be safe to run on a live database. The maintenance script's includes file is called by update.php.
* Until the category table is populated, the patch handles weird category table rows gracefully. It detects whether they're obviously impossible, and if so, it outputs appropriate messages.
2008-03-18 00:17:28 +00:00
|
|
|
/**
|
2011-06-29 22:09:51 +00:00
|
|
|
* Sets the context this Article is executed in
|
This is a schema change. It's only a table creation, but the table must be created on Wikimedia servers before this revision goes live. The maintenance script populateCategory.php should be run when convenient. If it's not run, there's only one substantial case where display will be harmed: the page of a category with more than 200 net pages added since the patch goes live will give an erroneously low count. In other cases category pages will just be better-worded, and it will recognize the count in the table is bogus.
* Adds Category and CategoryList classes to represent categories themselves.
* Adds a category table, giving each category a name, ID, and counts of all members, subcats only, and files.
* Adds a maintenance script to populate the category table efficiently. This script is careful to wait for slaves and should be safe to run on a live database. The maintenance script's includes file is called by update.php.
* Until the category table is populated, the patch handles weird category table rows gracefully. It detects whether they're obviously impossible, and if so, it outputs appropriate messages.
2008-03-18 00:17:28 +00:00
|
|
|
*
|
2011-09-15 15:19:49 +00:00
|
|
|
* @param $context IContextSource
|
2011-06-29 22:09:51 +00:00
|
|
|
* @since 1.18
|
This is a schema change. It's only a table creation, but the table must be created on Wikimedia servers before this revision goes live. The maintenance script populateCategory.php should be run when convenient. If it's not run, there's only one substantial case where display will be harmed: the page of a category with more than 200 net pages added since the patch goes live will give an erroneously low count. In other cases category pages will just be better-worded, and it will recognize the count in the table is bogus.
* Adds Category and CategoryList classes to represent categories themselves.
* Adds a category table, giving each category a name, ID, and counts of all members, subcats only, and files.
* Adds a maintenance script to populate the category table efficiently. This script is careful to wait for slaves and should be safe to run on a live database. The maintenance script's includes file is called by update.php.
* Until the category table is populated, the patch handles weird category table rows gracefully. It detects whether they're obviously impossible, and if so, it outputs appropriate messages.
2008-03-18 00:17:28 +00:00
|
|
|
*/
|
2011-06-29 22:09:51 +00:00
|
|
|
public function setContext( $context ) {
|
|
|
|
|
$this->mContext = $context;
|
|
|
|
|
}
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
/**
|
|
|
|
|
* Gets the context this Article is executed in
|
|
|
|
|
*
|
2011-09-15 15:19:49 +00:00
|
|
|
* @return IContextSource
|
2011-06-29 22:09:51 +00:00
|
|
|
* @since 1.18
|
|
|
|
|
*/
|
|
|
|
|
public function getContext() {
|
2011-09-15 15:19:49 +00:00
|
|
|
if ( $this->mContext instanceof IContextSource ) {
|
2011-06-29 22:09:51 +00:00
|
|
|
return $this->mContext;
|
|
|
|
|
} else {
|
|
|
|
|
wfDebug( __METHOD__ . " called and \$mContext is null. Return RequestContext::getMain(); for sanity\n" );
|
|
|
|
|
return RequestContext::getMain();
|
This is a schema change. It's only a table creation, but the table must be created on Wikimedia servers before this revision goes live. The maintenance script populateCategory.php should be run when convenient. If it's not run, there's only one substantial case where display will be harmed: the page of a category with more than 200 net pages added since the patch goes live will give an erroneously low count. In other cases category pages will just be better-worded, and it will recognize the count in the table is bogus.
* Adds Category and CategoryList classes to represent categories themselves.
* Adds a category table, giving each category a name, ID, and counts of all members, subcats only, and files.
* Adds a maintenance script to populate the category table efficiently. This script is careful to wait for slaves and should be safe to run on a live database. The maintenance script's includes file is called by update.php.
* Until the category table is populated, the patch handles weird category table rows gracefully. It detects whether they're obviously impossible, and if so, it outputs appropriate messages.
2008-03-18 00:17:28 +00:00
|
|
|
}
|
2011-06-29 22:09:51 +00:00
|
|
|
}
|
This is a schema change. It's only a table creation, but the table must be created on Wikimedia servers before this revision goes live. The maintenance script populateCategory.php should be run when convenient. If it's not run, there's only one substantial case where display will be harmed: the page of a category with more than 200 net pages added since the patch goes live will give an erroneously low count. In other cases category pages will just be better-worded, and it will recognize the count in the table is bogus.
* Adds Category and CategoryList classes to represent categories themselves.
* Adds a category table, giving each category a name, ID, and counts of all members, subcats only, and files.
* Adds a maintenance script to populate the category table efficiently. This script is careful to wait for slaves and should be safe to run on a live database. The maintenance script's includes file is called by update.php.
* Until the category table is populated, the patch handles weird category table rows gracefully. It detects whether they're obviously impossible, and if so, it outputs appropriate messages.
2008-03-18 00:17:28 +00:00
|
|
|
|
2011-11-11 15:58:17 +00:00
|
|
|
/**
|
|
|
|
|
* Info about this page
|
|
|
|
|
* @deprecated since 1.19
|
|
|
|
|
*/
|
|
|
|
|
public function info() {
|
2011-12-13 05:19:05 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.19' );
|
2011-11-11 15:58:17 +00:00
|
|
|
Action::factory( 'info', $this )->show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Mark this particular edit/page as patrolled
|
|
|
|
|
* @deprecated since 1.18
|
|
|
|
|
*/
|
|
|
|
|
public function markpatrolled() {
|
2011-12-13 05:19:05 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.18' );
|
2011-11-11 15:58:17 +00:00
|
|
|
Action::factory( 'markpatrolled', $this )->show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Handle action=purge
|
|
|
|
|
* @deprecated since 1.19
|
|
|
|
|
*/
|
|
|
|
|
public function purge() {
|
|
|
|
|
return Action::factory( 'purge', $this )->show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Handle action=revert
|
|
|
|
|
* @deprecated since 1.19
|
|
|
|
|
*/
|
|
|
|
|
public function revert() {
|
2011-12-13 05:19:05 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.19' );
|
2011-11-11 15:58:17 +00:00
|
|
|
Action::factory( 'revert', $this )->show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Handle action=rollback
|
|
|
|
|
* @deprecated since 1.19
|
|
|
|
|
*/
|
|
|
|
|
public function rollback() {
|
2011-12-13 05:19:05 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.19' );
|
2011-11-11 15:58:17 +00:00
|
|
|
Action::factory( 'rollback', $this )->show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* User-interface handler for the "watch" action.
|
|
|
|
|
* Requires Request to pass a token as of 1.18.
|
|
|
|
|
* @deprecated since 1.18
|
|
|
|
|
*/
|
|
|
|
|
public function watch() {
|
2011-12-13 05:19:05 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.18' );
|
2011-11-11 15:58:17 +00:00
|
|
|
Action::factory( 'watch', $this )->show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Add this page to $wgUser's watchlist
|
|
|
|
|
*
|
|
|
|
|
* This is safe to be called multiple times
|
|
|
|
|
*
|
|
|
|
|
* @return bool true on successful watch operation
|
|
|
|
|
* @deprecated since 1.18
|
|
|
|
|
*/
|
|
|
|
|
public function doWatch() {
|
|
|
|
|
global $wgUser;
|
2011-12-13 05:19:05 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.18' );
|
2011-11-11 15:58:17 +00:00
|
|
|
return WatchAction::doWatch( $this->getTitle(), $wgUser );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* User interface handler for the "unwatch" action.
|
|
|
|
|
* Requires Request to pass a token as of 1.18.
|
|
|
|
|
* @deprecated since 1.18
|
|
|
|
|
*/
|
|
|
|
|
public function unwatch() {
|
2011-12-13 05:19:05 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.18' );
|
2011-11-11 15:58:17 +00:00
|
|
|
Action::factory( 'unwatch', $this )->show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Stop watching a page
|
|
|
|
|
* @return bool true on successful unwatch
|
|
|
|
|
* @deprecated since 1.18
|
|
|
|
|
*/
|
|
|
|
|
public function doUnwatch() {
|
|
|
|
|
global $wgUser;
|
2011-12-13 05:19:05 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.18' );
|
2011-11-11 15:58:17 +00:00
|
|
|
return WatchAction::doUnwatch( $this->getTitle(), $wgUser );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Output a redirect back to the article.
|
|
|
|
|
* This is typically used after an edit.
|
|
|
|
|
*
|
|
|
|
|
* @deprecated in 1.18; call $wgOut->redirect() directly
|
|
|
|
|
* @param $noRedir Boolean: add redirect=no
|
|
|
|
|
* @param $sectionAnchor String: section to redirect to, including "#"
|
|
|
|
|
* @param $extraQuery String: extra query params
|
|
|
|
|
*/
|
|
|
|
|
public function doRedirect( $noRedir = false, $sectionAnchor = '', $extraQuery = '' ) {
|
2011-12-13 05:19:05 +00:00
|
|
|
wfDeprecated( __METHOD__, '1.18' );
|
2011-11-11 15:58:17 +00:00
|
|
|
global $wgOut;
|
|
|
|
|
|
|
|
|
|
if ( $noRedir ) {
|
|
|
|
|
$query = 'redirect=no';
|
|
|
|
|
if ( $extraQuery )
|
|
|
|
|
$query .= "&$extraQuery";
|
|
|
|
|
} else {
|
|
|
|
|
$query = $extraQuery;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$wgOut->redirect( $this->getTitle()->getFullURL( $query ) . $sectionAnchor );
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
/**
|
|
|
|
|
* Use PHP's magic __get handler to handle accessing of
|
|
|
|
|
* raw WikiPage fields for backwards compatibility.
|
|
|
|
|
*
|
|
|
|
|
* @param $fname String Field name
|
|
|
|
|
*/
|
|
|
|
|
public function __get( $fname ) {
|
|
|
|
|
if ( property_exists( $this->mPage, $fname ) ) {
|
|
|
|
|
#wfWarn( "Access to raw $fname field " . __CLASS__ );
|
|
|
|
|
return $this->mPage->$fname;
|
2008-03-19 11:19:00 +00:00
|
|
|
}
|
2011-08-16 16:03:29 +00:00
|
|
|
trigger_error( 'Inaccessible property via __get(): ' . $fname, E_USER_NOTICE );
|
2011-06-29 22:09:51 +00:00
|
|
|
}
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
/**
|
|
|
|
|
* Use PHP's magic __set handler to handle setting of
|
|
|
|
|
* raw WikiPage fields for backwards compatibility.
|
|
|
|
|
*
|
|
|
|
|
* @param $fname String Field name
|
|
|
|
|
* @param $fvalue mixed New value
|
|
|
|
|
*/
|
|
|
|
|
public function __set( $fname, $fvalue ) {
|
|
|
|
|
if ( property_exists( $this->mPage, $fname ) ) {
|
|
|
|
|
#wfWarn( "Access to raw $fname field of " . __CLASS__ );
|
|
|
|
|
$this->mPage->$fname = $fvalue;
|
|
|
|
|
// Note: extensions may want to toss on new fields
|
|
|
|
|
} elseif ( !in_array( $fname, array( 'mContext', 'mPage' ) ) ) {
|
|
|
|
|
$this->mPage->$fname = $fvalue;
|
|
|
|
|
} else {
|
2011-09-07 12:54:57 +00:00
|
|
|
trigger_error( 'Inaccessible property via __set(): ' . $fname, E_USER_NOTICE );
|
2008-03-19 11:19:00 +00:00
|
|
|
}
|
This is a schema change. It's only a table creation, but the table must be created on Wikimedia servers before this revision goes live. The maintenance script populateCategory.php should be run when convenient. If it's not run, there's only one substantial case where display will be harmed: the page of a category with more than 200 net pages added since the patch goes live will give an erroneously low count. In other cases category pages will just be better-worded, and it will recognize the count in the table is bogus.
* Adds Category and CategoryList classes to represent categories themselves.
* Adds a category table, giving each category a name, ID, and counts of all members, subcats only, and files.
* Adds a maintenance script to populate the category table efficiently. This script is careful to wait for slaves and should be safe to run on a live database. The maintenance script's includes file is called by update.php.
* Until the category table is populated, the patch handles weird category table rows gracefully. It detects whether they're obviously impossible, and if so, it outputs appropriate messages.
2008-03-18 00:17:28 +00:00
|
|
|
}
|
2009-12-26 20:03:33 +00:00
|
|
|
|
2010-03-15 12:04:24 +00:00
|
|
|
/**
|
2011-06-29 22:09:51 +00:00
|
|
|
* Use PHP's magic __call handler to transform instance calls to
|
|
|
|
|
* WikiPage functions for backwards compatibility.
|
2010-03-15 12:04:24 +00:00
|
|
|
*
|
2011-06-29 22:09:51 +00:00
|
|
|
* @param $fname String Name of called method
|
|
|
|
|
* @param $args Array Arguments to the method
|
2012-02-09 21:33:27 +00:00
|
|
|
* @return mixed
|
2009-12-26 20:03:33 +00:00
|
|
|
*/
|
2011-06-29 22:09:51 +00:00
|
|
|
public function __call( $fname, $args ) {
|
|
|
|
|
if ( is_callable( array( $this->mPage, $fname ) ) ) {
|
|
|
|
|
#wfWarn( "Call to " . __CLASS__ . "::$fname; please use WikiPage instead" );
|
|
|
|
|
return call_user_func_array( array( $this->mPage, $fname ), $args );
|
|
|
|
|
}
|
2011-08-16 16:03:29 +00:00
|
|
|
trigger_error( 'Inaccessible function via __call(): ' . $fname, E_USER_ERROR );
|
2011-06-29 22:09:51 +00:00
|
|
|
}
|
2009-06-23 21:52:39 +00:00
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
// ****** B/C functions to work-around PHP silliness with __call and references ****** //
|
2011-10-26 03:44:47 +00:00
|
|
|
|
2011-12-18 16:01:31 +00:00
|
|
|
/**
|
|
|
|
|
* @param $limit array
|
|
|
|
|
* @param $expiry array
|
|
|
|
|
* @param $cascade bool
|
|
|
|
|
* @param $reason string
|
|
|
|
|
* @param $user User
|
|
|
|
|
* @return Status
|
|
|
|
|
*/
|
|
|
|
|
public function doUpdateRestrictions( array $limit, array $expiry, &$cascade, $reason, User $user ) {
|
|
|
|
|
return $this->mPage->doUpdateRestrictions( $limit, $expiry, $cascade, $reason, $user );
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-26 03:44:47 +00:00
|
|
|
/**
|
|
|
|
|
* @param $limit array
|
|
|
|
|
* @param $reason string
|
|
|
|
|
* @param $cascade int
|
|
|
|
|
* @param $expiry array
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
2011-06-29 22:09:51 +00:00
|
|
|
public function updateRestrictions( $limit = array(), $reason = '', &$cascade = 0, $expiry = array() ) {
|
|
|
|
|
return $this->mPage->updateRestrictions( $limit, $reason, $cascade, $expiry );
|
|
|
|
|
}
|
2009-12-26 20:03:33 +00:00
|
|
|
|
2011-10-26 03:44:47 +00:00
|
|
|
/**
|
|
|
|
|
* @param $reason string
|
|
|
|
|
* @param $suppress bool
|
|
|
|
|
* @param $id int
|
|
|
|
|
* @param $commit bool
|
|
|
|
|
* @param $error string
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
2011-06-29 22:09:51 +00:00
|
|
|
public function doDeleteArticle( $reason, $suppress = false, $id = 0, $commit = true, &$error = '' ) {
|
|
|
|
|
return $this->mPage->doDeleteArticle( $reason, $suppress, $id, $commit, $error );
|
|
|
|
|
}
|
2010-05-30 14:28:54 +00:00
|
|
|
|
2011-10-26 03:44:47 +00:00
|
|
|
/**
|
|
|
|
|
* @param $fromP
|
|
|
|
|
* @param $summary
|
|
|
|
|
* @param $token
|
|
|
|
|
* @param $bot
|
|
|
|
|
* @param $resultDetails
|
|
|
|
|
* @param $user User
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
2011-07-02 15:10:39 +00:00
|
|
|
public function doRollback( $fromP, $summary, $token, $bot, &$resultDetails, User $user = null ) {
|
|
|
|
|
global $wgUser;
|
|
|
|
|
$user = is_null( $user ) ? $wgUser : $user;
|
|
|
|
|
return $this->mPage->doRollback( $fromP, $summary, $token, $bot, $resultDetails, $user );
|
2011-06-29 22:09:51 +00:00
|
|
|
}
|
2009-06-23 21:52:39 +00:00
|
|
|
|
2011-10-26 03:44:47 +00:00
|
|
|
/**
|
|
|
|
|
* @param $fromP
|
|
|
|
|
* @param $summary
|
|
|
|
|
* @param $bot
|
|
|
|
|
* @param $resultDetails
|
|
|
|
|
* @param $guser User
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
2011-07-02 15:10:39 +00:00
|
|
|
public function commitRollback( $fromP, $summary, $bot, &$resultDetails, User $guser = null ) {
|
|
|
|
|
global $wgUser;
|
|
|
|
|
$guser = is_null( $guser ) ? $wgUser : $guser;
|
|
|
|
|
return $this->mPage->commitRollback( $fromP, $summary, $bot, $resultDetails, $guser );
|
2011-06-29 22:09:51 +00:00
|
|
|
}
|
2009-06-23 21:52:39 +00:00
|
|
|
|
2011-10-26 03:44:47 +00:00
|
|
|
/**
|
|
|
|
|
* @param $hasHistory bool
|
|
|
|
|
* @return mixed
|
|
|
|
|
*/
|
2011-09-07 17:55:37 +00:00
|
|
|
public function generateReason( &$hasHistory ) {
|
|
|
|
|
return $this->mPage->getAutoDeleteReason( $hasHistory );
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-29 22:09:51 +00:00
|
|
|
// ****** B/C functions for static methods ( __callStatic is PHP>=5.3 ) ****** //
|
2011-10-26 03:44:47 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
2011-06-29 22:09:51 +00:00
|
|
|
public static function selectFields() {
|
|
|
|
|
return WikiPage::selectFields();
|
|
|
|
|
}
|
2011-03-04 20:16:35 +00:00
|
|
|
|
2011-10-26 03:44:47 +00:00
|
|
|
/**
|
|
|
|
|
* @param $title Title
|
|
|
|
|
*/
|
2011-06-29 22:09:51 +00:00
|
|
|
public static function onArticleCreate( $title ) {
|
2011-10-29 01:53:28 +00:00
|
|
|
WikiPage::onArticleCreate( $title );
|
2009-06-23 21:52:39 +00:00
|
|
|
}
|
2010-06-28 07:17:16 +00:00
|
|
|
|
2011-10-26 03:44:47 +00:00
|
|
|
/**
|
|
|
|
|
* @param $title Title
|
|
|
|
|
*/
|
2011-06-29 22:09:51 +00:00
|
|
|
public static function onArticleDelete( $title ) {
|
2011-10-29 01:53:28 +00:00
|
|
|
WikiPage::onArticleDelete( $title );
|
2011-04-12 23:00:49 +00:00
|
|
|
}
|
|
|
|
|
|
2011-10-26 03:44:47 +00:00
|
|
|
/**
|
|
|
|
|
* @param $title Title
|
|
|
|
|
*/
|
2011-06-29 22:09:51 +00:00
|
|
|
public static function onArticleEdit( $title ) {
|
2011-10-29 01:53:28 +00:00
|
|
|
WikiPage::onArticleEdit( $title );
|
2011-04-12 23:00:49 +00:00
|
|
|
}
|
|
|
|
|
|
2011-10-26 03:44:47 +00:00
|
|
|
/**
|
|
|
|
|
* @param $oldtext
|
|
|
|
|
* @param $newtext
|
|
|
|
|
* @param $flags
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2011-06-29 22:09:51 +00:00
|
|
|
public static function getAutosummary( $oldtext, $newtext, $flags ) {
|
|
|
|
|
return WikiPage::getAutosummary( $oldtext, $newtext, $flags );
|
|
|
|
|
}
|
|
|
|
|
// ******
|
2007-07-22 14:45:12 +00:00
|
|
|
}
|