__construct() public method

Initializes the purifier.
public __construct ( HTMLPurifier_Config | mixed $config = null )
$config HTMLPurifier_Config | mixed Optional HTMLPurifier_Config object for all instances of the purifier, if omitted, a default configuration is supplied (which can be overridden on a per-use basis). The parameter can also be any type that HTMLPurifier_Config::create() supports.
Example #1
0
 function __construct($opt)
 {
     // prepare config
     $config = HTMLPurifier_Config::createDefault();
     // set cache directory
     $config->set('Cache.SerializerPath', $opt['html_purifier']['cache_path']);
     // create parent object with config
     parent::__construct($config);
 }
 public function __construct($opt)
 {
     // prepare config
     /** @var HTMLPurifier_Config $config */
     $config = HTMLPurifier_Config::createDefault();
     // set cache directory
     $config->set('Cache.SerializerPath', $opt['html_purifier']['cache_path']);
     // adjust URI filtering to fix issue #89 (enable special chars in URIs)
     $config->set('Core.EnableIDNA', true);
     // allow comments
     $config->set('HTML.AllowedCommentsRegexp', '/.*/');
     // enable href target='_blank'
     $config->set('Attr.AllowedFrameTargets', ['_blank', 'blank']);
     // enable ids/names with namespace 'custom_'
     $config->set('Attr.EnableID', true);
     $config->set('Attr.IDPrefix', 'custom_');
     // enable 'display' and 'visibility' styles for mystery descriptions
     $config->set('CSS.AllowTricky', true);
     // + display, visibility, overflow
     $config->set('CSS.ForbiddenProperties', 'overflow');
     // - overflow
     // prepare additional definitions
     $def = $config->getHTMLDefinition(true);
     // add tags
     $def->addElement('fieldset', 'Block', 'Flow', 'Common');
     //  HTML5 attribs currently not supported by TinyMCE
     $def->addElement('legend', 'Inline', 'Flow', 'Common');
     $def->addElement('q', 'Inline', 'Inline', 'Common', ['cite' => 'URI']);
     $def->addElement('strike', 'Inline', 'Inline', 'Common');
     // -> wird in CSS umgewandelt
     $def->addElement('area', 'Inline', 'Empty', 'Common', ['alt' => 'CDATA', 'coords' => 'CDATA', 'href' => 'URI', 'shape' => 'Enum#default,rect,circle,poly', 'target' => 'Enum#_blank,blank']);
     $def->addElement('map', 'Block', new HTMLPurifier_ChildDef_Optional('area'), 'Common', ['name' => 'ID']);
     // add attributes
     $def->addAttribute('img', 'usemap', 'CDATA');
     // create parent object with config
     parent::__construct($config);
 }
Example #3
0
 public function __construct()
 {
   $config = HTMLPurifier_Config::createDefault();
   $config->set('HTML.Allowed', $this->getHTMLAllowed());
   parent::__construct($config);
 }