Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add diff patch #105

Merged
merged 9 commits into from
Mar 22, 2019
Merged
12 changes: 8 additions & 4 deletions includes/ReviewHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,14 @@ public function getTemplate() {

$diff = new DifferenceEngine( null, $lastSeenId, 0 );

$template =
"<div id='watch-analytics-review-handler'>
$unReviewLink $reviewLink
<p>$bannerText</p>";
$template = "<div id='watch-analytics-review-handler'> $unReviewLink";

// Don't show "close banner" button when viewing full diff page
if ( !( $this->isDiff ) ) {
$template .= $reviewLink;
}

$template .= "<p>$bannerText</p>";

global $egWatchAnalyticsShowUnreviewDiff;
if ( $egWatchAnalyticsShowUnreviewDiff ) {
Expand Down
4 changes: 4 additions & 0 deletions modules/pendingreviews/ext.watchanalytics.pendingreviews.css
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ tr.pendingreviews-row-hover td {
background-color: #f9f9f9;
}

div.pending-review-diff td {
background-color: #fff;
}

.pendingreviews-legend {
float:right;
margin-bottom: 10px;
Expand Down
7 changes: 7 additions & 0 deletions modules/reviewhandler/reviewhandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@
rowLines.remove();
});

rowLines.css("background-color", "#00af89");
rowLines.html("<strong>Page reviewed!</strong>");

rowLines.fadeOut( 700, function() {
rowLines.remove();
});

});

});
Expand Down
47 changes: 24 additions & 23 deletions specials/SpecialPendingReviews.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,32 +300,33 @@ public function getStandardChangeRow( PendingReview $item, $rowCount ) {
$changes = $this->getPendingReviewChangesList( $combinedList );
$acceptChangesButton = null;

if ( count( $item->newRevisions ) ) {
$previousViewedChange = Revision::newFromRow( $item->newRevisions[0] )->getPrevious();
if ( $previousViewedChange ) {
$prevId = $previousViewedChange->getId();
$context = new DerivativeContext( RequestContext::getMain() );
$context->setTitle( $item->title );
$diff = new DifferenceEngine( $context, $prevId, 0 );
$diff->showDiffStyle();
$theDiff = $diff->getDiff( '<b>Last seen</b>', '<b>Current</b>' );

$numChars = strlen( $theDiff );
$numRows = substr_count( $theDiff, '<tr' );

if ( $numRows < $egPendingReviewMaxDiffRows && $numChars < $egPendingReviewMaxDiffChar ) {
$changes .= "<div class='pending-review-diff'>";
$changes .= $theDiff;
$changes .= '</div>';
$acceptChangesButton = $this->getAcceptChangeButton( $item );
}

}
}

if ( $item->title->isRedirect() ) {
$reviewButton = $this->getAcceptRedirectButton( $item );
} else {

if ( count( $item->newRevisions ) ) {
$previousViewedChange = Revision::newFromRow( $item->newRevisions[0] )->getPrevious();
if ( $previousViewedChange ) {
$prevId = $previousViewedChange->getId();
$context = new DerivativeContext( RequestContext::getMain() );
$context->setTitle( $item->title );
$diff = new DifferenceEngine( $context, $prevId, 0 );
$diff->showDiffStyle();
$theDiff = $diff->getDiff( '<b>Last seen</b>', '<b>Current</b>' );

$numChars = strlen( $theDiff );
$numRows = substr_count( $theDiff, '<tr' );

if ( $numRows < $egPendingReviewMaxDiffRows && $numChars < $egPendingReviewMaxDiffChar ) {
$changes .= "<div class='pending-review-diff'>";
$changes .= $theDiff;
$changes .= '</div>';
$acceptChangesButton = $this->getAcceptChangeButton( $item );
}

}
}

$reviewButton = $this->getReviewButton( $item );
}

Expand Down