Enhanced RC: Add a "view changes since my last visit" link
authorMatmaRex <matma.rex@gmail.com>
Wed, 24 Jul 2013 11:45:17 +0000 (13:45 +0200)
committerNikerabbit <niklas.laxstrom@gmail.com>
Mon, 26 Aug 2013 15:47:59 +0000 (15:47 +0000)
It's only shown if there are any unviewed changes and if as least one
of previous versions was viewed already.

* Added new message 'enhancedrc-since-last-visit' for link text
* Added 'enhancedrc-history' to replace 'hist' in enhanced RC context

Bug: 51901
Change-Id: Id74fe88bb2a1879651935ac56e9cdcb2e54b331f

includes/ChangesList.php
languages/messages/MessagesEn.php
languages/messages/MessagesQqq.php
maintenance/language/messages.inc

index f3dcf67..9c441af 100644 (file)
@@ -122,7 +122,7 @@ class ChangesList extends ContextSource {
        private function preCacheMessages() {
                if ( !isset( $this->message ) ) {
                        foreach ( array(
-                               'cur', 'diff', 'hist', 'last', 'blocklink', 'history',
+                               'cur', 'diff', 'hist', 'enhancedrc-history', 'last', 'blocklink', 'history',
                                'semicolon-separator', 'pipe-separator' ) as $msg
                        ) {
                                $this->message[$msg] = $this->msg( $msg )->escaped();
@@ -976,12 +976,30 @@ class EnhancedChangesList extends ChangesList {
                $r .= $this->getLanguage()->getDirMark();
 
                $queryParams['curid'] = $curId;
+
                # Changes message
-               $n = count( $block );
                static $nchanges = array();
+               static $sinceLastVisitMsg = array();
+
+               $n = count( $block );
                if ( !isset( $nchanges[$n] ) ) {
                        $nchanges[$n] = $this->msg( 'nchanges' )->numParams( $n )->escaped();
                }
+
+               $sinceLast = 0;
+               $unvisitedOldid = null;
+               foreach ( $block as $rcObj ) {
+                       // Same logic as below inside main foreach
+                       if ( $rcObj->watched && $rcObj->mAttribs['rc_timestamp'] >= $rcObj->watched ) {
+                               $sinceLast++;
+                               $unvisitedOldid = $rcObj->mAttribs['rc_last_oldid'];
+                       }
+               }
+               if ( !isset( $sinceLastVisitMsg[$sinceLast] ) ) {
+                       $sinceLastVisitMsg[$sinceLast] =
+                               $this->msg( 'enhancedrc-since-last-visit' )->numParams( $sinceLast )->escaped();
+               }
+
                # Total change link
                $r .= ' ';
                $logtext = '';
@@ -991,17 +1009,28 @@ class EnhancedChangesList extends ChangesList {
                        } elseif ( $isnew ) {
                                $logtext .= $nchanges[$n];
                        } else {
-                               $params = $queryParams;
-                               $params['diff'] = $currentRevision;
-                               $params['oldid'] = $oldid;
-
                                $logtext .= Linker::link(
                                        $block[0]->getTitle(),
                                        $nchanges[$n],
                                        array(),
-                                       $params,
+                                       $queryParams + array(
+                                               'diff' => $currentRevision,
+                                               'oldid' => $oldid,
+                                       ),
                                        array( 'known', 'noclasses' )
                                );
+                               if ( $sinceLast > 0 && $sinceLast < $n ) {
+                                       $logtext .= $this->message['pipe-separator'] . Linker::link(
+                                               $block[0]->getTitle(),
+                                               $sinceLastVisitMsg[$sinceLast],
+                                               array(),
+                                               $queryParams + array(
+                                                       'diff' => $currentRevision,
+                                                       'oldid' => $unvisitedOldid,
+                                               ),
+                                               array( 'known', 'noclasses' )
+                                       );
+                               }
                        }
                }
 
@@ -1009,7 +1038,7 @@ class EnhancedChangesList extends ChangesList {
                if ( $allLogs ) {
                        // don't show history link for logs
                } elseif ( $namehidden || !$block[0]->getTitle()->exists() ) {
-                       $logtext .= $this->message['pipe-separator'] . $this->message['hist'];
+                       $logtext .= $this->message['pipe-separator'] . $this->message['enhancedrc-history'];
                } else {
                        $params = $queryParams;
                        $params['action'] = 'history';
@@ -1017,7 +1046,7 @@ class EnhancedChangesList extends ChangesList {
                        $logtext .= $this->message['pipe-separator'] .
                                Linker::linkKnown(
                                        $block[0]->getTitle(),
-                                       $this->message['hist'],
+                                       $this->message['enhancedrc-history'],
                                        array(),
                                        $params
                                );
index f98267b..72ea315 100644 (file)
@@ -2195,6 +2195,8 @@ Your email address is not revealed when other users contact you.',
 
 # Recent changes
 'nchanges'                          => '$1 {{PLURAL:$1|change|changes}}',
+'enhancedrc-since-last-visit'       => '$1 {{PLURAL:$1|since last visit}}',
+'enhancedrc-history'                => 'history',
 'recentchanges'                     => 'Recent changes',
 'recentchanges-url'                 => 'Special:RecentChanges', # do not translate or duplicate this message to other languages
 'recentchanges-legend'              => 'Recent changes options',
index 73e6199..cc6e13b 100644 (file)
@@ -3357,7 +3357,15 @@ This action allows editing of all of the "user rights", not just the rights of t
 'action-editmyprivateinfo' => '{{doc-action|editmyprivateinfo}}',
 
 # Recent changes
-'nchanges' => 'Appears on the [[Special:RecentChanges]] special page in brackets after pages having more than one change on that date. $1 is the number of changes on that day.',
+'nchanges' => 'Appears on enhanced watchlist and recent changes when page has more than one change on given date, linking to a diff of the changes.
+$1 is the number of changes on that day (2 or more).
+Three messages are shown side-by-side: ({{msg-mw|nchanges}} | {{msg-mw|enhancedrc-since-last-visit}} | {{msg-mw|enhancedrc-history}}).',
+'enhancedrc-since-last-visit' => 'Appears on enhanced watchlist and recent changes when page has more than one change on given date and at least one that the user hasn\'t seen yet, linking to a diff of the unviewed changes.
+$1 is the number of unviewed changes (1 or more).
+Three messages are shown side-by-side: ({{msg-mw|nchanges}} | {{msg-mw|enhancedrc-since-last-visit}} | {{msg-mw|enhancedrc-history}}).',
+'enhancedrc-history' => 'Appears on enhanced watchlist and recent changes when page has more than one change on given date, linking to its history.
+This is the same as {{msg-mw|hist}}, but not abbreviated.
+Three messages are shown side-by-side: ({{msg-mw|nchanges}} | {{msg-mw|enhancedrc-since-last-visit}} | {{msg-mw|enhancedrc-history}}).',
 'recentchanges' => 'The text of the link in sidebar going to the special page [[Special:RecentChanges]]. Also the page title of that special page.
 
 See also:
index 68b2d17..a81df71 100644 (file)
@@ -1317,6 +1317,8 @@ $wgMessageStructure = array(
        ),
        'recentchanges' => array(
                'nchanges',
+               'enhancedrc-since-last-visit',
+               'enhancedrc-history',
                'recentchanges',
                'recentchanges-url',
                'recentchanges-legend',