From 5ce5cd42604f0c370d42045d9153c28088c84442 Mon Sep 17 00:00:00 2001 From: Umherirrender Date: Sun, 13 Nov 2016 15:53:55 +0100 Subject: [PATCH] Add hooks to Special:TrackingCategories Added for use in the CategoryTree extension to show the category count on the special page, see If3815586c2a280b4e8958c13010c9f7436b8723d Change-Id: If195fb55dee1350a6de095892ce89e6565287cd9 --- docs/hooks.txt | 9 +++++++++ includes/specials/SpecialTrackingCategories.php | 10 ++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/docs/hooks.txt b/docs/hooks.txt index 5b707c1ca2..09370edfd1 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -3217,6 +3217,15 @@ $engine: the search engine message key to use in the name column, $context: IContextSource object +'SpecialTrackingCategories::preprocess': Called after LinkBatch on Special:TrackingCategories +$specialPage: The SpecialTrackingCategories object +$trackingCategories: Array of data from Special:TrackingCategories with msg and cats + +'SpecialTrackingCategories::generateCatLink': Called for each cat link on Special:TrackingCategories +$specialPage: The SpecialTrackingCategories object +$catTitle: The Title object of the linked category +&$html: The Result html + 'SpecialUploadComplete': Called after successfully uploading a file from Special:Upload. &$form: The SpecialUpload object diff --git a/includes/specials/SpecialTrackingCategories.php b/includes/specials/SpecialTrackingCategories.php index 3b502f8960..4c6a3457db 100644 --- a/includes/specials/SpecialTrackingCategories.php +++ b/includes/specials/SpecialTrackingCategories.php @@ -87,6 +87,8 @@ class SpecialTrackingCategories extends SpecialPage { } $batch->execute(); + Hooks::run( 'SpecialTrackingCategories::preprocess', [ $this, $trackingCategories ] ); + foreach ( $trackingCategories as $catMsg => $data ) { $allMsgs = []; $catDesc = $catMsg . '-desc'; @@ -97,11 +99,15 @@ class SpecialTrackingCategories extends SpecialPage { ); foreach ( $data['cats'] as $catTitle ) { - $catTitleText = Linker::link( + $html = Linker::link( $catTitle, htmlspecialchars( $catTitle->getText() ) ); - $allMsgs[] = $catTitleText; + + Hooks::run( 'SpecialTrackingCategories::generateCatLink', + [ $this, $catTitle, &$html ] ); + + $allMsgs[] = $html; } # Extra message, when no category was found -- 2.20.1