r40684 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r40683‎ | r40684 | r40685 >
Date:22:12, 9 September 2008
Author:mrzman
Status:old
Tags:
Comment:
Actually parse the options so links and templates will work in captions, code adapted from Cite extension.
Modified paths:
  • /trunk/extensions/ImageMap/ImageMap_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ImageMap/ImageMap_body.php
@@ -70,7 +70,33 @@
7171 if ( wfIsBadImage( $imageTitle->getDBkey() , $parser->mTitle ) ) {
7272 return self::error( 'imagemap_bad_image' );
7373 }
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 );
75101 $parser->mOutput->addImage( $imageTitle->getDBkey() );
76102
77103 $domDoc = new DOMDocument();