* '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
*
'letter' => 'newpageletter',
'title' => 'recentchanges-label-newpage',
'legend' => 'recentchanges-legend-newpage',
+ 'grouping' => 'any',
],
'minor' => [
'letter' => 'minoreditletter',
'title' => 'recentchanges-label-minor',
'legend' => 'recentchanges-legend-minor',
'class' => 'minoredit',
+ 'grouping' => 'all',
],
'bot' => [
'letter' => 'boteditletter',
'title' => 'recentchanges-label-bot',
'legend' => 'recentchanges-legend-bot',
'class' => 'botedit',
+ 'grouping' => 'all',
],
'unpatrolled' => [
'letter' => 'unpatrolledletter',
'title' => 'recentchanges-label-unpatrolled',
'legend' => 'recentchanges-legend-unpatrolled',
+ 'grouping' => 'any',
],
];
* Enhanced RC group
* @param RCCacheEntry[] $block
* @return string
+ * @throws DomainException
*/
protected function recentChangesBlockGroup( $block ) {
+ $recentChangesFlags = $this->getConfig()->get( 'RecentChangesFlags' );
# Add the namespace and title of the block as part of the class
$tableClasses = [ 'mw-collapsible', 'mw-collapsed', 'mw-enhanced-rc' ];
$namehidden = true;
$allLogs = true;
$RCShowChangedSize = $this->getConfig()->get( 'RCShowChangedSize' );
- $collectedRcFlags = [
- // All are by bots?
- 'bot' => true,
- // Includes a new page?
- 'newpage' => false,
- // All are minor edits?
- 'minor' => true,
- // Contains an unpatrolled edit?
- 'unpatrolled' => false,
- ];
- foreach ( $block as $rcObj ) {
- if ( $rcObj->mAttribs['rc_type'] == RC_NEW ) {
- $collectedRcFlags['newpage'] = true;
+
+ # Default values for RC flags
+ $collectedRcFlags = [];
+ foreach ( $recentChangesFlags as $key => $value ) {
+ $flagGrouping = ( isset( $recentChangesFlags[$key]['grouping'] ) ?
+ $recentChangesFlags[$key]['grouping'] : 'any' );
+ switch ( $flagGrouping ) {
+ case 'all':
+ $collectedRcFlags[$key] = true;
+ break;
+ case 'any':
+ $collectedRcFlags[$key] = false;
+ break;
+ default:
+ throw new DomainException( "Unknown grouping type \"{$flagGrouping}\"" );
}
+ }
+ foreach ( $block as $rcObj ) {
// 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 ) ) {
if ( !isset( $userlinks[$u] ) ) {
$userlinks[$u] = 0;
}
- if ( $rcObj->unpatrolled ) {
- $collectedRcFlags['unpatrolled'] = true;
- }
if ( $rcObj->mAttribs['rc_type'] != RC_LOG ) {
$allLogs = false;
}
$curId = $rcObj->mAttribs['rc_cur_id'];
}
- if ( !$rcObj->mAttribs['rc_bot'] ) {
- $collectedRcFlags['bot'] = false;
- }
- if ( !$rcObj->mAttribs['rc_minor'] ) {
- $collectedRcFlags['minor'] = false;
- }
-
$userlinks[$u]++;
}
// completely ignore this RC entry if we don't want to render it
unset( $block[$i] );
}
+
+ // Roll up flags
+ foreach ( $line['recentChangesFlagsRaw'] as $key => $value ) {
+ $flagGrouping = ( isset( $recentChangesFlags[$key]['grouping'] ) ?
+ $recentChangesFlags[$key]['grouping'] : 'any' );
+ switch ( $flagGrouping ) {
+ case 'all':
+ if ( !$value ) {
+ $collectedRcFlags[$key] = false;
+ }
+ break;
+ case 'any':
+ if ( $value ) {
+ $collectedRcFlags[$key] = true;
+ }
+ break;
+ default:
+ throw new DomainException( "Unknown grouping type \"{$flagGrouping}\"" );
+ }
+ }
+
$lines[] = $line;
}
// Further down are some assumptions that $block is a 0-indexed array
return [];
}
+ $lineParams['recentChangesFlagsRaw'] = [];
if ( isset( $data['recentChangesFlags'] ) ) {
$lineParams['recentChangesFlags'] = $this->recentChangesFlags( $data['recentChangesFlags'] );
+ # FIXME: This is used by logic, don't return it in the template params.
+ $lineParams['recentChangesFlagsRaw'] = $data['recentChangesFlags'];
unset( $data['recentChangesFlags'] );
}