From: Aryeh Gregor Date: Mon, 4 Aug 2008 19:36:20 +0000 (+0000) Subject: Make good-faith effort to run BrokenLink hook in Linker::link(). No parser-test... X-Git-Tag: 1.31.0-rc.0~46139 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=47a1e38e789a34758d36b69dfdd325f5487b98f2;p=lhc%2Fweb%2Fwiklou.git Make good-faith effort to run BrokenLink hook in Linker::link(). No parser-test regressions, and it shouldn't change behavior unless Xml::expandAttributes() and Sanitizer::decodeTagAttributes() aren't inverses up to normalization. --- diff --git a/includes/Linker.php b/includes/Linker.php index b913ebf10c..476245ce2f 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -205,8 +205,24 @@ class Linker { $text = $this->linkText( $target ); } + # Compat cruft :( + if( in_array( 'broken', $options ) ) { + $hookQuery = wfArrayToCGI( $query ); + $hookUrl = $attribs['href']; + $hookAttribs = $attribs; + unset( $hookAttribs['href'] ); + $hookAttribs = Xml::expandAttributes( $hookAttribs ); + $hookPrefix = $hookInside = $hookTrail = ''; + wfRunHooks( 'BrokenLink', array( $this, $target, $hookQuery, + &$hookUrl, &$hookAttribs, &$hookPrefix, &$text, &$hookInside, + &$hookTrail ) ); + $attribs = Sanitizer::decodeTagAttributes( $hookAttribs ); + $attribs['href'] = $hookUrl; + $text = "$hookPrefix$text$hookInside"; + } + $ret = Xml::openElement( 'a', $attribs ) - . $text + . $text . ( isset( $hookTrail ) ? $hookTrail : '' ) . Xml::closeElement( 'a' ); wfProfileOut( __METHOD__ ); diff --git a/includes/Xml.php b/includes/Xml.php index 7db9ee8cca..1551878518 100644 --- a/includes/Xml.php +++ b/includes/Xml.php @@ -41,7 +41,7 @@ class Xml { * Return null if no attributes given. * @param $attribs Array of attributes for an XML element */ - private static function expandAttributes( $attribs ) { + public static function expandAttributes( $attribs ) { $out = ''; if( is_null( $attribs ) ) { return null; @@ -682,4 +682,4 @@ class XmlSelect { return Xml::tags( 'select', $this->attributes, implode( "\n", $this->options ) ); } -} \ No newline at end of file +}