FINAL suepr merge step : added all modules to this super repos
This commit is contained in:
@@ -0,0 +1,144 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Field formatters for Views RSS: Core Elements module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_field_formatter_info().
|
||||
*/
|
||||
function views_rss_core_field_formatter_info() {
|
||||
$formatters = array(
|
||||
'enclosure' => array(
|
||||
'label' => t('RSS <enclosure> element'),
|
||||
'field types' => array('file', 'media', 'image', 'text', 'link_field'),
|
||||
),
|
||||
);
|
||||
return $formatters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_field_formatter_settings_form().
|
||||
*/
|
||||
function views_rss_core_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
|
||||
$display = $instance['display'][$view_mode];
|
||||
$settings = $display['settings'];
|
||||
$element = NULL;
|
||||
|
||||
if ($field['type'] == 'image') {
|
||||
$image_styles = image_style_options(FALSE);
|
||||
$element['image_style'] = array(
|
||||
'#title' => t('Image style'),
|
||||
'#type' => 'select',
|
||||
'#default_value' => $settings['image_style'],
|
||||
'#empty_option' => t('None (original image)'),
|
||||
'#options' => $image_styles,
|
||||
);
|
||||
}
|
||||
|
||||
return $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_field_formatter_settings_summary().
|
||||
*/
|
||||
function views_rss_core_field_formatter_settings_summary($field, $instance, $view_mode) {
|
||||
$display = $instance['display'][$view_mode];
|
||||
$settings = $display['settings'];
|
||||
|
||||
$summary = array();
|
||||
|
||||
if ($field['type'] == 'image') {
|
||||
$image_styles = image_style_options(FALSE);
|
||||
// Unset possible 'No defined styles' option.
|
||||
unset($image_styles['']);
|
||||
// Styles could be lost because of enabled/disabled modules that defines
|
||||
// their styles in code.
|
||||
if (isset($image_styles[$settings['image_style']])) {
|
||||
$summary[] = t('Image style: @style', array('@style' => $image_styles[$settings['image_style']]));
|
||||
}
|
||||
else {
|
||||
$summary[] = t('Original image');
|
||||
}
|
||||
}
|
||||
|
||||
return implode('<br />', $summary);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_field_formatter_view().
|
||||
*
|
||||
* This is a dirty trick here. Essentially, we do not want to call a theme
|
||||
* function from here, as it should be called from within a view (amongst
|
||||
* other to have $view object in $variables). Therefore here we want to
|
||||
* return value only, hence use of array('#markup' => $value). However,
|
||||
* in some cases it won't be just a simple string value to return,
|
||||
* sometimes we'd want to return an array (for example value with
|
||||
* additional arguments) - hence the need to serialize it (plus add
|
||||
* "serialized" string at the beginning so that our field preprocess
|
||||
* function template_preprocess_views_view_views_rss_field() is able
|
||||
* to recognize it as serialized array and treat accordingly.
|
||||
*
|
||||
* Any better ideas?
|
||||
*/
|
||||
function views_rss_core_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
|
||||
$element = NULL;
|
||||
foreach ($items as $delta => $item) {
|
||||
// Inside a view item may contain NULL data. In that case, just return.
|
||||
if (
|
||||
($field['type'] == 'file' || $field['type'] == 'image') && empty($item['fid'])
|
||||
|| $field['type'] == 'media' && empty($item['file']->fid)
|
||||
|| $field['type'] == 'text' && empty($item['safe_value'])
|
||||
|| $field['type'] == 'link_field' && empty($item['url'])
|
||||
) {
|
||||
unset($items[$delta]);
|
||||
continue;
|
||||
}
|
||||
// Get full image URL based on provided image style.
|
||||
if ($field['type'] == 'image' && !empty($display['settings']['image_style']) && $image_style = image_style_load($display['settings']['image_style'])) {
|
||||
$uri = image_style_url($display['settings']['image_style'], $item['uri']);
|
||||
// Get file size of image preset file (if it has already been created,
|
||||
// otherwise just create it first and then get file size).
|
||||
$path = image_style_path($display['settings']['image_style'], $item['uri']);
|
||||
$real_path = drupal_realpath($path);
|
||||
if (file_exists($real_path) || image_style_create_derivative($image_style, $item['uri'], $path)) {
|
||||
$item['filesize'] = filesize($real_path);
|
||||
}
|
||||
}
|
||||
elseif ($field['type'] == 'media') {
|
||||
$uri = file_create_url($item['file']->uri);
|
||||
$item['filesize'] = $item['file']->filesize;
|
||||
$item['filemime'] = $item['file']->filemime;
|
||||
}
|
||||
elseif ($field['type'] == 'text' || $field['type'] == 'link_field') {
|
||||
$uri = ($field['type'] == 'text') ? $item['safe_value'] : $item['url'];
|
||||
// Great idea to use get_headers() here by Dan Feidt,
|
||||
// http://drupal.org/user/60005 Thanks Dan!
|
||||
$headers = get_headers($uri, $format = 1);
|
||||
$item['filesize'] = $headers['Content-Length'];
|
||||
$item['filemime'] = $headers['Content-Type'];
|
||||
}
|
||||
else {
|
||||
$uri = file_create_url($item['uri']);
|
||||
}
|
||||
|
||||
// XML element array in format_xml_elements() format.
|
||||
$rss_element = array(
|
||||
'key' => 'enclosure',
|
||||
'attributes' => array(
|
||||
'url' => $uri,
|
||||
'length' => $item['filesize'],
|
||||
'type' => $item['filemime'],
|
||||
),
|
||||
);
|
||||
|
||||
$element[$delta] = array(
|
||||
'#item' => $item,
|
||||
'#markup' => format_xml_elements(array($rss_element)),
|
||||
'#rss_element' => $rss_element,
|
||||
);
|
||||
|
||||
}
|
||||
return $element;
|
||||
}
|
@@ -0,0 +1,197 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Preprocess functions for Views RSS: Core Elements module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Preprocess function for channel <title> element.
|
||||
*/
|
||||
function views_rss_core_preprocess_channel_title(&$variables) {
|
||||
$view_title = $variables['view']->get_title();
|
||||
$variables['elements'][0]['value'] = ($view_title) ? $view_title : variable_get('site_name', t('Drupal'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Preprocess function for channel <description> element.
|
||||
*/
|
||||
function views_rss_core_preprocess_channel_description(&$variables) {
|
||||
if (empty($variables['elements'][0]['value'])) {
|
||||
$variables['elements'][0]['value'] = variable_get('site_slogan', '');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Preprocess function for channel <link> element.
|
||||
*/
|
||||
function views_rss_core_preprocess_channel_link(&$variables) {
|
||||
$variables['elements'][0]['value'] = url('<front>', array('absolute' => TRUE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Preprocess function for channel <atom:link> element.
|
||||
*/
|
||||
function views_rss_core_preprocess_channel_atom_link(&$variables) {
|
||||
$url_options = array('absolute' => TRUE);
|
||||
$input = $variables['view']->get_exposed_input();
|
||||
if ($input) {
|
||||
$url_options['query'] = $input;
|
||||
}
|
||||
$url = url($variables['view']->get_url(), $url_options);
|
||||
$variables['elements'][0]['attributes'] = array(
|
||||
'rel' => 'self',
|
||||
'href' => $url,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Preprocess function for channel <category> element.
|
||||
*/
|
||||
function views_rss_core_preprocess_channel_category(&$variables) {
|
||||
// No value = no preprocessing.
|
||||
if (empty($variables['elements'][0]['value'])) {
|
||||
return;
|
||||
}
|
||||
$elements = array();
|
||||
$categories = explode(',', $variables['elements'][0]['value']);
|
||||
foreach ($categories as $category) {
|
||||
$elements[] = array(
|
||||
'key' => 'category',
|
||||
'value' => trim($category),
|
||||
);
|
||||
}
|
||||
$variables['elements'] = $elements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Preprocess function for channel <image> element.
|
||||
*/
|
||||
function views_rss_core_preprocess_channel_image(&$variables) {
|
||||
// No value = no preprocessing.
|
||||
if (empty($variables['elements'][0]['value'])) {
|
||||
return;
|
||||
}
|
||||
$path = $variables['elements'][0]['value'];
|
||||
// Get value of channel <title> element from its preprocess function.
|
||||
views_rss_core_preprocess_channel_title($variables);
|
||||
$title = $variables['elements'][0]['value'];
|
||||
// Get value of channel <title> element from its preprocess function.
|
||||
views_rss_core_preprocess_channel_link($variables);
|
||||
$link = $variables['elements'][0]['value'];
|
||||
// Create subelements array.
|
||||
$variables['elements'][0]['value'] = array(
|
||||
'url' => file_create_url($path),
|
||||
'title' => $title,
|
||||
'link' => $link,
|
||||
);
|
||||
// Try to get image description from website's mission.
|
||||
$site_slogan = variable_get('site_slogan', '');
|
||||
if (!empty($site_slogan)) {
|
||||
$variables['elements'][0]['value']['description'] = $site_slogan;
|
||||
}
|
||||
// Get image width and height.
|
||||
$image = image_load($path);
|
||||
if (!empty($image)) {
|
||||
$variables['elements'][0]['value']['width'] = $image->info['width'];
|
||||
$variables['elements'][0]['value']['height'] = $image->info['height'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Preprocess function for channel <pubDate> and <lastBuildDate> elements.
|
||||
*
|
||||
* It will return values for date element providing that original Views query
|
||||
* was modified appropriately by views_rss_core_views_query_alter() by adding
|
||||
* new fields to SELECT clause retrieving object creation (for <pubDate>)
|
||||
* or modification timestamp (for <lastBuildDate>).
|
||||
*/
|
||||
function views_rss_core_preprocess_channel_date(&$variables) {
|
||||
if (count($variables['view']->result) > 0) {
|
||||
$max_date = 0;
|
||||
foreach ($variables['view']->result as $row) {
|
||||
$key = strtolower($variables['elements'][0]['key']);
|
||||
if (isset($row->$key) && $row->$key > $max_date) {
|
||||
$max_date = $row->$key;
|
||||
}
|
||||
}
|
||||
if ($max_date) {
|
||||
$variables['elements'][0]['value'] = date('r', $max_date);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Preprocess function for channel <skipHours> and <skipDays> elements.
|
||||
*/
|
||||
function views_rss_core_preprocess_channel_skip(&$variables) {
|
||||
// No value = no preprocessing.
|
||||
if (empty($variables['elements'][0]['value'])) {
|
||||
return;
|
||||
}
|
||||
$elements = array();
|
||||
$skips = strip_tags($variables['elements'][0]['value']);
|
||||
if (!empty($skips)) {
|
||||
foreach (explode(',', $skips) as $skip_value) {
|
||||
$elements[] = array(
|
||||
'key' => ($variables['elements'][0]['key'] == 'skipHours') ? 'hour' : 'day',
|
||||
'value' => trim($skip_value),
|
||||
);
|
||||
}
|
||||
}
|
||||
$variables['elements'][0]['value'] = $elements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Preprocess function for channel <cloud> element.
|
||||
*/
|
||||
function views_rss_core_preprocess_channel_cloud(&$variables) {
|
||||
// No value = no preprocessing.
|
||||
if (empty($variables['elements'][0]['value'])) {
|
||||
return;
|
||||
}
|
||||
if ($url = parse_url($variables['elements'][0]['value'])) {
|
||||
$variables['elements'][0]['value'] = NULL;
|
||||
$variables['elements'][0]['attributes'] = array(
|
||||
'domain' => $url['host'],
|
||||
'port' => $url['port'],
|
||||
'path' => $url['path'],
|
||||
'registerProcedure' => $url['fragment'],
|
||||
'protocol' => $url['scheme'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Preprocess function for item <guid> element.
|
||||
*/
|
||||
function views_rss_core_preprocess_item_guid(&$variables) {
|
||||
// No value = no preprocessing.
|
||||
if (empty($variables['elements'][0]['value'])) {
|
||||
return;
|
||||
}
|
||||
$is_permalink = 'false';
|
||||
if (
|
||||
(!isset($variables['item']['views_rss_core']['link']) || empty($variables['item']['views_rss_core']['link']))
|
||||
&& valid_url($variables['elements'][0]['value'], TRUE)
|
||||
) {
|
||||
$is_permalink = 'true';
|
||||
}
|
||||
$variables['elements'][0]['attributes']['isPermaLink'] = $is_permalink;
|
||||
}
|
||||
|
||||
/**
|
||||
* Preprocess function for item <source> element.
|
||||
*/
|
||||
function views_rss_core_preprocess_item_source(&$variables) {
|
||||
$url_options = array('absolute' => TRUE);
|
||||
$input = $variables['view']->get_exposed_input();
|
||||
if ($input) {
|
||||
$url_options['query'] = $input;
|
||||
}
|
||||
$url = url($variables['view']->get_url(), $url_options);
|
||||
|
||||
$view_title = $variables['view']->get_title();
|
||||
$variables['elements'][0]['value'] = (!empty($view_title)) ? $view_title : variable_get('site_name', t('Drupal'));
|
||||
$variables['elements'][0]['attributes'] = array('url' => $url);
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
name = "Views RSS: Core Elements"
|
||||
description = "Provides core XML channel and item elements for Views RSS."
|
||||
package = Views
|
||||
dependencies[] = views_rss
|
||||
core = "7.x"
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-09-11
|
||||
version = "7.x-2.0-rc3+4-dev"
|
||||
core = "7.x"
|
||||
project = "views_rss"
|
||||
datestamp = "1378900636"
|
||||
|
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* (Un)installation functions for Views RSS: Core Elements module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_install().
|
||||
*/
|
||||
function views_rss_core_install() {
|
||||
cache_clear_all('views_rss:', 'cache_views', TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_uninstall().
|
||||
*/
|
||||
function views_rss_core_uninstall() {
|
||||
if (db_table_exists('cache_views')) {
|
||||
cache_clear_all('views_rss:', 'cache_views', TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename all old "enclosure_file" and "enclosure_image" field formatters
|
||||
* for any field in any view to new "enclosure".
|
||||
*/
|
||||
function views_rss_core_update_7201() {
|
||||
$sql = "SELECT vd.*, vv.name FROM {views_display} vd JOIN {views_view} vv USING(vid)";
|
||||
$result = db_query($sql);
|
||||
foreach ($result as $record) {
|
||||
$updated = 0;
|
||||
if (isset($record->display_options)) {
|
||||
$display_options = unserialize($record->display_options);
|
||||
if (isset($display_options['fields']) && is_array($display_options['fields'])) {
|
||||
foreach ($display_options['fields'] as $field_key => $field) {
|
||||
if (isset($field['type']) && ($field['type'] == 'enclosure_image' || $field['type'] == 'enclosure_file')) {
|
||||
$display_options['fields'][$field_key]['type'] = 'enclosure';
|
||||
$updated++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($updated) {
|
||||
db_update('views_display')
|
||||
->fields(array('display_options' => serialize($display_options)))
|
||||
->condition('vid', $record->vid)
|
||||
->condition('id', $record->id)
|
||||
->execute();
|
||||
drupal_set_message(t('Enclosure formatter has been updated for %count fields in %display display in %view_name.', array(
|
||||
'%count' => $updated,
|
||||
'%display' => $record->display_title,
|
||||
'%view_name' => $record->name,
|
||||
)));
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,284 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Provides core <channel> and <item> elements for Views RSS module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module installation path.
|
||||
*/
|
||||
define('VIEWS_RSS_CORE_PATH', drupal_get_path('module', 'views_rss_core'));
|
||||
|
||||
/**
|
||||
* Include file with field formatters.
|
||||
*/
|
||||
include_once VIEWS_RSS_CORE_PATH .'/views_rss_core.field.inc';
|
||||
|
||||
/**
|
||||
* Include file with all preprocess functions.
|
||||
*/
|
||||
include_once VIEWS_RSS_CORE_PATH . '/views_rss_core.inc';
|
||||
|
||||
/**
|
||||
* Implementation of hook_views_rss_namespaces().
|
||||
*/
|
||||
function views_rss_core_views_rss_namespaces() {
|
||||
$namespaces['atom'] = array(
|
||||
'prefix' => 'xmlns',
|
||||
'uri' => 'http://www.w3.org/2005/Atom',
|
||||
);
|
||||
return $namespaces;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_views_rss_channel_elements().
|
||||
*/
|
||||
function views_rss_core_views_rss_channel_elements() {
|
||||
$elements['title'] = array(
|
||||
'configurable' => FALSE,
|
||||
'preprocess functions' => array('views_rss_core_preprocess_channel_title'),
|
||||
'help' => 'http://www.rssboard.org/rss-profile#element-channel-title',
|
||||
);
|
||||
$elements['description'] = array(
|
||||
'description' => t('Description for this feed. If left blank, the default site mission will be used.'),
|
||||
'settings form' => array('#type' => 'textarea', '#rows' => 3),
|
||||
'preprocess functions' => array(
|
||||
'views_rss_core_preprocess_channel_description',
|
||||
'views_rss_rewrite_relative_paths',
|
||||
),
|
||||
'help' => 'http://www.rssboard.org/rss-profile#element-channel-description',
|
||||
);
|
||||
$elements['link'] = array(
|
||||
'configurable' => FALSE,
|
||||
'preprocess functions' => array('views_rss_core_preprocess_channel_link'),
|
||||
'help' => 'http://www.rssboard.org/rss-profile#element-channel-link',
|
||||
);
|
||||
$elements['atom:link'] = array(
|
||||
'configurable' => FALSE,
|
||||
'preprocess functions' => array('views_rss_core_preprocess_channel_atom_link'),
|
||||
'help' => 'http://www.rssboard.org/rss-profile#namespace-elements-atom-link',
|
||||
);
|
||||
$elements['language'] = array(
|
||||
'description' => t('The language the channel is written in. This allows aggregators to group all Italian language sites, for example, on a single page. See list of <a href="@w3c_url">allowable values</a> for this element defined by the W3C.', array(
|
||||
'@w3c_url' => url('http://www.w3.org/TR/REC-html40/struct/dirlang.html', array('fragment' => 'langcodes')),
|
||||
)),
|
||||
'help' => 'http://www.rssboard.org/rss-profile#element-channel-language',
|
||||
);
|
||||
$elements['category'] = array(
|
||||
'description' => t('Specify one or more categories that the channel belongs to. Separate multiple items with comma.'),
|
||||
'preprocess functions' => array('views_rss_core_preprocess_channel_category'),
|
||||
'help' => 'http://www.rssboard.org/rss-profile#element-channel-category',
|
||||
);
|
||||
$elements['image'] = array(
|
||||
'description' => t('Path to the image to be used as the artwork for your feed, for example <em>sites/default/files/AllAboutEverything.jpg</em>. Allowed image formats are GIF, JPEG or PNG. Maximum image width is 144 pixels, maximum height 400 pixels.'),
|
||||
'preprocess functions' => array('views_rss_core_preprocess_channel_image'),
|
||||
'help' => 'http://www.rssboard.org/rss-profile#element-channel-image',
|
||||
);
|
||||
$elements['copyright'] = array(
|
||||
'description' => t('Copyright notice for content in the channel.'),
|
||||
'help' => 'http://www.rssboard.org/rss-profile#element-channel-copyright',
|
||||
);
|
||||
$elements['managingEditor'] = array(
|
||||
'description' => t('Email address for person responsible for editorial content.'),
|
||||
'help' => 'http://www.rssboard.org/rss-profile#element-channel-managingeditor',
|
||||
);
|
||||
$elements['webMaster'] = array(
|
||||
'description' => t('Email address for person responsible for technical issues relating to channel.'),
|
||||
'help' => 'http://www.rssboard.org/rss-profile#element-channel-webmaster',
|
||||
);
|
||||
$elements['generator'] = array(
|
||||
'description' => t('A string indicating the program used to generate the channel.'),
|
||||
'help' => 'http://www.rssboard.org/rss-profile#element-channel-generator',
|
||||
);
|
||||
$elements['docs'] = array(
|
||||
'description' => t("A URL that points to the documentation for the format used in the RSS file. It's for people who might stumble across an RSS file on a Web server 25 years from now and wonder what it is."),
|
||||
'help' => 'http://www.rssboard.org/rss-profile#element-channel-docs',
|
||||
);
|
||||
$elements['cloud'] = array(
|
||||
'description' => t("Allows processes to register with a cloud to be notified of updates to the channel, implementing a lightweight publish-subscribe protocol for RSS feeds. Example: <em>soap://rpc.sys.com:80/RPC2#pingMe</em>"),
|
||||
'preprocess functions' => array('views_rss_core_preprocess_channel_cloud'),
|
||||
'help' => 'http://www.rssboard.org/rss-profile#element-channel-cloud',
|
||||
);
|
||||
$elements['ttl'] = array(
|
||||
'description' => t("ttl stands for time to live. It's a number of minutes that indicates how long a channel can be cached before refreshing from the source."),
|
||||
'help' => 'http://www.rssboard.org/rss-profile#element-channel-ttl',
|
||||
);
|
||||
$elements['skipHours'] = array(
|
||||
'description' => t('A hint for aggregators telling them which hours they can skip. The hours must be expressed as an integer representing the number of hours since 00:00:00 GMT. Values from 0 to 23 are permitted, with 0 representing midnight. An hour must not be duplicated.'),
|
||||
'preprocess functions' => array('views_rss_core_preprocess_channel_skip'),
|
||||
'help' => 'http://www.rssboard.org/rss-profile#element-channel-skiphours',
|
||||
);
|
||||
$elements['skipDays'] = array(
|
||||
'description' => t('A hint for aggregators telling them which days of the week they can skip (up to seven days).'),
|
||||
'preprocess functions' => array('views_rss_core_preprocess_channel_skip'),
|
||||
'help' => 'http://www.rssboard.org/rss-profile#element-channel-skipdays',
|
||||
);
|
||||
$elements['pubDate'] = array(
|
||||
'configurable' => FALSE,
|
||||
'preprocess functions' => array('views_rss_core_preprocess_channel_date'),
|
||||
'help' => 'http://www.rssboard.org/rss-profile#element-channel-pubdate',
|
||||
);
|
||||
$elements['lastBuildDate'] = array(
|
||||
'configurable' => FALSE,
|
||||
'preprocess functions' => array('views_rss_core_preprocess_channel_date'),
|
||||
'help' => 'http://www.rssboard.org/rss-profile#element-channel-lastbuilddate',
|
||||
);
|
||||
return $elements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_views_rss_item_elements().
|
||||
*/
|
||||
function views_rss_core_views_rss_item_elements() {
|
||||
$elements['title'] = array(
|
||||
'description' => t('The title of the item. Required by RSS specification.'),
|
||||
'help' => 'http://www.rssboard.org/rss-profile#element-channel-item-title',
|
||||
);
|
||||
$elements['link'] = array(
|
||||
'description' => t('The URL of the item. Required by RSS specification.'),
|
||||
'help' => 'http://www.rssboard.org/rss-profile#element-channel-item-link',
|
||||
);
|
||||
$elements['description'] = array(
|
||||
'description' => t('The item synopsis. Required by RSS specification.'),
|
||||
'preprocess functions' => array('views_rss_rewrite_relative_paths'),
|
||||
'help' => 'http://www.rssboard.org/rss-profile#element-channel-item-description',
|
||||
);
|
||||
$elements['author'] = array(
|
||||
'description' => t('Email address of the author of the item. A feed published by an individual should omit this element and use the <managingEditor> or <webMaster> channel elements to provide contact information.'),
|
||||
'help' => 'http://www.rssboard.org/rss-profile#element-channel-item-author',
|
||||
);
|
||||
$elements['category'] = array(
|
||||
'description' => t('Includes the item in one or more categories.'),
|
||||
'help' => 'http://www.rssboard.org/rss-profile#element-channel-item-category',
|
||||
);
|
||||
$elements['comments'] = array(
|
||||
'description' => t('URL of a page for comments relating to the item.'),
|
||||
'help' => 'http://www.rssboard.org/rss-profile#element-channel-item-comments',
|
||||
);
|
||||
$elements['enclosure'] = array(
|
||||
'description' => t('Describes a media object that is attached to the item.'),
|
||||
'help' => 'http://www.rssboard.org/rss-profile#element-channel-item-enclosure',
|
||||
);
|
||||
$elements['guid'] = array(
|
||||
'description' => t('A string that uniquely identifies the item.'),
|
||||
'preprocess functions' => array('views_rss_core_preprocess_item_guid'),
|
||||
'help' => 'http://www.rssboard.org/rss-profile#element-channel-item-guid',
|
||||
);
|
||||
$elements['pubDate'] = array(
|
||||
'description' => t('Indicates when the item was published.'),
|
||||
'help' => 'http://www.rssboard.org/rss-profile#element-channel-item-pubdate',
|
||||
);
|
||||
$elements['source'] = array(
|
||||
'configurable' => FALSE,
|
||||
'description' => t('The RSS channel that the item came from.'),
|
||||
'preprocess functions' => array('views_rss_core_preprocess_item_source'),
|
||||
'help' => 'http://www.rssboard.org/rss-profile#element-channel-item-source',
|
||||
);
|
||||
return $elements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_views_rss_date_sources().
|
||||
*/
|
||||
function views_rss_core_views_rss_date_sources() {
|
||||
$sources['node'] = array(
|
||||
'pubDate' => array(
|
||||
'table' => 'node',
|
||||
'field' => 'created',
|
||||
),
|
||||
'lastBuildDate' => array(
|
||||
'table' => 'node',
|
||||
'field' => 'changed',
|
||||
),
|
||||
);
|
||||
$sources['node_revisions'] = array(
|
||||
'pubDate' => array(
|
||||
'table' => 'node_revisions',
|
||||
'field' => 'timestamp',
|
||||
),
|
||||
);
|
||||
$sources['comments'] = array(
|
||||
'lastBuildDate' => array(
|
||||
'table' => 'comments',
|
||||
'field' => 'timestamp',
|
||||
),
|
||||
);
|
||||
$sources['files'] = array(
|
||||
'pubDate' => array(
|
||||
'table' => 'files',
|
||||
'field' => 'timestamp',
|
||||
),
|
||||
);
|
||||
$sources['users'] = array(
|
||||
'pubDate' => array(
|
||||
'table' => 'users',
|
||||
'field' => 'created',
|
||||
),
|
||||
);
|
||||
return $sources;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_views_query_alter().
|
||||
*/
|
||||
function views_rss_core_views_query_alter(&$view, &$query) {
|
||||
if ($view->style_plugin->definition['handler'] == 'views_rss_plugin_style_fields') {
|
||||
$date_sources = views_rss_get('date_sources');
|
||||
foreach (array_keys($date_sources) as $module) {
|
||||
if (isset($date_sources[$module][$view->base_table])) {
|
||||
// Select the most recent node creation date for <pubDate> element.
|
||||
if (isset($date_sources[$module][$view->base_table]['pubDate'])) {
|
||||
$query->fields['pubDate'] = $date_sources[$module][$view->base_table]['pubDate'];
|
||||
}
|
||||
// Select the most recent node update date for <lastBuildDate> element.
|
||||
if (isset($date_sources[$module][$view->base_table]['lastBuildDate'])) {
|
||||
$query->fields['lastBuildDate'] = $date_sources[$module][$view->base_table]['lastBuildDate'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_views_rss_options_form_validate().
|
||||
*/
|
||||
function views_rss_core_views_rss_options_form_validate($form, &$form_state) {
|
||||
|
||||
// Validate channel <image> element.
|
||||
if (!empty($form_state['values']['style_options']['channel']['core']['views_rss_core']['image'])) {
|
||||
// Do not validate absolute URLs, as this could mean external image.
|
||||
if (!valid_url($form_state['values']['style_options']['channel']['core']['views_rss_core']['image'], TRUE)) {
|
||||
// Check that image exists and is in acceptable format.
|
||||
$image = image_load($form_state['values']['style_options']['channel']['core']['views_rss_core']['image']);
|
||||
if (empty($image)) {
|
||||
form_set_error('style_options][channel][core][views_rss_core][image', t('Unable to find %image or incorrect image format.', array(
|
||||
'%image' => $form_state['values']['style_options']['channel']['core']['views_rss_core']['image'],
|
||||
)));
|
||||
}
|
||||
else {
|
||||
// Check image width.
|
||||
if ($image->info['width'] > 144) {
|
||||
form_set_error('style_options][channel][core][views_rss_core][image', t("Maximum allowed width of an image for feed channel's <image> element is 144 pixels. Specified %image is !width pixels wide.", array(
|
||||
'%image' => $form_state['values']['style_options']['channel']['core']['views_rss_core']['image'],
|
||||
'!width' => $image->info['width'],
|
||||
)));
|
||||
}
|
||||
// Check image height.
|
||||
if ($image->info['height'] > 400) {
|
||||
form_set_error('style_options][channel][core][views_rss_core][image', t("Maximum allowed height of an image for feed channel's <image> element is 400 pixels. Specified %image is !height pixels high.", array(
|
||||
'%image' => $form_state['values']['style_options']['channel']['core']['views_rss_core']['image'],
|
||||
'!height' => $image->info['height'],
|
||||
)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Validate channel <docs> element.
|
||||
if (!empty($form_state['values']['style_options']['channel']['core']['views_rss_core']['docs'])) {
|
||||
if (!valid_url($form_state['values']['style_options']['channel']['core']['views_rss_core']['docs'], TRUE)) {
|
||||
form_set_error('style_options][channel][core][views_rss_core][docs', t("Not a valid URL."));
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
name = "Views RSS: DC Elements"
|
||||
description = "Provides Dublin Core Metadata element set for Views RSS"
|
||||
package = Views
|
||||
dependencies[] = views_rss
|
||||
core = "7.x"
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-09-11
|
||||
version = "7.x-2.0-rc3+4-dev"
|
||||
core = "7.x"
|
||||
project = "views_rss"
|
||||
datestamp = "1378900636"
|
||||
|
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* (Un)installation functions for Views RSS: DC Elements module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_install().
|
||||
*/
|
||||
function views_rss_dc_install() {
|
||||
cache_clear_all('views_rss:', 'cache_views', TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_uninstall().
|
||||
*/
|
||||
function views_rss_dc_uninstall() {
|
||||
if (db_table_exists('cache_views')) {
|
||||
cache_clear_all('views_rss:', 'cache_views', TRUE);
|
||||
}
|
||||
}
|
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Provides Dublin Core namespace and <item> elements for Views RSS module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_views_rss_namespaces().
|
||||
*/
|
||||
function views_rss_dc_views_rss_namespaces() {
|
||||
$namespaces['dc'] = array(
|
||||
'prefix' => 'xmlns',
|
||||
'uri' => 'http://purl.org/dc/elements/1.1/',
|
||||
);
|
||||
return $namespaces;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_views_rss_item_elements().
|
||||
*/
|
||||
function views_rss_dc_views_rss_item_elements() {
|
||||
$elements['dc:title'] = array(
|
||||
'description' => t('A name given to the resource. Typically, a Title will be a name by which the resource is formally known.'),
|
||||
'help' => 'http://dublincore.org/documents/1999/07/02/dces/#title',
|
||||
);
|
||||
$elements['dc:creator'] = array(
|
||||
'description' => t('An entity primarily responsible for making the content of the resource. Examples of a Creator include a person, an organisation, or a service. Typically, the name of a Creator should be used to indicate the entity.'),
|
||||
'help' => 'http://dublincore.org/documents/1999/07/02/dces/#creator',
|
||||
);
|
||||
$elements['dc:subject'] = array(
|
||||
'description' => t('The topic of the content of the resource. Typically, a Subject will be expressed as keywords, key phrases or classification codes that describe a topic of the resource. Recommended best practice is to select a value from a controlled vocabulary or formal classification scheme.'),
|
||||
'help' => 'http://dublincore.org/documents/1999/07/02/dces/#subject',
|
||||
);
|
||||
$elements['dc:description'] = array(
|
||||
'description' => t('An account of the content of the resource. Description may include but is not limited to: an abstract, table of contents, reference to a graphical representation of content or a free-text account of the content.'),
|
||||
'preprocess functions' => array('views_rss_rewrite_relative_paths'),
|
||||
'help' => 'http://dublincore.org/documents/1999/07/02/dces/#description',
|
||||
);
|
||||
$elements['dc:publisher'] = array(
|
||||
'description' => t('An entity responsible for making the resource available. Examples of a Publisher include a person, an organisation, or a service. Typically, the name of a Publisher should be used to indicate the entity.'),
|
||||
'help' => 'http://dublincore.org/documents/1999/07/02/dces/#publisher',
|
||||
);
|
||||
$elements['dc:contributor'] = array(
|
||||
'description' => t('An entity responsible for making contributions to the content of the resource. Examples of a Contributor include a person, an organisation, or a service. Typically, the name of a Contributor should be used to indicate the entity.'),
|
||||
'help' => 'http://dublincore.org/documents/1999/07/02/dces/#contributor',
|
||||
);
|
||||
$elements['dc:date'] = array(
|
||||
'description' => t('A date associated with an event in the life cycle of the resource. Typically, Date will be associated with the creation or availability of the resource. Recommended best practice for encoding the date value is defined in a profile of <a href="@formats_url">ISO 8601</a> and follows the YYYY-MM-DD format.', array(
|
||||
'@formats_url' => url('http://www.w3.org/TR/NOTE-datetime'),
|
||||
)),
|
||||
'help' => 'http://dublincore.org/documents/1999/07/02/dces/#date',
|
||||
);
|
||||
$elements['dc:type'] = array(
|
||||
'description' => t('The nature or genre of the content of the resource. Type includes terms describing general categories, functions, genres, or aggregation levels for content. Recommended best practice is to select a value from a controlled vocabulary (for example, the working draft list of <a href="@core_types_url">Dublin Core Types</a>). To describe the physical or digital manifestation of the resource, use the FORMAT element.', array(
|
||||
'@core_types_url' => url('http://dublincore.org/documents/dcmi-type-vocabulary/'),
|
||||
)),
|
||||
'help' => 'http://dublincore.org/documents/1999/07/02/dces/#type',
|
||||
);
|
||||
$elements['dc:format'] = array(
|
||||
'description' => t('The physical or digital manifestation of the resource. Typically, Format may include the media-type or dimensions of the resource. Format may be used to determine the software, hardware or other equipment needed to display or operate the resource. Examples of dimensions include size and duration. Recommended best practice is to select a value from a controlled vocabulary (for example, the list of <a href="@types_url">Internet Media Types</a> defining computer media formats).', array(
|
||||
'@types_url' => url('http://www.isi.edu/in-notes/iana/assignments/media-types/media-types'),
|
||||
)),
|
||||
'help' => 'http://dublincore.org/documents/1999/07/02/dces/#format',
|
||||
);
|
||||
$elements['dc:identifier'] = array(
|
||||
'description' => t('An unambiguous reference to the resource within a given context. Recommended best practice is to identify the resource by means of a string or number conforming to a formal identification system. Example formal identification systems include the Uniform Resource Identifier (URI) (including the Uniform Resource Locator (URL)), the Digital Object Identifier (DOI) and the International Standard Book Number (ISBN).'),
|
||||
'help' => 'http://dublincore.org/documents/1999/07/02/dces/#identifier',
|
||||
);
|
||||
$elements['dc:source'] = array(
|
||||
'description' => t('A Reference to a resource from which the present resource is derived. The present resource may be derived from the Source resource in whole or in part. Recommended best practice is to reference the resource by means of a string or number conforming to a formal identification system.'),
|
||||
'help' => 'http://dublincore.org/documents/1999/07/02/dces/#source',
|
||||
);
|
||||
$elements['dc:language'] = array(
|
||||
'description' => t("A language of the intellectual content of the resource. Recommended best practice for the values of the Language element is defined by <a href='@RFC1766_url'>RFC 1766</a> which includes a two-letter Language Code (taken from the <a href='@ISO639_url'>ISO 639 standard</a>), followed optionally, by a two-letter Country Code (taken from the <a href='@ISO3166_url'>ISO 3166 standard</a>). For example, 'en' for English, 'fr' for French, or 'en-uk' for English used in the United Kingdom.", array(
|
||||
'@RFC1766_url' => url('http://www.ietf.org/rfc/rfc1766.txt'),
|
||||
'@ISO639_url' => url('http://www.oasis-open.org/cover/iso639a.html'),
|
||||
'@ISO3166_url' => url('http://www.oasis-open.org/cover/iso639a.html'),
|
||||
)),
|
||||
'help' => 'http://dublincore.org/documents/1999/07/02/dces/#language',
|
||||
);
|
||||
$elements['dc:relation'] = array(
|
||||
'description' => t('A reference to a related resource. Recommended best practice is to reference the resource by means of a string or number conforming to a formal identification system.'),
|
||||
'help' => 'http://dublincore.org/documents/1999/07/02/dces/#relation',
|
||||
);
|
||||
$elements['dc:coverage'] = array(
|
||||
'description' => t('The extent or scope of the content of the resource. Coverage will typically include spatial location (a place name or geographic coordinates), temporal period (a period label, date, or date range) or jurisdiction (such as a named administrative entity). Recommended best practice is to select a value from a controlled vocabulary (for example, the Thesaurus of Geographic Names) and that, where appropriate, named places or time periods be used in preference to numeric identifiers such as sets of coordinates or date ranges.'),
|
||||
'help' => 'http://dublincore.org/documents/1999/07/02/dces/#coverage',
|
||||
);
|
||||
$elements['dc:rights'] = array(
|
||||
'description' => t('Information about rights held in and over the resource. Typically, a Rights element will contain a rights management statement for the resource, or reference a service providing such information. Rights information often encompasses Intellectual Property Rights (IPR), Copyright, and various Property Rights. If the Rights element is absent, no assumptions can be made about the status of these and other rights with respect to the resource.'),
|
||||
'help' => 'http://dublincore.org/documents/1999/07/02/dces/#rights',
|
||||
);
|
||||
return $elements;
|
||||
}
|
Reference in New Issue
Block a user