From c9100d36166b7e92d2d6e9250dadbc417872f4f6 Mon Sep 17 00:00:00 2001 From: Andrew Garrett Date: Thu, 27 Feb 2014 17:27:42 +1100 Subject: [PATCH] Add WhatLinksHereProps hook, to allow extensions to annotate WhatLinksHere entries. Needed by change 110090 Change-Id: I679abfbbdbd56498ec87579b4fe4e49ad486c84c --- RELEASE-NOTES-1.24 | 2 ++ docs/hooks.txt | 6 ++++++ includes/specials/SpecialWhatlinkshere.php | 8 +++++--- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/RELEASE-NOTES-1.24 b/RELEASE-NOTES-1.24 index fd422faaf3..c0bb2858cb 100644 --- a/RELEASE-NOTES-1.24 +++ b/RELEASE-NOTES-1.24 @@ -11,6 +11,8 @@ production. === Configuration changes in 1.24 === === New features in 1.24 === +* Added a new hook, "WhatLinksHereProps", to allow extensions to annotate + WhatLinksHere entries. === Bug fixes in 1.24 === * (bug 62258) A bug was fixed in File::getUnscaledThumb when a height diff --git a/docs/hooks.txt b/docs/hooks.txt index 80f388bd90..688e0cd91b 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -2922,6 +2922,12 @@ Return false to prevent setting of the cookie. &$expire: Cookie expiration, as for PHP's setcookie() $options: Options passed to WebResponse::setcookie() +'WhatLinksHereProps': Allows annotations to be added to WhatLinksHere +$row: The DB row of the entry. +$title: The Title of the page where the link comes FROM +$target: The Title of the page where the link goes TO +&$props: Array of HTML strings to display after the title. + 'WikiExporter::dumpStableQuery': Get the SELECT query for "stable" revisions dumps. One, and only one hook should set this, and return false. &$tables: Database tables to use in the SELECT query diff --git a/includes/specials/SpecialWhatlinkshere.php b/includes/specials/SpecialWhatlinkshere.php index 0587649c4b..6488810378 100644 --- a/includes/specials/SpecialWhatlinkshere.php +++ b/includes/specials/SpecialWhatlinkshere.php @@ -265,11 +265,11 @@ class SpecialWhatLinksHere extends IncludableSpecialPage { $nt = Title::makeTitle( $row->page_namespace, $row->page_title ); if ( $row->rd_from && $level < 2 ) { - $out->addHTML( $this->listItem( $row, $nt, true ) ); + $out->addHTML( $this->listItem( $row, $nt, $target, true ) ); $this->showIndirectLinks( $level + 1, $nt, $wgMaxRedirectLinksRetrieved ); $out->addHTML( Xml::closeElement( 'li' ) ); } else { - $out->addHTML( $this->listItem( $row, $nt ) ); + $out->addHTML( $this->listItem( $row, $nt, $target ) ); } } @@ -286,7 +286,7 @@ class SpecialWhatLinksHere extends IncludableSpecialPage { return Xml::openElement( 'ul', ( $level ? array() : array( 'id' => 'mw-whatlinkshere-list' ) ) ); } - protected function listItem( $row, $nt, $notClose = false ) { + protected function listItem( $row, $nt, $target, $notClose = false ) { $dirmark = $this->getLanguage()->getDirMark(); # local message cache @@ -326,6 +326,8 @@ class SpecialWhatLinksHere extends IncludableSpecialPage { $props[] = $msgcache['isimage']; } + wfRunHooks( 'WhatLinksHereProps', array( $row, $nt, $target, &$props ) ); + if ( count( $props ) ) { $propsText = $this->msg( 'parentheses' ) ->rawParams( implode( $msgcache['semicolon-separator'], $props ) )->escaped(); -- 2.20.1