Commit 32126161 authored by Robert Rollins's avatar Robert Rollins

Fixed up loads of issues reported by www.PAReview.sh

parent 1e130962
......@@ -23,10 +23,11 @@ Date iCal has several required dependencies, and an optional one:
- The Feeds module is optional, but it's needed to enable import of iCal feeds
from other sites.
To install the iCalcreator library, download it from http://github.com/iCalcreator/iCalcreator
using either git clone or the "Download Zip" button. Inside you'll find the file
iCalcreator.class.php. Copy that file to a folder in your Drupal site named
sites/all/libraries/iCalcreator.
To install the iCalcreator library, download it from the project's github:
http://github.com/iCalcreator/iCalcreator
Using either git clone or the "Download Zip" button, you'll find the file
iCalcreator.class.php inside. Copy that file to a folder in your Drupal site
named sites/all/libraries/iCalcreator.
Or, if you have drush, install iCalcreator by running this command from your
site's root directory:
......@@ -50,10 +51,10 @@ the iCal Fields plugin is a bit more versatile.
HOW TO EXPORT AN ICAL FEED USING THE iCal Entities PLUGIN
1. Go to the Manage Display page for the content type you want to export in an
1. Go to the Manage Display page for the content type you want to export in an
iCal feed. On the "Default" tab, check the box for "iCal" in the section
titled "Use custom display settings for the following view modes", then click
Save.
titled "Use custom display settings for the following view modes", then
click Save.
2. Click the new "iCal" tab that now appears in the upper-right corner of the
Manage Display page for this content type.
3. Set up the iCal view mode to contain whatever should be exported as the
......@@ -63,10 +64,10 @@ HOW TO EXPORT AN ICAL FEED USING THE iCal Entities PLUGIN
site's iCal feeds.
5. Create a new View that displays the entities that you want to include in the
iCal feed.
6. Add a "Feed" to the view. Change the Format to 'iCal Feed'. When you click
Apply from that dialog, you'll be given the option to name the calendar. This
name will appear in your users' calendar clients as the calendar's title.
7. Change the Show setting to 'iCal Entity' (rather than 'Content' or 'Fields').
6. Add a "Feed" to the view. Change the Format to 'iCal Feed'. When you click
Apply from that dialog, you'll be given the option to name the calendar,
which will appear in your users' calendar clients as the calendar's title.
7. Change the Show setting to 'iCal Entity'.
8. In the settings for iCal Entity, select the date field that should be used
as the event date for the iCal feed. Make sure that you choose a field that
is a part of every entity that your View displays. Otherwise, the entities
......@@ -95,10 +96,10 @@ HOW TO EXPORT AN ICAL FEED USING THE iCal Entities PLUGIN
HOW TO EXPORT AN ICAL FEED USING THE iCal Fields PLUGIN
1-6.These steps are the same as above.
7. Add views fields for each piece of information that you want to populate your
iCal feed with. A Date field is required, and fields that will act as the
Title and Description of the events are reccomended. You can also include a
Location field.
7. Add views fields for each piece of information that you want to populate
your iCal feed with. A Date field is required, and fields that will act as
the Title and Description of the events are reccomended. You can also
include a Location field.
8. Back in the FORMAT section, change the Show setting to 'iCal Fields'.
9. In the settings for iCal Fields, choose which views fields you want to use
for the Date, Title, Description, and Location.
......
......@@ -23,7 +23,7 @@
* - 'summary': The title field string
* - 'location': The location field string.
* @param object $view
* The view object that is being executed to render the iCal feed.
* The view object that is being executed to render the iCal feed.
* @param array $context
* Depending on whether this event is being constructed using the Fields or
* Entity plugins, this context array will have different keys and values.
......@@ -96,7 +96,7 @@ function hook_date_ical_export_raw_event_alter(&$event, $view, $context) {
* @param object $vevent
* A reference to an iCalcreator vevent which will be exported in this feed.
* @param object $view
* The view object that is being executed to render the iCal feed.
* The view object that is being executed to render the iCal feed.
* @param object $event_array
* The array representation of the event that's been rendered to the $vevent.
*/
......@@ -113,7 +113,7 @@ function hook_date_ical_export_vevent_alter(&$vevent, $view, $event_array) {
* @param object $vcalendar
* A reference to the iCalcreator vcalendar object representing this feed.
* @param object $view
* The view object that is being executed to render the iCal feed.
* The view object that is being executed to render the iCal feed.
*/
function hook_date_ical_export_vcalendar_alter(&$vcalendar, $view) {
......@@ -128,7 +128,7 @@ function hook_date_ical_export_vcalendar_alter(&$vcalendar, $view) {
* @param string $rendered_calendar
* A reference to the string containing the rendered the iCal feed.
* @param object $view
* The view that is being executed to render this iCal feed.
* The view that is being executed to render this iCal feed.
*/
function hook_date_ical_export_post_render_alter(&$rendered_calendar, $view) {
......@@ -149,7 +149,7 @@ function hook_date_ical_export_post_render_alter(&$rendered_calendar, $view) {
* - 'fetcher_result': The FeedsFetcherResult object for this Feed.
*/
function hook_date_ical_import_vcalendar_alter(&$calendar, $context) {
}
/**
......@@ -165,14 +165,15 @@ function hook_date_ical_import_vcalendar_alter(&$calendar, $context) {
* - 'fetcher_result': The FeedsFetcherResult object for this Feed.
*/
function hook_date_ical_import_component_alter(&$component, $context) {
// Example of what might be done with this alter hook
// Example of what might be done with this alter hook.
if ($component->objName == 'vevent') {
// Do something for vevents ...
// Do something for vevents...
}
else if ($component->objName == 'valarm') {
// Do something different for valarms ...
elseif ($component->objName == 'valarm') {
// Do something different for valarms...
}
}
/**
* Alter the timezone string from an imported iCal Feed.
*
......
......@@ -5,6 +5,7 @@
* Install, update and uninstall functions for the date_ical module.
*
*/
/**
* Implements hook_requirements().
*/
......@@ -41,7 +42,7 @@ function date_ical_requirements($phase) {
}
/**
* Implementation of hook_enable().
* Implements of hook_enable().
*/
function date_ical_enable() {
cache_clear_all('plugins:feeds:plugins', 'cache');
......@@ -53,6 +54,7 @@ function date_ical_enable() {
/**
* Migrates all iCal feed importers for from Date iCal 2.x to 3.0.
*
* <br>
* PLEASE NOTE: If any of your importers are defined by Features, you'll need
* to update their feature(s) to match.
......@@ -96,7 +98,7 @@ function date_ical_update_7300() {
// parser plugin being missing. We corrected that warning above, so we
// should clear it out to avoid potential confusion.
$messages = drupal_get_messages('warning');
foreach($messages['warning'] as $warning) {
foreach ($messages['warning'] as $warning) {
// Calling drupal_get_messages() removed *every* warning from the
// message queue, so we need to re-issue any warnings that aren't
// about missing Feeds plugins.
......
This diff is collapsed.
<?php
/**
* @file
* DateiCalFeedsParser is Date iCal's Feeds parser plugin.
* DateiCalFeedsParser is Date iCal's Feeds parser plugin.
*/
class DateiCalFeedsParser extends FeedsParser {
......@@ -44,7 +43,7 @@ class DateiCalFeedsParser extends FeedsParser {
// We've got a vcalendar object created from the feed data. Now we need to
// convert that vcalendar into an array of Feeds-compatible data arrays.
// ParserVcalendar->parse() does that.
require_once(DRUPAL_ROOT . '/' . drupal_get_path('module', 'date_ical') . '/libraries/ParserVcalendar.inc');
require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'date_ical') . '/libraries/ParserVcalendar.inc';
$parser = new ParserVcalendar($calendar, $source, $fetcher_result, $source->getConfigFor($this));
// Using the stored progress pointer (or 0 if it's not set),
......@@ -103,8 +102,6 @@ class DateiCalFeedsParser extends FeedsParser {
/**
* Creates the list of mapping sources offered by DateiCalFeedsParser.
*
* @return array
*/
public static function getiCalMappingSources() {
$sources = array();
......
......@@ -6,25 +6,30 @@
*/
/**
* Plugin which creates a view on the resulting object
* and formats it as an iCal VEVENT.
* A Views plugin which builds an iCal VEVENT from a single node.
*/
class date_ical_plugin_row_ical_entity extends views_plugin_row {
// Basic properties that let the row style follow relationships.
var $base_table = 'node';
var $base_field = 'nid';
protected $base_table = 'node';
protected $base_field = 'nid';
// Stores the nodes loaded with pre_render.
var $entities = array();
protected $entities = array();
function init(&$view, &$display, $options = NULL) {
/**
* Initialize the row plugin.
*/
public function init(&$view, &$display, $options = NULL) {
parent::init($view, $display, $options);
$this->base_table = $view->base_table;
$this->base_field = $view->base_field;
}
function option_definition() {
/**
* Set up the options for the row plugin.
*/
public function option_definition() {
$options = parent::option_definition();
$options['date_field'] = array('default' => array());
$options['summary_field'] = array('default' => array());
......@@ -33,17 +38,18 @@ class date_ical_plugin_row_ical_entity extends views_plugin_row {
}
/**
* Provide a form for setting options.
* Build the form for setting the row plugin's options.
*/
function options_form(&$form, &$form_state) {
public function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
// Build the select dropdown for the date field that the user wants to use
// to populate the date fields in VEVENTs.
// Build the select dropdown for the Date field that the user wants to use
// to populate the date properties in VEVENTs.
$data = date_views_fields($this->base_table);
$options = array();
foreach ($data['name'] as $item => $value) {
// We only want to see one value for each field, skip '_value2', and other columns.
// We only want to see one value for each field, so we need to
// skip '_value2' and other columns.
if ($item == $value['fromto'][0]) {
$options[$item] = $value['label'];
}
......@@ -58,7 +64,7 @@ class date_ical_plugin_row_ical_entity extends views_plugin_row {
'#required' => TRUE,
);
$form['instructions'] = array(
// The surrounding <div> is necessary to ensure that the settings dialog expands to show everything.
// The surrounding <div> ensures that the settings dialog expands.
'#prefix' => '<div style="font-size: 90%">',
'#suffix' => '</div>',
'#markup' => t("Each item's Title and iCal view mode will be included as the SUMMARY and DESCRIPTION elements (respectively) in the VEVENTs output by this View.
......@@ -101,18 +107,21 @@ class date_ical_plugin_row_ical_entity extends views_plugin_row {
);
}
function pre_render($values) {
// @TODO When the date is coming in through a relationship, the nid
// of the view is not the right node to use, then we need the related node.
// Need to sort out how that should be handled.
/**
* Preload the list of entities which will appear in the view.
*
* @TODO: When the date is coming in through a relationship, the nid
* of the view is not the right node to use, then we need the related node.
* Need to sort out how that should be handled.
*/
public function pre_render($values) {
// Preload each entity used in this view from the cache.
// Provides all the entity values relatively cheaply, and we don't
// need to do it repeatedly for the same entity if there are
// multiple results for one entity.
$ids = array();
foreach ($values as $row) {
// Use the $id as the key so we don't create more than one value per entity.
// Use the $id as the key so we create only value per entity.
$id = $row->{$this->field_alias};
// Node revisions need special loading.
......@@ -140,8 +149,10 @@ class date_ical_plugin_row_ical_entity extends views_plugin_row {
}
}
function render($row) {
global $base_url;
/**
* Renders the entities returned by the view into event arrays.
*/
public function render($row) {
$id = $row->{$this->field_alias};
if (!is_numeric($id)) {
return NULL;
......@@ -157,20 +168,17 @@ class date_ical_plugin_row_ical_entity extends views_plugin_row {
$date_fields = date_views_fields($this->base_table);
$date_info = $date_fields['name'][$this->options['date_field']];
$field_name = str_replace(array('_value', '_value2'), '', $date_info['real_field_name']);
$table_name = $date_info['table_name'];
$delta_field = $date_info['delta_field'];
$is_field = $date_info['is_field'];
// This is ugly and hacky but I can't figure out any generic way to
// recognize that the node module is going to give some the revision timestamp
// a different field name on the entity than the actual column name in the database.
// Sometimes the timestamp is actually the revision timestamp.
if ($this->view->base_table == 'node_revision' && $field_name == 'timestamp') {
$field_name = 'revision_timestamp';
}
if (!isset($entity->$field_name)) {
// This entity doesn't have the date property that the user configured
// our view to use. We can't do anything with it
// our view to use. We can't do anything with it.
return NULL;
}
$date_field = $entity->$field_name;
......@@ -193,7 +201,7 @@ class date_ical_plugin_row_ical_entity extends views_plugin_row {
if (!empty($date_field['value'])) {
$start = new DateObject($date_field['value'], $date_field['timezone_db']);
if (array_key_exists('value2', $date_field)) {
if (!empty($date_field['value2'])) {
$end = new DateObject($date_field['value2'], $date_field['timezone_db']);
}
else {
......@@ -244,7 +252,7 @@ class date_ical_plugin_row_ical_entity extends views_plugin_row {
}
elseif ($location_info['type'] == 'addressfield') {
$locations = array();
foreach($location_field as $key => $loc) {
foreach ($location_field as $key => $loc) {
if ($loc && !in_array($key, array('first_name', 'last_name'))) {
$locations[] = $loc;
}
......@@ -257,11 +265,12 @@ class date_ical_plugin_row_ical_entity extends views_plugin_row {
}
}
// Create the rendered display using the display settings from the 'iCal' view mode.
// Create the rendered event using the display settings from the
// iCal view mode.
$rendered_array = entity_view($this->entity_type, array($entity), 'ical', $this->language, TRUE);
$data = array(
'description' => drupal_render($rendered_array),
'summary' => entity_label($this->entity_type, $entity)
'summary' => entity_label($this->entity_type, $entity),
);
if (!empty($this->options['summary_field']) && $this->options['summary_field'] != 'default_title') {
$summary_fields = date_ical_get_summary_fields();
......@@ -281,7 +290,7 @@ class date_ical_plugin_row_ical_entity extends views_plugin_row {
}
elseif ($summary_info['type'] == 'taxonomy_term_reference') {
$terms = taxonomy_term_load_multiple($items);
// Make sure that there are terms that were loaded
// Make sure that there are terms that were loaded.
if ($terms) {
$term_names = array();
foreach ($terms as $term) {
......@@ -293,7 +302,7 @@ class date_ical_plugin_row_ical_entity extends views_plugin_row {
else {
$summary = trim($summary_field['value']);
}
$data['summary'] = $summary ? $summary : $data['summary'];
$data['summary'] = $summary ? $summary : $data['summary'];
}
}
// Allow other modules to alter the HTML of the Summary and Description,
......@@ -320,8 +329,8 @@ class date_ical_plugin_row_ical_entity extends views_plugin_row {
$event['location'] = $location;
}
// For this event's UID, use either the date_id generated by the Date module, or the
// event page's URL, if the date_id isn't available.
// For this event's UID, use either the date_id generated by the Date
// module, or the event page's URL if the date_id isn't available.
$event['uid'] = !empty($entity->date_id) ? $entity->date_id[0] : $event['url'];
// If we are using a repeat rule (and not just multi-day events) we
......@@ -342,7 +351,7 @@ class date_ical_plugin_row_ical_entity extends views_plugin_row {
if (isset($entity->changed)) {
$event['last-modified'] = new DateObject($entity->changed, 'UTC');
}
else if (isset($entity->created)) {
elseif (isset($entity->created)) {
// If changed is unset, but created is, use that for last-modified.
$event['last-modified'] = new DateObject($entity->created, 'UTC');
}
......
......@@ -6,12 +6,14 @@
*/
/**
* Plugin which creates a view on the resulting object
* and formats it as an iCal VEVENT.
* A Views plugin which builds an iCal VEVENT from a views row with Fields.
*/
class date_ical_plugin_row_ical_fields extends views_plugin_row {
function option_definition() {
/**
* Set up the options for the row plugin.
*/
public function option_definition() {
$options = parent::option_definition();
$options['date_field'] = array('default' => '');
$options['title_field'] = array('default' => '');
......@@ -21,7 +23,10 @@ class date_ical_plugin_row_ical_fields extends views_plugin_row {
return $options;
}
function options_form(&$form, &$form_state) {
/**
* Build the form for setting the row plugin's options.
*/
public function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
$all_field_labels = $this->display->handler->get_field_labels();
$date_field_labels = $this->get_date_field_candidates($all_field_labels);
......@@ -29,7 +34,7 @@ class date_ical_plugin_row_ical_fields extends views_plugin_row {
$text_field_label_options = array_merge(array('' => t('- None -')), $all_field_labels);
$form['instructions'] = array(
// The surrounding <div> is necessary to ensure that the settings dialog expands to show everything.
// The surrounding <div> ensures that the settings dialog expands.
'#prefix' => '<div style="font-size: 90%">',
'#suffix' => '</div>',
'#markup' => t("Once you've finished setting up the fields for this View, you may want to return to this dialog to set the Date field."),
......@@ -84,7 +89,10 @@ class date_ical_plugin_row_ical_fields extends views_plugin_row {
);
}
function pre_render($result) {
/**
* Set up the environment for the render() function.
*/
public function pre_render($result) {
// Get the language for this view.
$this->language = $this->display->handler->get_option('field_language');
$substitutions = views_views_query_substitutions($this->view);
......@@ -95,10 +103,9 @@ class date_ical_plugin_row_ical_fields extends views_plugin_row {
}
/**
* Returns an Event array based on the query result from the view whose
* index is $row->index.
* Returns an Event array row in the query with index: $row->index.
*/
function render($row) {
public function render($row) {
$date_field_name = $this->options['date_field'];
// If this view is set to use the first populated date field, check each
......@@ -153,7 +160,7 @@ class date_ical_plugin_row_ical_fields extends views_plugin_row {
if (isset($entity->changed)) {
$event['last-modified'] = new DateObject($entity->changed, 'UTC');
}
else if (isset($entity->created)) {
elseif (isset($entity->created)) {
// If changed is unset, but created is, use that for last-modified.
$event['last-modified'] = new DateObject($entity->created, 'UTC');
}
......@@ -238,8 +245,8 @@ class date_ical_plugin_row_ical_fields extends views_plugin_row {
*
* @return array
* The normalized array.
*/
function get_row_date($row, $date_field_name) {
*/
protected function get_row_date($row, $date_field_name) {
$start = NULL;
$end = NULL;
$rrule = NULL;
......@@ -315,24 +322,27 @@ class date_ical_plugin_row_ical_fields extends views_plugin_row {
}
/**
* Filter the list of views fields down to only those which are supported date-type fields.
* At this time, the supported date-type fields are timestamps and the three Date fields.
* Filter the list of views fields down to only supported date-type fields.
*
* The supported date-type fields are timestamps and the three Date fields.
*
* @param array $view_fields
* An key=>value array @see views_plugin_display::get_field_labels().
* An associative array like views_plugin_display::get_field_labels().
*
* @return array
* An key=>value array (alias => label) of date fields.
* An associative array (alias => label) of date fields.
*/
function get_date_field_candidates($view_fields) {
protected function get_date_field_candidates($view_fields) {
$handlers = $this->display->handler->get_handlers('field');
$field_candidates = array();
// These are Date, Date (ISO format), and Date (Unix timestamp).
$date_fields = array('datetime', 'date', 'datestamp');
foreach ($view_fields as $alias => $label) {
$handler = $handlers[$alias];
if (get_class($handler) == 'views_handler_field_date'
|| (get_class($handler) == 'views_handler_field_field' &&
// These are Date, Date (ISO format), and Date (Unix timestamp).
in_array($handler->field_info['type'], array('datetime', 'date', 'datestamp')))) {
$handler_class = get_class($handlers[$alias]);
if ($handler_class == 'views_handler_field_date'
|| ($handler_class == 'views_handler_field_field'
&& in_array($handlers[$alias]->field_info['type'], $date_fields))) {
$field_candidates[$alias] = $label;
}
}
......@@ -347,9 +357,9 @@ class date_ical_plugin_row_ical_fields extends views_plugin_row {
* @param string $field_id
* The ID assigned to the required field in the display.
*
* @see views_plugin_style::get_field().
* @see views_plugin_style::get_field()
*/
function get_field($index, $field_id) {
protected function get_field($index, $field_id) {
if (empty($this->view->style_plugin) || !is_object($this->view->style_plugin) || empty($field_id)) {
return '';
}
......
<?php
/**
* @file
* Views style plugin for the Date iCal module.
*/
/**
* Default style plugin to render an iCal feed.
* Defines a Views style plugin that renders iCal feeds.
*/
class date_ical_plugin_style_ical_feed extends views_plugin_style {
/**
* Internal helper function.
*/
protected function _get_option($option_name) {
return isset($this->options[$option_name]) ? $this->options[$option_name] : '';
}
// Sets up the iCal feed icon on calendar pages.
function attach_to($display_id, $path, $title) {
$display = $this->view->display[$display_id]->handler;
/**
* Sets up the iCal feed icon on calendar pages.
*/
public function attach_to($display_id, $path, $title) {
$url_options = array();
$input = $this->view->get_exposed_input();
if ($input) {
......@@ -25,8 +28,8 @@ class date_ical_plugin_style_ical_feed extends views_plugin_style {
$url_options['absolute'] = TRUE;
$url = url($this->view->get_url(NULL, $path), $url_options);
// If the user didn't disable the option, change the scheme to webcal:// so
// that calendar clients can automatically subscribe via the iCal link.
// If the user didn't disable the option, change the scheme to webcal://
// so calendar clients can automatically subscribe via the iCal link.
if (!$this->_get_option('disable_webcal')) {
$url = str_replace(array('http://', 'https://'), 'webcal://', $url);
}
......@@ -35,10 +38,17 @@ class date_ical_plugin_style_ical_feed extends views_plugin_style {
if (empty($this->view->live_preview)) {
$tooltip = t('Add to My Calendar');
if (!isset($this->view->feed_icon)) {
// In PHP 5.5, you're no longer allowed to concatinate onto a not-yet-existent property.
// In PHP 5.5, you're not allowed to concatinate onto an unset
// property. But we need to do a concat, because there may be
// other attachments.
$this->view->feed_icon = '';
}
$this->view->feed_icon .= theme('date_ical_icon', array('url' => check_url($url), 'tooltip' => $tooltip, 'view' => $this->view));
$variables = array(
'url' => check_url($url),
'tooltip' => $tooltip,
'view' => $this->view,
);
$this->view->feed_icon .= theme('date_ical_icon', $variables);
drupal_add_html_head_link(array(
'rel' => 'alternate',
'type' => 'text/calendar',
......@@ -48,17 +58,25 @@ class date_ical_plugin_style_ical_feed extends views_plugin_style {
}
}
function option_definition() {
/**
* Set up the options for the style plugin.
*/
public function option_definition() {
$false_bool = array('default' => FALSE, 'bool' => TRUE);
$options = parent::option_definition();
$options['cal_name'] = array('default' => array());
$options['no_calname'] = array('default' => FALSE, 'bool' => TRUE);
$options['disable_webcal'] = array('default' => FALSE, 'bool' => TRUE);
$options['exclude_dtstamp'] = array('default' => FALSE, 'bool' => TRUE);
$options['unescape_punctuation'] = array('default' => FALSE, 'bool' => TRUE);
$options['no_calname'] = $false_bool;
$options['disable_webcal'] = $false_bool;
$options['exclude_dtstamp'] = $false_bool;
$options['unescape_punctuation'] = $false_bool;
return $options;
}
function options_form(&$form, &$form_state) {
/**
* Build the form for setting the style plugin's options.
*/
public function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
// Allow users to override the default Calendar name (X-WR-CALNAME).
$form['cal_name'] = array(
......@@ -98,19 +116,23 @@ class date_ical_plugin_style_ical_feed extends views_plugin_style {
'#title' => t('Unescape Commas and Semicolons'),
'#default_value' => $this->_get_option('unescape_punctuation'),
'#description' => t('In order to comply with the iCal spec, Date iCal will "escape" commas and semicolons (prepend them with backslashes).
However, many calendar clients are bugged to not unescape these characters, leaving the backslashes littered throughout your events\' text fields.
However, many calendar clients are bugged to not unescape these characters, leaving the backslashes littered throughout your events.
Enable this option to have Date iCal unescape these characters before it exports the iCal feed.'),
);
}
function render() {
/**
* Render the event arrays returned by the row plugin into a VCALENDAR.
*/
public function render() {
if (empty($this->row_plugin) || !in_array($this->row_plugin->plugin_name, array('date_ical', 'date_ical_fields'))) {
debug('date_ical_plugin_style_ical_feed: This style plugin supports only the "iCal Entity" and "iCal Fields" row plugins.', NULL, TRUE);
return t('To enable iCal output, this view\'s Format must be configured to Show: iCal Entity or iCal Fields.');
}
if ($this->row_plugin->plugin_name == 'date_ical_fields' && empty($this->row_plugin->options['date_field'])) {
// Because the Date field is required by the form, this error state will rarely occur. But I ran across it during
// testing, and the error that resulted was totally non-sensical, so I'm adding this in case it does ever happen.
// Because the Date field is required by the form, this error state will
// rarely occur. But I ran across it during testing, and the error that
// resulted was totally non-sensical, so I'm adding this just in case.
return t("When using the iCal Fields row plugin, the Date field is required. Please set it up using the Settings link under 'Format -> Show: iCal Fields'.");
}
$events = array();
......@@ -174,7 +196,7 @@ class date_ical_plugin_style_ical_feed extends views_plugin_style {
$timezones[$start_timezone] = $start_timezone;
if ($event['all_day']) {
// All Day events need to be specified as DATE, rather than DATE-TIME, or they get interpretted wrong.
// All Day events need to be DATEs, rather than DATE-TIMEs.
$vevent->setDtstart($start['year'], $start['month'], $start['day'],
FALSE, FALSE, FALSE, FALSE, array('VALUE' => 'DATE'));
}
......@@ -227,7 +249,7 @@ class date_ical_plugin_style_ical_feed extends views_plugin_style {
// Add the RRULE itself. We need to massage the data a bit, since
// iCalcreator expects RRULEs to be in a different format than how
// Date API gives them to us.
$vevent->setRrule(self::convert_rrule_for_icalcreator($rrule));
$vevent->setRrule(_date_ical_convert_rrule_for_icalcreator($rrule));
// Convert any exceptions to EXDATE properties.
if (!empty($exceptions)) {
......@@ -383,16 +405,17 @@ class date_ical_plugin_style_ical_feed extends views_plugin_style {
}
}
// These steps shouldn't be run when doing a Preview on the View config page.
// These steps shouldn't be run when during Preview on the View page.
if (empty($this->view->live_preview)) {
// Prevent devel module from appending queries to ical export.
$GLOBALS['devel_shutdown'] = FALSE;
drupal_add_http_header('Content-Type', 'text/calendar; charset=utf-8');
// For sites with Clean URLs disabled, the "path" value in the view Display
// doesn't actually get applied to the URL of the calendar feed. So, we
// need to manually instruct browsers to download a .ics file.
// For sites with Clean URLs disabled, the Display's "path" value ends
// up only in the query args, meaning the filename won't be set properly
// when users download the feed. So we need to manually instruct browsers
// to download a .ics file.
if (!variable_get('clean_url', FALSE)) {
$path_array = explode('/', $this->display->display_options['path']);
$filename = end($path_array);
......@@ -405,39 +428,4 @@ class date_ical_plugin_style_ical_feed extends views_plugin_style {
return $output;
}
/**
* This function converts an rrule array to the iCalcreator format.
*
* iCalcreator expects the BYDAY element to be an array like this:
* (array) ( [([plus] ordwk / minus ordwk)], "DAY" => weekday )
*
* But the way that the Date API gives it to us is like this:
* (array) ( [([plus] ordwk / minus ordwk)]weekday )
*/
public static function convert_rrule_for_icalcreator($rrule) {
$new_rrule = array();
foreach ($rrule as $key => $value) {