From: Brion Vibber Date: Mon, 22 May 2006 21:17:38 +0000 (+0000) Subject: * (bug 5523) $wgNoFollowNsExceptions to allow disabling rel="nofollow" in specially... X-Git-Tag: 1.31.0-rc.0~57059 X-Git-Url: http://git.cyclocoop.org/ecrire?a=commitdiff_plain;h=1d281db39f664ff6d6202e65fe31c05c498cdc8c;p=lhc%2Fweb%2Fwiklou.git * (bug 5523) $wgNoFollowNsExceptions to allow disabling rel="nofollow" in specially-selected namespaces. Patch by Ilmari Karonen, http://bugzilla.wikimedia.org/attachment.cgi?id=1789&action=view --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 15603fa717..ffae1a7d23 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -313,6 +313,9 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN look garbled when tidy isn't on * (bug 5511) Fix URL-encoding of usernames in links on Special:Ipblocklist * (bug 6046) Update to Indonesian localisation (id) #15 +* (bug 5523) $wgNoFollowNsExceptions to allow disabling rel="nofollow" in + specially-selected namespaces. + == Compatibility == diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 9837bcec9b..a5c394f5a9 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -1746,6 +1746,12 @@ $wgSearchForwardUrl = null; */ $wgNoFollowLinks = true; +/** + * Namespaces in which $wgNoFollowLinks doesn't apply. + * See Language.php for a list of namespaces. + */ +$wgNoFollowNsExceptions = array(); + /** * Specifies the minimal length of a user password. If set to * 0, empty passwords are allowed. diff --git a/includes/Linker.php b/includes/Linker.php index f088fafeeb..4fe385f257 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -734,10 +734,10 @@ class Linker { } /** @todo document */ - function makeExternalLink( $url, $text, $escape = true, $linktype = '' ) { + function makeExternalLink( $url, $text, $escape = true, $linktype = '', $ns = null ) { $style = $this->getExternalLinkAttributes( $url, $text, 'external ' . $linktype ); - global $wgNoFollowLinks; - if( $wgNoFollowLinks ) { + global $wgNoFollowLinks, $wgNoFollowNsExceptions; + if( $wgNoFollowLinks && !(isset($ns) && in_array($ns, $wgNoFollowNsExceptions)) ) { $style .= ' rel="nofollow"'; } $url = htmlspecialchars( $url ); diff --git a/includes/Parser.php b/includes/Parser.php index a3c3adf664..cb6d692e07 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -1190,7 +1190,7 @@ class Parser # 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 ) . $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 @@ -1270,7 +1270,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' ); + $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 = Parser::replaceUnusualEscapes( $url );