function template_preprocess_views_atom_fields_item in Views Atom 6
Same name and namespace in other branches
- 7 views_atom.theme.inc \template_preprocess_views_atom_fields_item()
Preprocess for theme('views_atom_fields_item').
File
- theme/
views_atom.theme.inc, line 108
Code
function template_preprocess_views_atom_fields_item(&$vars) {
$item = $vars['item'];
$view = $vars['view'];
$options = $view->style_options;
$vars['entry_type'] = $options['entry_type'] == 'xml' ? $options['entry_type_custom'] : $options['entry_type'];
$nid_alias = isset($view->field['nid']) ? $view->field['nid']->field_alias : 'nid';
// Figure out which results go with the row we're working with.
foreach ($view->result as $key => $result) {
if ($result->{$nid_alias} == $item->{$nid_alias}) {
$result_id = $key;
}
}
foreach ($options['fields'] as $field => $column) {
$alias = $view->field[$column]->field_alias;
if (!empty($item->{$alias})) {
$vars[$field] = filter_xss_admin($item->{$alias});
}
else {
if (!empty($view->style_plugin->rendered_fields[$result_id][$column])) {
$vars[$field] = filter_xss_admin($view->style_plugin->rendered_fields[$result_id][$column]);
}
else {
$vars[$field] = '';
}
}
}
$guid_options = isset($view->style_options['guid']) ? $view->style_options['guid'] : array();
$vars['atom_uuid'] = views_atom_guid('node', $item->{$nid_alias}, $guid_options);
if (empty($vars['atom_url'])) {
// If the user did not set up an atom_url in the view, set a default.
// In contrast to what views_atom_guid() currently provides, this URL
// includes the path alias and possible associated PURL.
$vars['atom_url'] = url('node/' . $item->{$nid_alias}, array(
'absolute' => TRUE,
));
}
date_default_timezone_set(variable_get('date_default_timezone_name', 'America/New_York'));
if ($vars['atom_published']) {
// format_date() doesn't support the 'c' formatting code.
$vars['atom_published'] = date('c', $vars['atom_published']);
}
if ($vars['atom_updated']) {
// format_date() doesn't support the 'c' formatting code.
$vars['atom_updated'] = date('c', $vars['atom_updated']);
}
$vars['language'] = $GLOBALS['language']->language;
}