You are here

function _views_rss_process_namespaces in Views RSS 8.3

Same name and namespace in other branches
  1. 8.2 views_rss.module \_views_rss_process_namespaces()
  2. 6.2 views_rss.module \_views_rss_process_namespaces()
  3. 7.2 views_rss.module \_views_rss_process_namespaces()

Add namespaces not defined by any hook_views_rss_namespaces(), but used in any of defined <channel> or <item> elements. Let's also add "xmlns" prefix by default to such namespaces.

File

./views_rss.module, line 54
Module providing fields-based views style plugin for RSS feed generation.

Code

function _views_rss_process_namespaces($namespaces) {
  foreach (views_rss_get('channel_elements') as $module => $elements) {
    foreach (array_keys($elements) as $element) {
      list($namespace, $element_name) = views_rss_extract_element_names($element);
      if ($namespace && !isset($namespaces[$module][$namespace])) {
        $namespaces[$module][$namespace] = array(
          'prefix' => 'xmlns',
          'uri' => NULL,
        );
      }
    }
  }
  foreach (views_rss_get('item_elements') as $module => $elements) {
    foreach (array_keys($elements) as $element) {
      list($namespace, $element_name) = views_rss_extract_element_names($element);
      if ($namespace && !isset($namespaces[$module][$namespace])) {
        $namespaces[$module][$namespace] = array(
          'prefix' => 'xmlns',
          'uri' => NULL,
        );
      }
    }
  }
  return $namespaces;
}