Forums / All Other Contributions/Addons / Can someone please help me to modify this sanitizer function for Google Base Feeder?

Can someone please help me to modify this sanitizer function for Google Base Feeder?

Locked

Started by lankeeyankee on 23 Jan 2008, 5:44 AM · Views: 1,377

Results 1 to 2 of 2
This thread is locked. New replies are disabled.
23 Jan 2008, 5:44 AM
#1
lankeeyankee avatar

lankeeyankee

Totally Zenned

Join Date:
Jan 2007
Posts:
1,514
Plugin Contributions:
1

Can someone please help me to modify this sanitizer function for Google Base Feeder?

I've been tinkering around with the code a bit to try to get it to work the way I want but need some advice about the regular expressions.

The way the Google Base Feeder is now, all & and " gets stripped out of the XML file. I entered the & and " as & and " when I created the product listings. I don't know if ZC changes it to & and ". Anyway, the Feed creator strips them out and I would like to leave them in the title and descriptions.

Here is the zen_xml_sanitizer function:

 function zen_xml_sanitizer ($str) {
  $_strip_search = array("![\t ]+$|^[\t ]+!m",'%[\r\n]+%m'); // remove CRs and newlines
  $_strip_replace = array('',' ');
  $_cleaner_array = array(">" => "> ", "®" => "", "®" => "", "™" => "", "™" => "", "\t" => "", "    " => "");
  $str = html_entity_decode($str);
  $str = strtr($str, $_cleaner_array);
  $str = preg_replace($_strip_search, $_strip_replace, $str);
  $str = strip_tags($str);
  $str = eregi_replace("[^[:alnum:][:space:].,!()'-_/+=?]", "", $str);
  $str = htmlentities($str);
  $str = str_replace('&', '&', $str);
  return $str;
 }

What needs to be changed to leave " alone, it doesn't affect the XML file, and change the & to &? I'm almost there but not quite!:huh:

Thanks!

Matt


Zen Cart and it's community are the best!!

27 Jan 2008, 4:37 AM
#2
lankeeyankee avatar

lankeeyankee

Totally Zenned

Join Date:
Jan 2007
Posts:
1,514
Plugin Contributions:
1

Re: Can someone please help me to modify this sanitizer function for Google Base Feeder?

I've been trying to figure it out but I am still not getting it.

Can anyone please help me figure out this function? My main problem is that it strips out all double quotes from the titles and leaves & instead of changing it to & in the descriptions

Please help.......:frusty:


Zen Cart and it's community are the best!!