ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
Nofollow.php
Go to the documentation of this file.
1<?php
2
3// must be called POST validation
4
10{
14 private $parser;
15
16 public function __construct()
17 {
18 $this->parser = new HTMLPurifier_URIParser();
19 }
20
27 public function transform($attr, $config, $context)
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 }
50}
51
52// vim: et sw=4 sts=4
Adds rel="nofollow" to all outbound links.
Definition: Nofollow.php:10
$parser
@type HTMLPurifier_URIParser
Definition: Nofollow.php:14
transform($attr, $config, $context)
Definition: Nofollow.php:27
Processes an entire attribute array for corrections needing multiple values.
Parses a URI into the components and fragment identifier as specified by RFC 3986.
Definition: URIParser.php:8
$url
Definition: shib_logout.php:72