<?php

class Zend_Filter_HTMLPurifier implements Zend_Filter_Interface
{
	    
	protected $_htmlPurifier = null;
   
    public function __construct($options = null)
    {
    	if(extension_loaded('dom') )
		{
			
			$config = null;
	        if (!is_null($options)) 
			{
	            $config = HTMLPurifier_Config::createDefault();
	                foreach ($options as $option) 
					{
					
	                    $config->set($option[0], $option[1], $option[2]);

	                }
    
	    	}
	        $this->_htmlPurifier = new HTMLPurifier($config);

    	}
    	else
    	{
    		file_put_contents('php://stderr', "CRITICAL WARNING ! Atmail : PHP DOM is missing, so no input fields can be sanitized!");
    	}

	}

    public function filter($value)
    {

		if(extension_loaded('dom') )
		{
		
			return $this->_htmlPurifier->purify( $value );
			
		}
		else
		{
			
			return strip_unsafe_tags( $value );
		}

    }

}