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() ) {
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 );
}
}
- $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;
}
$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];
}
}
} 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];
}