You are here

function template_preprocess_views_view_views_atom_fields in Views Atom 7

Same name and namespace in other branches
  1. 6 theme/views_atom.theme.inc \template_preprocess_views_view_views_atom_fields()

File

./views_atom.theme.inc, line 34

Code

function template_preprocess_views_view_views_atom_fields(&$vars) {

  // Inherit the base processing for all atom feeds.
  template_preprocess_views_view_views_atom($vars);
  $view = $vars['view'];
  $options = $vars['options'];
  $vars['content'] = '';
  $updated = 0;
  foreach ($vars['rows'] as $i => $content) {
    $item = $view->result[$i];

    // We need to know the updated time of the most recently updated entry
    // so that we can set the whole feed's updated time to that.
    if (!empty($options['fields']['atom_updated']) && !empty($view->field[$options['fields']['atom_updated']])) {
      $alias = $view->field[$options['fields']['atom_updated']]->field_alias;
      $updated = max($item->{$alias}, $updated);
    }
    $vars['content'] .= theme('views_atom_fields_item', array(
      'content' => $content,
      'view' => $view,
      'item' => $item,
      'options' => $options,
    ));
  }

  // If this is an empty feed, set the last updated time to right now.
  if (!$updated) {
    $updated = REQUEST_TIME;
  }
  $vars['updated'] = date('c', $updated);
}