function template_preprocess_views_view_views_rss_fields in Views RSS 6
Same name and namespace in other branches
- 6.2 theme/theme.inc \template_preprocess_views_view_views_rss_fields()
- 7 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['feed_settings']['feed_description']) {
$description = $view->style_options['feed_settings']['feed_description'];
}
else {
$description = variable_get('site_mission', '');
}
$vars['description'] = theme('views_rss_feed_description', $description, $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) {
$rows .= theme('views_rss_fields_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
drupal_set_header('Content-Type: application/rss+xml; charset=utf-8');
}