Sbisson has uploaded a new change for review. https://gerrit.wikimedia.org/r/220931
Change subject: [WIP] Add 'EnhancedChangesList::getRecentChangeEntryLineData' hook ...................................................................... [WIP] Add 'EnhancedChangesList::getRecentChangeEntryLineData' hook Gives extensions a chance to modify the data used to build each enhanced recent change 'inner' lines (as opposed to the header lines). Bug: T102021 Change-Id: Ia8a796fb9621db14d6574e66a4572e1fdf3bad03 --- M RELEASE-NOTES-1.26 M docs/hooks.txt M includes/changes/ChangesList.php M includes/changes/EnhancedChangesList.php M includes/changes/OldChangesList.php 5 files changed, 69 insertions(+), 27 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/31/220931/1 diff --git a/RELEASE-NOTES-1.26 b/RELEASE-NOTES-1.26 index c2228ae..c3c6311 100644 --- a/RELEASE-NOTES-1.26 +++ b/RELEASE-NOTES-1.26 @@ -30,6 +30,8 @@ * (T68699) The expiration of the UserID and Token login cookies ($wgExtendedLoginCookieExpiration) can be configured independently of the expiration of all other cookies ($wgCookieExpiration). +* Added a new hook 'EnhancedChangesList::getRecentChangeEntryLineData', to + modify the data used to build lines in recent changes and watch list. ==== External libraries ==== * Update es5-shim from v4.0.0 to v4.1.5. diff --git a/docs/hooks.txt b/docs/hooks.txt index 8cfdee9..9be297a 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -1304,6 +1304,13 @@ &$links: The links that were generated by EnhancedChangesList $block: The RecentChanges objects in that block +'EnhancedChangesList::getRecentChangeEntryLineData': to alter data used to build +a recent change inner line in EnhancedChangesList. +$changesList: EnhancedChangesList object +&$data: The data used to build the line +$block: The RecentChanges objects in that block +$rc: The RecentChange object for this line + 'ExemptFromAccountCreationThrottle': Exemption from the account creation throttle. $ip: The ip address of the user diff --git a/includes/changes/ChangesList.php b/includes/changes/ChangesList.php index 932006d..341194b 100644 --- a/includes/changes/ChangesList.php +++ b/includes/changes/ChangesList.php @@ -514,12 +514,12 @@ } } - /** Inserts a rollback link + /** Returns a rollback link * - * @param string $s * @param RecentChange $rc + * @return string */ - public function insertRollback( &$s, &$rc ) { + public function insertRollback( &$rc ) { if ( $rc->mAttribs['rc_type'] == RC_EDIT && $rc->mAttribs['rc_this_oldid'] && $rc->mAttribs['rc_cur_id'] @@ -537,19 +537,20 @@ 'user_text' => $rc->mAttribs['rc_user_text'], 'deleted' => $rc->mAttribs['rc_deleted'] ) ); - $s .= ' ' . Linker::generateRollback( $rev, $this->getContext() ); + return ' ' . Linker::generateRollback( $rev, $this->getContext() ); } + return ''; } } /** - * @param string $s * @param RecentChange $rc * @param array $classes + * @return string */ - public function insertTags( &$s, &$rc, &$classes ) { + public function insertTags( &$rc, &$classes ) { if ( empty( $rc->mAttribs['ts_tags'] ) ) { - return; + return ''; } list( $tagSummary, $newClasses ) = ChangeTags::formatSummaryRow( @@ -557,7 +558,7 @@ 'changeslist' ); $classes = array_merge( $classes, $newClasses ); - $s .= ' ' . $tagSummary; + return ' ' . $tagSummary; } public function insertExtra( &$s, &$rc, &$classes ) { diff --git a/includes/changes/EnhancedChangesList.php b/includes/changes/EnhancedChangesList.php index 54cde0d..cedcd9f 100644 --- a/includes/changes/EnhancedChangesList.php +++ b/includes/changes/EnhancedChangesList.php @@ -304,18 +304,17 @@ # Classes to apply -- TODO implement $classes = array(); $type = $rcObj->mAttribs['rc_type']; + $data = array(); $trClass = $rcObj->watched && $rcObj->mAttribs['rc_timestamp'] >= $rcObj->watched ? ' class="mw-enhanced-watched"' : ''; - $r .= '<tr' . $trClass . '><td></td><td class="mw-enhanced-rc">'; - $r .= $this->recentChangesFlags( array( + $data['recentChangesFlags'] = array( 'newpage' => $type == RC_NEW, 'minor' => $rcObj->mAttribs['rc_minor'], 'unpatrolled' => $rcObj->unpatrolled, 'bot' => $rcObj->mAttribs['rc_bot'], - ) ); - $r .= ' </td><td class="mw-enhanced-rc-nested"><span class="mw-enhanced-rc-time">'; + ); $params = $queryParams; @@ -340,40 +339,73 @@ $link = '<span class="history-deleted">' . $link . '</span> '; } } - $r .= $link . '</span>'; + $data['timestampLink'] = $link; + $currentAndLastLinks = ''; if ( !$type == RC_LOG || $type == RC_NEW ) { - $r .= ' ' . $this->msg( 'parentheses' )->rawParams( + $currentAndLastLinks .= ' ' . $this->msg( 'parentheses' )->rawParams( $rcObj->curlink . $this->message['pipe-separator'] . $rcObj->lastlink )->escaped(); } - $r .= ' <span class="mw-changeslist-separator">. .</span> '; + $data['currentAndLastLinks'] = $currentAndLastLinks; + + $data['separator'] = ' <span class="mw-changeslist-separator">. .</span> '; # Character diff + $characterDiff = ''; if ( $RCShowChangedSize ) { $cd = $this->formatCharacterDifference( $rcObj ); if ( $cd !== '' ) { - $r .= $cd . ' <span class="mw-changeslist-separator">. .</span> '; + $characterDiff .= $cd; + $characterDiff .= $data['separator']; } } + $data['characterDiff'] = $characterDiff; + if ( $rcObj->mAttribs['rc_type'] == RC_LOG ) { - $r .= $this->insertLogEntry( $rcObj ); + $data['logEntry'] = $this->insertLogEntry( $rcObj ); } else { # User links - $r .= $rcObj->userlink; - $r .= $rcObj->usertalklink; - $r .= $this->insertComment( $rcObj ); + $data['userLink'] = $rcObj->userlink; + $data['userTalkLink'] = $rcObj->usertalklink; + $data['comment'] = $this->insertComment( $rcObj ); } # Rollback - $this->insertRollback( $r, $rcObj ); + $data['rollback'] = $this->insertRollback( $rcObj ); # Tags - $this->insertTags( $r, $rcObj, $classes ); + $data['tags'] = $this->insertTags( $rcObj, $classes ); - $r .= "</td></tr>\n"; + // give the hook a chance to modify the data + Hooks::run( 'EnhancedChangesList::getRecentChangeEntryLineData', + array( $this, &$data, $block, $rcObj ) ); + + // build the line + $lineParts = array(); + $lineParts[] = '<tr' . $trClass . '>'; + $lineParts[] = '<td></td>'; + $lineParts[] = '<td class="mw-enhanced-rc">'; + $lineParts[] = $this->recentChangesFlags( $data['recentChangesFlags'] ); + $lineParts[] = ' </td><td class="mw-enhanced-rc-nested">'; + $lineParts[] = '<span class="mw-enhanced-rc-time">' . $data['timestampLink'] . '</span>'; + $lineParts[] = $data['currentAndLastLinks']; + $lineParts[] = $data['separator']; + $lineParts[] = $data['characterDiff']; + if ( $rcObj->mAttribs['rc_type'] == RC_LOG ) { + $lineParts[] = $data['logEntry']; + } else { + $lineParts[] = $data['userLink']; + $lineParts[] = $data['userTalkLink']; + $lineParts[] = $data['comment']; + } + $lineParts[] = $data['rollback']; + $lineParts[] = $data['tags']; + $lineParts[] = "</td></tr>\n"; + + $r .= implode( '', $lineParts ); } $r .= "</table>\n"; @@ -558,11 +590,11 @@ } else { $r .= ' ' . $rcObj->userlink . $rcObj->usertalklink; $r .= $this->insertComment( $rcObj ); - $this->insertRollback( $r, $rcObj ); + $r .= $this->insertRollback( $rcObj ); } # Tags - $this->insertTags( $r, $rcObj, $classes ); + $r .= $this->insertTags( $rcObj, $classes ); # Show how many people are watching this if enabled $r .= $this->numberofWatchingusers( $rcObj->numberofWatchingusers ); diff --git a/includes/changes/OldChangesList.php b/includes/changes/OldChangesList.php index 4ce564d..95d1609 100644 --- a/includes/changes/OldChangesList.php +++ b/includes/changes/OldChangesList.php @@ -122,9 +122,9 @@ } # Tags - $this->insertTags( $html, $rc, $classes ); + $html .= $this->insertTags( $rc, $classes ); # Rollback - $this->insertRollback( $html, $rc ); + $html .= $this->insertRollback( $rc ); # For subclasses $this->insertExtra( $html, $rc, $classes ); -- To view, visit https://gerrit.wikimedia.org/r/220931 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia8a796fb9621db14d6574e66a4572e1fdf3bad03 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Sbisson <sbis...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits