ILIAS  release_4-4 Revision
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
 

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 13 of file Nofollow.php.

13  {
14  $this->parser = new HTMLPurifier_URIParser();
15  }
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 
)

Definition at line 17 of file Nofollow.php.

17  {
18 
19  if (!isset($attr['href'])) {
20  return $attr;
21  }
22 
23  // XXX Kind of inefficient
24  $url = $this->parser->parse($attr['href']);
25  $scheme = $url->getSchemeObj($config, $context);
26 
27  if ($scheme->browsable && !$url->isLocal($config, $context)) {
28  if (isset($attr['rel'])) {
29  $rels = explode(' ', $attr['rel']);
30  if (!in_array('nofollow', $rels)) {
31  $rels[] = 'nofollow';
32  }
33  $attr['rel'] = implode(' ', $rels);
34  } else {
35  $attr['rel'] = 'nofollow';
36  }
37  }
38 
39  return $attr;
40 
41  }

Field Documentation

◆ $parser

HTMLPurifier_AttrTransform_Nofollow::$parser
private

Definition at line 11 of file Nofollow.php.


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