Ruud Koot has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/65310


Change subject: Add an option to show related changes to associated pages (2/2)
......................................................................

Add an option to show related changes to associated pages (2/2)

Add a new option to the related changes special
pages, making it possible to also show changes to
the associated page of this pages linked to (i.e.
the talk page associated with a content page or
vice versa.)

Part 2 of 2: The actual feature.

Change-Id: I9536df6784de8c8edc50fa4b281782d270d0a68d
---
M includes/RecentChange.php
M includes/Title.php
M includes/specials/SpecialRecentchangeslinked.php
M languages/messages/MessagesEn.php
M maintenance/language/messages.inc
5 files changed, 41 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/10/65310/1

diff --git a/includes/RecentChange.php b/includes/RecentChange.php
index b5d4a1c..0064c1e 100644
--- a/includes/RecentChange.php
+++ b/includes/RecentChange.php
@@ -32,6 +32,7 @@
  *  rc_type         is new entry, used to determine whether updating is 
necessary
  *  rc_minor        is minor
  *  rc_cur_id       page_id of associated page entry
+ *  rc_cur_id_assoc page_id of associated "associated page" entry
  *  rc_user         user id who made the entry
  *  rc_user_text    user name who made the entry
  *  rc_comment      edit summary
@@ -153,6 +154,7 @@
                        'rc_bot',
                        'rc_new',
                        'rc_cur_id',
+                       'rc_cur_id_assoc',
                        'rc_this_oldid',
                        'rc_last_oldid',
                        'rc_type',
@@ -443,6 +445,7 @@
                        'rc_type'       => RC_EDIT,
                        'rc_minor'      => $minor ? 1 : 0,
                        'rc_cur_id'     => $title->getArticleID(),
+                       'rc_cur_id_assoc' => 
$title->getAssociatedPage()->getArticleID(),
                        'rc_user'       => $user->getId(),
                        'rc_user_text'  => $user->getName(),
                        'rc_comment'    => $comment,
@@ -502,6 +505,7 @@
                        'rc_type'           => RC_NEW,
                        'rc_minor'          => $minor ? 1 : 0,
                        'rc_cur_id'         => $title->getArticleID(),
+                       'rc_cur_id_assoc'   => 
$title->getAssociatedPage()->getArticleID(),
                        'rc_user'           => $user->getId(),
                        'rc_user_text'      => $user->getName(),
                        'rc_comment'        => $comment,
@@ -611,6 +615,7 @@
                        'rc_type'       => RC_LOG,
                        'rc_minor'      => 0,
                        'rc_cur_id'     => $target->getArticleID(),
+                       'rc_cur_id_assoc' => 
$target->getAssociatedPage()->getArticleID(),
                        'rc_user'       => $user->getId(),
                        'rc_user_text'  => $user->getName(),
                        'rc_comment'    => $logComment,
diff --git a/includes/Title.php b/includes/Title.php
index 66a6ce5..b7f6dc3 100644
--- a/includes/Title.php
+++ b/includes/Title.php
@@ -1061,6 +1061,19 @@
                return Title::makeTitle( $subjectNS, $this->getDBkey() );
        }
 
