From 683618fd33264246e36c5f6d785c0d465b4d2f5e Mon Sep 17 00:00:00 2001 From: Guy Van den Broeck Date: Thu, 21 Aug 2008 00:45:13 +0000 Subject: [PATCH] Added button for Visual Comparison to history page, previous and next diff buttons follow that choice consistently and diff pages have a link to switch from/to source/visual comparison --- includes/Article.php | 10 +- includes/DifferenceEngine.php | 34 +++- includes/PageHistory.php | 276 +++++++++++++++++------------- languages/messages/MessagesEn.php | 3 + maintenance/language/messages.inc | 3 + skins/common/diff.css | 6 + skins/common/history.js | 48 ++++++ 7 files changed, 254 insertions(+), 126 deletions(-) diff --git a/includes/Article.php b/includes/Article.php index b0b9db78bf..135ad8b16e 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -51,14 +51,14 @@ class Article { $this->mTitle =& $title; $this->mOldId = $oldId; } - + /** * Constructor from an article article * @param $id The article ID to load */ public static function newFromID( $id ) { $t = Title::newFromID( $id ); - + return $t == null ? null : new Article( $t ); } @@ -730,7 +730,9 @@ class Article { if ( !is_null( $diff ) ) { $wgOut->setPageTitle( $this->mTitle->getPrefixedText() ); - $de = new DifferenceEngine( $this->mTitle, $oldid, $diff, $rcid, $purge ); + $diff = $wgRequest->getVal( 'diff' ); + $htmldiff = $wgRequest->getVal( 'htmldiff' ); + $de = new DifferenceEngine( $this->mTitle, $oldid, $diff, $rcid, $purge, $htmldiff); // DifferenceEngine directly fetched the revision: $this->mRevIdFetched = $de->mNewid; $de->showDiffPage( $diffOnly ); @@ -1397,7 +1399,7 @@ class Article { */ function doEdit( $text, $summary, $flags = 0, $baseRevId = false, $user = null ) { global $wgUser, $wgDBtransactions, $wgUseAutomaticEditSummaries; - + if ($user == null) { $user = $wgUser; } diff --git a/includes/DifferenceEngine.php b/includes/DifferenceEngine.php index 9eed21b124..7f549da0a1 100644 --- a/includes/DifferenceEngine.php +++ b/includes/DifferenceEngine.php @@ -27,6 +27,7 @@ class DifferenceEngine { var $mOldRev, $mNewRev; var $mRevisionsLoaded = false; // Have the revisions been loaded var $mTextLoaded = 0; // How many text blobs have been loaded, 0, 1 or 2? + var $htmldiff; /**#@-*/ /** @@ -37,7 +38,7 @@ class DifferenceEngine { * @param $rcid Integer: ??? FIXME (default 0) * @param $refreshCache boolean If set, refreshes the diff cache */ - function __construct( $titleObj = null, $old = 0, $new = 0, $rcid = 0, $refreshCache = false ) { + function __construct( $titleObj = null, $old = 0, $new = 0, $rcid = 0, $refreshCache = false , $htmldiff = false) { $this->mTitle = $titleObj; wfDebug("DifferenceEngine old '$old' new '$new' rcid '$rcid'\n"); @@ -67,6 +68,7 @@ class DifferenceEngine { } $this->mRcidMarkPatrolled = intval($rcid); # force it to be an integer $this->mRefreshCache = $refreshCache; + $this->htmldiff = $htmldiff; } function getTitle() { @@ -202,13 +204,14 @@ CONTROL; $patrol = ''; } + $htmldiffarg = $this->htmlDiffArgument(); $prevlink = $sk->makeKnownLinkObj( $this->mTitle, wfMsgHtml( 'previousdiff' ), - 'diff=prev&oldid='.$this->mOldid, '', '', 'id="differences-prevlink"' ); + 'diff=prev&oldid='.$this->mOldid.$htmldiffarg, '', '', 'id="differences-prevlink"' ); if ( $this->mNewRev->isCurrent() ) { $nextlink = ' '; } else { $nextlink = $sk->makeKnownLinkObj( $this->mTitle, wfMsgHtml( 'nextdiff' ), - 'diff=next&oldid='.$this->mNewid, '', '', 'id="differences-nextlink"' ); + 'diff=next&oldid='.$this->mNewid.$htmldiffarg, '', '', 'id="differences-nextlink"' ); } $oldminor = ''; @@ -266,14 +269,18 @@ CONTROL; '
' . $newminor . $sk->revComment( $this->mNewRev, !$diffOnly, true ) . $rdel . "
" . '
' . $nextlink . $patrol . '
'; - if( $wgEnableHtmlDiff ) { + if( $wgEnableHtmlDiff && $this->htmldiff) { $multi = $this->getMultiNotice(); + $wgOut->addHTML('
'.$sk->makeKnownLinkObj( $this->mTitle, wfMsgHtml( 'wikicodecomparison' ), + 'diff='.$this->mNewid.'&oldid='.$this->mOldid.'&htmldiff=0', '', '', 'id="differences-switchtype"' ).'
'); $wgOut->addHTML( $this->addHeader( '', $oldHeader, $newHeader, $multi ) ); $this->renderHtmlDiff(); } else { - + if($wgEnableHtmlDiff){ + $wgOut->addHTML('
'.$sk->makeKnownLinkObj( $this->mTitle, wfMsgHtml( 'visualcomparison' ), + 'diff='.$this->mNewid.'&oldid='.$this->mOldid.'&htmldiff=1', '', '', 'id="differences-switchtype"' ).'
'); + } $this->showDiff( $oldHeader, $newHeader ); - if( !$diffOnly ) { $this->renderNewRevision(); } @@ -422,7 +429,7 @@ CONTROL; # $sk = $wgUser->getSkin(); - $nextlink = $sk->makeKnownLinkObj( $this->mTitle, wfMsgHtml( 'nextdiff' ), 'diff=next&oldid='.$this->mNewid, '', '', 'id="differences-nextlink"' ); + $nextlink = $sk->makeKnownLinkObj( $this->mTitle, wfMsgHtml( 'nextdiff' ), 'diff=next&oldid='.$this->mNewid.$this->htmlDiffArgument(), '', '', 'id="differences-nextlink"' ); $header = "
{$this->mOldtitle}
" . $sk->revUserTools( $this->mNewRev ) . "
" . $sk->revComment( $this->mNewRev ) . "
" . @@ -436,6 +443,19 @@ CONTROL; wfProfileOut( __METHOD__ ); } + function htmlDiffArgument(){ + global $wgEnableHtmlDiff; + if($wgEnableHtmlDiff){ + if($this->htmldiff){ + return '&htmldiff=1'; + }else{ + return '&htmldiff=0'; + } + }else{ + return ''; + } + } + /** * Get the diff text, send it to $wgOut * Returns false if the diff could not be generated, otherwise returns true diff --git a/includes/PageHistory.php b/includes/PageHistory.php index 1b56349d6a..5ea8461d9f 100644 --- a/includes/PageHistory.php +++ b/includes/PageHistory.php @@ -44,7 +44,7 @@ class PageHistory { function getArticle() { return $this->mArticle; } - + function getTitle() { return $this->mTitle; } @@ -74,8 +74,8 @@ class PageHistory { * Allow client caching. */ if( $wgOut->checkLastModified( $this->mArticle->getTouched() ) ) - /* Client cache fresh and headers sent, nothing more to do. */ - return; + /* Client cache fresh and headers sent, nothing more to do. */ + return; wfProfileIn( __METHOD__ ); @@ -123,41 +123,41 @@ class PageHistory { $wgOut->redirect( $wgTitle->getLocalURL( "action=history&limit={$limit}&dir=prev" ) ); return; } - + /** * Add date selector to quickly get to a certain time */ $year = $wgRequest->getInt( 'year' ); $month = $wgRequest->getInt( 'month' ); - + $action = htmlspecialchars( $wgScript ); $wgOut->addHTML( - Xml::fieldset( wfMsg( 'history-search' ), false, array( 'id' => 'mw-history-search' ) ) . + Xml::fieldset( wfMsg( 'history-search' ), false, array( 'id' => 'mw-history-search' ) ) . "
" . - Xml::hidden( 'title', $this->mTitle->getPrefixedDBKey() ) . "\n" . - Xml::hidden( 'action', 'history' ) . "\n" . - $this->getDateMenu( $year, $month ) . ' ' . - Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "\n" . + Xml::hidden( 'title', $this->mTitle->getPrefixedDBKey() ) . "\n" . + Xml::hidden( 'action', 'history' ) . "\n" . + $this->getDateMenu( $year, $month ) . ' ' . + Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "\n" . '
' - ); + ); - wfRunHooks( 'PageHistoryBeforeList', array( &$this->mArticle ) ); + wfRunHooks( 'PageHistoryBeforeList', array( &$this->mArticle ) ); - /** - * Do the list - */ - $pager = new PageHistoryPager( $this, $year, $month ); - $this->linesonpage = $pager->getNumRows(); - $wgOut->addHTML( + /** + * Do the list + */ + $pager = new PageHistoryPager( $this, $year, $month ); + $this->linesonpage = $pager->getNumRows(); + $wgOut->addHTML( $pager->getNavigationBar() . $this->beginHistoryList() . $pager->getBody() . $this->endHistoryList() . $pager->getNavigationBar() - ); - wfProfileOut( __METHOD__ ); + ); + wfProfileOut( __METHOD__ ); } - + /** * @return string Formatted HTML * @param int $year @@ -183,10 +183,10 @@ class PageHistory { $encYear = ''; } return Xml::label( wfMsg( 'year' ), 'year' ) . ' '. - Xml::input( 'year', 4, $encYear, array('id' => 'year', 'maxlength' => 4) ) . + Xml::input( 'year', 4, $encYear, array('id' => 'year', 'maxlength' => 4) ) . ' '. - Xml::label( wfMsg( 'month' ), 'month' ) . ' '. - Xml::monthSelector( $encMonth, -1 ); + Xml::label( wfMsg( 'month' ), 'month' ) . ' '. + Xml::monthSelector( $encMonth, -1 ); } /** @@ -195,12 +195,38 @@ class PageHistory { * @return string HTML output */ function beginHistoryList() { - global $wgTitle, $wgScript; + global $wgTitle, $wgScript, $wgEnableHtmlDiff; $this->lastdate = ''; $s = wfMsgExt( 'histlegend', array( 'parse') ); $s .= Xml::openElement( 'form', array( 'action' => $wgScript ) ); $s .= Xml::hidden( 'title', $wgTitle->getPrefixedDbKey() ); - $s .= $this->submitButton(); + if($wgEnableHtmlDiff){ + $s .= Xml::hidden( 'htmldiff', 0 , array('id' => 'htmldiff')); + $s .= $this->submitButton( wfMsg( 'visualcomparison'), + array( + 'id' => 'submithtmldiff1', + 'class' => 'historysubmit', + 'accesskey' => wfMsg( 'accesskey-visualcomparison' ), + 'title' => wfMsg( 'tooltip-compareselectedversions' ), + ) + ); + $s .= $this->submitButton( wfMsg( 'wikicodecomparison'), + array( + 'id' => 'submitsourcediff1', + 'class' => 'historysubmit', + 'accesskey' => wfMsg( 'accesskey-compareselectedversions' ), + 'title' => wfMsg( 'tooltip-compareselectedversions' ), + ) + ); + }else{ + $s .= $this->submitButton( wfMsg( 'compareselectedversions'), + array( + 'class' => 'historysubmit', + 'accesskey' => wfMsg( 'accesskey-compareselectedversions' ), + 'title' => wfMsg( 'tooltip-compareselectedversions' ), + ) + ); + } $s .= ''; - $s .= $this->submitButton( array( 'id' => 'historysubmit' ) ); + if($wgEnableHtmlDiff){ + $s .= $this->submitButton( wfMsg( 'visualcomparison'), + array( + 'id' => 'submithtmldiff2', + 'class' => 'historysubmit', + 'accesskey' => wfMsg( 'accesskey-visualcomparison' ), + 'title' => wfMsg( 'tooltip-compareselectedversions' ), + ) + ); + $s .= $this->submitButton( wfMsg( 'wikicodecomparison'), + array( + 'id' => 'submitsourcediff2', + 'class' => 'historysubmit', + 'accesskey' => wfMsg( 'accesskey-compareselectedversions' ), + 'title' => wfMsg( 'tooltip-compareselectedversions' ), + ) + ); + }else{ + $s .= $this->submitButton( wfMsg( 'compareselectedversions'), + array( + 'class' => 'historysubmit', + 'accesskey' => wfMsg( 'accesskey-compareselectedversions' ), + 'title' => wfMsg( 'tooltip-compareselectedversions' ), + ) + ); + } $s .= ''; return $s; } @@ -220,19 +272,13 @@ class PageHistory { /** * Creates a submit button * - * @param array $bits optional CSS ID + * @param array $attributes attributes * @return string HTML output for the submit button */ - function submitButton( $bits = array() ) { + function submitButton($message, $attributes = array() ) { # Disable submit button if history has 1 revision only if ( $this->linesonpage > 1 ) { - return Xml::submitButton( wfMsg( 'compareselectedversions' ), - $bits + array( - 'class' => 'historysubmit', - 'accesskey' => wfMsg( 'accesskey-compareselectedversions' ), - 'title' => wfMsg( 'tooltip-compareselectedversions' ), - ) - ); + return Xml::submitButton( $message , $attributes ); } else { return ''; } @@ -267,19 +313,19 @@ class PageHistory { if( $wgUser->isAllowed( 'deleterevision' ) ) { $revdel = SpecialPage::getTitleFor( 'Revisiondelete' ); if( $firstInList ) { - // We don't currently handle well changing the top revision's settings + // We don't currently handle well changing the top revision's settings $del = $this->message['rev-delundel']; } else if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) { - // If revision was hidden from sysops + // If revision was hidden from sysops $del = $this->message['rev-delundel']; } else { $del = $this->mSkin->makeKnownLinkObj( $revdel, - $this->message['rev-delundel'], + $this->message['rev-delundel'], 'target=' . urlencode( $this->mTitle->getPrefixedDbkey() ) . '&oldid=' . urlencode( $rev->getId() ) ); // Bolden oversighted content if( $rev->isDeleted( Revision::DELETED_RESTRICTED ) ) - $del = "$del"; + $del = "$del"; } $s .= " ($del) "; } @@ -312,16 +358,16 @@ class PageHistory { && !$this->mTitle->getUserPermissionsErrors( 'edit', $wgUser ) && $latest ) { $tools[] = '' - . $this->mSkin->buildRollbackLink( $rev ) - . ''; + . $this->mSkin->buildRollbackLink( $rev ) + . ''; } if( $this->mTitle->quickUserCan( 'edit' ) && - !$rev->isDeleted( Revision::DELETED_TEXT ) && - !$next->rev_deleted & Revision::DELETED_TEXT ) { + !$rev->isDeleted( Revision::DELETED_TEXT ) && + !$next->rev_deleted & Revision::DELETED_TEXT ) { $undolink = $this->mSkin->makeKnownLinkObj( - $this->mTitle, - wfMsgHtml( 'editundo' ), + $this->mTitle, + wfMsgHtml( 'editundo' ), 'action=edit&undoafter=' . $next->rev_id . '&undo=' . $rev->getId() ); $tools[] = "{$undolink}"; @@ -338,16 +384,16 @@ class PageHistory { } /** - * Create a link to view this revision of the page - * @param Revision $rev - * @returns string - */ + * Create a link to view this revision of the page + * @param Revision $rev + * @returns string + */ function revLink( $rev ) { global $wgLang; $date = $wgLang->timeanddate( wfTimestamp(TS_MW, $rev->getTimestamp()), true ); if( $rev->userCan( Revision::DELETED_TEXT ) ) { $link = $this->mSkin->makeKnownLinkObj( - $this->mTitle, $date, "oldid=" . $rev->getId() ); + $this->mTitle, $date, "oldid=" . $rev->getId() ); } else { $link = $date; } @@ -358,30 +404,30 @@ class PageHistory { } /** - * Create a diff-to-current link for this revision for this page - * @param Revision $rev - * @param Bool $latest, this is the latest revision of the page? - * @returns string - */ + * Create a diff-to-current link for this revision for this page + * @param Revision $rev + * @param Bool $latest, this is the latest revision of the page? + * @returns string + */ function curLink( $rev, $latest ) { $cur = $this->message['cur']; if( $latest || !$rev->userCan( Revision::DELETED_TEXT ) ) { return $cur; } else { return $this->mSkin->makeKnownLinkObj( - $this->mTitle, $cur, + $this->mTitle, $cur, 'diff=' . $this->getLatestID() . "&oldid=" . $rev->getId() ); } } /** - * Create a diff-to-previous link for this revision for this page. - * @param Revision $prevRev, the previous revision - * @param mixed $next, the newer revision - * @param int $counter, what row on the history list this is - * @returns string - */ + * Create a diff-to-previous link for this revision for this page. + * @param Revision $prevRev, the previous revision + * @param mixed $next, the newer revision + * @param int $counter, what row on the history list this is + * @returns string + */ function lastLink( $prevRev, $next, $counter ) { $last = $this->message['last']; # $next may either be a Row, null, or "unkown" @@ -392,17 +438,17 @@ class PageHistory { } elseif( $next === 'unknown' ) { # Next row probably exists but is unknown, use an oldid=prev link return $this->mSkin->makeKnownLinkObj( - $this->mTitle, - $last, + $this->mTitle, + $last, "diff=" . $prevRev->getId() . "&oldid=prev" ); } elseif( !$prevRev->userCan(Revision::DELETED_TEXT) || !$nextRev->userCan(Revision::DELETED_TEXT) ) { return $last; } else { return $this->mSkin->makeKnownLinkObj( - $this->mTitle, - $last, + $this->mTitle, + $last, "diff=" . $prevRev->getId() . "&oldid={$next->rev_id}" - /*, + /*, '', '', "tabindex={$counter}"*/ ); @@ -431,8 +477,8 @@ class PageHistory { /** @todo: move title texts to javascript */ if ( $firstInList ) { $first = Xml::element( 'input', array_merge( - $radio, - array( + $radio, + array( 'style' => 'visibility:hidden', 'name' => 'oldid' ) ) ); $checkmark = array( 'checked' => 'checked' ); @@ -443,15 +489,15 @@ class PageHistory { $checkmark = array(); } $first = Xml::element( 'input', array_merge( - $radio, - $checkmark, - array( 'name' => 'oldid' ) ) ); + $radio, + $checkmark, + array( 'name' => 'oldid' ) ) ); $checkmark = array(); } $second = Xml::element( 'input', array_merge( - $radio, - $checkmark, - array( 'name' => 'diff' ) ) ); + $radio, + $checkmark, + array( 'name' => 'diff' ) ) ); return $first . $second; } else { return ''; @@ -465,8 +511,8 @@ class PageHistory { $db = wfGetDB( DB_SLAVE ); $this->mLatestId = $db->selectField( 'page', "page_latest", - array( 'page_id' => $id ), - __METHOD__ ); + array( 'page_id' => $id ), + __METHOD__ ); } return $this->mLatestId; } @@ -480,23 +526,23 @@ class PageHistory { $dbr = wfGetDB( DB_SLAVE ); if ($direction == PageHistory::DIR_PREV) - list($dirs, $oper) = array("ASC", ">="); + list($dirs, $oper) = array("ASC", ">="); else /* $direction == PageHistory::DIR_NEXT */ - list($dirs, $oper) = array("DESC", "<="); + list($dirs, $oper) = array("DESC", "<="); if ($offset) - $offsets = array("rev_timestamp $oper '$offset'"); + $offsets = array("rev_timestamp $oper '$offset'"); else - $offsets = array(); + $offsets = array(); $page_id = $this->mTitle->getArticleID(); return $dbr->select( 'revision', - Revision::selectFields(), - array_merge(array("rev_page=$page_id"), $offsets), - __METHOD__, - array('ORDER BY' => "rev_timestamp $dirs", + Revision::selectFields(), + array_merge(array("rev_page=$page_id"), $offsets), + __METHOD__, + array('ORDER BY' => "rev_timestamp $dirs", 'USE INDEX' => 'page_timestamp', 'LIMIT' => $limit) ); } @@ -506,21 +552,21 @@ class PageHistory { global $wgUser, $wgShowUpdatedMarker; if ($this->mNotificationTimestamp !== NULL) - return $this->mNotificationTimestamp; + return $this->mNotificationTimestamp; if ($wgUser->isAnon() || !$wgShowUpdatedMarker) - return $this->mNotificationTimestamp = false; + return $this->mNotificationTimestamp = false; $dbr = wfGetDB(DB_SLAVE); $this->mNotificationTimestamp = $dbr->selectField( 'watchlist', 'wl_notificationtimestamp', - array( 'wl_namespace' => $this->mTitle->getNamespace(), + array( 'wl_namespace' => $this->mTitle->getNamespace(), 'wl_title' => $this->mTitle->getDBkey(), 'wl_user' => $wgUser->getId() - ), - __METHOD__ ); + ), + __METHOD__ ); // Don't use the special value reserved for telling whether the field is filled if ( is_null( $this->mNotificationTimestamp ) ) { @@ -541,10 +587,10 @@ class PageHistory { } $feed = new $wgFeedClasses[$type]( - $this->mTitle->getPrefixedText() . ' - ' . - wfMsgForContent( 'history-feed-title' ), - wfMsgForContent( 'history-feed-description' ), - $this->mTitle->getFullUrl( 'action=history' ) ); + $this->mTitle->getPrefixedText() . ' - ' . + wfMsgForContent( 'history-feed-title' ), + wfMsgForContent( 'history-feed-description' ), + $this->mTitle->getFullUrl( 'action=history' ) ); // Get a limit on number of feed entries. Provide a sane default // of 10 if none is defined (but limit to $wgFeedLimit max) @@ -552,7 +598,7 @@ class PageHistory { if( $limit > $wgFeedLimit || $limit < 1 ) { $limit = 10; } - $items = $this->fetchRevisions($limit, 0, PageHistory::DIR_NEXT); + $items = $this->fetchRevisions($limit, 0, PageHistory::DIR_NEXT); $feed->outHeader(); if( $items ) { @@ -568,12 +614,12 @@ class PageHistory { function feedEmpty() { global $wgOut; return new FeedItem( - wfMsgForContent( 'nohistory' ), - $wgOut->parse( wfMsgForContent( 'history-feed-empty' ) ), - $this->mTitle->getFullUrl(), - wfTimestamp( TS_MW ), + wfMsgForContent( 'nohistory' ), + $wgOut->parse( wfMsgForContent( 'history-feed-empty' ) ), + $this->mTitle->getFullUrl(), + wfTimestamp( TS_MW ), '', - $this->mTitle->getTalkPage()->getFullUrl() ); + $this->mTitle->getTalkPage()->getFullUrl() ); } /** @@ -588,27 +634,27 @@ class PageHistory { $rev = new Revision( $row ); $rev->setTitle( $this->mTitle ); $text = FeedUtils::formatDiffRow( $this->mTitle, - $this->mTitle->getPreviousRevisionID( $rev->getId() ), - $rev->getId(), - $rev->getTimestamp(), - $rev->getComment() ); + $this->mTitle->getPreviousRevisionID( $rev->getId() ), + $rev->getId(), + $rev->getTimestamp(), + $rev->getComment() ); if( $rev->getComment() == '' ) { global $wgContLang; $title = wfMsgForContent( 'history-feed-item-nocomment', - $rev->getUserText(), - $wgContLang->timeanddate( $rev->getTimestamp() ) ); + $rev->getUserText(), + $wgContLang->timeanddate( $rev->getTimestamp() ) ); } else { $title = $rev->getUserText() . ": " . $this->stripComment( $rev->getComment() ); } return new FeedItem( - $title, - $text, - $this->mTitle->getFullUrl( 'diff=' . $rev->getId() . '&oldid=prev' ), - $rev->getTimestamp(), - $rev->getUserText(), - $this->mTitle->getTalkPage()->getFullUrl() ); + $title, + $text, + $this->mTitle->getFullUrl( 'diff=' . $rev->getId() . '&oldid=prev' ), + $rev->getTimestamp(), + $rev->getUserText(), + $this->mTitle->getTalkPage()->getFullUrl() ); } /** @@ -652,7 +698,7 @@ class PageHistoryPager extends ReverseChronologicalPager { $latest = $this->mCounter == 1 && $this->mIsFirst; $firstInList = $this->mCounter == 1; $s = $this->mPageHistory->historyLine( $this->mLastRow, $row, $this->mCounter++, - $this->mPageHistory->getNotificationTimestamp(), $latest, $firstInList ); + $this->mPageHistory->getNotificationTimestamp(), $latest, $firstInList ); } else { $s = ''; } @@ -682,7 +728,7 @@ class PageHistoryPager extends ReverseChronologicalPager { $next = $this->mPastTheEndRow; } $s = $this->mPageHistory->historyLine( $this->mLastRow, $next, $this->mCounter++, - $this->mPageHistory->getNotificationTimestamp(), $latest, $firstInList ); + $this->mPageHistory->getNotificationTimestamp(), $latest, $firstInList ); } else { $s = ''; } diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 6b602529e8..0efbcfe3b0 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -1327,6 +1327,8 @@ Note that using the navigation links will reset this column.', 'difference' => '(Difference between revisions)', 'lineno' => 'Line $1:', 'compareselectedversions' => 'Compare selected versions', +'visualcomparison' => 'Visual comparison', +'wikicodecomparison' => 'Wikitext comparison', 'editundo' => 'undo', 'diff-multi' => '({{PLURAL:$1|One intermediate revision|$1 intermediate revisions}} not shown.)', 'diff-movedto' => 'Moved to', @@ -2746,6 +2748,7 @@ A temporary folder is missing.', 'accesskey-preview' => 'p', # do not translate or duplicate this message to other languages 'accesskey-diff' => 'v', # do not translate or duplicate this message to other languages 'accesskey-compareselectedversions' => 'v', # do not translate or duplicate this message to other languages +'accesskey-visualcomparison' => 'b', # do not translate or duplicate this message to other languages 'accesskey-watch' => 'w', # do not translate or duplicate this message to other languages 'accesskey-upload' => 's', # do not translate or duplicate this message to other languages diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index 92f0b09f79..9951184cc6 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -688,6 +688,8 @@ $wgMessageStructure = array( 'difference', 'lineno', 'compareselectedversions', + 'visualcomparison', + 'wikicodecomparison', 'editundo', 'diff-multi', 'diff-movedto', @@ -1910,6 +1912,7 @@ $wgMessageStructure = array( 'accesskey-preview', 'accesskey-diff', 'accesskey-compareselectedversions', + 'accesskey-visualcomparison', 'accesskey-watch', 'accesskey-upload', ), diff --git a/skins/common/diff.css b/skins/common/diff.css index d2075ba89b..23de7857cc 100644 --- a/skins/common/diff.css +++ b/skins/common/diff.css @@ -78,6 +78,12 @@ table.diff td div { /* * Styles for the HTML Diff */ +div.diff-switchtype{ + text-align: center; + font-weight: bold; + font-size: smaller; +} + span.diff-html-added { font-size: 100%; background-color: #20ff20 diff --git a/skins/common/history.js b/skins/common/history.js index 57e6184918..0611a0a4da 100644 --- a/skins/common/history.js +++ b/skins/common/history.js @@ -80,4 +80,52 @@ function histrowinit() { diffcheck(); } +// attach htmldiff event handler +function htmldiffsubmit() { + var hf = document.getElementById('submithtmldiff1'); + if (!hf) { + return; + } + hf.onclick = enablehtmldiff; + hf = document.getElementById('submithtmldiff2'); + if (!hf) { + return; + } + hf.onclick = enablehtmldiff; +} + +// change hidden field when choosing html compare +function enablehtmldiff() { + var hf = document.getElementById('htmldiff'); + if (!hf) { + return; + } + hf.value = 1; +} + +// attach source diff event handler +function sourcediffsubmit() { + var hf = document.getElementById('submitsourcediff1'); + if (!hf) { + return; + } + hf.onclick = disablehtmldiff; + hf = document.getElementById('submitsourcediff2'); + if (!hf) { + return; + } + hf.onclick = disablehtmldiff; +} + +// change hidden field when choosing source diff +function disablehtmldiff() { + var hf = document.getElementById('htmldiff'); + if (!hf) { + return; + } + hf.value = 0; +} + hookEvent("load", histrowinit); +hookEvent("load", htmldiffsubmit); +hookEvent("load", sourcediffsubmit); -- 2.20.1