MediaWiki r41789 - Code Review

Jump to: navigation, search
Repository:MediaWiki
Revision:r41788‎ | r41789 (on ViewVC)‎ | r41790 >
Date:00:31, 7 October 2008
Author:brion
Status:old (Comments)
Tags:
Comment:
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]
Modified paths:

Diff [purge]

Index: trunk/phase3/maintenance/parserTests.txt
===================================================================
--- trunk/phase3/maintenance/parserTests.txt	(revision 41788)
+++ trunk/phase3/maintenance/parserTests.txt	(revision 41789)
@@ -3095,6 +3095,35 @@
 !! 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]]]]
Index: trunk/phase3/includes/parser/Parser.php
===================================================================
--- trunk/phase3/includes/parser/Parser.php	(revision 41788)
+++ trunk/phase3/includes/parser/Parser.php	(revision 41789)
@@ -4224,7 +4224,7 @@
 				'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 @@
 							/// 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 @@
 								$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: trunk/phase3/includes/Linker.php
===================================================================
--- trunk/phase3/includes/Linker.php	(revision 41788)
+++ trunk/phase3/includes/Linker.php	(revision 41789)
@@ -699,8 +699,8 @@
 	 *                          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 @@
 				'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: trunk/phase3/languages/messages/MessagesEn.php
===================================================================
--- trunk/phase3/languages/messages/MessagesEn.php	(revision 41788)
+++ trunk/phase3/languages/messages/MessagesEn.php	(revision 41789)
@@ -288,7 +288,7 @@
 	'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: trunk/phase3/RELEASE-NOTES
===================================================================
--- trunk/phase3/RELEASE-NOTES	(revision 41788)
+++ trunk/phase3/RELEASE-NOTES	(revision 41789)
@@ -153,7 +153,7 @@
   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.
 

Comments

#Comment by Bennylin (Talk | contribs)   07:19, 2 December 2008

I'm an admin at a wiki using ver MediaWiki: 1.11.0 How can I add this recent feature?

Status & tagging log

  • 15:32, 12 September 2011 Meno25 (Talk | contribs) changed the status of r41789 [removed: ok added: old]
  • 18:46, 2 April 2011 Happy-melon (Talk | contribs) changed the tags for r41789 [removed: image,link]
Personal tools
Namespaces
Variants
Views
Actions
Site
Support
Download
Development
Communication
Toolbox