diff --git a/date_ical.api.php b/date_ical.api.php index f1ba8e9ee459f9d3bb6b060bcb95e71ea22f4e2f..24abdb1d8d6268be8f17dee2a7e627604744fd58 100644 --- a/date_ical.api.php +++ b/date_ical.api.php @@ -139,7 +139,7 @@ function hook_date_ical_export_post_render_alter(&$rendered_calendar, $view) { *****************************************************************************/ /** - * Alter the vcalendar object created from an imported iCal feed. + * Alter the vcalendar object imported from an iCal feed. * * @param object $calendar * An instance of the iCalcreator library's vcalendar class. @@ -153,7 +153,7 @@ function hook_date_ical_import_vcalendar_alter(&$calendar, $context) { } /** - * Alter a calendar component created from an imported iCal feed. + * Alter a calendar component imported from an iCal feed. * * @param object $component * This will usually be an iCalcreator vevent object, but Date iCal also @@ -174,6 +174,24 @@ function hook_date_ical_import_component_alter(&$component, $context) { } } +/** + * Alter the parsed data for an event imported from an iCal feed. + * + * @param array $data + * An associative array of field data that represents an imported event. + * @param array $context + * An associative array of context, with the following keys and values: + * - 'calendar': The iCalcreator vcalendar parent object of this component. + * - 'source': FeedsSource object for this Feed. + * - 'fetcher_result': The FeedsFetcherResult object for this Feed. + */ +function hook_date_ical_import_post_parse_alter(&$data, $context) { + // Example of what might be done with this alter hook. + if (!empty($context['calendar']->xprop['X-WR-CALNAME']['value'])) { + // Do something with the calendar name.... + } +} + /** * Alter the timezone string from an imported iCal Feed. * diff --git a/includes/date_ical_plugin_style_ical_feed.inc b/includes/date_ical_plugin_style_ical_feed.inc index c36a6745d40475e7fbb18635e8a5cb0c7a4ca869..fa987034c55dc6523c0ff828fe7bb8005136c1f4 100644 --- a/includes/date_ical_plugin_style_ical_feed.inc +++ b/includes/date_ical_plugin_style_ical_feed.inc @@ -410,7 +410,9 @@ class date_ical_plugin_style_ical_feed extends views_plugin_style { // Prevent devel module from appending queries to ical export. $GLOBALS['devel_shutdown'] = FALSE; - drupal_add_http_header('Content-Type', 'text/calendar; charset=utf-8'); + drupal_add_http_header('Content-Type', 'text/calendar; charset=UTF-8'); + drupal_add_http_header('Cache-Control', 'no-cache, must-revalidate'); + drupal_add_http_header('Expires', 'Sat, 26 Jul 1997 05:00:00 GMT'); // 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 diff --git a/libraries/ParserVcalendar.inc b/libraries/ParserVcalendar.inc index 690aeb6f400d4b6545944a2bb4f09753edb00418..7daedce2e31973e9253b6ee6a7360e9a22a04e78 100644 --- a/libraries/ParserVcalendar.inc +++ b/libraries/ParserVcalendar.inc @@ -69,6 +69,14 @@ class ParserVcalendar { $this->timezones[] = $component; } + // This content array is used by date_ical_import_component_alter() and + // date_ical_import_parsed_data_alter(). + $context2 = array( + 'calendar' => $this->calendar, + 'source' => $this->source, + 'fetcher_result' => $this->fetcherResult, + ); + // Collect each component, so we can batch them properly in the next loop. $raw_components = array(); $types = array('VEVENT', 'VTODO', 'VJOURNAL', 'VFREEBUSY', 'VALARM'); @@ -76,12 +84,7 @@ class ParserVcalendar { while ($vcalendar_component = $this->calendar->getComponent($type)) { // Allow modules to alter the vcalendar component before we parse it // into a Feeds-compatible data array. - $context = array( - 'calendar' => $this->calendar, - 'source' => $this->source, - 'fetcher_result' => $this->fetcherResult, - ); - drupal_alter('date_ical_import_component', $vcalendar_component, $context); + drupal_alter('date_ical_import_component', $vcalendar_component, $context2); $raw_components[] = $vcalendar_component; } } @@ -100,6 +103,10 @@ class ParserVcalendar { $handler = $data['date_ical_parse_handler']; $parsed_component[$property_key] = $this->$handler($property_key, $raw_component); } + // Allow modules to alter the final parsed data before we send it to the + // Feeds processor. + drupal_alter('date_ical_import_post_parse', $parsed_component, $context2); + $events[] = $parsed_component; // The indices of the original $raw_components array are preserved in // $batch, so using the $ndx value here lets us communicate our progress