Hello again :)
Disclaimer: I'm not an expert on PHP or Cake or anything, so what I'm saying might contain random errors or inaccuracies :)
patnaik wrote:I am curious as to why you did/could not just give a call to the htmLawed function in your code -- is it difficult when using CakePHP?
I could have, brute-forcing an include somewhere, but as CakePHP has facilities that let you organize the code so to have it available easily where you need it, it seemed better to try to adapt htmLawed to it.
I've *not* done any real OO programming – I guess I wouldn't be able to... I've just took the code and wrapped a class around it (that's basically all that Cake requires, so it can import the class instead of importing the source).
That is, instead of writing:
I can now write in any controller:
var $helpers = array('HtmLawed', 'AnotherHelper');
and access it from the view of any action in that controller like this:
<?= $htmLawed->htmLawed($dirty_html); ?>
It looks the right way to go.
The only problem then is that some of your functions call each other, but being now inside of a class (so they're no more merely "functions" but fully-fledged "methods" ;-P) they have to use "$this->function_name" instead of just "function_name". So I've basically searched and replaced for these call.
The other problem is the use of "preg_replace_callback()", to which you pass a function name that will be called later. Again, that function is now a method inside of your class. I've googled for it and the solution seems to be to replace, in the arguments, the string " 'function_name' " with the array "array(get_class($this), 'function_name')".
I guess I could send you the slightly modified code or put it up on CakeForge, but really it's nothing to write home about :)