HtmlPurifier.php

Go to the documentation of this file.
00001 <?php
00002 
00033 class Robo47_Application_Resource_HtmlPurifier
00034 extends Zend_Application_Resource_ResourceAbstract
00035 {
00036 
00040     protected $_htmlpurifier = null;
00041     
00042     public function init()
00043     {
00044         if (!empty($this->_options)) {
00045             $this->_htmlpurifier = $this->_setupHtmlpurifier($this->_options);
00046         } else {
00047             $message = 'Empty options in resource ' .
00048                 'Robo47_Application_Resource_HtmlPurifier.';
00049             throw new Robo47_Application_Resource_Exception($message);
00050         }
00051     }
00052 
00057     public function _setupHtmlpurifier($options)
00058     {
00059         $config = HTMLPurifier_Config::createDefault();
00060 
00061         foreach ($options['options'] as $option => $value) {
00062             $config->set($option, $value);
00063         }
00064 
00065         $purifier = new HTMLPurifier($config);
00066 
00067         if (isset($options['registryKey'])) {
00068             Zend_Registry::set($options['registryKey'], $purifier);
00069         }
00070 
00071         return $purifier;
00072     }
00073 
00079     public function getHtmlPurifier()
00080     {
00081         return $this->_htmlpurifier;
00082     }
00083 }