summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--modules/views_rss_dc/views_rss_dc.module5
-rw-r--r--theme/theme.inc19
-rw-r--r--views/views_rss_plugin_style_fields.inc6
-rw-r--r--views_rss.module5
4 files changed, 24 insertions, 11 deletions
diff --git a/modules/views_rss_dc/views_rss_dc.module b/modules/views_rss_dc/views_rss_dc.module
index fe16348..8f85093 100644
--- a/modules/views_rss_dc/views_rss_dc.module
+++ b/modules/views_rss_dc/views_rss_dc.module
@@ -9,7 +9,10 @@
* Implementation of hook_views_rss_namespaces().
*/
function views_rss_dc_views_rss_namespaces() {
- $namespaces['dc'] = 'http://purl.org/dc/elements/1.1/';
+ $namespaces['dc'] = array(
+ 'prefix' => 'xmlns',
+ 'uri' => 'http://purl.org/dc/elements/1.1/',
+ );
return $namespaces;
}
diff --git a/theme/theme.inc b/theme/theme.inc
index 39ca5aa..483f69b 100644
--- a/theme/theme.inc
+++ b/theme/theme.inc
@@ -135,15 +135,24 @@ function template_preprocess_views_view_views_rss(&$vars) {
// Prepare namespaces.
$namespaces = array();
foreach (views_rss_get_namespaces() as $module => $module_namespaces) {
- foreach ($module_namespaces as $namespace => $predefined_uri_reference) {
- if (!empty($predefined_uri_reference)) {
- $namespaces[$namespace] = "xmlns:$namespace=\"$predefined_uri_reference\"";
- }
+ foreach ($module_namespaces as $namespace => $definition) {
+ // Check if definition provided through modules hooks
+ // should be overwritten by module configuration.
if (
isset($view->style_plugin->options['namespaces'][$module][$namespace])
&& !empty($view->style_plugin->options['namespaces'][$module][$namespace])
) {
- $namespaces[$namespace] = "xmlns:$namespace=\"{$view->style_plugin->options['namespaces'][$module][$namespace]}\"";
+ $definition['uri'] = $view->style_plugin->options['namespaces'][$module][$namespace];
+ }
+ if (isset($definition['uri']) && !empty($definition['uri'])) {
+ // Namespaces with prefix, for example: xml:base="" or xmlns:dc=""
+ if (isset($definition['prefix']) && !empty($definition['prefix'])) {
+ $namespaces[$namespace] = "{$definition['prefix']}:$namespace=\"{$definition['uri']}\"";
+ }
+ // Namespaces without prefix, for example: content="" or foaf=""
+ else {
+ $namespaces[$namespace] = "$namespace=\"{$definition['uri']}\"";
+ }
}
}
}
diff --git a/views/views_rss_plugin_style_fields.inc b/views/views_rss_plugin_style_fields.inc
index 5a1ef53..8cd7841 100644
--- a/views/views_rss_plugin_style_fields.inc
+++ b/views/views_rss_plugin_style_fields.inc
@@ -46,7 +46,7 @@ class views_rss_plugin_style_fields extends views_plugin_style {
$namespaces = views_rss_get_namespaces();
if (count($namespaces)) {
foreach ($namespaces as $module => $module_namespaces) {
- foreach ($module_namespaces as $namespace => $predefined_uri_reference) {
+ foreach (array_keys($module_namespaces) as $namespace) {
$options['namespaces'][$module][$namespace] = array('default' => NULL);
}
}
@@ -199,8 +199,8 @@ class views_rss_plugin_style_fields extends views_plugin_style {
$namespaces = views_rss_get_namespaces();
if (count($namespaces)) {
foreach ($namespaces as $module => $module_namespaces) {
- foreach ($module_namespaces as $namespace => $predefined_uri_reference) {
- if (empty($predefined_uri_reference)) {
+ foreach ($module_namespaces as $namespace => $definition) {
+ if (empty($definition['uri'])) {
// Add fieldset for namespace if not yet added.
if (!isset($form['namespaces'])) {
$form['namespaces'] = array(
diff --git a/views_rss.module b/views_rss.module
index 564eaeb..73f5359 100644
--- a/views_rss.module
+++ b/views_rss.module
@@ -61,11 +61,12 @@ function views_rss_get_namespaces() {
drupal_alter('views_rss_namespaces', $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.
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] = NULL;
+ $namespaces[$module][$namespace] = array('prefix' => 'xmlns', 'uri' => NULL);;
}
}
}
@@ -73,7 +74,7 @@ function views_rss_get_namespaces() {
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] = NULL;
+ $namespaces[$module][$namespace] = array('prefix' => 'xmlns', 'uri' => NULL);;
}
}
}