View source
<?php
define('VIEWS_RSS_BUILD', '6.x-2.x-dev-20120413');
define('VIEWS_RSS_PATH', drupal_get_path('module', 'views_rss'));
function views_rss_views_api() {
return array(
'api' => 2,
'path' => VIEWS_RSS_PATH . '/views',
);
}
function views_rss_theme() {
return array(
'views_view_views_rss_fields' => array(
'template' => 'views-view-views-rss-fields',
'file' => 'theme.inc',
'path' => VIEWS_RSS_PATH . '/theme',
'pattern' => 'views-view-views-rss-fields__',
'arguments' => array(
'row' => NULL,
'view' => NULL,
),
),
'views_view_views_rss_field' => array(
'template' => 'views-view-views-rss-field',
'file' => 'theme.inc',
'path' => VIEWS_RSS_PATH . '/theme',
'pattern' => 'views-view-views-rss-field__',
'arguments' => array(
'elements' => NULL,
'element' => NULL,
'arguments' => NULL,
'value' => NULL,
'markup' => NULL,
'subelements' => NULL,
'item' => NULL,
'view' => NULL,
),
),
);
}
function views_rss_get($key, $rebuild = FALSE) {
static $data = array();
if (!isset($data[$key]) || empty($data[$key]) || $rebuild === TRUE) {
$cid = 'views_rss:' . $key;
$cached = cache_get($cid, 'cache_views');
if (is_object($cached) && isset($cached->data) && $rebuild === FALSE) {
$data[$key] = $cached->data;
}
else {
$data[$key] = array();
$hook_name = 'views_rss_' . $key;
foreach (module_implements($hook_name) as $module) {
$module_data = call_user_func($module . '_' . $hook_name);
if (isset($module_data) && is_array($module_data)) {
$data[$key][$module] = $module_data;
}
}
$function = '_views_rss_process_' . $key;
if (function_exists($function)) {
$data[$key] = $function($data[$key]);
}
drupal_alter($hook_name, $data[$key]);
cache_set($cid, $data[$key], 'cache_views');
}
}
return $data[$key];
}
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;
}
function _views_rss_process_date_sources($date_sources) {
foreach ($date_sources as $module => $module_date_sources) {
foreach ($module_date_sources as $base_table => $elements) {
foreach ($elements as $element_name => $definition) {
if (!isset($definition['alias'])) {
$date_sources[$module][$base_table][$element_name]['alias'] = $element_name;
}
}
}
}
return $date_sources;
}
function views_rss_extract_element_names($element, $core_namespace = '') {
if (!strstr($element, ':')) {
$element = $core_namespace . ':' . $element;
}
return explode(':', $element);
}
function views_rss_rewrite_relative_paths(&$element) {
if (!isset($element['view']->style_plugin->options['feed_settings']['absolute_paths']) || !empty($element['view']->style_plugin->options['feed_settings']['absolute_paths'])) {
global $base_path;
$pattern = '/(src|href)=(\'|")[^\\/]' . preg_quote($base_path, '/') . '/';
$replacement = '$1=$2' . url('<front>', array(
'absolute' => TRUE,
));
$element['value'] = preg_replace($pattern, $replacement, $element['value']);
}
}
function views_rss_map_assoc($array) {
if (!(array_keys($array) !== range(0, count($array) - 1))) {
$array = drupal_map_assoc($array);
}
return $array;
}
function views_rss_htmlspecialchars(&$element) {
if (isset($element['value']) && !is_array($element['value'])) {
$element['value'] = check_plain(decode_entities($element['value']));
}
}
function views_rss_theme7($callback, $variables) {
static $hooks = NULL;
if (!isset($hooks)) {
init_theme();
$hooks = theme_get_registry();
}
$parameters = array(
$callback,
);
$arguments = !empty($hooks[$callback]['arguments']) ? $hooks[$callback]['arguments'] : array();
foreach (array_keys($arguments) as $argument) {
$parameters[] = !empty($variables[$argument]) ? $variables[$argument] : $hooks[$callback]['arguments'][$argument];
}
return call_user_func_array('theme', $parameters);
}