While it is very useful, the fourth parameter, double_encode, is only available for php version 5.2.3 and onwards. All core MODx code that I have seen avoids it, probably for that reason.
I encountered this problem some time ago when I wrote some code for an unrelated application using the four parameter version and then found out that an old version of php was being used on the final system. I tried to solve the problem by using the Pear compatibility library but a compatibility layer wasn’t available for htmlspecialchars at that time. In the end I updated the code to remove the fourth parameter. Nevertheless, I put in a request for it to be added to the Pear compatibility library and I understand that it has been added since then.
So, rather than modifying AjaxSearch, you could try using the Pear compatibilty layer for htmlspecialchars. This will allow you to use the fourth parameter with older versions of php.
I haven’t upgraded to AjaxSearch 1.8.2 yet on all MODx installations, but thanks for the heads up on this: I too will have to do the same for one of my installations where I am unable to upgrade php.
Attached is the htmlspecialchars function from the
pear PHP compatibility library that you could include with ajaxSearch to get it to work.
How should i include that with AjaxSearch?
I think that if you rename the file from my previous post as htmlspecialchars.php, place it next to search.class.inc.php in the classes subdirectory and then add the line
include('htmlspecialchars.php');
at the beginning of the original search.class.inc.php file it will probably just work. If not then you’ll have to read the PHP_compat documentation I’m afraid. Sorry I haven’t got time to do that myself this second.