* @ingroup DifferenceEngine
*/
class DifferenceEngine extends ContextSource {
- /**#@+
- * @private
- */
- var $mOldid, $mNewid;
- var $mOldTags, $mNewTags;
+ public $mOldid;
+ public $mNewid;
+ private $mOldTags;
+ private $mNewTags;
+
/**
* @var Content
*/
- var $mOldContent, $mNewContent;
+ public $mOldContent;
+ public $mNewContent;
protected $mDiffLang;
/**
* @var Title
*/
- var $mOldPage, $mNewPage;
+ public $mOldPage;
+ public $mNewPage;
/**
* @var Revision
*/
- var $mOldRev, $mNewRev;
+ public $mOldRev;
+ public $mNewRev;
private $mRevisionsIdsLoaded = false; // Have the revisions IDs been loaded
- 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?
+ public $mRevisionsLoaded = false; // Have the revisions been loaded
+ public $mTextLoaded = 0; // How many text blobs have been loaded, 0, 1 or 2?
+ public $mCacheHit = false; // Was the diff fetched from cache?
/**
* 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;
+ public $enableDebugComment = false;
// If true, line X is not displayed when X is 1, for example to increase
// readability and conserve space with many small diffs.
* Constructor
* @param $context IContextSource context to use, anything else will be ignored
* @param $old Integer old ID we want to show and diff with.
- * @param $new String either 'prev' or 'next'.
+ * @param $new String|int either 'prev' or 'next'. Default: 0.
* @param $rcid Integer Deprecated, no longer used!
* @param $refreshCache boolean If set, refreshes the diff cache
* @param $unhide boolean If set, allow viewing deleted revs
*/
function __construct( $context = null, $old = 0, $new = 0, $rcid = 0,
- $refreshCache = false, $unhide = false )
- {
+ $refreshCache = false, $unhide = false
+ ) {
if ( $context instanceof IContextSource ) {
$this->setContext( $context );
}
$out->setPageTitle( $this->msg( 'difference-title', $this->mNewPage->getPrefixedText() ) );
$samePage = true;
} else {
- $out->setPageTitle( $this->msg( 'difference-title-multipage', $this->mOldPage->getPrefixedText(),
- $this->mNewPage->getPrefixedText() ) );
+ $out->setPageTitle( $this->msg( 'difference-title-multipage',
+ $this->mOldPage->getPrefixedText(), $this->mNewPage->getPrefixedText() ) );
$out->addSubtitle( $this->msg( 'difference-multipage' ) );
$samePage = false;
}
$rollback = '   ' . $rollbackLink;
}
}
- if ( !$this->mOldRev->isDeleted( Revision::DELETED_TEXT ) && !$this->mNewRev->isDeleted( Revision::DELETED_TEXT ) ) {
+
+ if ( !$this->mOldRev->isDeleted( Revision::DELETED_TEXT ) &&
+ !$this->mNewRev->isDeleted( Revision::DELETED_TEXT )
+ ) {
$undoLink = Html::element( 'a', array(
'href' => $this->mNewPage->getLocalURL( array(
'action' => 'edit',
foreach ( $revisionTools as $tool ) {
$formattedRevisionTools[] = $this->msg( 'parentheses' )->rawParams( $tool )->escaped();
}
- $newRevisionHeader = $this->getRevisionHeader( $this->mNewRev, 'complete' ) . ' ' . implode( ' ', $formattedRevisionTools );
+ $newRevisionHeader = $this->getRevisionHeader( $this->mNewRev, 'complete' ) .
+ ' ' . implode( ' ', $formattedRevisionTools );
$newChangeTags = ChangeTags::formatSummaryRow( $this->mNewTags, 'diff' );
$newHeader = '<div id="mw-diff-ntitle1"><strong>' . $newRevisionHeader . '</strong></div>' .
array( $msg ) );
} else {
# Give explanation and add a link to view the diff...
- $link = $this->getTitle()->getFullURL( $this->getRequest()->appendQueryValue( 'unhide', '1', true ) );
+ $query = $this->getRequest()->appendQueryValue( 'unhide', '1', true );
+ $link = $this->getTitle()->getFullURL( $query );
$msg = $suppressed ? 'rev-suppressed-unhide-diff' : 'rev-deleted-unhide-diff';
- $out->wrapWikiMsg( "<div id='mw-$msg' class='mw-warning plainlinks'>\n$1\n</div>\n", array( $msg, $link ) );
+ $out->wrapWikiMsg(
+ "<div id='mw-$msg' class='mw-warning plainlinks'>\n$1\n</div>\n",
+ array( $msg, $link )
+ );
}
# Otherwise, output a regular diff...
} else {
$notice = '';
if ( $deleted ) {
$msg = $suppressed ? 'rev-suppressed-diff-view' : 'rev-deleted-diff-view';
- $notice = "<div id='mw-$msg' class='mw-warning plainlinks'>\n" . $this->msg( $msg )->parse() . "</div>\n";
+ $notice = "<div id='mw-$msg' class='mw-warning plainlinks'>\n" .
+ $this->msg( $msg )->parse() .
+ "</div>\n";
}
$this->showDiff( $oldHeader, $newHeader, $notice );
if ( !$diffOnly ) {
$out->addHTML( "<hr class='diff-hr' />
<h2 class='diff-currentversion-title'>{$revHeader}</h2>\n" );
# Page content may be handled by a hooked call instead...
+ # @codingStandardsIgnoreStart Ignoring long lines.
if ( wfRunHooks( 'ArticleContentOnDiff', array( $this, $out ) ) ) {
$this->loadNewText();
$out->setRevisionId( $this->mNewid );
}
}
}
+ # @codingStandardsIgnoreEnd
+
# Add redundant patrol link on bottom...
$out->addHTML( $this->markPatrolledLink() );
* Get the diff text, send it to the OutputPage object
* Returns false if the diff could not be generated, otherwise returns true
*
+ * @param string|bool $otitle Header for old text or false
+ * @param string|bool $ntitle Header for new text or false
+ * @param string $notice
* @return bool
*/
function showDiff( $otitle, $ntitle, $notice = '' ) {
$body = $this->getDiffBody();
if ( $body === false ) {
return false;
- } else {
- $multi = $this->getMultiNotice();
- // Display a message when the diff is empty
- if ( $body === '' ) {
- $notice .= '<div class="mw-diff-empty">' . $this->msg( 'diff-empty' )->parse() . "</div>\n";
- }
- return $this->addHeader( $body, $otitle, $ntitle, $multi, $notice );
}
+
+ $multi = $this->getMultiNotice();
+ // Display a message when the diff is empty
+ if ( $body === '' ) {
+ $notice .= '<div class="mw-diff-empty">' .
+ $this->msg( 'diff-empty' )->parse() .
+ "</div>\n";
+ }
+
+ return $this->addHeader( $body, $otitle, $ntitle, $multi, $notice );
}
/**
if ( !$this->loadRevisionData() ) {
wfProfileOut( __METHOD__ );
return false;
- } elseif ( $this->mOldRev && !$this->mOldRev->userCan( Revision::DELETED_TEXT, $this->getUser() ) ) {
+ } elseif ( $this->mOldRev &&
+ !$this->mOldRev->userCan( Revision::DELETED_TEXT, $this->getUser() )
+ ) {
wfProfileOut( __METHOD__ );
return false;
- } elseif ( $this->mNewRev && !$this->mNewRev->userCan( Revision::DELETED_TEXT, $this->getUser() ) ) {
+ } elseif ( $this->mNewRev &&
+ !$this->mNewRev->userCan( Revision::DELETED_TEXT, $this->getUser() )
+ ) {
wfProfileOut( __METHOD__ );
return false;
}
$editQuery['oldid'] = $rev->getID();
}
- $msg = $this->msg( $title->quickUserCan( 'edit', $user ) ? 'editold' : 'viewsourceold' )->escaped();
+ $key = $title->quickUserCan( 'edit', $user ) ? 'editold' : 'viewsourceold';
+ $msg = $this->msg( $key )->escaped();
$header .= ' ' . $this->msg( 'parentheses' )->rawParams(
Linker::linkKnown( $title, $msg, array(), $editQuery ) )->plain();
if ( $rev->isDeleted( Revision::DELETED_TEXT ) ) {
- $header = Html::rawElement( 'span', array( 'class' => 'history-deleted' ), $header );
+ $header = Html::rawElement(
+ 'span',
+ array( 'class' => 'history-deleted' ),
+ $header
+ );
}
} else {
$header = Html::rawElement( 'span', array( 'class' => 'history-deleted' ), $header );
}
if ( $multi != '' ) {
- $header .= "<tr><td colspan='{$multiColspan}' style='text-align: center;' class='diff-multi'>{$multi}</td></tr>";
+ $header .= "<tr><td colspan='{$multiColspan}' style='text-align: center;' " .
+ "class='diff-multi'>{$multi}</td></tr>";
}
if ( $notice != '' ) {
$header .= "<tr><td colspan='{$multiColspan}' style='text-align: center;'>{$notice}</td></tr>";
$this->loadRevisionIds();
// Load the new revision object
- $this->mNewRev = $this->mNewid
- ? Revision::newFromId( $this->mNewid )
- : Revision::newFromTitle( $this->getTitle(), false, Revision::READ_NORMAL );
+ if ( $this->mNewid ) {
+ $this->mNewRev = Revision::newFromId( $this->mNewid );
+ } else {
+ $this->mNewRev = Revision::newFromTitle(
+ $this->getTitle(),
+ false,
+ Revision::READ_NORMAL
+ );
+ }
if ( !$this->mNewRev instanceof Revision ) {
return false;