Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/lib/htmlpurifier/HTMLPurifier/AttrTransform/Nofollow.php
Go to the documentation of this file.
00001 <?php
00002 
00003 // must be called POST validation
00004 
00009 class HTMLPurifier_AttrTransform_Nofollow extends HTMLPurifier_AttrTransform
00010 {
00011     private $parser;
00012 
00013     public function __construct() {
00014         $this->parser = new HTMLPurifier_URIParser();
00015     }
00016 
00017     public function transform($attr, $config, $context) {
00018 
00019         if (!isset($attr['href'])) {
00020             return $attr;
00021         }
00022 
00023         // XXX Kind of inefficient
00024         $url = $this->parser->parse($attr['href']);
00025         $scheme = $url->getSchemeObj($config, $context);
00026 
00027         if (!is_null($url->host) && $scheme !== false && $scheme->browsable) {
00028             if (isset($attr['rel'])) {
00029                 $attr['rel'] .= ' nofollow';
00030             } else {
00031                 $attr['rel'] = 'nofollow';
00032             }
00033         }
00034 
00035         return $attr;
00036 
00037     }
00038 
00039 }
00040 
00041 // vim: et sw=4 sts=4
 All Data Structures Namespaces Files Functions Variables Enumerations