From 0a611b47a87f23fd23e37809d269003c5b234be9 Mon Sep 17 00:00:00 2001 From: Huji Lee Date: Thu, 22 Aug 2019 19:18:38 -0400 Subject: [PATCH] Skin: Add new hook, UndeletePageToolLinks, for Special:Undelete views This allows extensions to add further links; the particular use case in mind is for the AbuseFilter extension, but others may want this too. Bug: T231055 Change-Id: I671a0479e877e6c37606b688064cb9c893717709 --- docs/hooks.txt | 6 ++++++ includes/skins/Skin.php | 15 ++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/docs/hooks.txt b/docs/hooks.txt index 719c60f90c..b7ea02cea3 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -3504,6 +3504,12 @@ processing. &$archive: PageArchive object $title: Title object of the page that we're about to undelete +'UndeletePageToolLinks': Add one or more links to edit page subtitle when a page +has been previously deleted. +$context: IContextSource (object) +$linkRenderer: LinkRenderer instance +&$links: Array of HTML strings + 'UndeleteShowRevision': Called when showing a revision in Special:Undelete. $title: title object related to the revision $rev: revision (object) that will be viewed diff --git a/includes/skins/Skin.php b/includes/skins/Skin.php index bcc257adfd..eeed05e95f 100644 --- a/includes/skins/Skin.php +++ b/includes/skins/Skin.php @@ -736,11 +736,24 @@ abstract class Skin extends ContextSource { $msg = 'viewdeleted'; } - return $this->msg( $msg )->rawParams( + $subtitle = $this->msg( $msg )->rawParams( $linkRenderer->makeKnownLink( SpecialPage::getTitleFor( 'Undelete', $this->getTitle()->getPrefixedDBkey() ), $this->msg( 'restorelink' )->numParams( $n )->text() ) )->escaped(); + + // Allow extensions to add more links + $links = []; + Hooks::run( 'UndeletePageToolLinks', [ $this->getContext(), $linkRenderer, &$links ] ); + + if ( $links ) { + $subtitle .= '' + . $this->msg( 'word-separator' )->escaped() + . $this->msg( 'parentheses' ) + ->rawParams( $this->getLanguage()->pipeList( $links ) ) + ->escaped(); + } + return Html::rawElement( 'div', [ 'class' => 'mw-undelete-subtitle' ], $subtitle ); } } -- 2.20.1