From 4202d4a881cd896551e9f922cdcd1158edbd3a40 Mon Sep 17 00:00:00 2001 From: cicalese Date: Sat, 5 Apr 2014 22:06:43 -0400 Subject: [PATCH] Add SelfLinkBeginHook Called before a link to the current article is displayed to allow the display of the link to be customized. Bug: 63592 Change-Id: I343e1b1b08ec841d22a1b22bcb8af43bb65a5a50 --- docs/hooks.txt | 8 ++++++++ includes/Linker.php | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/docs/hooks.txt b/docs/hooks.txt index ff1d6a18f5..31abbd4744 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -2136,6 +2136,14 @@ $title : Current Title object being displayed in search results. 'SearchableNamespaces': An option to modify which namespaces are searchable. &$arr : Array of namespaces ($nsId => $name) which will be used. +'SelfLinkBegin': Called before a link to the current article is displayed to +allow the display of the link to be customized. +$nt: the Title object +&$html: html to display for the link +&$trail: optional text to display before $html +&$prefix: optional text to display after $html +&$ret: the value to return if your hook returns false + 'SetupAfterCache': Called in Setup.php, after cache objects are set 'ShowMissingArticle': Called when generating the output for a non-existent page. diff --git a/includes/Linker.php b/includes/Linker.php index 094a304b23..3489931aa2 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -407,6 +407,11 @@ class Linker { * @return string */ public static function makeSelfLinkObj( $nt, $html = '', $query = '', $trail = '', $prefix = '' ) { + $ret = "{$prefix}{$html}{$trail}"; + if ( !wfRunHooks( 'SelfLinkBegin', array( $nt, &$html, &$trail, &$prefix, &$ret ) ) ) { + return $ret; + } + if ( $html == '' ) { $html = htmlspecialchars( $nt->getPrefixedText() ); } -- 2.20.1