From: tinajohnson.1234 Date: Tue, 25 Mar 2014 16:01:51 +0000 (+0530) Subject: HistoryAction: Implement HistoryPageToolLinks hook for adding more links X-Git-Tag: 1.34.0-rc.0~4644^2 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=1f88334983a758c92f24276eaddf3e1047e135e9;p=lhc%2Fweb%2Fwiklou.git HistoryAction: Implement HistoryPageToolLinks hook for adding more links This allows AbuseFilter to add an extra link in the tool links section of the subtitle on a history page Co-authored-by: Matěj Suchánek Bug: T28934 Change-Id: I2e0e9e92d3fc303135b0eb9acf06b5fd120178a5 --- diff --git a/RELEASE-NOTES-1.32 b/RELEASE-NOTES-1.32 index 54352138a3..90396ea108 100644 --- a/RELEASE-NOTES-1.32 +++ b/RELEASE-NOTES-1.32 @@ -56,6 +56,8 @@ production. * Added new 'OutputPageAfterGetHeadLinksArray' hook, allowing extensions to modify the return value of OutputPage#getHeadLinksArray in order to add, remove or otherwise alter the elements to be output in the page . +* (T28934) The 'HistoryPageToolLinks' hook allows extensions to append + additional links to the subtitle of a history page. === External library changes in 1.32 === * … diff --git a/docs/hooks.txt b/docs/hooks.txt index 40777da4ba..251bea6581 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -1823,6 +1823,11 @@ $rev: Revision object $prevRev: Revision object, next in line in page history, or null $user: Current user object +'HistoryPageToolLinks': Add one or more links to revision history page subtitle. +$context: IContextSource (object) +$linkRenderer: LinkRenderer instance +&$links: Array of HTML strings + 'HTMLFileCache::useFileCache': Override whether a page should be cached in file cache. $context: An IContextSource object with information about the request being diff --git a/includes/actions/HistoryAction.php b/includes/actions/HistoryAction.php index 20637fcdf7..1a15fc0179 100644 --- a/includes/actions/HistoryAction.php +++ b/includes/actions/HistoryAction.php @@ -62,12 +62,25 @@ class HistoryAction extends FormlessAction { protected function getDescription() { // Creation of a subtitle link pointing to [[Special:Log]] - return MediaWikiServices::getInstance()->getLinkRenderer()->makeKnownLink( + $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer(); + $subtitle = $linkRenderer->makeKnownLink( SpecialPage::getTitleFor( 'Log' ), $this->msg( 'viewpagelogs' )->text(), [], [ 'page' => $this->getTitle()->getPrefixedText() ] ); + + $links = []; + // Allow extensions to add more links + Hooks::run( 'HistoryPageToolLinks', [ $this->getContext(), $linkRenderer, &$links ] ); + if ( $links ) { + $subtitle .= '' + . $this->msg( 'word-separator' )->escaped() + . $this->msg( 'parentheses' ) + ->rawParams( $this->getLanguage()->pipeList( $links ) ) + ->escaped(); + } + return $subtitle; } /**