Clean inputted html with CakePHP BritaBehaviour
I’ve been using TinyMCE as a text editor in my CMSs, and whilst it’s good, it can lead to the odd empty tag/para ending up in the html, font tags and all manner of other crap (especially if M$ Word has been involved at all), so I created a cakephp behaviour that uses the HTMLPurifier class to make all inputted html valid.
First, you need to download the most recent version of the HTMLPurifier class fromĀ http://htmlpurifier.org/download, drop this in /{app}/vendors, and save the pasted code as ‘brita.php’ in /{app}/models/behaviors/.
It’s dead simple to use, just do:
var $actsAs = array(
'Brita'=>array('synopsis', 'body', 'extended_body')
);
In the model(s) you need to clean up.