diff options
-rw-r--r-- | RELEASE-NOTES | 2 | ||||
-rw-r--r-- | includes/Linker.php | 12 | ||||
-rw-r--r-- | includes/parser/Parser.php | 16 | ||||
-rw-r--r-- | languages/messages/MessagesEn.php | 2 | ||||
-rw-r--r-- | maintenance/parserTests.txt | 29 |
5 files changed, 45 insertions, 16 deletions
diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 6edcc9fa16e9..deded94eb866 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -153,7 +153,7 @@ The following extensions are migrated into MediaWiki 1.14: MediaWiki:Pagenumber-#-PAGENAME where # is the page's namespace number and PAGENAME is the page name minus the namespace prefix. Can be disabled with the new magic word __NOHEADER__ -* Added "click" parameter to image links, to allow images to link to an +* Added "link" parameter to image links, to allow images to link to an arbitrary title or URL. This should replace inaccessible and incomplete solutions such as CSS-based overlays and ImageMap. diff --git a/includes/Linker.php b/includes/Linker.php index bc9d12cbc93a..5401d251b25f 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -699,8 +699,8 @@ class Linker { * bottom, text-bottom) * alt Alternate text for image (i.e. alt attribute). Plain text. * caption HTML for image caption. - * click-url URL to link to - * click-title Title object to link to + * link-url URL to link to + * link-title Title object to link to * no-link Boolean, suppress description link * * @param array $handlerParams Associative array of media handler parameters, to be passed @@ -802,10 +802,10 @@ class Linker { 'alt' => $fp['alt'], 'valign' => isset( $fp['valign'] ) ? $fp['valign'] : false , 'img-class' => isset( $fp['border'] ) ? 'thumbborder' : false ); - if ( !empty( $fp['click-url'] ) ) { - $params['custom-url-link'] = $fp['click-url']; - } elseif ( !empty( $fp['click-title'] ) ) { - $params['custom-title-link'] = $fp['click-title']; + if ( !empty( $fp['link-url'] ) ) { + $params['custom-url-link'] = $fp['link-url']; + } elseif ( !empty( $fp['link-title'] ) ) { + $params['custom-title-link'] = $fp['link-title']; } elseif ( !empty( $fp['no-link'] ) ) { // No link } else { diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 7fa3eca780ef..a8e8f3d6076b 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -4224,7 +4224,7 @@ class Parser 'vertAlign' => array( 'baseline', 'sub', 'super', 'top', 'text-top', 'middle', 'bottom', 'text-bottom' ), 'frame' => array( 'thumbnail', 'manualthumb', 'framed', 'frameless', - 'upright', 'border', 'click' ), + 'upright', 'border', 'link' ), ); static $internalParamMap; if ( !$internalParamMap ) { @@ -4343,7 +4343,7 @@ class Parser /// downstream behavior seems odd with missing manual thumbs. $validated = true; break; - case 'click': + case 'link': $chars = self::EXT_LINK_URL_CLASS; $prots = $this->mUrlProtocols; if ( $value === '' ) { @@ -4352,16 +4352,16 @@ class Parser $validated = true; } elseif ( preg_match( "/^$prots/", $value ) ) { if ( preg_match( "/^($prots)$chars+$/", $value, $m ) ) { - $paramName = 'click-url'; + $paramName = 'link-url'; $this->mOutput->addExternalLink( $value ); $validated = true; } } else { - $clickTitle = Title::newFromText( $value ); - if ( $clickTitle ) { - $paramName = 'click-title'; - $value = $clickTitle; - $this->mOutput->addLink( $clickTitle ); + $linkTitle = Title::newFromText( $value ); + if ( $linkTitle ) { + $paramName = 'link-title'; + $value = $linkTitle; + $this->mOutput->addLink( $linkTitle ); $validated = true; } } diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 91c0b7de66d0..61ddb01105f1 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -288,7 +288,7 @@ $magicWords = array( 'img_middle' => array( 1, 'middle' ), 'img_bottom' => array( 1, 'bottom' ), 'img_text_bottom' => array( 1, 'text-bottom' ), - 'img_click' => array( 1, 'click=$1' ), + 'img_link' => array( 1, 'link=$1' ), 'int' => array( 0, 'INT:' ), 'sitename' => array( 1, 'SITENAME' ), 'ns' => array( 0, 'NS:' ), diff --git a/maintenance/parserTests.txt b/maintenance/parserTests.txt index 7631f142323e..9854cff0de17 100644 --- a/maintenance/parserTests.txt +++ b/maintenance/parserTests.txt @@ -3095,6 +3095,35 @@ Image with caption !! end !! test +Image with link parameter, wiki target +!! input +[[Image:foobar.jpg|link=Target page]] +!! result +<p><a href="/wiki/Target_page" title="Target page"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" border="0" /></a> +</p> +!! end + +!! test +Image with link parameter, URL target +!! input +[[Image:foobar.jpg|link=http://example.com/]] +!! result +<p><a href="http://example.com/"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" border="0" /></a> +</p> +!! end + +!! test +Image with empty link parameter +!! input +[[Image:foobar.jpg|link=]] +!! result +<p><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" border="0" /> +</p> +!! end + + + +!! test Image with frame and link !! input [[Image:Foobar.jpg|frame|left|This is a test image [[Main Page]]]] |