You are here

function template_preprocess_views_view_views_atom_fields in Views Atom 6

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

File

theme/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 = $view->style_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', $content, $view, $item);
  }

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