Add $attribs as a param to LinkerMakeExternalLink Hook.
authorAndrew Garrett <werdna@users.mediawiki.org>
Mon, 9 Mar 2009 13:21:14 +0000 (13:21 +0000)
committerAndrew Garrett <werdna@users.mediawiki.org>
Mon, 9 Mar 2009 13:21:14 +0000 (13:21 +0000)
docs/hooks.txt
includes/Linker.php

index 6a43432..54b8e4b 100644 (file)
@@ -831,6 +831,7 @@ $options: the options.  Will always include either 'known' or 'broken', and may
 &$url: the image url
 &$alt: the image's alt text
 &$img: the new image HTML (if returning false)
+&$attribs: the attributes to be applied.
 
 'LinkerMakeExternalLink': At the end of Linker::makeExternalLink() just before the return
 &$url: the link url
index 21fa15b..8d3a529 100644 (file)
@@ -1010,19 +1010,19 @@ class Linker {
        /** @todo document */
        function makeExternalLink( $url, $text, $escape = true, $linktype = '', $attribs = array() ) {
                $attribsText = $this->getExternalLinkAttributes( $url, $text, 'external ' . $linktype );
-               if ( $attribs ) {
-                       $attribsText .= Xml::expandAttributes( $attribs );
-               }
                $url = htmlspecialchars( $url );
                if( $escape ) {
                        $text = htmlspecialchars( $text );
                }
                $link = '';
-               $success = wfRunHooks('LinkerMakeExternalLink', array( &$url, &$text, &$link ) );
+               $success = wfRunHooks('LinkerMakeExternalLink', array( &$url, &$text, &$link, &$attribs ) );
                if(!$success) {
                        wfDebug("Hook LinkerMakeExternalLink changed the output of link with url {$url} and text {$text} to {$link}\n", true);
                        return $link;
                }
+               if ( $attribs ) {
+                       $attribsText .= Xml::expandAttributes( $attribs );
+               }
                return '<a href="'.$url.'"'.$attribsText.'>'.$text.'</a>';
        }