mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/ImageMap
synced 2024-11-23 13:56:46 +00:00
Set target to $wgExternalLinkTarget
Set hyperlink 'target' attribute to $wgExternalLinkTarget. In addition, set the 'rel' attribute according to the $wgNoFollowLinks, $wgNoFollowDomainExceptions and $wgNoFollowNsExceptions settings (bug T186241). Bug: T356730 Change-Id: If4880e4e0b3cd2056521d44baf261ed848511bcd
This commit is contained in:
parent
0cf105323f
commit
754b722c56
|
@ -60,7 +60,7 @@ class ImageMap implements ParserFirstCallInitHook {
|
|||
* @return string HTML (Image map, or error message)
|
||||
*/
|
||||
public function render( $input, $params, Parser $parser ) {
|
||||
global $wgUrlProtocols, $wgNoFollowLinks;
|
||||
global $wgUrlProtocols;
|
||||
$config = MediaWikiServices::getInstance()->getMainConfig();
|
||||
$enableLegacyMediaDOM = $config->get( 'ParserEnableLegacyMediaDOM' );
|
||||
|
||||
|
@ -246,11 +246,11 @@ class ImageMap implements ParserFirstCallInitHook {
|
|||
// Construct the area tag
|
||||
$attribs = [];
|
||||
if ( $externLink ) {
|
||||
// Get the 'target' and 'rel' attributes for external link.
|
||||
$attribs = $parser->getExternalLinkAttribs( $title );
|
||||
|
||||
$attribs['href'] = $title;
|
||||
$attribs['class'] = 'plainlinks';
|
||||
if ( $wgNoFollowLinks ) {
|
||||
$attribs['rel'] = 'nofollow';
|
||||
}
|
||||
} elseif ( $title->getFragment() !== '' && $title->getPrefixedDBkey() === '' ) {
|
||||
// XXX: kluge to handle [[#Fragment]] links, should really fix getLocalURL()
|
||||
// in Title.php to return an empty string in this case
|
||||
|
|
|
@ -14,6 +14,7 @@ use Wikimedia\Parsoid\Ext\ExtensionTagHandler;
|
|||
use Wikimedia\Parsoid\Ext\ParsoidExtensionAPI;
|
||||
use Wikimedia\Parsoid\Ext\WTUtils;
|
||||
use Wikimedia\Parsoid\Utils\DOMCompat;
|
||||
use Wikimedia\Parsoid\Utils\UrlUtils;
|
||||
|
||||
/**
|
||||
* This is an adaptation of the existing ImageMap extension of the legacy
|
||||
|
@ -251,13 +252,32 @@ class ParsoidImageMap extends ExtensionTagHandler implements ExtensionModule {
|
|||
}
|
||||
|
||||
// Construct the area tag
|
||||
|
||||
$attribs = [ 'href' => $href ];
|
||||
if ( $externLink ) {
|
||||
$attribs['class'] = 'plainlinks';
|
||||
// FIXME: T186241
|
||||
// if ( $wgNoFollowLinks ) {
|
||||
// $attribs['rel'] = 'nofollow';
|
||||
// }
|
||||
|
||||
$siteConfig = $extApi->getSiteConfig();
|
||||
|
||||
// Get the 'rel' attribute for external link.
|
||||
$noFollowConfig = $siteConfig->getNoFollowConfig();
|
||||
if (
|
||||
$noFollowConfig['nofollow'] &&
|
||||
!in_array(
|
||||
$extApi->getPageConfig()->getLinkTarget()->getNamespace(),
|
||||
$noFollowConfig['nsexceptions'],
|
||||
true
|
||||
) &&
|
||||
!UrlUtils::matchesDomainList( $href, $noFollowConfig['domainexceptions'] )
|
||||
) {
|
||||
$attribs['rel'] = 'nofollow';
|
||||
}
|
||||
|
||||
// Get the 'target' attribute for external link
|
||||
$externLinkTarget = $siteConfig->getExternalLinkTarget();
|
||||
if ( $externLinkTarget ) {
|
||||
$attribs['target'] = $externLinkTarget;
|
||||
}
|
||||
}
|
||||
if ( $shape != 'default' ) {
|
||||
$attribs['shape'] = $shape;
|
||||
|
|
Loading…
Reference in a new issue