function template_preprocess_views_view_views_rss_fields in Views RSS 7
Same name and namespace in other branches
- 6.2 theme/theme.inc \template_preprocess_views_view_views_rss_fields()
- 6 views/views_rss_views_fields.theme.inc \template_preprocess_views_view_views_rss_fields()
Template preprocessor for views-view-views-rss-fields.tpl.php.
File
- views/
views_rss_views_fields.theme.inc, line 6
Code
function template_preprocess_views_view_views_rss_fields(&$vars) {
$view = $vars['view'];
// Set basic info - title, description - about the feed
if ($view->display_handler
->get_option('sitename_title')) {
$title = variable_get('site_name', 'Drupal');
if ($slogan = variable_get('site_slogan', '')) {
$title .= ' - ' . $slogan;
}
}
else {
$title = $view
->get_title();
}
$vars['viewtitle'] = check_plain($title);
if ($view->style_options['description']['feed_description']) {
$description = $view->style_options['description']['feed_description'];
}
else {
$description = variable_get('site_mission', '');
}
$vars['description'] = theme('views_rss_feed_description', array(
'0' => $description,
'1' => $view,
));
// Base URL for link tag
global $base_url;
$vars['link'] = $base_url;
// Grab the rows, push to field mapping function, gather namespaces.
$elements = $namespaces = array();
$rows = '';
$items = $view->style_plugin
->map_rows($vars['rows']);
foreach ($items as $item) {
// Special handling for GeoRSS.
if (isset($item['lat']) && is_numeric($item['lat']) && isset($item['lon']) && is_numeric($item['lon'])) {
$item['georss:point'] = $item['lat'] . ' ' . $item['lon'];
}
if (isset($item['featureName'])) {
$item['georss:featureName'] = $item['featureName'];
}
unset($item['lat']);
unset($item['lon']);
unset($item['featureName']);
$rows .= theme('views_rss_fields_item', array(
'item' => $item,
));
foreach ($item as $k => $v) {
$elements[$k] = $k;
}
}
$vars['rows'] = $rows;
foreach ($elements as $e) {
if ($namespace = $view->style_plugin
->xml_namespace($e)) {
$namespaces[] = "xmlns:{$namespace['local']}=\"{$namespace['namespace']}\"";
}
}
$vars['namespaces'] = implode(' ', array_unique($namespaces));
// Set Headers
// During live preview we don't want to output the header since the contents
// of the feed are being displayed inside a normal HTML page.
if (empty($vars['view']->live_preview)) {
drupal_add_http_header('Content-Type', 'application/rss+xml; charset=utf-8');
}
}