Permalink
Browse files

moving htmlpurifier registration to the plugin configuration

  • Loading branch information...
1 parent 21f62d3 commit a1750cbf11c2e4e05e46ad3f4fe183e514dd751f @nibsirahsieu committed Apr 10, 2011
Showing with 17 additions and 2 deletions.
  1. +17 −1 config/sfNestedCommentPluginConfiguration.class.php
  2. +0 −1 lib/sfNestedCommentTools.class.php
@@ -1,6 +1,8 @@
<?php
class sfNestedCommentPluginConfiguration extends sfPluginConfiguration
{
+ static protected $HTMLPurifierLoaded = false;
+
public function initialize()
{
if ($this->configuration instanceof sfApplicationConfiguration)
@@ -18,6 +20,20 @@ public function initialize()
$this->dispatcher->connect('routing.load_configuration', array('sfNestedCommentRouting', 'addRouteForNestedCommentAdmin'));
}
sfOutputEscaper::markClassAsSafe('sfNestedCommentsRenderer');
+ self::registerHTMLPurifier();
}
}
-}
+
+ static public function registerHTMLPurifier()
+ {
+ if(self::$HTMLPurifierLoaded) {
+ return;
+ }
+
+ require_once(sfConfig::get('sf_plugins_dir').'/sfNestedCommentPlugin/lib/vendor/htmlpurifier/library/HTMLPurifier/Bootstrap.php');
+
+ spl_autoload_register(array('HTMLPurifier_Bootstrap', 'autoload'));
+
+ self::$HTMLPurifierLoaded = true;
+ }
+}
@@ -71,7 +71,6 @@ public static function getComments(BaseObject $commentableObject, sfWebRequest $
static public function clean($text)
{
$allowed_html_tags = sfNestedCommentConfig::getAllowedTags();
- spl_autoload_register(array('HTMLPurifier_Bootstrap', 'autoload'));
$config = HTMLPurifier_Config::createDefault();
$config->set('HTML.Doctype', 'XHTML 1.0 Strict');
$config->set('HTML.Allowed', implode(',', array_keys($allowed_html_tags)));

0 comments on commit a1750cb

Please sign in to comment.