* (bug 21364) External links using link= attribute on images now respect $wgExternalL...
authorAlexandre Emsenhuber <ialex@users.mediawiki.org>
Tue, 9 Nov 2010 12:25:57 +0000 (12:25 +0000)
committerAlexandre Emsenhuber <ialex@users.mediawiki.org>
Tue, 9 Nov 2010 12:25:57 +0000 (12:25 +0000)
RELEASE-NOTES
includes/Linker.php
includes/media/MediaTransformOutput.php
includes/parser/Parser.php

index ab0650d..43c50c1 100644 (file)
@@ -410,6 +410,8 @@ LocalSettings.php. The specific bugs are listed below in the general notes.
 * (bug 13353) Diff3 version checks were too strict, did not detect working diff3
 * (bug 25843) Links to special pages using link= attribute on images are now
   normalised like normal links to special pages
+* (bug 21364) External links using link= attribute on images now respect
+  $wgExternalLinkTarget
 
 === API changes in 1.17 ===
 * (bug 22738) Allow filtering by action type on query=logevent.
index 0a460b0..476878e 100644 (file)
@@ -428,6 +428,7 @@ class Linker {
         *          caption         HTML for image caption.
         *          link-url        URL to link to
         *          link-title      Title object to link to
+        *          link-target     Value for the target attribue, only with link-url
         *          no-link         Boolean, suppress description link
         *
         * @param $handlerParams Array: associative array of media handler parameters, to be passed
@@ -552,6 +553,9 @@ class Linker {
                $mtoParams = array();
                if ( isset( $frameParams['link-url'] ) && $frameParams['link-url'] !== '' ) {
                        $mtoParams['custom-url-link'] = $frameParams['link-url'];
+                       if ( isset( $frameParams['link-target'] ) ) {
+                               $mtoParams['custom-target-link'] = $frameParams['link-target'];
+                       }
                } elseif ( isset( $frameParams['link-title'] ) && $frameParams['link-title'] !== '' ) {
                        $mtoParams['custom-title-link'] = $this->normaliseSpecialPage( $frameParams['link-title'] );
                } elseif ( !empty( $frameParams['no-link'] ) ) {
index 276d254..c441f06 100644 (file)
@@ -144,6 +144,7 @@ class ThumbnailImage extends MediaTransformOutput {
         *     desc-query   String, description link query params
         *     custom-url-link    Custom URL to link to
         *     custom-title-link  Custom Title object to link to
+        *     custom target-link Value of the target attribute, for custom-target-link
         *
         * For images, desc-link and file-link are implemented as a click-through. For
         * sounds and videos, they may be displayed in other ways.
@@ -164,6 +165,9 @@ class ThumbnailImage extends MediaTransformOutput {
                        if ( !empty( $options['title'] ) ) {
                                $linkAttribs['title'] = $options['title'];
                        }
+                       if ( !empty( $options['custom-target-link'] ) ) {
+                               $linkAttribs['target'] = $options['custom-target-link'];
+                       }
                } elseif ( !empty( $options['custom-title-link'] ) ) {
                        $title = $options['custom-title-link'];
                        $linkAttribs = array(
index 1e2b3af..4a83524 100644 (file)
@@ -4694,6 +4694,9 @@ class Parser {
                                                                if ( preg_match( "/^($prots)$chars+$/", $value, $m ) ) {
                                                                        $paramName = 'link-url';
                                                                        $this->mOutput->addExternalLink( $value );
+                                                                       if ( $this->mOptions->getExternalLinkTarget() ) {
+                                                                               $params[$type]['link-target'] = $this->mOptions->getExternalLinkTarget();
+                                                                       }
                                                                        $validated = true;
                                                                }
                                                        } else {