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/includes/parser/Parser.php
@@ -4224,7 +4224,7 @@
42254225 'vertAlign' => array( 'baseline', 'sub', 'super', 'top', 'text-top', 'middle',
42264226 'bottom', 'text-bottom' ),
42274227 'frame' => array( 'thumbnail', 'manualthumb', 'framed', 'frameless',
4228 - 'upright', 'border', 'click' ),
 4228+ 'upright', 'border', 'link' ),
42294229 );
42304230 static $internalParamMap;
42314231 if ( !$internalParamMap ) {
@@ -4343,7 +4343,7 @@
43444344 /// downstream behavior seems odd with missing manual thumbs.
43454345 $validated = true;
43464346 break;
4347 - case 'click':
 4347+ case 'link':
43484348 $chars = self::EXT_LINK_URL_CLASS;
43494349 $prots = $this->mUrlProtocols;
43504350 if ( $value === '' ) {
@@ -4352,16 +4352,16 @@
43534353 $validated = true;
43544354 } elseif ( preg_match( "/^$prots/", $value ) ) {
43554355 if ( preg_match( "/^($prots)$chars+$/", $value, $m ) ) {
4356 - $paramName = 'click-url';
 4356+ $paramName = 'link-url';
43574357 $this->mOutput->addExternalLink( $value );
43584358 $validated = true;
43594359 }
43604360 } else {
4361 - $clickTitle = Title::newFromText( $value );
4362 - if ( $clickTitle ) {
4363 - $paramName = 'click-title';
4364 - $value = $clickTitle;
4365 - $this->mOutput->addLink( $clickTitle );
 4361+ $linkTitle = Title::newFromText( $value );
 4362+ if ( $linkTitle ) {
 4363+ $paramName = 'link-title';
 4364+ $value = $linkTitle;
 4365+ $this->mOutput->addLink( $linkTitle );
43664366 $validated = true;
43674367 }
43684368 }
Index: trunk/phase3/includes/Linker.php
@@ -699,8 +699,8 @@
700700 * bottom, text-bottom)
701701 * alt Alternate text for image (i.e. alt attribute). Plain text.
702702 * caption HTML for image caption.
703 - * click-url URL to link to
704 - * click-title Title object to link to
 703+ * link-url URL to link to
 704+ * link-title Title object to link to
705705 * no-link Boolean, suppress description link
706706 *
707707 * @param array $handlerParams Associative array of media handler parameters, to be passed
@@ -802,10 +802,10 @@
803803 'alt' => $fp['alt'],
804804 'valign' => isset( $fp['valign'] ) ? $fp['valign'] : false ,
805805 'img-class' => isset( $fp['border'] ) ? 'thumbborder' : false );
806 - if ( !empty( $fp['click-url'] ) ) {
807 - $params['custom-url-link'] = $fp['click-url'];
808 - } elseif ( !empty( $fp['click-title'] ) ) {
809 - $params['custom-title-link'] = $fp['click-title'];
 806+ if ( !empty( $fp['link-url'] ) ) {
 807+ $params['custom-url-link'] = $fp['link-url'];
 808+ } elseif ( !empty( $fp['link-title'] ) ) {
 809+ $params['custom-title-link'] = $fp['link-title'];
810810 } elseif ( !empty( $fp['no-link'] ) ) {
811811 // No link
812812 } else {
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -288,7 +288,7 @@
289289 'img_middle' => array( 1, 'middle' ),
290290 'img_bottom' => array( 1, 'bottom' ),
291291 'img_text_bottom' => array( 1, 'text-bottom' ),
292 - 'img_click' => array( 1, 'click=$1' ),
 292+ 'img_link' => array( 1, 'link=$1' ),
293293 'int' => array( 0, 'INT:' ),
294294 'sitename' => array( 1, 'SITENAME' ),
295295 'ns' => array( 0, 'NS:' ),
Index: trunk/phase3/RELEASE-NOTES
@@ -153,7 +153,7 @@
154154 MediaWiki:Pagenumber-#-PAGENAME where # is the page's namespace number and
155155 PAGENAME is the page name minus the namespace prefix. Can be disabled with
156156 the new magic word __NOHEADER__
157 -* Added "click" parameter to image links, to allow images to link to an
 157+* Added "link" parameter to image links, to allow images to link to an
158158 arbitrary title or URL. This should replace inaccessible and incomplete
159159 solutions such as CSS-based overlays and ImageMap.
160160
Index: trunk/phase3/maintenance/parserTests.txt
@@ -3095,6 +3095,35 @@
30963096 !! end
30973097
30983098 !! test
 3099+Image with link parameter, wiki target
 3100+!! input
 3101+[[Image:foobar.jpg|link=Target page]]
 3102+!! result
 3103+<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>
 3104+</p>
 3105+!! end
 3106+
 3107+!! test
 3108+Image with link parameter, URL target
 3109+!! input
 3110+[[Image:foobar.jpg|link=http://example.com/]]
 3111+!! result
 3112+<p><a href="http://example.com/"><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" border="0" /></a>
 3113+</p>
 3114+!! end
 3115+
 3116+!! test
 3117+Image with empty link parameter
 3118+!! input
 3119+[[Image:foobar.jpg|link=]]
 3120+!! result
 3121+<p><img alt="" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" border="0" />
 3122+</p>
 3123+!! end
 3124+
 3125+
 3126+
 3127+!! test
30993128 Image with frame and link
31003129 !! input
31013130 [[Image:Foobar.jpg|frame|left|This is a test image [[Main Page]]]]

Past revisions this follows-up on

Rev.Commit summaryAuthorDate
r41727* Added "click" parameter to image links, to allow images to link to an arbit...tstarling05:55, 6 October 2008

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]