From 0dd22a54067e4348246009bddb82373c42df71ee Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 30 Sep 2008 00:14:25 +0000 Subject: [PATCH] Back out r41333 -- causes lots of parser test regressions due to funny spacing. Probably an easy fix but it wasn't tested apparently. :) --- RELEASE-NOTES | 2 -- includes/DefaultSettings.php | 5 ----- includes/Linker.php | 11 ++++++----- includes/parser/Parser.php | 26 ++------------------------ includes/parser/ParserOptions.php | 5 ----- includes/parser/Parser_OldPP.php | 18 ++---------------- 6 files changed, 10 insertions(+), 57 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 2ed9bfd105..78b85360b2 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -140,8 +140,6 @@ The following extensions are migrated into MediaWiki 1.14: restriction types on the protection form. * (bug 8440) Allow preventing blocked users from editing their talk pages * Improved upload file type detection for OpenDocument formats -* Added the ability to set the target attribute on external links with - $wgExternalLinkTarget * (bug 368) Don't use caption for alt attribute; allow manual specification using new "alt=" parameter for images diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 78b7327b7c..a7a975b1ca 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -2890,11 +2890,6 @@ $wgDisableInternalSearch = false; */ $wgSearchForwardUrl = null; -/** - * Set a default target for external links, e.g. _blank to pop up a new window - */ -$wgExternalLinkTarget = false; - /** * If true, external URL links in wiki text will be given the * rel="nofollow" attribute as a hint to search engines that diff --git a/includes/Linker.php b/includes/Linker.php index bb1bf921f8..529891cafe 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -990,10 +990,11 @@ class Linker { } /** @todo document */ - function makeExternalLink( $url, $text, $escape = true, $linktype = '', $attribs = array() ) { - $attribsText = $this->getExternalLinkAttributes( $url, $text, 'external ' . $linktype ); - if ( $attribs ) { - $attribsText .= ' ' . Xml::expandAttributes( $attribs ); + function makeExternalLink( $url, $text, $escape = true, $linktype = '', $ns = null ) { + $style = $this->getExternalLinkAttributes( $url, $text, 'external ' . $linktype ); + global $wgNoFollowLinks, $wgNoFollowNsExceptions; + if( $wgNoFollowLinks && !(isset($ns) && in_array($ns, $wgNoFollowNsExceptions)) ) { + $style .= ' rel="nofollow"'; } $url = htmlspecialchars( $url ); if( $escape ) { @@ -1005,7 +1006,7 @@ class Linker { wfDebug("Hook LinkerMakeExternalLink changed the output of link with url {$url} and text {$text} to {$link}", true); return $link; } - return ''.$text.''; + return ''.$text.''; } /** diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 8687091631..99463d2f35 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -1118,8 +1118,7 @@ class Parser $text = $this->maybeMakeExternalImage( $url ); if ( $text === false ) { # Not an image, make a link - $text = $sk->makeExternalLink( $url, $wgContLang->markNoConversion($url), true, 'free', - $this->getExternalLinkAttribs() ); + $text = $sk->makeExternalLink( $url, $wgContLang->markNoConversion($url), true, 'free', $this->mTitle->getNamespace() ); # Register it in the output object... # Replace unnecessary URL escape codes with their equivalent characters $pasteurized = self::replaceUnusualEscapes( $url ); @@ -1395,18 +1394,11 @@ class Parser $url = Sanitizer::cleanUrl( $url ); - if ( $this->mOptions->mExternalLinkTarget ) { - $attribs = array( 'target' => $this->mOptions->mExternalLinkTarget ); - } else { - $attribs = array(); - } - # Use the encoded URL # This means that users can paste URLs directly into the text # Funny characters like ö aren't valid in URLs anyway # This was changed in August 2004 - $s .= $sk->makeExternalLink( $url, $text, false, $linktype, $this->getExternalLinkAttribs() ) - . $dtrail . $trail; + $s .= $sk->makeExternalLink( $url, $text, false, $linktype, $this->mTitle->getNamespace() ) . $dtrail . $trail; # Register link in the output object. # Replace unnecessary URL escape codes with the referenced character @@ -1419,20 +1411,6 @@ class Parser return $s; } - function getExternalLinkAttribs() { - $attribs = array(); - global $wgNoFollowLinks, $wgNoFollowNsExceptions; - $ns = $this->mTitle->getNamespace(); - if( $wgNoFollowLinks && !in_array($ns, $wgNoFollowNsExceptions) ) { - $attribs['rel'] = 'nofollow'; - } - if ( $this->mOptions->getExternalLinkTarget() ) { - $attribs['target'] = $this->mOptions->getExternalLinkTarget(); - } - return $attribs; - } - - /** * Replace unusual URL escape codes with their equivalent characters * @param string diff --git a/includes/parser/ParserOptions.php b/includes/parser/ParserOptions.php index 5b8cd3ee64..2cde0197c3 100644 --- a/includes/parser/ParserOptions.php +++ b/includes/parser/ParserOptions.php @@ -30,7 +30,6 @@ class ParserOptions var $mTemplateCallback; # Callback for template fetching var $mEnableLimitReport; # Enable limit report in an HTML comment on output var $mTimestamp; # Timestamp used for {{CURRENTDAY}} etc. - var $mExternalLinkTarget; # Target attribute for external links var $mUser; # Stored user object, just used to initialise the skin @@ -53,7 +52,6 @@ class ParserOptions function getTemplateCallback() { return $this->mTemplateCallback; } function getEnableLimitReport() { return $this->mEnableLimitReport; } function getCleanSignatures() { return $this->mCleanSignatures; } - function getExternalLinkTarget() { return $this->mExternalLinkTarget; } function getSkin() { if ( !isset( $this->mSkin ) ) { @@ -98,7 +96,6 @@ class ParserOptions function enableLimitReport( $x = true ) { return wfSetVar( $this->mEnableLimitReport, $x ); } function setTimestamp( $x ) { return wfSetVar( $this->mTimestamp, $x ); } function setCleanSignatures( $x ) { return wfSetVar( $this->mCleanSignatures, $x ); } - function setExternalLinkTarget( $x ) { return wfSetVar( $this->mExternalLinkTarget, $x ); } function __construct( $user = null ) { $this->initialiseFromUser( $user ); @@ -117,7 +114,6 @@ class ParserOptions global $wgUseTeX, $wgUseDynamicDates, $wgInterwikiMagic, $wgAllowExternalImages; global $wgAllowExternalImagesFrom, $wgEnableImageWhitelist, $wgAllowSpecialInclusion, $wgMaxArticleSize; global $wgMaxPPNodeCount, $wgMaxTemplateDepth, $wgMaxPPExpandDepth, $wgCleanSignatures; - global $wgExternalLinkTarget; $fname = 'ParserOptions::initialiseFromUser'; wfProfileIn( $fname ); if ( !$userInput ) { @@ -155,7 +151,6 @@ class ParserOptions $this->mTemplateCallback = array( 'Parser', 'statelessFetchTemplate' ); $this->mEnableLimitReport = false; $this->mCleanSignatures = $wgCleanSignatures; - $this->mExternalLinkTarget = $wgExternalLinkTarget; wfProfileOut( $fname ); } } diff --git a/includes/parser/Parser_OldPP.php b/includes/parser/Parser_OldPP.php index 106e439f47..415ef23fdf 100644 --- a/includes/parser/Parser_OldPP.php +++ b/includes/parser/Parser_OldPP.php @@ -1353,7 +1353,7 @@ class Parser_OldPP # This means that users can paste URLs directly into the text # Funny characters like ö aren't valid in URLs anyway # This was changed in August 2004 - $s .= $sk->makeExternalLink( $url, $text, false, $linktype, $this->getExternalLinkAttribs() ) . $dtrail . $trail; + $s .= $sk->makeExternalLink( $url, $text, false, $linktype, $this->mTitle->getNamespace() ) . $dtrail . $trail; # Register link in the output object. # Replace unnecessary URL escape codes with the referenced character @@ -1366,19 +1366,6 @@ class Parser_OldPP return $s; } - function getExternalLinkAttribs() { - $attribs = array(); - global $wgNoFollowLinks, $wgNoFollowNsExceptions; - $ns = $this->mTitle->getNamespace(); - if( $wgNoFollowLinks && !in_array($ns, $wgNoFollowNsExceptions) ) { - $attribs['rel'] = 'nofollow'; - } - if ( $this->mOptions->getExternalLinkTarget() ) { - $attribs['target'] = $this->mOptions->getExternalLinkTarget(); - } - return $attribs; - } - /** * Replace anything that looks like a URL with a link * @private @@ -1445,8 +1432,7 @@ class Parser_OldPP $text = $this->maybeMakeExternalImage( $url ); if ( $text === false ) { # Not an image, make a link - $text = $sk->makeExternalLink( $url, $wgContLang->markNoConversion($url), true, 'free', - $this->getExternalLinkAttribs() ); + $text = $sk->makeExternalLink( $url, $wgContLang->markNoConversion($url), true, 'free', $this->mTitle->getNamespace() ); # Register it in the output object... # Replace unnecessary URL escape codes with their equivalent characters $pasteurized = self::replaceUnusualEscapes( $url ); -- 2.20.1