function views_xml_raw_render in Views Datasource 5
1 call to views_xml_raw_render()
File
- ./
views_xml.module, line 142 - views_xml.module - provides Views plugin for rendering node content as XML.
Code
function views_xml_raw_render($vid, $nodes, $type) {
$view = views_load_view($vid);
$result = views_build_view('items', $view);
$fields = _views_get_fields();
$xml .= '<?xml version="1.0" encoding="UTF-8" ?>' . "\n";
$xml .= '<!-- generator="Drupal Views_Datasource.Module" -->' . "\n";
$xml .= '<nodes>' . "\n";
foreach ($nodes as $node) {
$xml .= ' <node>' . "\n";
foreach ($view->field as $field) {
if ($fields[$field['id']]['visible'] !== false) {
$label = preg_replace('/\\W/', '', views_xml_strip_illegal_chars($field['label'] ? $field['label'] : $fields[$field['fullname']]['name']));
$value = views_xml_strip_illegal_chars(views_xml_is_date(views_theme_field('views_handle_field', $field['queryname'], $fields, $field, $node, $view)));
if (is_null($value) || $value === '') {
continue;
}
$label = str_replace("Profile", '', $label);
//strip out Profile: from profile fields
// if (preg_match('/\d/', $value)) {
// if (strtotime($value))
// $value = date(DATE_ISO8601, strtotime($value));
// }
$xml .= " <{$label}><![CDATA[{$value}]]></{$label}>\n";
}
}
$xml .= ' </node>' . "\n";
}
$xml .= '</nodes>' . "\n";
drupal_set_header('Content-Type: text/xml');
print $xml;
module_invoke_all('exit');
exit;
}