+       /** Get a title object associated with the associated page of this
+        *  page
+        *
+        * @return Title object of the associated page
+        */
+       public function getAssociatedPage() {
+               if ( $this->isTalkPage() ) {
+                       return $this->getSubjectPage();
+               } else {
+                       return $this->getTalkPage();
+               }
+       }
+
        /**
         * Get the default namespace index, for when there is no namespace
         *
diff --git a/includes/specials/SpecialRecentchangeslinked.php 
b/includes/specials/SpecialRecentchangeslinked.php
index 062e09d..dd5dc07 100644
--- a/includes/specials/SpecialRecentchangeslinked.php
+++ b/includes/specials/SpecialRecentchangeslinked.php
@@ -37,6 +37,7 @@
                $opts = parent::getDefaultOptions();
                $opts->add( 'target', '' );
                $opts->add( 'showlinkedto', false );
+               $opts->add( 'showassociated', false );
                return $opts;
        }
 
@@ -64,6 +65,7 @@
        public function doMainQuery( $conds, $opts ) {
                $target = $opts['target'];
                $showlinkedto = $opts['showlinkedto'];
+               $showassociated = $opts['showassociated'];
                $limit = $opts['limit'];
 
                if ( $target === '' ) {
@@ -171,7 +173,11 @@
                                } else {
                                        $subconds = array( "{$pfx}_namespace" 
=> $ns, "{$pfx}_title" => $dbkey );
                                }
-                               $subjoin = "rc_cur_id = {$pfx}_from";
+                               if( $showassociated ) {
+                                       $subjoin = "rc_cur_id = {$pfx}_from OR 
rc_cur_id_assoc = {$pfx}_from";
+                               } else {
+                                       $subjoin = "rc_cur_id = {$pfx}_from";
+                               }
                        } else {
                                // find changes to pages linked from this page
                                $subconds = array( "{$pfx}_from" => $id );
@@ -230,13 +236,15 @@
         * @return array
         */
        function getExtraOptions( $opts ) {
-               $opts->consumeValues( array( 'showlinkedto', 'target', 
'tagfilter' ) );
+               $opts->consumeValues( array( 'showlinkedto', 'showassociated', 
'target', 'tagfilter' ) );
                $extraOpts = array();
                $extraOpts['namespace'] = $this->namespaceFilterForm( $opts );
                $extraOpts['target'] = array( $this->msg( 
'recentchangeslinked-page' )->escaped(),
-                       Xml::input( 'target', 40, str_replace( '_', ' ', 
$opts['target'] ) ) .
-                       Xml::check( 'showlinkedto', $opts['showlinkedto'], 
array( 'id' => 'showlinkedto' ) ) . ' ' .
-                       Xml::label( $this->msg( 'recentchangeslinked-to' 
)->text(), 'showlinkedto' ) );
+                       Xml::input( 'target', 40, str_replace( '_', ' 
',$opts['target']) ) .
+                       Xml::check( 'showlinkedto', $opts['showlinkedto'], 
array('id' => 'showlinkedto') ) . ' ' .
+                       Xml::label( $this->msg( 'recentchangeslinked-to' 
)->text(), 'showlinkedto' ) .
+                       Xml::check( 'showassociated', $opts['showassociated'], 
array('id' => 'showassociated') ) . ' ' .
+                       Xml::label( $this->msg( 
'recentchangeslinked-associated' )->text(), 'showassociated' ) );
                $tagFilter = ChangeTags::buildTagFilterSelector( 
$opts['tagfilter'] );
                if ( $tagFilter ) {
                        $extraOpts['tagfilter'] = $tagFilter;
diff --git a/languages/messages/MessagesEn.php 
b/languages/messages/MessagesEn.php
index bc3a381..7fe2f77 100644
--- a/languages/messages/MessagesEn.php
+++ b/languages/messages/MessagesEn.php
@@ -2193,15 +2193,16 @@
 'rc-old-title'                      => 'originally created as "$1"',
 
 # Recent changes linked
-'recentchangeslinked'          => 'Related changes',
-'recentchangeslinked-feed'     => 'Related changes',
-'recentchangeslinked-toolbox'  => 'Related changes',
-'recentchangeslinked-title'    => 'Changes related to "$1"',
-'recentchangeslinked-noresult' => 'No changes on linked pages during the given 
period.',
-'recentchangeslinked-summary'  => "This is a list of changes made recently to 
pages linked from a specified page (or to members of a specified category).
+'recentchangeslinked'            => 'Related changes',
+'recentchangeslinked-feed'       => 'Related changes',
+'recentchangeslinked-toolbox'    => 'Related changes',
+'recentchangeslinked-title'      => 'Changes related to "$1"',
+'recentchangeslinked-noresult'   => 'No changes on linked pages during the 
given period.',
+'recentchangeslinked-summary'    => "This is a list of changes made recently 
to pages linked from a specified page (or to members of a specified category).
 Pages on [[Special:Watchlist|your watchlist]] are '''bold'''.",
-'recentchangeslinked-page'     => 'Page name:',
-'recentchangeslinked-to'       => 'Show changes to pages linked to the given 
page instead',
+'recentchangeslinked-page'       => 'Page name:',
+'recentchangeslinked-to'         => 'Show changes to pages linked to the given 
page instead',
+'recentchangeslinked-associated' => 'Also show changes to the associated 
content or talk pages',
 
 # Upload
 'upload'                      => 'Upload file',
diff --git a/maintenance/language/messages.inc 
b/maintenance/language/messages.inc
index fdd37e6..d1e976e 100644
--- a/maintenance/language/messages.inc
+++ b/maintenance/language/messages.inc
@@ -1329,6 +1329,7 @@
                'recentchangeslinked-summary',
                'recentchangeslinked-page',
                'recentchangeslinked-to',
+               'recentchangeslinked-associated',
        ),
        'upload' => array(
                'upload',

-- 
To view, visit https://gerrit.wikimedia.org/r/65310
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9536df6784de8c8edc50fa4b281782d270d0a68d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Ruud Koot <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to