Awight has uploaded a new change for review.

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

Change subject: Generalize recentChangesFlags rollup
......................................................................

Generalize recentChangesFlags rollup

Flags can be either 'any' or 'all' type, and both core and extension flags will 
be
rolled up into the top-level line of grouped changes.

See Ic49a355a2

Bug: T112856
Change-Id: If9fd6af3ac7ac2fbee9aa5536fe94d7574699966
---
M includes/DefaultSettings.php
M includes/changes/EnhancedChangesList.php
2 files changed, 30 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/49/247249/1

diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php
index f1e8f44..bfd1a77 100644
--- a/includes/DefaultSettings.php
+++ b/includes/DefaultSettings.php
@@ -6269,6 +6269,10 @@
  *   'legend' => 'legend-msg',
  *   // optional (defaults to 'flag'), CSS class to put on changes lists rows
  *   'class' => 'css-class',
+ *   // optional (defaults to 'any'), how top-level flag is determined.  'any'
+ *   // will set the top-level flag if any line contains the flag, 'all' will
+ *   // only be set if all lines contain the flag.
+ *   'grouping => 'any',
  * );
  * @endcode
  *
@@ -6279,23 +6283,27 @@
                'letter' => 'newpageletter',
                'title' => 'recentchanges-label-newpage',
                'legend' => 'recentchanges-legend-newpage',
+               'grouping' => 'any',
        ),
        'minor' => array(
                'letter' => 'minoreditletter',
                'title' => 'recentchanges-label-minor',
                'legend' => 'recentchanges-legend-minor',
                'class' => 'minoredit',
+               'grouping' => 'all',
        ),
        'bot' => array(
                'letter' => 'boteditletter',
                'title' => 'recentchanges-label-bot',
                'legend' => 'recentchanges-legend-bot',
                'class' => 'botedit',
+               'grouping' => 'all',
        ),
        'unpatrolled' => array(
                'letter' => 'unpatrolledletter',
                'title' => 'recentchanges-label-unpatrolled',
                'legend' => 'recentchanges-legend-unpatrolled',
+               'grouping' => 'any',
        ),
 );
 
diff --git a/includes/changes/EnhancedChangesList.php 
b/includes/changes/EnhancedChangesList.php
index c746252..b4e43f6 100644
--- a/includes/changes/EnhancedChangesList.php
+++ b/includes/changes/EnhancedChangesList.php
@@ -158,6 +158,7 @@
         * @return string
         */
        protected function recentChangesBlockGroup( $block ) {
+               global $wgRecentChangesFlags;
 
                # Add the namespace and title of the block as part of the class
                $tableClasses = array( 'mw-collapsible', 'mw-collapsed', 
'mw-enhanced-rc' );
@@ -196,9 +197,6 @@
                        'unpatrolled' => false,
                );
                foreach ( $block as $rcObj ) {
-                       if ( $rcObj->mAttribs['rc_type'] == RC_NEW ) {
-                               $collectedRcFlags['newpage'] = true;
-                       }
                        // If all log actions to this page were hidden, then 
don't
                        // give the name of the affected page for this block!
                        if ( !$this->isDeleted( $rcObj, LogPage::DELETED_ACTION 
) ) {
@@ -208,9 +206,6 @@
                        if ( !isset( $userlinks[$u] ) ) {
                                $userlinks[$u] = 0;
                        }
-                       if ( $rcObj->unpatrolled ) {
-                               $collectedRcFlags['unpatrolled'] = true;
-                       }
                        if ( $rcObj->mAttribs['rc_type'] != RC_LOG ) {
                                $allLogs = false;
                        }
@@ -218,13 +213,6 @@
                        # since logs may not have these.
                        if ( !$curId && $rcObj->mAttribs['rc_cur_id'] ) {
                                $curId = $rcObj->mAttribs['rc_cur_id'];
-                       }
-
-                       if ( !$rcObj->mAttribs['rc_bot'] ) {
-                               $collectedRcFlags['bot'] = false;
-                       }
-                       if ( !$rcObj->mAttribs['rc_minor'] ) {
-                               $collectedRcFlags['minor'] = false;
                        }
 
                        $userlinks[$u]++;
@@ -370,6 +358,27 @@
 
                        if ( isset( $data['recentChangesFlags'] ) ) {
                                $lineParams['recentChangesFlags'] = 
$this->recentChangesFlags( $data['recentChangesFlags'] );
+
+                               // Roll up flags
+                               foreach ( $data['recentChangesFlags'] as $key 
=> $value ) {
+                                       $flagGrouping = ( isset( 
$wgRecentChangesFlags[$key]['grouping'] ) ?
+                                               
$wgRecentChangesFlags[$key]['grouping'] : 'any' );
+                                       switch ( $flagGrouping ) {
+                                               case 'all':
+                                                       if ( !$value ) {
+                                                               
$collectedRcFlags[$key] = false;
+                                                       }
+                                                       break;
+                                               case 'any':
+                                                       if ( $value ) {
+                                                               
$collectedRcFlags[$key] = true;
+                                                       }
+                                                       break;
+                                               default:
+                                                       throw new 
RuntimeException( "Unknown grouping type \"{$flagGrouping}\"" );
+                                       }
+                               }
+
                                unset( $data['recentChangesFlags'] );
                        }
 

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

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

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

Reply via email to