http://www.mediawiki.org/wiki/Special:Code/MediaWiki/90849

Revision: 90849
Author:   mah
Date:     2011-06-26 19:52:11 +0000 (Sun, 26 Jun 2011)
Log Message:
-----------
Apply rgcjones' patch for Bug#29533:

    Whe placing an external link in the sidebar, $wgExternalLinkTarget is 
ignored.
    Also enables applying of $wgNoFollowLinks in the sidebar.

Modified Paths:
--------------
    trunk/phase3/CREDITS
    trunk/phase3/includes/Skin.php
    trunk/phase3/includes/SkinTemplate.php

Modified: trunk/phase3/CREDITS
===================================================================
--- trunk/phase3/CREDITS        2011-06-26 19:38:53 UTC (rev 90848)
+++ trunk/phase3/CREDITS        2011-06-26 19:52:11 UTC (rev 90849)
@@ -136,6 +136,7 @@
 * PieRRoMaN
 * quietust
 * René Kijewski
+* rgcjonas
 * Robert Treat
 * RockMFR
 * Salvatore Ingala

Modified: trunk/phase3/includes/Skin.php
===================================================================
--- trunk/phase3/includes/Skin.php      2011-06-26 19:38:53 UTC (rev 90848)
+++ trunk/phase3/includes/Skin.php      2011-06-26 19:52:11 UTC (rev 90849)
@@ -1253,6 +1253,7 @@
                                if ( strpos( $line, '|' ) !== false ) { // 
sanity check
                                        $line = 
MessageCache::singleton()->transform( $line, false, null, $this->getTitle() );
                                        $line = array_map( 'trim', explode( 
'|', $line, 2 ) );
+                                       $extraAttribs = array();
 
                                        $msgLink = wfMessage( $line[0] 
)->inContentLanguage();
                                        if ( $msgLink->exists() ) {
@@ -1273,6 +1274,28 @@
 
                                        if ( preg_match( '/^(?:' . 
wfUrlProtocols() . ')/', $link ) ) {
                                                $href = $link;
+                                               
//Parser::getExternalLinkAttribs won't work here because of the Namespace things
+                                               global $wgNoFollowLinks;
+                                               if ( $wgNoFollowLinks ) {
+                                                       $extraAttribs['rel'] = 
'nofollow';
+
+                                                       global 
$wgNoFollowDomainExceptions;
+                                                       if ( 
$wgNoFollowDomainExceptions ) {
+                                                               $bits = 
wfParseUrl( $url );
+                                                               if ( is_array( 
$bits ) && isset( $bits['host'] ) ) {
+                                                                       foreach 
( $wgNoFollowDomainExceptions as $domain ) {
+                                                                               
if ( substr( $bits['host'], -strlen( $domain ) ) == $domain ) {
+                                                                               
        unset( $extraAttribs['rel'] );
+                                                                               
        break;
+                                                                               
}
+                                                                       }
+                                                               }
+                                                       }
+                                               }
+                                               global $wgExternalLinkTarget;
+                                               if ( $wgExternalLinkTarget) {
+                                                       $extraAttribs['target'] 
= $wgExternalLinkTarget;
+                                               }
                                        } else {
                                                $title = Title::newFromText( 
$link );
 
@@ -1284,12 +1307,12 @@
                                                }
                                        }
 
-                                       $bar[$heading][] = array(
+                                       $bar[$heading][] = array_merge( array(
                                                'text' => $text,
                                                'href' => $href,
                                                'id' => 'n-' . strtr( $line[1], 
' ', '-' ),
                                                'active' => false
-                                       );
+                                       ), $extraAttribs );
                                } elseif ( ( substr( $line, 0, 2 ) == '{{' ) && 
( substr( $line, -2 ) == '}}' ) ) {
                                        global $wgParser;
 

Modified: trunk/phase3/includes/SkinTemplate.php
===================================================================
--- trunk/phase3/includes/SkinTemplate.php      2011-06-26 19:38:53 UTC (rev 
90848)
+++ trunk/phase3/includes/SkinTemplate.php      2011-06-26 19:52:11 UTC (rev 
90849)
@@ -1576,7 +1576,7 @@
                }
 
                $attrs = array();
-               foreach ( array( 'href', 'id', 'class', 'rel', 'type' ) as 
$attr ) {
+               foreach ( array( 'href', 'id', 'class', 'rel', 'type', 
'target') as $attr ) {
                        if ( isset( $item[$attr] ) ) {
                                $attrs[$attr] = $item[$attr];
                        }
@@ -1629,7 +1629,7 @@
                        }
                } else {
                        $link = array();
-                       foreach ( array( 'text', 'msg', 'href', 'rel', 'type', 
'tooltiponly' ) as $k ) {
+                       foreach ( array( 'text', 'msg', 'href', 'rel', 'type', 
'tooltiponly', 'target' ) as $k ) {
                                if ( isset( $item[$k] ) ) {
                                        $link[$k] = $item[$k];
                                }


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to