function content_views_atom_render in Views Atom 6
Implementation of hook_views_atom_render().
File
- ./
views_atom.module, line 129
Code
function content_views_atom_render($node, $entity_xml) {
// If there are any Fields associated with this entity, those each get
// added via a <field> element. Each <field> element is assumed to be
// multi-value, just as Fields in Drupal are.
// This is totally the wrong way to do it, but CCK's API is too convoluted
// for me to figure out something else right now.
$result = db_query("SELECT field_name, type FROM {content_node_field}");
while ($record = db_fetch_object($result)) {
if (!empty($node->{$record->field_name})) {
$field = array_filter($node->{$record->field_name});
$field_xml = $entity_xml
->addChild('field');
$field_xml
->addAttribute('type', $record->type);
$field_xml
->addAttribute('name', $record->field_name);
foreach ($field as $instance) {
$field_instance_xml = $field_xml
->addChild('field-instance');
foreach ($instance as $column => $value) {
$serialize = FALSE;
if (is_array($value)) {
$value = serialize($value);
$serialize = TRUE;
}
$element_xml = $field_instance_xml
->addChild('column', views_atom_sanitize($value));
$element_xml
->addAttribute('name', $column);
if (!empty($serialize)) {
$element_xml
->addAttribute('serialize', $serialize);
}
}
}
module_invoke_all('views_atom_render_field', $field_xml, $field, $record->type);
}
}
}