You are here

function field_views_atom_render in Views Atom 7

Implementation of hook_views_atom_render().

File

./views_atom.module, line 160

Code

function field_views_atom_render($node, $entity_xml) {

  // @todo, this is still completely node-centric
  $fields = field_info_instances('node', $node->type);
  foreach ($fields as $field_name => $field_config) {
    if (!empty($node->{$field_name})) {
      $field = array_filter($node->{$field_name});
      $field_info = field_info_field($field_name);
      $field_xml = $entity_xml
        ->addChild('field');
      $field_xml
        ->addAttribute('type', $field_info['type']);
      $field_xml
        ->addAttribute('name', $field_name);
      foreach ($field as $language_code => $field_language_instances) {
        $field_instance_language_xml = $field_xml
          ->addChild('language');
        $field_instance_language_xml
          ->addAttribute('name', $language_code);

        // @todo Need to account for language.
        foreach ($field_language_instances as $instance) {
          $field_instance_xml = $field_instance_language_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, $field_info['type']);
    }
  }
}