Update to r41727 (bug 539) "click" parameter on images.
authorBrion Vibber <brion@users.mediawiki.org>
Tue, 7 Oct 2008 00:31:26 +0000 (00:31 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Tue, 7 Oct 2008 00:31:26 +0000 (00:31 +0000)
* 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
includes/Linker.php
includes/parser/Parser.php
languages/messages/MessagesEn.php
maintenance/parserTests.txt

index 6edcc9f..deded94 100644 (file)
@@ -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.
 
index bc9d12c..5401d25 100644 (file)
@@ -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 {
index 7fa3eca..a8e8f3d 100644 (file)
@@ -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;
                                                                }
                                                        }
index 91c0b7d..61ddb01 100644 (file)
@@ -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:'                    ),
index 7631f14..9854cff 100644 (file)
@@ -3094,6 +3094,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