Index: trunk/extensions/ImageMap/ImageMap_body.php |
— | — | @@ -70,7 +70,33 @@ |
71 | 71 | if ( wfIsBadImage( $imageTitle->getDBkey() , $parser->mTitle ) ) { |
72 | 72 | return self::error( 'imagemap_bad_image' ); |
73 | 73 | } |
74 | | - $imageHTML = $parser->makeImage( $imageTitle, Sanitizer::escapeHtmlAllowEntities($options) ); |
| 74 | + // Parse the options so we can use links and the like in the caption, code adapted from Cite extension |
| 75 | + if ( method_exists( $parser, 'recursiveTagParse' ) ) { |
| 76 | + // New fast method |
| 77 | + $parsedoptions = $parser->recursiveTagParse( Sanitizer::escapeHtmlAllowEntities($options) ); |
| 78 | + } else { |
| 79 | + // Old method |
| 80 | + $ret = $parser->parse( |
| 81 | + Sanitizer::escapeHtmlAllowEntities($options), |
| 82 | + $parser->mTitle, |
| 83 | + $parser->mOptions, |
| 84 | + // Avoid whitespace buildup |
| 85 | + false, |
| 86 | + false |
| 87 | + ); |
| 88 | + $text = $ret->getText(); |
| 89 | + global $wgUseTidy; |
| 90 | + if ( ! $wgUseTidy ) |
| 91 | + $parsedoptions = $text; |
| 92 | + else { |
| 93 | + $text = preg_replace( '~^<p>\s*~', '', $text ); |
| 94 | + $text = preg_replace( '~\s*</p>\s*~', '', $text ); |
| 95 | + $text = preg_replace( '~\n$~', '', $text ); |
| 96 | + |
| 97 | + $parsedoptions = $text; |
| 98 | + } |
| 99 | + } |
| 100 | + $imageHTML = $parser->makeImage( $imageTitle, $parsedoptions ); |
75 | 101 | $parser->mOutput->addImage( $imageTitle->getDBkey() ); |
76 | 102 | |
77 | 103 | $domDoc = new DOMDocument(); |