ILIAS  release_5-2 Revision v5.2.25-18-g3f80b82851
HTMLPurifier_AttrTransform_Nofollow Class Reference

Adds rel="nofollow" to all outbound links. More...

+ Inheritance diagram for HTMLPurifier_AttrTransform_Nofollow:
+ Collaboration diagram for HTMLPurifier_AttrTransform_Nofollow:

Public Member Functions

 __construct ()
 
 transform ($attr, $config, $context)
 
- Public Member Functions inherited from HTMLPurifier_AttrTransform
 transform ($attr, $config, $context)
 Abstract: makes changes to the attributes dependent on multiple values. More...
 
 prependCSS (&$attr, $css)
 Prepends CSS properties to the style attribute, creating the attribute if it doesn't exist. More...
 
 confiscateAttr (&$attr, $key)
 Retrieves and removes an attribute. More...
 

Private Attributes

 $parser
 HTMLPurifier_URIParser More...
 

Detailed Description

Adds rel="nofollow" to all outbound links.

This transform is only attached if Attr.Nofollow is TRUE.

Definition at line 9 of file Nofollow.php.

Constructor & Destructor Documentation

◆ __construct()

HTMLPurifier_AttrTransform_Nofollow::__construct ( )

Definition at line 16 of file Nofollow.php.

17  {
18  $this->parser = new HTMLPurifier_URIParser();
19  }
Parses a URI into the components and fragment identifier as specified by RFC 3986.
Definition: URIParser.php:7

Member Function Documentation

◆ transform()

HTMLPurifier_AttrTransform_Nofollow::transform (   $attr,
  $config,
  $context 
)
Parameters
array$attr
HTMLPurifier_Config$config
HTMLPurifier_Context$context
Returns
array

Definition at line 27 of file Nofollow.php.

References $config, and $url.

28  {
29  if (!isset($attr['href'])) {
30  return $attr;
31  }
32 
33  // XXX Kind of inefficient
34  $url = $this->parser->parse($attr['href']);
35  $scheme = $url->getSchemeObj($config, $context);
36 
37  if ($scheme->browsable && !$url->isLocal($config, $context)) {
38  if (isset($attr['rel'])) {
39  $rels = explode(' ', $attr['rel']);
40  if (!in_array('nofollow', $rels)) {
41  $rels[] = 'nofollow';
42  }
43  $attr['rel'] = implode(' ', $rels);
44  } else {
45  $attr['rel'] = 'nofollow';
46  }
47  }
48  return $attr;
49  }
$url
Definition: shib_logout.php:72

Field Documentation

◆ $parser

HTMLPurifier_AttrTransform_Nofollow::$parser
private

HTMLPurifier_URIParser

Definition at line 14 of file Nofollow.php.


The documentation for this class was generated from the following file: