From 86055bdfa4fc7ba1016abc0ffbb20cafbf98436f Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 7 Oct 2008 00:31:26 +0000 Subject: [PATCH] Update to r41727 (bug 539) "click" parameter on images. * Renamed to "link", which seems clearer and less mouse-centric ;) * Added parser test cases: 3 new PASSING test(s) :) * Image with link parameter, wiki target [Has never failed] * Image with link parameter, URL target [Has never failed] * Image with empty link parameter [Has never failed] --- RELEASE-NOTES | 2 +- includes/Linker.php | 12 ++++++------ includes/parser/Parser.php | 16 ++++++++-------- languages/messages/MessagesEn.php | 2 +- maintenance/parserTests.txt | 29 +++++++++++++++++++++++++++++ 5 files changed, 45 insertions(+), 16 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 6edcc9fa16..deded94eb8 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 bc9d12cbc9..5401d251b2 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 7fa3eca780..a8e8f3d607 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 91c0b7de66..61ddb01105 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 7631f14232..9854cff0de 100644 --- a/maintenance/parserTests.txt +++ b/maintenance/parserTests.txt @@ -3094,6 +3094,35 @@ Image with caption !! end +!! test +Image with link parameter, wiki target +!! input +[[Image:foobar.jpg|link=Target page]] +!! result +

+

+!! end + +!! test +Image with link parameter, URL target +!! input +[[Image:foobar.jpg|link=http://example.com/]] +!! result +

+

+!! end + +!! test +Image with empty link parameter +!! input +[[Image:foobar.jpg|link=]] +!! result +

+

+!! end + + + !! test Image with frame and link !! input -- 2.20.1