r21360 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r21359‎ | r21360 | r21361 >
Date:06:00, 19 April 2007
Author:raymond
Status:old
Tags:
Comment:
* Changing $wgImageMapAllowExternLink -> $wgImageMapAllowExternalLinks
per hint of Rob Church at wikitech-l
* ooops, not every ImageMap use external links...
Modified paths:
  • /trunk/extensions/ImageMap/ImageMap.php (modified) (history)
  • /trunk/extensions/ImageMap/ImageMap_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ImageMap/ImageMap.php
@@ -4,7 +4,7 @@
55 * Set this to true to enable extern links [http://www.example.com] as
66 * link destination
77 */
8 -$wgImageMapAllowExternLink = false;
 8+$wgImageMapAllowExternalLinks = false;
99
1010 $wgExtensionFunctions[] = 'wfSetupImageMap';
1111 $wgAutoloadClasses['ImageMap'] = dirname(__FILE__).'/ImageMap_body.php';
Index: trunk/extensions/ImageMap/ImageMap_body.php
@@ -32,7 +32,7 @@
3333 const NONE = 4;
3434
3535 static function render( $input, $params, $parser ) {
36 - global $wgScriptPath, $wgUser, $wgImageMapAllowExternLink, $wgUrlProtocols, $wgNoFollowLinks;
 36+ global $wgScriptPath, $wgUser, $wgImageMapAllowExternalLinks, $wgUrlProtocols, $wgNoFollowLinks;
3737
3838 $lines = explode( "\n", $input );
3939
@@ -125,7 +125,7 @@
126126 } elseif ( preg_match( '/^ \[\[ ([^\]]*+) \]\] \w* $ /x', $link, $m ) ) {
127127 $title = Title::newFromText( $m[1] );
128128 $alt = $title->getFullText();
129 - } elseif ( $wgImageMapAllowExternLink && ( in_array( substr( $link , 1 , strpos($link, '//' )+1 ) , $wgUrlProtocols ) || in_array( substr( $link , 1 , strpos($link, ':' ) ) , $wgUrlProtocols ) ) ) {
 129+ } elseif ( $wgImageMapAllowExternalLinks && ( in_array( substr( $link , 1 , strpos($link, '//' )+1 ) , $wgUrlProtocols ) || in_array( substr( $link , 1 , strpos($link, ':' ) ) , $wgUrlProtocols ) ) ) {
130130 if ( preg_match( '/^ \[ ([^\s]*+) \s ([^\]]*+) \] \w* $ /x', $link, $m ) ) {
131131 $title = htmlspecialchars( $m[1] );
132132 $alt = htmlspecialchars( trim( $m[2] ) );
@@ -289,10 +289,11 @@
290290 foreach ( $links as $title ) {
291291 $parser->mOutput->addLink( $title );
292292 }
293 - foreach ( $extLinks as $title ) {
294 - $parser->mOutput->addExternalLink( $title );
 293+ if ( isset( $extLinks ) ) {
 294+ foreach ( $extLinks as $title ) {
 295+ $parser->mOutput->addExternalLink( $title );
 296+ }
295297 }
296 -
297298 # Armour output against broken parser
298299 $output = str_replace( "\n", '', $output );
299300 return $output;