function views_atom_sanitize in Views Atom 7
Same name and namespace in other branches
- 6 views_atom.module \views_atom_sanitize()
Sanitize a string for an atom feed.
Certain HTML character entities are not valid in XML and cause character encoding to go completely bananas. This function converts those characters to their unicode equivalents.
@link http://changelog.ca/log/2006/06/12/making_nbsp_work_with_xml_rss_and_atom
Parameters
$string: The string to sanitize. If any other data type is passed it is returned unaffected.
2 calls to views_atom_sanitize()
- field_views_atom_render in ./
views_atom.module - Implementation of hook_views_atom_render().
- views_plugin_row_rdf_node::render in ./
views_plugin_row_rdf_node.inc - Render a row object. This usually passes through to a theme template of some form, but not always.
File
- ./
views_atom.module, line 135
Code
function views_atom_sanitize($string) {
$search = array();
$replace = array();
if (empty($search)) {
$replacements = array(
' & ' => ' & ',
'&' => '&',
' ' => ' ',
'\\r\\n' => '\\n',
);
$search = array_keys($replacements);
$replace = array_values($replacements);
}
if (is_string($string)) {
return str_replace($search, $replace, $string);
}
return $string;
}