X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FDifferenceEngine.php;h=8d96e3d4769a11a722ce8339610c0ac6629a052c;hb=72a4abe588a7511ed5a92a5e30f889c60d824c1a;hp=adc8f08e74a63b345c4a91327ffed4c675fc62c2;hpb=bdd943ce0cbd0e125e18e786845692214e370c45;p=lhc%2Fweb%2Fwiklou.git
diff --git a/includes/DifferenceEngine.php b/includes/DifferenceEngine.php
index adc8f08e74..8d96e3d476 100644
--- a/includes/DifferenceEngine.php
+++ b/includes/DifferenceEngine.php
@@ -1,15 +1,22 @@
mRcidMarkPatrolled = intval($rcid); # force it to be an integer
}
- function showDiffPage() {
- global $wgUser, $wgOut, $wgContLang, $wgUseExternalEditor, $wgUseRCPatrol;
+ function showDiffPage( $diffOnly = false ) {
+ global $wgUser, $wgOut, $wgUseExternalEditor, $wgUseRCPatrol;
$fname = 'DifferenceEngine::showDiffPage';
wfProfileIn( $fname );
@@ -118,6 +125,7 @@ CONTROL;
# is the first version of that article. In that case, V' does not exist.
if ( $this->mOldid === false ) {
$this->showFirstRevision();
+ $this->renderNewRevision(); // should we respect $diffOnly here or not?
wfProfileOut( $fname );
return;
}
@@ -171,22 +179,41 @@ CONTROL;
wfMsg( 'minoreditletter') ) . ' ';
}
- if ($this->mNewRev->mMinorEdit == 1) {
- $newminor = wfElement( 'span', array( 'class' => 'minor' ),
- wfMsg( 'minoreditletter') ) . ' ';
- }
+ if ($this->mNewRev->mMinorEdit == 1) {
+ $newminor = wfElement( 'span', array( 'class' => 'minor' ),
+ wfMsg( 'minoreditletter') ) . ' ';
+ }
$oldHeader = "{$this->mOldtitle}
" .
$sk->revUserTools( $this->mOldRev ) . "
" .
- $oldminor . $sk->revComment( $this->mOldRev, true ) . "
" .
+ $oldminor . $sk->revComment( $this->mOldRev, !$diffOnly ) . "
" .
$prevlink;
$newHeader = "{$this->mNewtitle}
" .
$sk->revUserTools( $this->mNewRev ) . " $rollback
" .
- $newminor . $sk->revComment( $this->mNewRev, true ) . "
" .
+ $newminor . $sk->revComment( $this->mNewRev, !$diffOnly ) . "
" .
$nextlink . $patrol;
$this->showDiff( $oldHeader, $newHeader );
+
+ if ( !$diffOnly )
+ $this->renderNewRevision();
+
+ wfProfileOut( $fname );
+ }
+
+ /**
+ * Show the new revision of the page.
+ */
+ function renderNewRevision() {
+ global $wgOut;
+ $fname = 'DifferenceEngine::renderNewRevision';
+ wfProfileIn( $fname );
+
$wgOut->addHTML( "
{$this->mPagetitle}
\n" );
+ #add deleted rev tag if needed
+ if ( !$this->mNewRev->userCan(Revision::DELETED_TEXT) ) {
+ $wgOut->addWikiText( wfMsg( 'rev-deleted-text-permission' ) );
+ }
if( !$this->mNewRev->isCurrent() ) {
$oldEditSectionSetting = $wgOut->parserOptions()->setEditSection( false );
@@ -196,7 +223,8 @@ CONTROL;
if( is_object( $this->mNewRev ) ) {
$wgOut->setRevisionId( $this->mNewRev->getId() );
}
- $wgOut->addSecondaryWikiText( $this->mNewtext );
+
+ $wgOut->addWikiTextTidy( $this->mNewtext );
if( !$this->mNewRev->isCurrent() ) {
$wgOut->parserOptions()->setEditSection( $oldEditSectionSetting );
@@ -254,15 +282,6 @@ CONTROL;
$wgOut->setSubtitle( wfMsg( 'difference' ) );
$wgOut->setRobotpolicy( 'noindex,nofollow' );
-
- # Show current revision
- #
- $wgOut->addHTML( "
{$this->mPagetitle}
\n" );
- if( is_object( $this->mNewRev ) ) {
- $wgOut->setRevisionId( $this->mNewRev->getId() );
- }
- $wgOut->addSecondaryWikiText( $this->mNewtext );
-
wfProfileOut( $fname );
}
@@ -277,6 +296,7 @@ CONTROL;
$wgOut->addWikitext( wfMsg( 'missingarticle', "(fixme, bug)" ) );
return false;
} else {
+ $wgOut->addStyle( 'common/diff.css' );
$wgOut->addHTML( $diff );
return true;
}
@@ -311,7 +331,7 @@ CONTROL;
$key = false;
if ( $this->mOldid && $this->mNewid ) {
// Try cache
- $key = wfMemcKey( 'diff', 'oldid', $this->mOldid, 'newid', $this->mNewid );
+ $key = wfMemcKey( 'diff', 'version', MW_DIFF_VERSION, 'oldid', $this->mOldid, 'newid', $this->mNewid );
$difftext = $wgMemc->get( $key );
if ( $difftext ) {
wfIncrStats( 'diff_cache_hit' );
@@ -322,9 +342,14 @@ CONTROL;
}
}
+ #loadtext is permission safe, this just clears out the diff
if ( !$this->loadText() ) {
wfProfileOut( $fname );
return false;
+ } else if ( $this->mOldRev && !$this->mOldRev->userCan(Revision::DELETED_TEXT) ) {
+ return '';
+ } else if ( $this->mNewRev && !$this->mNewRev->userCan(Revision::DELETED_TEXT) ) {
+ return '';
}
$difftext = $this->generateDiffBody( $this->mOldtext, $this->mNewtext );
@@ -463,11 +488,23 @@ CONTROL;
* Add the header to a diff body
*/
function addHeader( $diff, $otitle, $ntitle, $multi = '' ) {
+ global $wgOut;
+
+ if ( $this->mOldRev && $this->mOldRev->isDeleted(Revision::DELETED_TEXT) ) {
+ $otitle = ''.$otitle.'';
+ }
+ if ( $this->mNewRev && $this->mNewRev->isDeleted(Revision::DELETED_TEXT) ) {
+ $ntitle = ''.$ntitle.'';
+ }
$header = "
-
+
+
+
+
+
- {$otitle} |
- {$ntitle} |
+ {$otitle} |
+ {$ntitle} |
";
@@ -523,19 +560,17 @@ CONTROL;
$newLink = $this->mNewPage->escapeLocalUrl();
$this->mPagetitle = htmlspecialchars( wfMsg( 'currentrev' ) );
$newEdit = $this->mNewPage->escapeLocalUrl( 'action=edit' );
-
- $this->mNewtitle = "{$this->mPagetitle} ($timestamp)"
+
+ $this->mNewtitle = "{$this->mPagetitle} ($timestamp)"
. " (" . htmlspecialchars( wfMsg( 'editold' ) ) . ")";
} else {
$newLink = $this->mNewPage->escapeLocalUrl( 'oldid=' . $this->mNewid );
$newEdit = $this->mNewPage->escapeLocalUrl( 'action=edit&oldid=' . $this->mNewid );
- $newUndo = $this->mNewPage->escapeLocalUrl( 'action=edit&undo=' . $this->mNewid );
$this->mPagetitle = htmlspecialchars( wfMsg( 'revisionasof', $timestamp ) );
-
- $this->mNewtitle = "{$this->mPagetitle}"
- . " (" . htmlspecialchars( wfMsg( 'editold' ) ) . ")"
- . " (" . htmlspecialchars( wfMsg( 'editundo' ) ) . ")";
+
+ $this->mNewtitle = "{$this->mPagetitle}"
+ . " (" . htmlspecialchars( wfMsg( 'editold' ) ) . ")";
}
// Load the old revision object
@@ -564,8 +599,11 @@ CONTROL;
$t = $wgLang->timeanddate( $this->mOldRev->getTimestamp(), true );
$oldLink = $this->mOldPage->escapeLocalUrl( 'oldid=' . $this->mOldid );
$oldEdit = $this->mOldPage->escapeLocalUrl( 'action=edit&oldid=' . $this->mOldid );
- $this->mOldtitle = "" . htmlspecialchars( wfMsg( 'revisionasof', $t ) )
- . " (" . htmlspecialchars( wfMsg( 'editold' ) ) . ")";
+ $this->mOldtitle = "" . htmlspecialchars( wfMsg( 'revisionasof', $t ) )
+ . " (" . htmlspecialchars( wfMsg( 'editold' ) ) . ")";
+ //now that we considered old rev, we can make undo link (bug 8133, multi-edit undo)
+ $newUndo = $this->mNewPage->escapeLocalUrl( 'action=edit&undoafter=' . $this->mOldid . '&undo=' . $this->mNewid);
+ $this->mNewtitle .= " (" . htmlspecialchars( wfMsg( 'editundo' ) ) . ")";
}
return true;
@@ -587,13 +625,13 @@ CONTROL;
}
if ( $this->mOldRev ) {
// FIXME: permission tests
- $this->mOldtext = $this->mOldRev->getText();
+ $this->mOldtext = $this->mOldRev->revText();
if ( $this->mOldtext === false ) {
return false;
}
}
if ( $this->mNewRev ) {
- $this->mNewtext = $this->mNewRev->getText();
+ $this->mNewtext = $this->mNewRev->revText();
if ( $this->mNewtext === false ) {
return false;
}
@@ -631,8 +669,7 @@ define('USE_ASSERTS', function_exists('assert'));
/**
* @todo document
* @private
- * @package MediaWiki
- * @subpackage DifferenceEngine
+ * @addtogroup DifferenceEngine
*/
class _DiffOp {
var $type;
@@ -655,8 +692,7 @@ class _DiffOp {
/**
* @todo document
* @private
- * @package MediaWiki
- * @subpackage DifferenceEngine
+ * @addtogroup DifferenceEngine
*/
class _DiffOp_Copy extends _DiffOp {
var $type = 'copy';
@@ -676,8 +712,7 @@ class _DiffOp_Copy extends _DiffOp {
/**
* @todo document
* @private
- * @package MediaWiki
- * @subpackage DifferenceEngine
+ * @addtogroup DifferenceEngine
*/
class _DiffOp_Delete extends _DiffOp {
var $type = 'delete';
@@ -695,8 +730,7 @@ class _DiffOp_Delete extends _DiffOp {
/**
* @todo document
* @private
- * @package MediaWiki
- * @subpackage DifferenceEngine
+ * @addtogroup DifferenceEngine
*/
class _DiffOp_Add extends _DiffOp {
var $type = 'add';
@@ -714,8 +748,7 @@ class _DiffOp_Add extends _DiffOp {
/**
* @todo document
* @private
- * @package MediaWiki
- * @subpackage DifferenceEngine
+ * @addtogroup DifferenceEngine
*/
class _DiffOp_Change extends _DiffOp {
var $type = 'change';
@@ -752,8 +785,7 @@ class _DiffOp_Change extends _DiffOp {
*
* @author Geoffrey T. Dairiki, Tim Starling
* @private
- * @package MediaWiki
- * @subpackage DifferenceEngine
+ * @addtogroup DifferenceEngine
*/
class _DiffEngine
{
@@ -1174,8 +1206,7 @@ class _DiffEngine
* Class representing a 'diff' between two sequences of strings.
* @todo document
* @private
- * @package MediaWiki
- * @subpackage DifferenceEngine
+ * @addtogroup DifferenceEngine
*/
class Diff
{
@@ -1313,11 +1344,9 @@ class Diff
}
/**
- * FIXME: bad name.
- * @todo document
+ * @todo document, bad name.
* @private
- * @package MediaWiki
- * @subpackage DifferenceEngine
+ * @addtogroup DifferenceEngine
*/
class MappedDiff extends Diff
{
@@ -1380,8 +1409,7 @@ class MappedDiff extends Diff
* to obtain fancier outputs.
* @todo document
* @private
- * @package MediaWiki
- * @subpackage DifferenceEngine
+ * @addtogroup DifferenceEngine
*/
class DiffFormatter
{
@@ -1547,8 +1575,7 @@ define('NBSP', ' '); // iso-8859-x non-breaking space.
/**
* @todo document
* @private
- * @package MediaWiki
- * @subpackage DifferenceEngine
+ * @addtogroup DifferenceEngine
*/
class _HWLDF_WordAccumulator {
function _HWLDF_WordAccumulator () {
@@ -1560,9 +1587,12 @@ class _HWLDF_WordAccumulator {
function _flushGroup ($new_tag) {
if ($this->_group !== '') {
- if ($this->_tag == 'mark')
- $this->_line .= '' .
- htmlspecialchars ( $this->_group ) . '';
+ if ($this->_tag == 'ins')
+ $this->_line .= '' .
+ htmlspecialchars ( $this->_group ) . '';
+ elseif ($this->_tag == 'del')
+ $this->_line .= '' .
+ htmlspecialchars ( $this->_group ) . '';
else
$this->_line .= htmlspecialchars ( $this->_group );
}
@@ -1606,8 +1636,7 @@ class _HWLDF_WordAccumulator {
/**
* @todo document
* @private
- * @package MediaWiki
- * @subpackage DifferenceEngine
+ * @addtogroup DifferenceEngine
*/
class WordLevelDiff extends MappedDiff
{
@@ -1667,7 +1696,7 @@ class WordLevelDiff extends MappedDiff
if ($edit->type == 'copy')
$orig->addWords($edit->orig);
elseif ($edit->orig)
- $orig->addWords($edit->orig, 'mark');
+ $orig->addWords($edit->orig, 'del');
}
$lines = $orig->getLines();
wfProfileOut( $fname );
@@ -1683,7 +1712,7 @@ class WordLevelDiff extends MappedDiff
if ($edit->type == 'copy')
$closing->addWords($edit->closing);
elseif ($edit->closing)
- $closing->addWords($edit->closing, 'mark');
+ $closing->addWords($edit->closing, 'ins');
}
$lines = $closing->getLines();
wfProfileOut( $fname );
@@ -1695,8 +1724,7 @@ class WordLevelDiff extends MappedDiff
* Wikipedia Table style diff formatter.
* @todo document
* @private
- * @package MediaWiki
- * @subpackage DifferenceEngine
+ * @addtogroup DifferenceEngine
*/
class TableDiffFormatter extends DiffFormatter
{
@@ -1706,8 +1734,8 @@ class TableDiffFormatter extends DiffFormatter
}
function _block_header( $xbeg, $xlen, $ybeg, $ylen ) {
- $r = ' | \n" .
- ' |
\n";
+ $r = ' | \n" .
+ ' |
\n";
return $r;
}
@@ -1723,17 +1751,25 @@ class TableDiffFormatter extends DiffFormatter
# HTML-escape parameter before calling this
function addedLine( $line ) {
- return "+ | {$line} | ";
+ return $this->wrapLine( '+', 'diff-addedline', $line );
}
# HTML-escape parameter before calling this
function deletedLine( $line ) {
- return "- | {$line} | ";
+ return $this->wrapLine( '-', 'diff-deletedline', $line );
}
# HTML-escape parameter before calling this
function contextLine( $line ) {
- return " | {$line} | ";
+ return $this->wrapLine( ' ', 'diff-context', $line );
+ }
+
+ private function wrapLine( $marker, $class, $line ) {
+ if( $line !== '' ) {
+ // The wrapper is needed for 'overflow: auto' style to scroll properly
+ $line = "
$line
";
+ }
+ return "
$marker | $line | ";
}
function emptyLine() {