Sbisson has uploaded a new change for review. https://gerrit.wikimedia.org/r/220766
Change subject: Add 'EnhancedChangesList::getTimestampLink' hook ...................................................................... Add 'EnhancedChangesList::getTimestampLink' hook Adding a hook so extentions can customize the timestamp link in grouped RC and watchlist. Bug: T102021 Change-Id: Ic8ed2d4831dffeff91776d343e7c2a868ce4c569 --- M docs/hooks.txt M includes/changes/EnhancedChangesList.php 2 files changed, 51 insertions(+), 25 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/66/220766/1 diff --git a/docs/hooks.txt b/docs/hooks.txt index 8cfdee9..18d66bf 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::getTimestampLink': to alter or replace the timestamp link +of individual change entries in EnhancedChangesList. +$changesList: EnhancedChangesList object +&$link: The timestamp link that was generated by EnhancedChangesList +$rc: The RecentChange object for that line +$isDeleted: Should the entry be marked as deleted and have no link + 'ExemptFromAccountCreationThrottle': Exemption from the account creation throttle. $ip: The ip address of the user diff --git a/includes/changes/EnhancedChangesList.php b/includes/changes/EnhancedChangesList.php index 54cde0d..ec2009b 100644 --- a/includes/changes/EnhancedChangesList.php +++ b/includes/changes/EnhancedChangesList.php @@ -315,32 +315,9 @@ 'unpatrolled' => $rcObj->unpatrolled, 'bot' => $rcObj->mAttribs['rc_bot'], ) ); - $r .= ' </td><td class="mw-enhanced-rc-nested"><span class="mw-enhanced-rc-time">'; + $r .= ' </td><td class="mw-enhanced-rc-nested">'; - $params = $queryParams; - - if ( $rcObj->mAttribs['rc_this_oldid'] != 0 ) { - $params['oldid'] = $rcObj->mAttribs['rc_this_oldid']; - } - - # Log timestamp - if ( $type == RC_LOG ) { - $link = $rcObj->timestamp; - # Revision link - } elseif ( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT, $this->getUser() ) ) { - $link = '<span class="history-deleted">' . $rcObj->timestamp . '</span> '; - } else { - $link = Linker::linkKnown( - $rcObj->getTitle(), - $rcObj->timestamp, - array(), - $params - ); - if ( $this->isDeleted( $rcObj, Revision::DELETED_TEXT ) ) { - $link = '<span class="history-deleted">' . $link . '</span> '; - } - } - $r .= $link . '</span>'; + $r .= $this->getTimestampLink( $queryParams, $rcObj ); if ( !$type == RC_LOG || $type == RC_NEW ) { $r .= ' ' . $this->msg( 'parentheses' )->rawParams( @@ -602,4 +579,46 @@ public function endRecentChangesList() { return $this->recentChangesBlock() . '</div>'; } + + /** + * Generates the timestamp link or a plain span when it cannot be a link. + * Invokes the 'EnhancedChangesList::getTimestampLink' hook. + * @param array $params + * @param RecentChange|RCCacheEntry $rcObj + * @return string + */ + protected function getTimestampLink( $params, $rcObj ) + { + $type = $rcObj->mAttribs['rc_type']; + $isDeleted = false; + + # Log timestamp + if ( $type == RC_LOG ) { + $link = $rcObj->timestamp; + # Revision link + } elseif ( !ChangesList::userCan( $rcObj, Revision::DELETED_TEXT, $this->getUser() ) ) { + $isDeleted = true; + $link = '<span class="history-deleted">' . $rcObj->timestamp . '</span> '; + } else { + if ( $rcObj->mAttribs['rc_this_oldid'] != 0 ) { + $params['oldid'] = $rcObj->mAttribs['rc_this_oldid']; + } + $link = Linker::linkKnown( + $rcObj->getTitle(), + $rcObj->timestamp, + array(), + $params + ); + if ( $this->isDeleted( $rcObj, Revision::DELETED_TEXT ) ) { + $isDeleted = true; + $link = '<span class="history-deleted">' . $link . '</span> '; + } + } + + # Allow others to alter or replace the timestamp link + Hooks::run( 'EnhancedChangesList::getTimestampLink', + array( $this, &$link, $rcObj, $isDeleted ) ); + + return '<span class="mw-enhanced-rc-time">' . $link . '</span>'; + } } -- To view, visit https://gerrit.wikimedia.org/r/220766 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic8ed2d4831dffeff91776d343e7c2a868ce4c569 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