Add SelfLinkBeginHook
authorcicalese <cicalese@mitre.org>
Sun, 6 Apr 2014 02:06:43 +0000 (22:06 -0400)
committercicalese <cicalese@mitre.org>
Tue, 27 May 2014 23:54:44 +0000 (19:54 -0400)
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
includes/Linker.php

index ff1d6a1..31abbd4 100644 (file)
@@ -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.
index 094a304..3489931 100644 (file)
@@ -407,6 +407,11 @@ class Linker {
         * @return string
         */
        public static function makeSelfLinkObj( $nt, $html = '', $query = '', $trail = '', $prefix = '' ) {
+               $ret = "<strong class=\"selflink\">{$prefix}{$html}</strong>{$trail}";
+               if ( !wfRunHooks( 'SelfLinkBegin', array( $nt, &$html, &$trail, &$prefix, &$ret ) ) ) {
+                       return $ret;
+               }
+
                if ( $html == '' ) {
                        $html = htmlspecialchars( $nt->getPrefixedText() );
                }