Skin: Add new hook, UndeletePageToolLinks, for Special:Undelete views
authorHuji Lee <huji.huji@gmail.com>
Thu, 22 Aug 2019 23:18:38 +0000 (19:18 -0400)
committerJdlrobson <jrobson@wikimedia.org>
Fri, 23 Aug 2019 20:51:21 +0000 (20:51 +0000)
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
includes/skins/Skin.php

index 719c60f..b7ea02c 100644 (file)
@@ -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
index bcc257a..eeed05e 100644 (file)
@@ -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 );
                        }
                }