2004-02-18 02:15:00 +00:00
|
|
|
<?php
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2010-11-07 16:28:11 +00:00
|
|
|
* User interface for the difference engine
|
2010-08-08 11:55:47 +00:00
|
|
|
*
|
|
|
|
|
* @file
|
|
|
|
|
* @ingroup DifferenceEngine
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2010-11-27 19:01:51 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
2010-11-07 16:28:11 +00:00
|
|
|
* Constant to indicate diff cache compatibility.
|
|
|
|
|
* Bump this when changing the diff formatting in a way that
|
|
|
|
|
* fixes important bugs or such to force cached diff views to
|
|
|
|
|
* clear.
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2010-11-07 16:28:11 +00:00
|
|
|
define( 'MW_DIFF_VERSION', '1.11a' );
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
* @todo document
|
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
|
|
|
* @ingroup DifferenceEngine
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2011-11-10 13:06:52 +00:00
|
|
|
class DifferenceEngine extends ContextSource {
|
2010-11-07 16:28:11 +00:00
|
|
|
/**#@+
|
|
|
|
|
* @private
|
|
|
|
|
*/
|
2011-05-01 21:56:02 +00:00
|
|
|
var $mOldid, $mNewid;
|
2010-11-07 16:28:11 +00:00
|
|
|
var $mOldtext, $mNewtext;
|
2011-09-04 16:09:58 +00:00
|
|
|
protected $mDiffLang;
|
2011-02-19 21:44:20 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var Title
|
|
|
|
|
*/
|
2011-11-10 13:06:52 +00:00
|
|
|
var $mOldPage, $mNewPage;
|
2010-11-07 16:28:11 +00:00
|
|
|
var $mRcidMarkPatrolled;
|
2011-02-19 21:44:20 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var Revision
|
|
|
|
|
*/
|
2010-11-07 16:28:11 +00:00
|
|
|
var $mOldRev, $mNewRev;
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
private $mRevisionsIdsLoaded = false; // Have the revisions IDs been loaded
|
2010-11-07 16:28:11 +00:00
|
|
|
var $mRevisionsLoaded = false; // Have the revisions been loaded
|
|
|
|
|
var $mTextLoaded = 0; // How many text blobs have been loaded, 0, 1 or 2?
|
|
|
|
|
var $mCacheHit = false; // Was the diff fetched from cache?
|
2004-04-17 07:37:55 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
/**
|
|
|
|
|
* Set this to true to add debug info to the HTML output.
|
|
|
|
|
* Warning: this may cause RSS readers to spuriously mark articles as "new"
|
|
|
|
|
* (bug 20601)
|
|
|
|
|
*/
|
|
|
|
|
var $enableDebugComment = false;
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
// If true, line X is not displayed when X is 1, for example to increase
|
|
|
|
|
// readability and conserve space with many small diffs.
|
|
|
|
|
protected $mReducedLineNumbers = false;
|
2004-08-09 05:38:11 +00:00
|
|
|
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
// Link to action=markpatrolled
|
|
|
|
|
protected $mMarkPatrolledLink = null;
|
|
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
protected $unhide = false; # show rev_deleted content if allowed
|
|
|
|
|
/**#@-*/
|
2004-04-17 07:37:55 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
/**
|
|
|
|
|
* Constructor
|
2011-11-10 13:06:52 +00:00
|
|
|
* @param $context IContextSource context to use, anything else will be ignored
|
2011-06-01 16:27:46 +00:00
|
|
|
* @param $old Integer old ID we want to show and diff with.
|
|
|
|
|
* @param $new String either 'prev' or 'next'.
|
|
|
|
|
* @param $rcid Integer ??? FIXME (default 0)
|
2010-11-07 16:28:11 +00:00
|
|
|
* @param $refreshCache boolean If set, refreshes the diff cache
|
|
|
|
|
* @param $unhide boolean If set, allow viewing deleted revs
|
|
|
|
|
*/
|
2011-11-10 13:06:52 +00:00
|
|
|
function __construct( $context = null, $old = 0, $new = 0, $rcid = 0,
|
2010-11-07 16:28:11 +00:00
|
|
|
$refreshCache = false, $unhide = false )
|
|
|
|
|
{
|
2011-11-10 13:06:52 +00:00
|
|
|
if ( $context instanceof IContextSource ) {
|
|
|
|
|
$this->setContext( $context );
|
2010-11-07 16:28:11 +00:00
|
|
|
}
|
2011-11-10 13:06:52 +00:00
|
|
|
|
2010-11-27 19:01:51 +00:00
|
|
|
wfDebug( "DifferenceEngine old '$old' new '$new' rcid '$rcid'\n" );
|
2010-11-07 16:28:11 +00:00
|
|
|
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
$this->mOldid = $old;
|
|
|
|
|
$this->mNewid = $new;
|
2010-11-27 19:01:51 +00:00
|
|
|
$this->mRcidMarkPatrolled = intval( $rcid ); # force it to be an integer
|
2010-11-07 16:28:11 +00:00
|
|
|
$this->mRefreshCache = $refreshCache;
|
|
|
|
|
$this->unhide = $unhide;
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2011-06-01 16:27:46 +00:00
|
|
|
/**
|
|
|
|
|
* @param $value bool
|
|
|
|
|
*/
|
2010-11-07 16:28:11 +00:00
|
|
|
function setReducedLineNumbers( $value = true ) {
|
|
|
|
|
$this->mReducedLineNumbers = $value;
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
|
|
|
|
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
/**
|
|
|
|
|
* @return Language
|
|
|
|
|
*/
|
|
|
|
|
function getDiffLang() {
|
|
|
|
|
if ( $this->mDiffLang === null ) {
|
|
|
|
|
# Default language in which the diff text is written.
|
2011-11-10 13:06:52 +00:00
|
|
|
$this->mDiffLang = $this->getTitle()->getPageLanguage();
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
}
|
|
|
|
|
return $this->mDiffLang;
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-01 16:27:46 +00:00
|
|
|
/**
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
2010-11-07 16:28:11 +00:00
|
|
|
function wasCacheHit() {
|
|
|
|
|
return $this->mCacheHit;
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
2010-11-27 19:01:51 +00:00
|
|
|
|
2011-06-01 16:27:46 +00:00
|
|
|
/**
|
|
|
|
|
* @return int
|
|
|
|
|
*/
|
2010-11-07 16:28:11 +00:00
|
|
|
function getOldid() {
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
$this->loadRevisionIds();
|
2010-11-07 16:28:11 +00:00
|
|
|
return $this->mOldid;
|
|
|
|
|
}
|
2010-11-27 19:01:51 +00:00
|
|
|
|
2011-06-01 16:27:46 +00:00
|
|
|
/**
|
|
|
|
|
* @return Bool|int
|
|
|
|
|
*/
|
2010-11-07 16:28:11 +00:00
|
|
|
function getNewid() {
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
$this->loadRevisionIds();
|
2010-11-07 16:28:11 +00:00
|
|
|
return $this->mNewid;
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
2006-10-03 13:00:52 +00:00
|
|
|
|
2011-05-10 01:17:01 +00:00
|
|
|
/**
|
|
|
|
|
* Look up a special:Undelete link to the given deleted revision id,
|
|
|
|
|
* as a workaround for being unable to load deleted diffs in currently.
|
|
|
|
|
*
|
|
|
|
|
* @param int $id revision ID
|
|
|
|
|
* @return mixed URL or false
|
|
|
|
|
*/
|
|
|
|
|
function deletedLink( $id ) {
|
2011-11-10 13:06:52 +00:00
|
|
|
if ( $this->getUser()->isAllowed( 'deletedhistory' ) ) {
|
2011-05-10 01:17:01 +00:00
|
|
|
$dbr = wfGetDB( DB_SLAVE );
|
|
|
|
|
$row = $dbr->selectRow('archive', '*',
|
|
|
|
|
array( 'ar_rev_id' => $id ),
|
|
|
|
|
__METHOD__ );
|
|
|
|
|
if ( $row ) {
|
|
|
|
|
$rev = Revision::newFromArchiveRow( $row );
|
|
|
|
|
$title = Title::makeTitleSafe( $row->ar_namespace, $row->ar_title );
|
|
|
|
|
return SpecialPage::getTitleFor( 'Undelete' )->getFullURL( array(
|
|
|
|
|
'target' => $title->getPrefixedText(),
|
|
|
|
|
'timestamp' => $rev->getTimestamp()
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Build a wikitext link toward a deleted revision, if viewable.
|
|
|
|
|
*
|
|
|
|
|
* @param int $id revision ID
|
|
|
|
|
* @return string wikitext fragment
|
|
|
|
|
*/
|
|
|
|
|
function deletedIdMarker( $id ) {
|
|
|
|
|
$link = $this->deletedLink( $id );
|
|
|
|
|
if ( $link ) {
|
|
|
|
|
return "[$link $id]";
|
|
|
|
|
} else {
|
|
|
|
|
return $id;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
function showDiffPage( $diffOnly = false ) {
|
2008-04-06 18:16:38 +00:00
|
|
|
wfProfileIn( __METHOD__ );
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2011-01-04 06:12:33 +00:00
|
|
|
# Allow frames except in certain special cases
|
2011-11-10 13:06:52 +00:00
|
|
|
$out = $this->getOutput();
|
|
|
|
|
$out->allowClickjacking();
|
|
|
|
|
$out->setRobotPolicy( 'noindex,nofollow' );
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
|
|
|
|
|
if ( !$this->loadRevisionData() ) {
|
|
|
|
|
// Sounds like a deleted revision... Let's see what we can do.
|
2011-11-10 13:06:52 +00:00
|
|
|
$t = $this->getTitle()->getPrefixedText();
|
|
|
|
|
$d = $this->msg( 'missingarticle-diff',
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
$this->deletedIdMarker( $this->mOldid ),
|
2011-11-10 13:06:52 +00:00
|
|
|
$this->deletedIdMarker( $this->mNewid ) )->escaped();
|
|
|
|
|
$out->setPageTitle( $this->msg( 'errorpagetitle' ) );
|
|
|
|
|
$out->addWikiMsg( 'missing-article', "<nowiki>$t</nowiki>", "<span class='plainlinks'>$d</span>" );
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-10 13:06:52 +00:00
|
|
|
$user = $this->getUser();
|
|
|
|
|
$permErrors = $this->mNewPage->getUserPermissionsErrors( 'read', $user );
|
2011-11-06 19:59:46 +00:00
|
|
|
if ( $this->mOldPage ) { # mOldPage might not be set, see below.
|
|
|
|
|
$permErrors = wfMergeErrorArrays( $permErrors,
|
2011-11-10 13:06:52 +00:00
|
|
|
$this->mOldPage->getUserPermissionsErrors( 'read', $user ) );
|
2011-11-06 19:59:46 +00:00
|
|
|
}
|
|
|
|
|
if ( count( $permErrors ) ) {
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
2011-11-06 19:59:46 +00:00
|
|
|
throw new PermissionsError( 'read', $permErrors );
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
}
|
2010-11-07 16:28:11 +00:00
|
|
|
|
|
|
|
|
# If external diffs are enabled both globally and for the user,
|
|
|
|
|
# we'll use the application/x-external-editor interface to call
|
|
|
|
|
# an external diff tool like kompare, kdiff3, etc.
|
2011-11-10 13:06:52 +00:00
|
|
|
if ( ExternalEdit::useExternalEngine( $this->getContext(), 'diff' ) ) {
|
2011-11-09 15:31:55 +00:00
|
|
|
$urls = array(
|
|
|
|
|
'File' => array( 'Extension' => 'wiki', 'URL' =>
|
|
|
|
|
# This should be mOldPage, but it may not be set, see below.
|
|
|
|
|
$this->mNewPage->getCanonicalURL( array(
|
|
|
|
|
'action' => 'raw', 'oldid' => $this->mOldid ) )
|
|
|
|
|
),
|
|
|
|
|
'File2' => array( 'Extension' => 'wiki', 'URL' =>
|
|
|
|
|
$this->mNewPage->getCanonicalURL( array(
|
|
|
|
|
'action' => 'raw', 'oldid' => $this->mNewid ) )
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
2011-11-10 13:06:52 +00:00
|
|
|
$externalEditor = new ExternalEdit( $this->getContext(), $urls );
|
2011-11-09 15:31:55 +00:00
|
|
|
$externalEditor->execute();
|
2011-02-10 16:04:19 +00:00
|
|
|
|
|
|
|
|
wfProfileOut( __METHOD__ );
|
2010-11-07 16:28:11 +00:00
|
|
|
return;
|
2008-08-15 11:46:46 +00:00
|
|
|
}
|
|
|
|
|
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
$rollback = '';
|
|
|
|
|
$undoLink = '';
|
|
|
|
|
|
|
|
|
|
$query = array();
|
|
|
|
|
# Carry over 'diffonly' param via navigation links
|
2011-11-10 13:06:52 +00:00
|
|
|
if ( $diffOnly != $user->getBoolOption( 'diffonly' ) ) {
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
$query['diffonly'] = $diffOnly;
|
|
|
|
|
}
|
|
|
|
|
# Cascade unhide param in links for easy deletion browsing
|
|
|
|
|
if ( $this->unhide ) {
|
|
|
|
|
$query['unhide'] = 1;
|
2010-11-07 16:28:11 +00:00
|
|
|
}
|
2004-08-09 05:38:11 +00:00
|
|
|
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
# Check if one of the revisions is deleted/suppressed
|
|
|
|
|
$deleted = $suppressed = false;
|
2011-11-10 13:06:52 +00:00
|
|
|
$allowed = $this->mNewRev->userCan( Revision::DELETED_TEXT, $user );
|
2006-01-07 13:31:29 +00:00
|
|
|
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
# mOldRev is false if the difference engine is called with a "vague" query for
|
2010-11-07 16:28:11 +00:00
|
|
|
# a diff between a version V and its previous version V' AND the version V
|
|
|
|
|
# is the first version of that article. In that case, V' does not exist.
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
if ( $this->mOldRev === false ) {
|
2011-11-10 13:06:52 +00:00
|
|
|
$out->setPageTitle( $this->mNewPage->getPrefixedText() );
|
|
|
|
|
$out->addSubtitle( $this->msg( 'difference' ) );
|
2011-10-05 19:59:39 +00:00
|
|
|
$samePage = true;
|
|
|
|
|
$oldHeader = '';
|
|
|
|
|
} else {
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
wfRunHooks( 'DiffViewHeader', array( $this, $this->mOldRev, $this->mNewRev ) );
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2011-11-10 13:06:52 +00:00
|
|
|
$sk = $this->getSkin();
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
if ( method_exists( $sk, 'suppressQuickbar' ) ) {
|
|
|
|
|
$sk->suppressQuickbar();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $this->mNewPage->equals( $this->mOldPage ) ) {
|
2011-11-10 13:06:52 +00:00
|
|
|
$out->setPageTitle( $this->mNewPage->getPrefixedText() );
|
|
|
|
|
$out->addSubtitle( $this->msg( 'difference' ) );
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
$samePage = true;
|
|
|
|
|
} else {
|
2011-11-10 13:06:52 +00:00
|
|
|
$out->setPageTitle( $this->mOldPage->getPrefixedText() . ', ' . $this->mNewPage->getPrefixedText() );
|
|
|
|
|
$out->addSubtitle( $this->msg( 'difference-multipage' ) );
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
$samePage = false;
|
|
|
|
|
}
|
2010-11-07 16:28:11 +00:00
|
|
|
|
2011-11-10 13:06:52 +00:00
|
|
|
if ( $samePage && $this->mNewPage->userCan( 'edit', $user ) ) {
|
|
|
|
|
if ( $this->mNewRev->isCurrent() && $this->mNewPage->userCan( 'rollback', $user ) ) {
|
|
|
|
|
$out->preventClickjacking();
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
$rollback = '   ' . Linker::generateRollback( $this->mNewRev );
|
|
|
|
|
}
|
|
|
|
|
if ( !$this->mOldRev->isDeleted( Revision::DELETED_TEXT ) && !$this->mNewRev->isDeleted( Revision::DELETED_TEXT ) ) {
|
2011-11-10 13:06:52 +00:00
|
|
|
$undoLink = ' ' . $this->msg( 'parentheses' )->rawParams(
|
|
|
|
|
Html::element( 'a', array(
|
|
|
|
|
'href' => $this->mNewPage->getLocalUrl( array(
|
|
|
|
|
'action' => 'edit',
|
|
|
|
|
'undoafter' => $this->mOldid,
|
|
|
|
|
'undo' => $this->mNewid ) ),
|
|
|
|
|
'title' => Linker::titleAttrib( 'undo' )
|
|
|
|
|
),
|
|
|
|
|
$this->msg( 'editundo' )->text()
|
|
|
|
|
) )->escaped();
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
}
|
|
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
# Make "previous revision link"
|
|
|
|
|
if ( $samePage && $this->mOldRev->getPrevious() ) {
|
|
|
|
|
$prevlink = Linker::linkKnown(
|
|
|
|
|
$this->mOldPage,
|
2011-11-10 13:06:52 +00:00
|
|
|
$this->msg( 'previousdiff' )->escaped(),
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
array( 'id' => 'differences-prevlink' ),
|
|
|
|
|
array( 'diff' => 'prev', 'oldid' => $this->mOldid ) + $query
|
2010-11-07 16:28:11 +00:00
|
|
|
);
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
} else {
|
|
|
|
|
$prevlink = ' ';
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
|
|
|
|
|
if ( $this->mOldRev->isMinor() ) {
|
|
|
|
|
$oldminor = ChangesList::flag( 'minor' );
|
2010-11-07 16:28:11 +00:00
|
|
|
} else {
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
$oldminor = '';
|
2010-11-07 16:28:11 +00:00
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
$ldel = $this->revisionDeleteLink( $this->mOldRev );
|
|
|
|
|
$oldRevisionHeader = $this->getRevisionHeader( $this->mOldRev, 'complete' );
|
2006-01-07 13:31:29 +00:00
|
|
|
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
$oldHeader = '<div id="mw-diff-otitle1"><strong>' . $oldRevisionHeader . '</strong></div>' .
|
|
|
|
|
'<div id="mw-diff-otitle2">' .
|
|
|
|
|
Linker::revUserTools( $this->mOldRev, !$this->unhide ) . '</div>' .
|
|
|
|
|
'<div id="mw-diff-otitle3">' . $oldminor .
|
|
|
|
|
Linker::revComment( $this->mOldRev, !$diffOnly, !$this->unhide ) . $ldel . '</div>' .
|
|
|
|
|
'<div id="mw-diff-otitle4">' . $prevlink . '</div>';
|
|
|
|
|
|
|
|
|
|
if ( $this->mOldRev->isDeleted( Revision::DELETED_TEXT ) ) {
|
|
|
|
|
$deleted = true; // old revisions text is hidden
|
|
|
|
|
if ( $this->mOldRev->isDeleted( Revision::DELETED_RESTRICTED ) ) {
|
|
|
|
|
$suppressed = true; // also suppressed
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Check if this user can see the revisions
|
2011-11-10 13:06:52 +00:00
|
|
|
if ( !$this->mOldRev->userCan( Revision::DELETED_TEXT, $user ) ) {
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
$allowed = false;
|
|
|
|
|
}
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
# Make "next revision link"
|
|
|
|
|
# Skip next link on the top revision
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
if ( $samePage && !$this->mNewRev->isCurrent() ) {
|
|
|
|
|
$nextlink = Linker::linkKnown(
|
|
|
|
|
$this->mNewPage,
|
2011-11-10 13:06:52 +00:00
|
|
|
$this->msg( 'nextdiff' )->escaped(),
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
array( 'id' => 'differences-nextlink' ),
|
|
|
|
|
array( 'diff' => 'next', 'oldid' => $this->mNewid ) + $query
|
2010-11-07 16:28:11 +00:00
|
|
|
);
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
} else {
|
|
|
|
|
$nextlink = ' ';
|
2010-11-07 16:28:11 +00:00
|
|
|
}
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2010-11-27 19:01:51 +00:00
|
|
|
if ( $this->mNewRev->isMinor() ) {
|
2010-11-07 16:28:11 +00:00
|
|
|
$newminor = ChangesList::flag( 'minor' );
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
} else {
|
|
|
|
|
$newminor = '';
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
# Handle RevisionDelete links...
|
|
|
|
|
$rdel = $this->revisionDeleteLink( $this->mNewRev );
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
$newRevisionHeader = $this->getRevisionHeader( $this->mNewRev, 'complete' ) . $undoLink;
|
2010-11-07 16:28:11 +00:00
|
|
|
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
$newHeader = '<div id="mw-diff-ntitle1"><strong>' . $newRevisionHeader . '</strong></div>' .
|
|
|
|
|
'<div id="mw-diff-ntitle2">' . Linker::revUserTools( $this->mNewRev, !$this->unhide ) .
|
2010-11-07 16:28:11 +00:00
|
|
|
" $rollback</div>" .
|
|
|
|
|
'<div id="mw-diff-ntitle3">' . $newminor .
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
Linker::revComment( $this->mNewRev, !$diffOnly, !$this->unhide ) . $rdel . '</div>' .
|
|
|
|
|
'<div id="mw-diff-ntitle4">' . $nextlink . $this->markPatrolledLink() . '</div>';
|
2010-11-07 16:28:11 +00:00
|
|
|
|
2010-11-27 19:01:51 +00:00
|
|
|
if ( $this->mNewRev->isDeleted( Revision::DELETED_TEXT ) ) {
|
2010-11-07 16:28:11 +00:00
|
|
|
$deleted = true; // new revisions text is hidden
|
2010-11-27 19:01:51 +00:00
|
|
|
if ( $this->mNewRev->isDeleted( Revision::DELETED_RESTRICTED ) )
|
2010-11-07 16:28:11 +00:00
|
|
|
$suppressed = true; // also suppressed
|
|
|
|
|
}
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
# If the diff cannot be shown due to a deleted revision, then output
|
|
|
|
|
# the diff header and links to unhide (if available)...
|
2010-11-27 19:01:51 +00:00
|
|
|
if ( $deleted && ( !$this->unhide || !$allowed ) ) {
|
2010-11-07 16:28:11 +00:00
|
|
|
$this->showDiffStyle();
|
|
|
|
|
$multi = $this->getMultiNotice();
|
2011-11-10 13:06:52 +00:00
|
|
|
$out->addHTML( $this->addHeader( '', $oldHeader, $newHeader, $multi ) );
|
2010-11-27 19:01:51 +00:00
|
|
|
if ( !$allowed ) {
|
2010-11-07 16:28:11 +00:00
|
|
|
$msg = $suppressed ? 'rev-suppressed-no-diff' : 'rev-deleted-no-diff';
|
|
|
|
|
# Give explanation for why revision is not visible
|
2011-11-10 13:06:52 +00:00
|
|
|
$out->wrapWikiMsg( "<div id='mw-$msg' class='mw-warning plainlinks'>\n$1\n</div>\n",
|
2010-11-07 16:28:11 +00:00
|
|
|
array( $msg ) );
|
|
|
|
|
} else {
|
|
|
|
|
# Give explanation and add a link to view the diff...
|
2011-11-10 13:06:52 +00:00
|
|
|
$link = $this->getTitle()->getFullUrl( $this->getRequest()->appendQueryValue( 'unhide', '1', true ) );
|
2010-11-07 16:28:11 +00:00
|
|
|
$msg = $suppressed ? 'rev-suppressed-unhide-diff' : 'rev-deleted-unhide-diff';
|
2011-11-10 13:06:52 +00:00
|
|
|
$out->wrapWikiMsg( "<div id='mw-$msg' class='mw-warning plainlinks'>\n$1\n</div>\n", array( $msg, $link ) );
|
2010-11-07 16:28:11 +00:00
|
|
|
}
|
|
|
|
|
# Otherwise, output a regular diff...
|
2004-11-25 23:49:52 +00:00
|
|
|
} else {
|
2010-11-07 16:28:11 +00:00
|
|
|
# Add deletion notice if the user is viewing deleted content
|
|
|
|
|
$notice = '';
|
2010-11-27 19:01:51 +00:00
|
|
|
if ( $deleted ) {
|
2010-11-07 16:28:11 +00:00
|
|
|
$msg = $suppressed ? 'rev-suppressed-diff-view' : 'rev-deleted-diff-view';
|
2011-11-10 13:06:52 +00:00
|
|
|
$notice = "<div id='mw-$msg' class='mw-warning plainlinks'>\n" . $this->msg( $msg )->parse() . "</div>\n";
|
2010-11-07 16:28:11 +00:00
|
|
|
}
|
|
|
|
|
$this->showDiff( $oldHeader, $newHeader, $notice );
|
2010-11-27 19:01:51 +00:00
|
|
|
if ( !$diffOnly ) {
|
2010-11-07 16:28:11 +00:00
|
|
|
$this->renderNewRevision();
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
|
|
|
|
}
|
2010-11-07 16:28:11 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
2010-11-27 19:01:51 +00:00
|
|
|
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
/**
|
|
|
|
|
* Get a link to mark the change as patrolled, or '' if there's either no
|
|
|
|
|
* revision to patrol or the user is not allowed to to it.
|
|
|
|
|
* Side effect: this method will call OutputPage::preventClickjacking()
|
|
|
|
|
* when a link is builded.
|
|
|
|
|
*
|
|
|
|
|
* @return String
|
|
|
|
|
*/
|
|
|
|
|
protected function markPatrolledLink() {
|
2011-11-10 13:06:52 +00:00
|
|
|
global $wgUseRCPatrol;
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
|
|
|
|
|
if ( $this->mMarkPatrolledLink === null ) {
|
|
|
|
|
// Prepare a change patrol link, if applicable
|
2011-11-10 13:06:52 +00:00
|
|
|
if ( $wgUseRCPatrol && $this->mNewPage->userCan( 'patrol', $this->getUser() ) ) {
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
// If we've been given an explicit change identifier, use it; saves time
|
|
|
|
|
if ( $this->mRcidMarkPatrolled ) {
|
|
|
|
|
$rcid = $this->mRcidMarkPatrolled;
|
|
|
|
|
$rc = RecentChange::newFromId( $rcid );
|
|
|
|
|
// Already patrolled?
|
|
|
|
|
$rcid = is_object( $rc ) && !$rc->getAttribute( 'rc_patrolled' ) ? $rcid : 0;
|
|
|
|
|
} else {
|
|
|
|
|
// Look for an unpatrolled change corresponding to this diff
|
|
|
|
|
$db = wfGetDB( DB_SLAVE );
|
|
|
|
|
$change = RecentChange::newFromConds(
|
|
|
|
|
array(
|
|
|
|
|
// Redundant user,timestamp condition so we can use the existing index
|
|
|
|
|
'rc_user_text' => $this->mNewRev->getRawUserText(),
|
|
|
|
|
'rc_timestamp' => $db->timestamp( $this->mNewRev->getTimestamp() ),
|
|
|
|
|
'rc_this_oldid' => $this->mNewid,
|
|
|
|
|
'rc_last_oldid' => $this->mOldid,
|
|
|
|
|
'rc_patrolled' => 0
|
|
|
|
|
),
|
|
|
|
|
__METHOD__
|
|
|
|
|
);
|
|
|
|
|
if ( $change instanceof RecentChange ) {
|
|
|
|
|
$rcid = $change->mAttribs['rc_id'];
|
|
|
|
|
$this->mRcidMarkPatrolled = $rcid;
|
|
|
|
|
} else {
|
|
|
|
|
// None found
|
|
|
|
|
$rcid = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Build the link
|
|
|
|
|
if ( $rcid ) {
|
2011-11-10 13:06:52 +00:00
|
|
|
$this->getOutput()->preventClickjacking();
|
2011-11-16 04:37:17 +00:00
|
|
|
$token = $this->getUser()->getEditToken( $rcid );
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
$this->mMarkPatrolledLink = ' <span class="patrollink">[' . Linker::linkKnown(
|
|
|
|
|
$this->mNewPage,
|
2011-11-10 13:06:52 +00:00
|
|
|
$this->msg( 'markaspatrolleddiff' )->escaped(),
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
array(),
|
|
|
|
|
array(
|
|
|
|
|
'action' => 'markpatrolled',
|
|
|
|
|
'rcid' => $rcid,
|
|
|
|
|
'token' => $token,
|
|
|
|
|
)
|
|
|
|
|
) . ']</span>';
|
|
|
|
|
} else {
|
|
|
|
|
$this->mMarkPatrolledLink = '';
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$this->mMarkPatrolledLink = '';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $this->mMarkPatrolledLink;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-19 21:44:20 +00:00
|
|
|
/**
|
|
|
|
|
* @param $rev Revision
|
|
|
|
|
* @return String
|
|
|
|
|
*/
|
2010-11-07 16:28:11 +00:00
|
|
|
protected function revisionDeleteLink( $rev ) {
|
|
|
|
|
$link = '';
|
2011-11-10 13:06:52 +00:00
|
|
|
$user = $this->getUser();
|
|
|
|
|
$canHide = $user->isAllowed( 'deleterevision' );
|
2010-11-07 16:28:11 +00:00
|
|
|
// Show del/undel link if:
|
|
|
|
|
// (a) the user can delete revisions, or
|
|
|
|
|
// (b) the user can view deleted revision *and* this one is deleted
|
2011-11-10 13:06:52 +00:00
|
|
|
if ( $canHide || ( $rev->getVisibility() && $user->isAllowed( 'deletedhistory' ) ) ) {
|
|
|
|
|
if ( !$rev->userCan( Revision::DELETED_RESTRICTED, $user ) ) {
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
$link = Linker::revDeleteLinkDisabled( $canHide ); // revision was hidden from sysops
|
2010-11-07 16:28:11 +00:00
|
|
|
} else {
|
|
|
|
|
$query = array(
|
|
|
|
|
'type' => 'revision',
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
'target' => $rev->getTitle()->getPrefixedDBkey(),
|
2010-11-07 16:28:11 +00:00
|
|
|
'ids' => $rev->getId()
|
|
|
|
|
);
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
$link = Linker::revDeleteLink( $query,
|
2010-11-07 16:28:11 +00:00
|
|
|
$rev->isDeleted( Revision::DELETED_RESTRICTED ), $canHide );
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
2010-11-07 16:28:11 +00:00
|
|
|
$link = '   ' . $link . ' ';
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
2010-11-07 16:28:11 +00:00
|
|
|
return $link;
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-11-07 16:28:11 +00:00
|
|
|
* Show the new revision of the page.
|
2004-04-17 07:37:55 +00:00
|
|
|
*/
|
2010-11-07 16:28:11 +00:00
|
|
|
function renderNewRevision() {
|
|
|
|
|
wfProfileIn( __METHOD__ );
|
2011-11-10 13:06:52 +00:00
|
|
|
$out = $this->getOutput();
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
$revHeader = $this->getRevisionHeader( $this->mNewRev );
|
2010-12-11 05:32:48 +00:00
|
|
|
# Add "current version as of X" title
|
2011-11-10 13:06:52 +00:00
|
|
|
$out->addHTML( "<hr class='diff-hr' />
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
<h2 class='diff-currentversion-title'>{$revHeader}</h2>\n" );
|
2010-12-11 05:32:48 +00:00
|
|
|
# Page content may be handled by a hooked call instead...
|
2011-11-10 13:06:52 +00:00
|
|
|
if ( wfRunHooks( 'ArticleContentOnDiff', array( $this, $out ) ) ) {
|
2010-12-11 05:32:48 +00:00
|
|
|
$this->loadNewText();
|
2011-11-14 18:28:01 +00:00
|
|
|
$out->setRevisionId( $this->mNewid );
|
2011-11-10 13:06:52 +00:00
|
|
|
$out->setArticleFlag( true );
|
2011-02-12 04:06:22 +00:00
|
|
|
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
if ( $this->mNewPage->isCssJsSubpage() || $this->mNewPage->isCssOrJsPage() ) {
|
2010-12-11 05:32:48 +00:00
|
|
|
// Stolen from Article::view --AG 2007-10-11
|
|
|
|
|
// Give hooks a chance to customise the output
|
|
|
|
|
// @TODO: standardize this crap into one function
|
2011-11-10 13:06:52 +00:00
|
|
|
if ( wfRunHooks( 'ShowRawCssJs', array( $this->mNewtext, $this->mNewPage, $out ) ) ) {
|
2010-12-11 05:32:48 +00:00
|
|
|
// Wrap the whole lot in a <pre> and don't parse
|
|
|
|
|
$m = array();
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
preg_match( '!\.(css|js)$!u', $this->mNewPage->getText(), $m );
|
2011-11-10 13:06:52 +00:00
|
|
|
$out->addHTML( "<pre class=\"mw-code mw-{$m[1]}\" dir=\"ltr\">\n" );
|
|
|
|
|
$out->addHTML( htmlspecialchars( $this->mNewtext ) );
|
|
|
|
|
$out->addHTML( "\n</pre>\n" );
|
2010-12-11 05:32:48 +00:00
|
|
|
}
|
2011-11-14 18:28:01 +00:00
|
|
|
} elseif ( !wfRunHooks( 'ArticleViewCustom', array( $this->mNewtext, $this->mNewPage, $out ) ) ) {
|
|
|
|
|
// Handled by extension
|
|
|
|
|
} else {
|
2011-11-17 20:21:54 +00:00
|
|
|
// Normal page
|
2011-11-14 18:28:01 +00:00
|
|
|
$wikiPage = WikiPage::factory( $this->mNewPage );
|
|
|
|
|
|
|
|
|
|
$parserOptions = ParserOptions::newFromContext( $this->getContext() );
|
|
|
|
|
$parserOptions->enableLimitReport();
|
|
|
|
|
$parserOptions->setTidy( true );
|
|
|
|
|
|
|
|
|
|
if ( !$this->mNewRev->isCurrent() ) {
|
|
|
|
|
$parserOptions->setEditSection( false );
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-17 20:21:54 +00:00
|
|
|
$parserOutput = $wikiPage->getParserOutput( $parserOptions, $this->mNewid );
|
2011-11-14 18:28:01 +00:00
|
|
|
|
2011-11-17 20:21:54 +00:00
|
|
|
# WikiPage::getParserOutput() should not return false, but just in case
|
2011-11-14 18:28:01 +00:00
|
|
|
if( $parserOutput ) {
|
|
|
|
|
$out->addParserOutput( $parserOutput );
|
2011-02-12 04:06:22 +00:00
|
|
|
}
|
2010-12-11 05:32:48 +00:00
|
|
|
}
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
2010-11-07 16:28:11 +00:00
|
|
|
# Add redundant patrol link on bottom...
|
2011-11-10 13:06:52 +00:00
|
|
|
$out->addHTML( $this->markPatrolledLink() );
|
2010-11-07 16:28:11 +00:00
|
|
|
|
2008-04-06 18:16:38 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2004-04-17 07:37:55 +00:00
|
|
|
/**
|
2011-11-10 13:06:52 +00:00
|
|
|
* Get the diff text, send it to the OutputPage object
|
2010-11-07 16:28:11 +00:00
|
|
|
* Returns false if the diff could not be generated, otherwise returns true
|
2011-06-01 16:27:46 +00:00
|
|
|
*
|
|
|
|
|
* @return bool
|
2004-04-17 07:37:55 +00:00
|
|
|
*/
|
2010-11-07 16:28:11 +00:00
|
|
|
function showDiff( $otitle, $ntitle, $notice = '' ) {
|
|
|
|
|
$diff = $this->getDiff( $otitle, $ntitle, $notice );
|
|
|
|
|
if ( $diff === false ) {
|
2011-11-10 13:06:52 +00:00
|
|
|
$this->getOutput()->addWikiMsg( 'missing-article', "<nowiki>(fixme, bug)</nowiki>", '' );
|
2010-11-07 16:28:11 +00:00
|
|
|
return false;
|
|
|
|
|
} else {
|
|
|
|
|
$this->showDiffStyle();
|
2011-11-10 13:06:52 +00:00
|
|
|
$this->getOutput()->addHTML( $diff );
|
2010-11-07 16:28:11 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-04-17 07:37:55 +00:00
|
|
|
|
|
|
|
|
/**
|
2010-11-07 16:28:11 +00:00
|
|
|
* Add style sheets and supporting JS for diff display.
|
|
|
|
|
*/
|
|
|
|
|
function showDiffStyle() {
|
2011-11-10 13:06:52 +00:00
|
|
|
$this->getOutput()->addModuleStyles( 'mediawiki.action.history.diff' );
|
2010-11-07 16:28:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get complete diff table, including header
|
2004-04-17 07:37:55 +00:00
|
|
|
*
|
2010-11-07 16:28:11 +00:00
|
|
|
* @param $otitle Title: old title
|
|
|
|
|
* @param $ntitle Title: new title
|
|
|
|
|
* @param $notice String: HTML between diff header and body
|
|
|
|
|
* @return mixed
|
2004-04-17 07:37:55 +00:00
|
|
|
*/
|
2010-11-07 16:28:11 +00:00
|
|
|
function getDiff( $otitle, $ntitle, $notice = '' ) {
|
|
|
|
|
$body = $this->getDiffBody();
|
|
|
|
|
if ( $body === false ) {
|
|
|
|
|
return false;
|
|
|
|
|
} else {
|
|
|
|
|
$multi = $this->getMultiNotice();
|
|
|
|
|
return $this->addHeader( $body, $otitle, $ntitle, $multi, $notice );
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-04-17 07:37:55 +00:00
|
|
|
|
|
|
|
|
/**
|
2010-11-07 16:28:11 +00:00
|
|
|
* Get the diff table body, without header
|
2004-04-17 07:37:55 +00:00
|
|
|
*
|
2010-11-18 20:34:02 +00:00
|
|
|
* @return mixed (string/false)
|
2004-04-17 07:37:55 +00:00
|
|
|
*/
|
2010-11-18 20:34:02 +00:00
|
|
|
public function getDiffBody() {
|
2010-11-07 16:28:11 +00:00
|
|
|
global $wgMemc;
|
2008-04-06 18:16:38 +00:00
|
|
|
wfProfileIn( __METHOD__ );
|
2010-11-07 16:28:11 +00:00
|
|
|
$this->mCacheHit = true;
|
|
|
|
|
// Check if the diff should be hidden from this user
|
2010-11-18 20:34:02 +00:00
|
|
|
if ( !$this->loadRevisionData() ) {
|
2011-02-10 16:04:19 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
2010-11-18 20:34:02 +00:00
|
|
|
return false;
|
2011-11-10 13:06:52 +00:00
|
|
|
} elseif ( $this->mOldRev && !$this->mOldRev->userCan( Revision::DELETED_TEXT, $this->getUser() ) ) {
|
2011-02-10 16:04:19 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
2010-11-18 20:34:02 +00:00
|
|
|
return false;
|
2011-11-10 13:06:52 +00:00
|
|
|
} elseif ( $this->mNewRev && !$this->mNewRev->userCan( Revision::DELETED_TEXT, $this->getUser() ) ) {
|
2011-02-10 16:04:19 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
2010-11-18 20:34:02 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
// Short-circuit
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
// If mOldRev is false, it means that the
|
|
|
|
|
if ( $this->mOldRev === false || ( $this->mOldRev && $this->mNewRev
|
|
|
|
|
&& $this->mOldRev->getID() == $this->mNewRev->getID() ) )
|
2010-11-18 20:34:02 +00:00
|
|
|
{
|
2011-02-10 16:04:19 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
2010-11-07 16:28:11 +00:00
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
// Cacheable?
|
|
|
|
|
$key = false;
|
|
|
|
|
if ( $this->mOldid && $this->mNewid ) {
|
2010-11-18 20:34:02 +00:00
|
|
|
$key = wfMemcKey( 'diff', 'version', MW_DIFF_VERSION,
|
|
|
|
|
'oldid', $this->mOldid, 'newid', $this->mNewid );
|
2010-11-07 16:28:11 +00:00
|
|
|
// Try cache
|
|
|
|
|
if ( !$this->mRefreshCache ) {
|
|
|
|
|
$difftext = $wgMemc->get( $key );
|
|
|
|
|
if ( $difftext ) {
|
|
|
|
|
wfIncrStats( 'diff_cache_hit' );
|
|
|
|
|
$difftext = $this->localiseLineNumbers( $difftext );
|
|
|
|
|
$difftext .= "\n<!-- diff cache key $key -->\n";
|
|
|
|
|
wfProfileOut( __METHOD__ );
|
|
|
|
|
return $difftext;
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
2010-11-07 16:28:11 +00:00
|
|
|
} // don't try to load but save the result
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
2010-11-07 16:28:11 +00:00
|
|
|
$this->mCacheHit = false;
|
2004-04-17 07:37:55 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
// Loadtext is permission safe, this just clears out the diff
|
|
|
|
|
if ( !$this->loadText() ) {
|
|
|
|
|
wfProfileOut( __METHOD__ );
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2004-04-17 07:37:55 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
$difftext = $this->generateDiffBody( $this->mOldtext, $this->mNewtext );
|
2004-04-17 07:37:55 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
// Save to cache for 7 days
|
|
|
|
|
if ( !wfRunHooks( 'AbortDiffCache', array( &$this ) ) ) {
|
|
|
|
|
wfIncrStats( 'diff_uncacheable' );
|
2010-11-18 20:34:02 +00:00
|
|
|
} elseif ( $key !== false && $difftext !== false ) {
|
2010-11-07 16:28:11 +00:00
|
|
|
wfIncrStats( 'diff_cache_miss' );
|
2010-11-27 19:01:51 +00:00
|
|
|
$wgMemc->set( $key, $difftext, 7 * 86400 );
|
2010-11-07 16:28:11 +00:00
|
|
|
} else {
|
|
|
|
|
wfIncrStats( 'diff_uncacheable' );
|
|
|
|
|
}
|
|
|
|
|
// Replace line numbers with the text in the user's language
|
|
|
|
|
if ( $difftext !== false ) {
|
|
|
|
|
$difftext = $this->localiseLineNumbers( $difftext );
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
2008-04-06 18:16:38 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
2010-11-07 16:28:11 +00:00
|
|
|
return $difftext;
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
|
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
/**
|
|
|
|
|
* Make sure the proper modules are loaded before we try to
|
|
|
|
|
* make the diff
|
|
|
|
|
*/
|
|
|
|
|
private function initDiffEngines() {
|
|
|
|
|
global $wgExternalDiffEngine;
|
|
|
|
|
if ( $wgExternalDiffEngine == 'wikidiff' && !function_exists( 'wikidiff_do_diff' ) ) {
|
|
|
|
|
wfProfileIn( __METHOD__ . '-php_wikidiff.so' );
|
2011-04-10 14:21:37 +00:00
|
|
|
wfDl( 'php_wikidiff' );
|
2010-11-07 16:28:11 +00:00
|
|
|
wfProfileOut( __METHOD__ . '-php_wikidiff.so' );
|
|
|
|
|
}
|
2011-06-17 16:03:52 +00:00
|
|
|
elseif ( $wgExternalDiffEngine == 'wikidiff2' && !function_exists( 'wikidiff2_do_diff' ) ) {
|
2010-11-07 16:28:11 +00:00
|
|
|
wfProfileIn( __METHOD__ . '-php_wikidiff2.so' );
|
|
|
|
|
wfDl( 'wikidiff2' );
|
|
|
|
|
wfProfileOut( __METHOD__ . '-php_wikidiff2.so' );
|
|
|
|
|
}
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
/**
|
|
|
|
|
* Generate a diff, no caching
|
|
|
|
|
*
|
|
|
|
|
* @param $otext String: old text, must be already segmented
|
|
|
|
|
* @param $ntext String: new text, must be already segmented
|
|
|
|
|
*/
|
|
|
|
|
function generateDiffBody( $otext, $ntext ) {
|
|
|
|
|
global $wgExternalDiffEngine, $wgContLang;
|
2007-11-27 21:36:43 +00:00
|
|
|
|
2011-07-19 19:05:23 +00:00
|
|
|
wfProfileIn( __METHOD__ );
|
2011-07-13 22:57:04 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
$otext = str_replace( "\r\n", "\n", $otext );
|
|
|
|
|
$ntext = str_replace( "\r\n", "\n", $ntext );
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
$this->initDiffEngines();
|
2007-11-27 21:36:43 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
if ( $wgExternalDiffEngine == 'wikidiff' && function_exists( 'wikidiff_do_diff' ) ) {
|
|
|
|
|
# For historical reasons, external diff engine expects
|
|
|
|
|
# input text to be HTML-escaped already
|
|
|
|
|
$otext = htmlspecialchars ( $wgContLang->segmentForDiff( $otext ) );
|
|
|
|
|
$ntext = htmlspecialchars ( $wgContLang->segmentForDiff( $ntext ) );
|
2011-07-19 19:05:23 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
2011-04-19 14:04:00 +00:00
|
|
|
return $wgContLang->unsegmentForDiff( wikidiff_do_diff( $otext, $ntext, 2 ) ) .
|
2010-11-07 16:28:11 +00:00
|
|
|
$this->debug( 'wikidiff1' );
|
2008-08-05 19:40:29 +00:00
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
if ( $wgExternalDiffEngine == 'wikidiff2' && function_exists( 'wikidiff2_do_diff' ) ) {
|
|
|
|
|
# Better external diff engine, the 2 may some day be dropped
|
|
|
|
|
# This one does the escaping and segmenting itself
|
|
|
|
|
wfProfileIn( 'wikidiff2_do_diff' );
|
|
|
|
|
$text = wikidiff2_do_diff( $otext, $ntext, 2 );
|
|
|
|
|
$text .= $this->debug( 'wikidiff2' );
|
|
|
|
|
wfProfileOut( 'wikidiff2_do_diff' );
|
2011-07-19 19:05:23 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
2010-11-07 16:28:11 +00:00
|
|
|
return $text;
|
|
|
|
|
}
|
|
|
|
|
if ( $wgExternalDiffEngine != 'wikidiff3' && $wgExternalDiffEngine !== false ) {
|
|
|
|
|
# Diff via the shell
|
|
|
|
|
global $wgTmpDirectory;
|
|
|
|
|
$tempName1 = tempnam( $wgTmpDirectory, 'diff_' );
|
|
|
|
|
$tempName2 = tempnam( $wgTmpDirectory, 'diff_' );
|
|
|
|
|
|
|
|
|
|
$tempFile1 = fopen( $tempName1, "w" );
|
|
|
|
|
if ( !$tempFile1 ) {
|
|
|
|
|
wfProfileOut( __METHOD__ );
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
$tempFile2 = fopen( $tempName2, "w" );
|
|
|
|
|
if ( !$tempFile2 ) {
|
|
|
|
|
wfProfileOut( __METHOD__ );
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
fwrite( $tempFile1, $otext );
|
|
|
|
|
fwrite( $tempFile2, $ntext );
|
|
|
|
|
fclose( $tempFile1 );
|
|
|
|
|
fclose( $tempFile2 );
|
|
|
|
|
$cmd = wfEscapeShellArg( $wgExternalDiffEngine, $tempName1, $tempName2 );
|
|
|
|
|
wfProfileIn( __METHOD__ . "-shellexec" );
|
|
|
|
|
$difftext = wfShellExec( $cmd );
|
|
|
|
|
$difftext .= $this->debug( "external $wgExternalDiffEngine" );
|
|
|
|
|
wfProfileOut( __METHOD__ . "-shellexec" );
|
|
|
|
|
unlink( $tempName1 );
|
|
|
|
|
unlink( $tempName2 );
|
2011-02-10 16:04:19 +00:00
|
|
|
wfProfileOut( __METHOD__ );
|
2010-11-07 16:28:11 +00:00
|
|
|
return $difftext;
|
2004-08-30 23:17:04 +00:00
|
|
|
}
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
# Native PHP diff
|
|
|
|
|
$ota = explode( "\n", $wgContLang->segmentForDiff( $otext ) );
|
|
|
|
|
$nta = explode( "\n", $wgContLang->segmentForDiff( $ntext ) );
|
|
|
|
|
$diffs = new Diff( $ota, $nta );
|
|
|
|
|
$formatter = new TableDiffFormatter();
|
2011-02-10 16:04:19 +00:00
|
|
|
$difftext = $wgContLang->unsegmentForDiff( $formatter->format( $diffs ) ) .
|
|
|
|
|
wfProfileOut( __METHOD__ );
|
|
|
|
|
return $difftext;
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
/**
|
|
|
|
|
* Generate a debug comment indicating diff generating time,
|
|
|
|
|
* server node, and generator backend.
|
|
|
|
|
*/
|
2010-11-27 19:01:51 +00:00
|
|
|
protected function debug( $generator = "internal" ) {
|
2010-11-07 16:28:11 +00:00
|
|
|
global $wgShowHostnames;
|
|
|
|
|
if ( !$this->enableDebugComment ) {
|
|
|
|
|
return '';
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
2010-11-07 16:28:11 +00:00
|
|
|
$data = array( $generator );
|
2010-11-27 19:01:51 +00:00
|
|
|
if ( $wgShowHostnames ) {
|
2010-11-07 16:28:11 +00:00
|
|
|
$data[] = wfHostname();
|
|
|
|
|
}
|
|
|
|
|
$data[] = wfTimestamp( TS_DB );
|
|
|
|
|
return "<!-- diff generator: " .
|
|
|
|
|
implode( " ",
|
|
|
|
|
array_map(
|
|
|
|
|
"htmlspecialchars",
|
|
|
|
|
$data ) ) .
|
|
|
|
|
" -->\n";
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
|
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
/**
|
|
|
|
|
* Replace line numbers with the text in the user's language
|
|
|
|
|
*/
|
|
|
|
|
function localiseLineNumbers( $text ) {
|
|
|
|
|
return preg_replace_callback( '/<!--LINE (\d+)-->/',
|
|
|
|
|
array( &$this, 'localiseLineNumbersCb' ), $text );
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
function localiseLineNumbersCb( $matches ) {
|
|
|
|
|
if ( $matches[1] === '1' && $this->mReducedLineNumbers ) return '';
|
2011-11-10 13:06:52 +00:00
|
|
|
return $this->msg( 'lineno' )->numParams( $matches[1] )->escaped();
|
2010-11-07 16:28:11 +00:00
|
|
|
}
|
2006-10-03 13:00:52 +00:00
|
|
|
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
/**
|
|
|
|
|
* If there are revisions between the ones being compared, return a note saying so.
|
2010-11-18 00:08:37 +00:00
|
|
|
* @return string
|
2010-11-07 16:28:11 +00:00
|
|
|
*/
|
|
|
|
|
function getMultiNotice() {
|
2010-11-18 00:08:37 +00:00
|
|
|
if ( !is_object( $this->mOldRev ) || !is_object( $this->mNewRev ) ) {
|
|
|
|
|
return '';
|
|
|
|
|
} elseif ( !$this->mOldPage->equals( $this->mNewPage ) ) {
|
2010-11-07 16:28:11 +00:00
|
|
|
// Comparing two different pages? Count would be meaningless.
|
|
|
|
|
return '';
|
|
|
|
|
}
|
2004-04-17 07:37:55 +00:00
|
|
|
|
2011-04-05 23:28:39 +00:00
|
|
|
if ( $this->mOldRev->getTimestamp() > $this->mNewRev->getTimestamp() ) {
|
|
|
|
|
$oldRev = $this->mNewRev; // flip
|
|
|
|
|
$newRev = $this->mOldRev; // flip
|
|
|
|
|
} else { // normal case
|
|
|
|
|
$oldRev = $this->mOldRev;
|
|
|
|
|
$newRev = $this->mNewRev;
|
2010-11-07 16:28:11 +00:00
|
|
|
}
|
2005-08-31 02:22:05 +00:00
|
|
|
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
$nEdits = $this->mNewPage->countRevisionsBetween( $oldRev, $newRev );
|
2010-11-27 19:01:51 +00:00
|
|
|
if ( $nEdits > 0 ) {
|
2011-04-05 23:28:39 +00:00
|
|
|
$limit = 100; // use diff-multi-manyusers if too many users
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
$numUsers = $this->mNewPage->countAuthorsBetween( $oldRev, $newRev, $limit );
|
2010-11-18 00:08:37 +00:00
|
|
|
return self::intermediateEditsMsg( $nEdits, $numUsers, $limit );
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
2010-11-18 00:08:37 +00:00
|
|
|
return ''; // nothing
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
|
|
|
|
|
2010-11-18 00:08:37 +00:00
|
|
|
/**
|
|
|
|
|
* Get a notice about how many intermediate edits and users there are
|
|
|
|
|
* @param $numEdits int
|
|
|
|
|
* @param $numUsers int
|
|
|
|
|
* @param $limit int
|
|
|
|
|
* @return string
|
2010-11-27 19:01:51 +00:00
|
|
|
*/
|
2010-11-18 00:08:37 +00:00
|
|
|
public static function intermediateEditsMsg( $numEdits, $numUsers, $limit ) {
|
|
|
|
|
if ( $numUsers > $limit ) {
|
|
|
|
|
$msg = 'diff-multi-manyusers';
|
|
|
|
|
$numUsers = $limit;
|
|
|
|
|
} else {
|
|
|
|
|
$msg = 'diff-multi';
|
|
|
|
|
}
|
2011-11-10 13:06:52 +00:00
|
|
|
return wfMessage( $msg )->numParams( $numEdits, $numUsers )->parse();
|
2010-11-18 00:08:37 +00:00
|
|
|
}
|
2004-08-09 05:38:11 +00:00
|
|
|
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
/**
|
|
|
|
|
* Get a header for a specified revision.
|
|
|
|
|
*
|
|
|
|
|
* @param $rev Revision
|
|
|
|
|
* @param $complete String: 'complete' to get the header wrapped depending
|
|
|
|
|
* the visibility of the revision and a link to edit the page.
|
|
|
|
|
* @return String HTML fragment
|
|
|
|
|
*/
|
|
|
|
|
private function getRevisionHeader( Revision $rev, $complete = '' ) {
|
2011-11-10 13:06:52 +00:00
|
|
|
$lang = $this->getLang();
|
|
|
|
|
$user = $this->getUser();
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
$revtimestamp = $rev->getTimestamp();
|
2011-11-10 13:06:52 +00:00
|
|
|
$timestamp = $lang->userTimeAndDate( $revtimestamp, $user );
|
|
|
|
|
$dateofrev = $lang->userDate( $revtimestamp, $user );
|
|
|
|
|
$timeofrev = $lang->userTime( $revtimestamp, $user );
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
|
2011-11-10 13:06:52 +00:00
|
|
|
$header = $this->msg(
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
$rev->isCurrent() ? 'currentrev-asof' : 'revisionasof',
|
|
|
|
|
$timestamp,
|
|
|
|
|
$dateofrev,
|
|
|
|
|
$timeofrev
|
2011-11-10 13:06:52 +00:00
|
|
|
)->escaped();
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
|
|
|
|
|
if ( $complete !== 'complete' ) {
|
|
|
|
|
return $header;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$title = $rev->getTitle();
|
|
|
|
|
|
|
|
|
|
$header = Linker::linkKnown( $title, $header, array(),
|
|
|
|
|
array( 'oldid' => $rev->getID() ) );
|
|
|
|
|
|
2011-11-10 13:06:52 +00:00
|
|
|
if ( $rev->userCan( Revision::DELETED_TEXT, $user ) ) {
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
$editQuery = array( 'action' => 'edit' );
|
|
|
|
|
if ( !$rev->isCurrent() ) {
|
|
|
|
|
$editQuery['oldid'] = $rev->getID();
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-10 13:06:52 +00:00
|
|
|
$msg = $this->msg( $title->userCan( 'edit', $user ) ? 'editold' : 'viewsourceold' )->escaped();
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
$header .= ' (' . Linker::linkKnown( $title, $msg, array(), $editQuery ) . ')';
|
|
|
|
|
if ( $rev->isDeleted( Revision::DELETED_TEXT ) ) {
|
|
|
|
|
$header = Html::rawElement( 'span', array( 'class' => 'history-deleted' ), $header );
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$header = Html::rawElement( 'span', array( 'class' => 'history-deleted' ), $header );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $header;
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
/**
|
|
|
|
|
* Add the header to a diff body
|
2011-06-01 16:27:46 +00:00
|
|
|
*
|
|
|
|
|
* @return string
|
2010-11-07 16:28:11 +00:00
|
|
|
*/
|
2011-06-29 10:51:15 +00:00
|
|
|
function addHeader( $diff, $otitle, $ntitle, $multi = '', $notice = '' ) {
|
2011-07-23 19:03:54 +00:00
|
|
|
// shared.css sets diff in interface language/dir, but the actual content
|
|
|
|
|
// is often in a different language, mostly the page content language/dir
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
$tableClass = 'diff diff-contentalign-' . htmlspecialchars( $this->getDiffLang()->alignStart() );
|
2011-06-19 18:53:55 +00:00
|
|
|
$header = "<table class='$tableClass'>";
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
|
|
|
|
|
if ( !$diff && !$otitle ) {
|
2010-11-07 16:28:11 +00:00
|
|
|
$header .= "
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
<tr valign='top'>
|
|
|
|
|
<td class='diff-ntitle'>{$ntitle}</td>
|
|
|
|
|
</tr>";
|
|
|
|
|
$multiColspan = 1;
|
2010-11-07 16:28:11 +00:00
|
|
|
} else {
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
if ( $diff ) { // Safari/Chrome show broken output if cols not used
|
|
|
|
|
$header .= "
|
|
|
|
|
<col class='diff-marker' />
|
|
|
|
|
<col class='diff-content' />
|
|
|
|
|
<col class='diff-marker' />
|
|
|
|
|
<col class='diff-content' />";
|
|
|
|
|
$colspan = 2;
|
|
|
|
|
$multiColspan = 4;
|
|
|
|
|
} else {
|
|
|
|
|
$colspan = 1;
|
|
|
|
|
$multiColspan = 2;
|
|
|
|
|
}
|
|
|
|
|
$header .= "
|
|
|
|
|
<tr valign='top'>
|
|
|
|
|
<td colspan='$colspan' class='diff-otitle'>{$otitle}</td>
|
|
|
|
|
<td colspan='$colspan' class='diff-ntitle'>{$ntitle}</td>
|
|
|
|
|
</tr>";
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
2010-11-07 16:28:11 +00:00
|
|
|
|
|
|
|
|
if ( $multi != '' ) {
|
|
|
|
|
$header .= "<tr><td colspan='{$multiColspan}' align='center' class='diff-multi'>{$multi}</td></tr>";
|
|
|
|
|
}
|
|
|
|
|
if ( $notice != '' ) {
|
|
|
|
|
$header .= "<tr><td colspan='{$multiColspan}' align='center'>{$notice}</td></tr>";
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
return $header . $diff . "</table>";
|
2008-03-21 11:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
/**
|
|
|
|
|
* Use specified text instead of loading from the database
|
|
|
|
|
*/
|
|
|
|
|
function setText( $oldText, $newText ) {
|
|
|
|
|
$this->mOldtext = $oldText;
|
|
|
|
|
$this->mNewtext = $newText;
|
|
|
|
|
$this->mTextLoaded = 2;
|
|
|
|
|
$this->mRevisionsLoaded = true;
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
2011-07-23 19:03:54 +00:00
|
|
|
/**
|
|
|
|
|
* Set the language in which the diff text is written
|
|
|
|
|
* (Defaults to page content language).
|
|
|
|
|
* @since 1.19
|
|
|
|
|
*/
|
2011-09-04 16:09:58 +00:00
|
|
|
function setTextLanguage( $lang ) {
|
2011-07-23 19:03:54 +00:00
|
|
|
$this->mDiffLang = wfGetLangObj( $lang );
|
|
|
|
|
}
|
|
|
|
|
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
/**
|
|
|
|
|
* Load revision IDs
|
|
|
|
|
*/
|
|
|
|
|
private function loadRevisionIds() {
|
|
|
|
|
if ( $this->mRevisionsIdsLoaded ) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->mRevisionsIdsLoaded = true;
|
|
|
|
|
|
|
|
|
|
$old = $this->mOldid;
|
|
|
|
|
$new = $this->mNewid;
|
|
|
|
|
|
|
|
|
|
if ( $new === 'prev' ) {
|
|
|
|
|
# Show diff between revision $old and the previous one.
|
|
|
|
|
# Get previous one from DB.
|
|
|
|
|
$this->mNewid = intval( $old );
|
2011-11-10 13:06:52 +00:00
|
|
|
$this->mOldid = $this->getTitle()->getPreviousRevisionID( $this->mNewid );
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
} elseif ( $new === 'next' ) {
|
|
|
|
|
# Show diff between revision $old and the next one.
|
|
|
|
|
# Get next one from DB.
|
|
|
|
|
$this->mOldid = intval( $old );
|
2011-11-10 13:06:52 +00:00
|
|
|
$this->mNewid = $this->getTitle()->getNextRevisionID( $this->mOldid );
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
if ( $this->mNewid === false ) {
|
|
|
|
|
# if no result, NewId points to the newest old revision. The only newer
|
|
|
|
|
# revision is cur, which is "0".
|
|
|
|
|
$this->mNewid = 0;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$this->mOldid = intval( $old );
|
|
|
|
|
$this->mNewid = intval( $new );
|
2011-11-10 13:06:52 +00:00
|
|
|
wfRunHooks( 'NewDifferenceEngine', array( $this->getTitle(), &$this->mOldid, &$this->mNewid, $old, $new ) );
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
/**
|
|
|
|
|
* Load revision metadata for the specified articles. If newid is 0, then compare
|
|
|
|
|
* the old article in oldid to the current article; if oldid is 0, then
|
|
|
|
|
* compare the current article to the immediately previous one (ignoring the
|
|
|
|
|
* value of newid).
|
|
|
|
|
*
|
|
|
|
|
* If oldid is false, leave the corresponding revision object set
|
|
|
|
|
* to false. This is impossible via ordinary user input, and is provided for
|
|
|
|
|
* API convenience.
|
2011-06-01 16:27:46 +00:00
|
|
|
*
|
|
|
|
|
* @return bool
|
2010-11-07 16:28:11 +00:00
|
|
|
*/
|
|
|
|
|
function loadRevisionData() {
|
|
|
|
|
if ( $this->mRevisionsLoaded ) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
// Whether it succeeds or fails, we don't want to try again
|
|
|
|
|
$this->mRevisionsLoaded = true;
|
|
|
|
|
|
|
|
|
|
$this->loadRevisionIds();
|
|
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
// Load the new revision object
|
|
|
|
|
$this->mNewRev = $this->mNewid
|
|
|
|
|
? Revision::newFromId( $this->mNewid )
|
2011-11-10 13:06:52 +00:00
|
|
|
: Revision::newFromTitle( $this->getTitle() );
|
Big cleanup to DifferenceEngine:
* Call Linker methods statically
* Factorised a lot of duplicate code, such as "Mark patrolled" links, revisions headers, etc.
* Removed showFirstRevision() and made that case be handled through the normal showDiffPage(). In such case, the header will look like a normal diff page, except it is centred. For this, addHeader() will now center the "new revision" header if the string passed to the "old revision" header and the diff is empty. getDiffBody() will also return an empty string if $mOldRev is false.
* Showing only one revision when the previous was not found will also ask to unhide the revision is deleted as in normal case
* Backed out code that generates the revision header from loadRevisionData() so that this function does not make a mix of backend and UI stuff. Factorised the code in getRevisionHeader().
* Lazy-load page's language and revisions IDs (in case of "prev", "next", etc. are passed) instead of doing that in constructor.
* Made a good part of links compatible with Special:ComparePages, such as navigation links, "undo", etc. that links to the title corresponding to the revision and not the given title in the constuctor.
* "Current revision as of" can also be displayed on the old revision, useful when comparing two current revisions in Special:ComparePages
* Removed navigation, undo and rollback links when comparing two different pages, this can confuses users thinking they are comparing two revisions of the same page. Also clicking on a "undo" link in such case will give "revision not found".
* Check if the user can read the revisions before sending a external editor file
2011-10-05 19:55:04 +00:00
|
|
|
|
2011-06-01 16:27:46 +00:00
|
|
|
if ( !$this->mNewRev instanceof Revision ) {
|
2010-11-07 16:28:11 +00:00
|
|
|
return false;
|
2011-06-01 16:27:46 +00:00
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
// Update the new revision ID in case it was 0 (makes life easier doing UI stuff)
|
|
|
|
|
$this->mNewid = $this->mNewRev->getId();
|
|
|
|
|
$this->mNewPage = $this->mNewRev->getTitle();
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
// Load the old revision object
|
|
|
|
|
$this->mOldRev = false;
|
2010-11-27 19:01:51 +00:00
|
|
|
if ( $this->mOldid ) {
|
2010-11-07 16:28:11 +00:00
|
|
|
$this->mOldRev = Revision::newFromId( $this->mOldid );
|
|
|
|
|
} elseif ( $this->mOldid === 0 ) {
|
|
|
|
|
$rev = $this->mNewRev->getPrevious();
|
2010-11-27 19:01:51 +00:00
|
|
|
if ( $rev ) {
|
2010-11-07 16:28:11 +00:00
|
|
|
$this->mOldid = $rev->getId();
|
|
|
|
|
$this->mOldRev = $rev;
|
|
|
|
|
} else {
|
|
|
|
|
// No previous revision; mark to show as first-version only.
|
|
|
|
|
$this->mOldid = false;
|
|
|
|
|
$this->mOldRev = false;
|
|
|
|
|
}
|
2010-11-27 19:01:51 +00:00
|
|
|
} /* elseif ( $this->mOldid === false ) leave mOldRev false; */
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2010-11-27 19:01:51 +00:00
|
|
|
if ( is_null( $this->mOldRev ) ) {
|
2010-11-07 16:28:11 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
if ( $this->mOldRev ) {
|
|
|
|
|
$this->mOldPage = $this->mOldRev->getTitle();
|
2007-05-16 17:57:00 +00:00
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
return true;
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2004-08-09 05:38:11 +00:00
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
/**
|
|
|
|
|
* Load the text of the revisions, as well as revision data.
|
2011-06-01 16:27:46 +00:00
|
|
|
*
|
|
|
|
|
* @return bool
|
2010-11-07 16:28:11 +00:00
|
|
|
*/
|
|
|
|
|
function loadText() {
|
|
|
|
|
if ( $this->mTextLoaded == 2 ) {
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
// Whether it succeeds or fails, we don't want to try again
|
|
|
|
|
$this->mTextLoaded = 2;
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
if ( !$this->loadRevisionData() ) {
|
|
|
|
|
return false;
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2010-11-07 16:28:11 +00:00
|
|
|
if ( $this->mOldRev ) {
|
|
|
|
|
$this->mOldtext = $this->mOldRev->getText( Revision::FOR_THIS_USER );
|
|
|
|
|
if ( $this->mOldtext === false ) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ( $this->mNewRev ) {
|
|
|
|
|
$this->mNewtext = $this->mNewRev->getText( Revision::FOR_THIS_USER );
|
|
|
|
|
if ( $this->mNewtext === false ) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2010-11-07 16:28:11 +00:00
|
|
|
return true;
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
2010-11-07 16:28:11 +00:00
|
|
|
/**
|
|
|
|
|
* Load the text of the new revision, not the old one
|
2011-06-01 16:27:46 +00:00
|
|
|
*
|
|
|
|
|
* @return bool
|
2010-11-07 16:28:11 +00:00
|
|
|
*/
|
|
|
|
|
function loadNewText() {
|
|
|
|
|
if ( $this->mTextLoaded >= 1 ) {
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
$this->mTextLoaded = 1;
|
2003-04-14 23:10:40 +00:00
|
|
|
}
|
2010-11-07 16:28:11 +00:00
|
|
|
if ( !$this->loadRevisionData() ) {
|
|
|
|
|
return false;
|
2004-08-30 23:45:05 +00:00
|
|
|
}
|
2010-11-07 16:28:11 +00:00
|
|
|
$this->mNewtext = $this->mNewRev->getText( Revision::FOR_THIS_USER );
|
|
|
|
|
return true;
|
2004-04-17 07:37:55 +00:00
|
|
|
}
|
2008-09-24 09:44:45 +00:00
|
|
|
}
|