function template_preprocess_views_data_export_xml_body in Views data export 6.2
Same name and namespace in other branches
- 6.3 theme/views_data_export.theme.inc \template_preprocess_views_data_export_xml_body()
- 6 theme/views_data_export.theme.inc \template_preprocess_views_data_export_xml_body()
- 7.4 theme/views_data_export.theme.inc \template_preprocess_views_data_export_xml_body()
- 7 theme/views_data_export.theme.inc \template_preprocess_views_data_export_xml_body()
- 7.3 theme/views_data_export.theme.inc \template_preprocess_views_data_export_xml_body()
Preprocess xml output template.
File
- theme/
views_data_export.theme.inc, line 366 - Theme related functions for processing our output style plugins.
Code
function template_preprocess_views_data_export_xml_body(&$vars) {
_views_data_export_header_shared_preprocess($vars);
_views_data_export_body_shared_preprocess($vars);
$vars['item_node'] = _views_data_export_xml_tag_clean($vars['options']['item_node']);
foreach ($vars['themed_rows'] as $num => $row) {
foreach ($row as $field => $content) {
if (empty($vars['options']['cdata_wrapper'][$field])) {
// Prevent double encoding of the ampersand. Look for the entities produced by check_plain().
$content = preg_replace('/&(?!(amp|quot|#039|lt|gt);)/', '&', $content);
// Convert < and > to HTML entities.
$content = str_replace(array(
'<',
'>',
), array(
'<',
'>',
), $content);
}
else {
// Escape CDATA end sequence only.
$content = '<![CDATA[' . str_replace(']]>', ']]]]><![CDATA[>', $content) . ']]>';
}
$vars['themed_rows'][$num][$field] = $content;
}
}
foreach ($vars['header'] as $field => $header) {
// If there is no field label, use 'no name'.
if (empty($header)) {
$header = 'no name';
}
if ($vars['options']['transform']) {
switch ($vars['options']['transform_type']) {
case 'dash':
$vars['xml_tag'][$field] = str_replace(' ', '-', $header);
break;
case 'underline':
$vars['xml_tag'][$field] = str_replace(' ', '_', $header);
break;
case 'camel':
$vars['xml_tag'][$field] = str_replace(' ', '', ucwords(strtolower($header)));
// Convert the very first character of the string to lowercase.
$vars['xml_tag'][$field][0] = strtolower($vars['xml_tag'][$field][0]);
break;
case 'pascal':
$vars['xml_tag'][$field] = str_replace(' ', '', ucwords(strtolower($header)));
break;
}
}
// We should always try to output valid XML.
$vars['xml_tag'][$field] = _views_data_export_xml_tag_clean($vars['xml_tag'][$field]);
}
}