Commit 11f49c89 authored by Robert Rollins's avatar Robert Rollins

Initial commit of Date iCal 3.0!

This new version is still in a state of partial completeness. You may need to do
some manual fixing to get it working, due to a change I made in the classes
offered by this module. Try 'drush cc registry' if 'drush cc all' fails.

Please note that ALL of the hooks exposed by Date iCal have changed. They do
essentially the same things they used to do, but they're named differently.

The big change is that the Feeds plugin has been completely re-written to
conform to the Feeds APIs. It's now much more resilient and powerful. Feeds
Tamper will now work, and is in fact the prescribed way to alter data, since I
removed several alter hooks.
parent 3073af84
<?php
/**
* Alter the HTML of an event's Summary and Description, before it gets converted
* to plaintext for output in an iCal feed. This hook is only used by the
* iCal Entity views row plugin.
*
* @param $data
* A reference to an associative array with the following keys and values:
* - 'description': The rendered HTML of the iCal view mode of the entity.
* - 'summary': The title of the entity.
* @param $view
* The view object that is being executed to render the iCal feed.
* @param $context
* An associative array of context, with the following keys and values:
* - 'entity_type': The type of entity being rendered, 'node', 'user' etc.
* - 'entity': The fully loaded entity being rendered.
* - 'language': The language code that indicates which translation of field
* data should be used.
* @file
* Documentation for the hooks provided by Date iCal.
*/
function hook_date_ical_html_alter(&$data, $view, $context) {
}
/******************************************************************************
* ALTER HOOKS FOR EXPORTED ICAL FEEDS
*****************************************************************************/
/**
* Alter the HTML of an event's text fields, before it gets converted
* to plaintext for output in an iCal feed. This hook is only used by the
* iCal Fields views row plugin.
* Alter the HTML from an event's text fields before they get exported.
*
* Because HTML must be converted to plaintext for iCal spec compliance, this
* hook exists to allow users to alter the original HTML to ensure that it
* gets converted into pretty plaintext.
*
* @param $text_fields
* ONLY <p> tags will be converted to newlines by the plaintext conversion.
*
* @param array $text_fields
* A reference to an associative array with the following keys and values:
* - 'description': The description field string.
* - 'summary': The title field string
* - 'location': The location field string.
* @param $view
* @param object $view
* The view object that is being executed to render the iCal feed.
* @param $context
* An associative array of context, with the following keys and values:
* - 'row': The single query result row that is being converted into an iCal VEVENT.
* - 'row_index': The index into the full query results for this row.
* @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.
*
* Entity Plugin:
* - 'entity_type': The type of entity being rendered (e.g. 'node').
* - 'entity': The fully loaded entity being rendered.
* - 'language': The language code that indicates which translation of field
* data should be used.
*
* Fields Plugin:
* - 'row': The full Views row object being converted to an event.
* - 'row_index': The index into the query results for this view.
* - 'language': The language code that indicates which translation of field
* data should be used.
* - 'options': The Fields plugin options.
*/
function hook_date_ical_fields_html_alter(&$text_fields, $view, $context) {
function hook_date_ical_export_html_alter(&$text_fields, $view, $context) {
}
/**
* Modify a structured event before it is rendered to iCal format.
* Modify an event's raw data.
*
* This hook is invoked after the Date iCal module has generated its
* representation of the event and allows you to modify or add to the
* representation. Use this hook to set values of iCal fields that are supported
* but have no values mapped into them by default.
* This hook is invoked after Date iCal has gathered all the data it will use
* to build an event object. Use this hook to set values of iCal fields which
* Date iCal doesn't directly support.
*
* @param $event
* An associative array representation of the iCal event. This will be used by
* the Date iCal rendering system to create an entry in an iCal feed.
* @param $view
* @param array $event
* A reference to an associative array containing the event's raw data.
* @param object $view
* The view object that is being executed to render the iCal feed.
* @param $context
* An associative array of context, with the following keys and values:
* - 'entity_type': The type of entity being rendered, 'node', 'user' etc.
* @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.
*
* Entity Plugin:
* - 'entity_type': The type of entity being rendered (e.g. 'node').
* - 'entity': The fully loaded entity being rendered.
* - 'language': The language code that indicates which translation of field
* data should be used.
*
* Fields Plugin:
* - 'row': The full Views row object being converted to an event.
* - 'row_index': The index into the query results for this view.
* - 'language': The language code that indicates which translation of field
* data should be used.
* - 'options': The Fields plugin options.
*/
function hook_date_ical_feed_event_render_alter(&$event, $view, $context) {
// Simple example adding the location to a rendered event from a simple
// textfield called 'field_location'.
$entity_type = $context['entity_type'];
$entity = $context['entity'];
$language = $context['language'];
if ($locations = field_get_items($entity_type, $entity, 'field_location', $language)) {
foreach ($locations as $location) {
$event['location'] = check_plain($location['value']);
function hook_date_ical_export_raw_event_alter(&$event, $view, $context) {
// Example: adding a comment to an event from a simple
// textfield called 'field_comment' (using the Entity plugin).
if ($comments = field_get_items($context['entity_type'], $context['entity'], 'field_comment', $context['language'])) {
foreach ($comments as $comment) {
$event['comment'] = check_plain($comment['value']);
}
}
// Example: Retrieving information from additional fields in the View (using
// the Fields plugin).
$event['comment'] = $view->style_plugin->get_field($context['row_index'], 'field_comment');
}
/**
* Alter an iCal representation of an event.
*
* This hook allows you to modify the event that is being added to the
* iCal calendar. If Date iCal doesn't support an iCal property that you
* need to use, then you can add it to the event in the iCal feed here.
* This hook allows you to modify an event as it is added to the iCal calendar.
* If Date iCal doesn't support an iCal property that you need to use, then you
* can add it to the event here.
*
* @param $vevent
* The iCalcreator vevent object that is being added to the iCal feed. See the
* iCalcreator library for documentation on how to use this object correctly.
* @param $view
* @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.
* @param $event_array
* @param object $event_array
* The array representation of the event that's been rendered to the $vevent.
*/
function hook_date_ical_feed_ical_vevent_render_alter($vevent, $view, $event_array) {
function hook_date_ical_export_vevent_alter(&$vevent, $view, $event_array) {
}
/**
* Alter the iCalcreator vcalendar object that will be rendered into an iCal
* feed View.
*
* This hook allows you to modify the iCal calendar that will be rendered into
* an iCal feed. You can use this hook to add sections to the generated iCal
* feeds that the Date iCal module doesn't support, etc.
*
* @param $vcalendar
* The iCalcreator vcalendar object that will be rendered to generate the iCal
* feed. See the iCalcreator library for documentation on how to use this
* object correctly.
* @param $view
* Alter the iCalcreator vcalendar object before it's exported as an iCal feed.
*
* You can use this hook to add sections to the generated iCal feed which Date
* iCal might not support.
*
* @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.
*/
function hook_date_ical_feed_ical_vcalendar_render_alter(&$vcalendar, $view) {
function hook_date_ical_export_vcalendar_alter(&$vcalendar, $view) {
}
/**
* Alter the final rendered text of an iCal feed before it gets sent to Views.
* Alter the final rendered text of an iCal feed before it gets exported.
*
* @param $rendered_calendar
* The rendered string of iCal text created from an iCalcreator vcalendar object.
* @param $view
* The view object that is being executed to render the iCal feed.
* This is a last resort hook, allowing you to alter the output of the feed
* in case nothing else works.
*
* @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.
*/
function hook_date_ical_post_render_alter(&$rendered_calendar, $view) {
function hook_date_ical_export_post_render_alter(&$rendered_calendar, $view) {
}
/******************************************************************************
* ALTER HOOKS FOR IMPORTED ICAL FEEDS
*****************************************************************************/
/**
* Alter the iCalcreator vcalendar object that was parsed from an imported
* iCal feed.
* Alter the vcalendar object created from an imported iCal feed.
*
* @param $calendar
* The iCalcreator vcalendar object that was created by parsing the iCal
* feed. See the iCalcreator library for documentation on this object.
* @param $context
* @param object $calendar
* An instance of the iCalcreator library's vcalendar class.
* @param array $context
* An associative array of context, with the following keys and values:
* - 'source' FeedsSource object associated with this Feed.
* - 'fetcher_result': The FeedsFetcherResult object associated with this Feed.
* - 'source' FeedsSource object for this Feed.
* - 'fetcher_result': The FeedsFetcherResult object for this Feed.
*/
function hook_date_ical_icalcreator_calendar_alter(&$calendar, &$context) {
function hook_date_ical_import_calendar_alter(&$calendar, $context) {
}
/**
* Alter an individual DateIcalIcalcreatorComponent (vevent, valarm, vtodo, etc.)
* that was parsed from an iCal feed.
* Alter a calendar component created from an imported iCal feed.
*
* @param $component
* A DateIcalIcalcreatorComponent. See the definition of this class in
* includes/DateIcalIcalcreatorParser.inc for more information.
* @param $context
* @param object $component
* This will usually be an iCalcreator vevent object, but Date iCal also
* experimentally supports vtodo, vjournal, vfreebusy, and valarm.
* @param array $context
* An associative array of context, with the following keys and values:
* - 'calendar': The iCalcreator vcalendar object from which this
* DateIcalIcalcreatorComponent originates.
* - 'parser_result': The DateIcalParserResult object which contains the parsed
* values from the vcalendar object.
* - 'source': FeedsSource object associated with this Feed.
* - 'fetcher_result': The FeedsFetcherResult object associated with this Feed.
* - '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_icalcreator_component_alter(&$component, $context) {
function hook_date_ical_import_component_alter(&$component, $context) {
// Example of what might be done with this alter hook
if ($component->getComponentType() == 'vevent') {
if ($component->objName == 'vevent') {
// Do something for vevents ...
}
if ($component->getComponentType() == 'vtimezone') {
// Do something different for vtimezones ...
else if ($component->objName == 'valarm') {
// Do something different for valarms ...
}
}
/**
* Alter the post-parse data for a single field from an iCal feed.
* Alter the timezone string from an imported iCal Feed.
*
* @param $value
* A string or object representing one parsed property of an iCal component.
* @param $context
* An associative array of context, with the following keys and values:
* - 'property_key': Inernal, parser-specific identifier for this property.
* - 'property': "RAW" value of this property.
* - 'item': The DateIcalComponentInterface object that holds the unparsed component.
* - 'parser_result': The parsed result of the whole Calendar.
* - 'feeds_source': Contains all the metadata about the configuration of this Feed.
*/
function hook_date_ical_feeds_object_alter(&$value, $context) {
// Example of what might be done with this alter hook
if ($context['property_key'] == 'dtstart') {
// Tweak the parsed FeedsDateTime object created from the start time.
// ...
}
}
/**
* Alter the timezone string before it gets converted into a DateTimeZone object.
* This is useful for when an iCal feed you're trying to import uses deprecated
* timezone names, like "Eastern Standard Time", rather than "America/New_York".
* timezone names, like "Eastern Standard Time" rather than "America/New_York".
*
* @param $tz_string
* The timezone sting to be altered (e.g. "America/Los_Angeles").
* @param $context
* @param string $tzid
* The timezone id sting to be altered (e.g. "America/Los_Angeles").
* @param array $context
* An associative array of context, with the following keys and values:
* - 'property_key': Inernal, parser-specific identifier for this property.
* - 'property': "RAW" value of this property.
* - 'item': The DateIcalComponentInterface object that holds the unparsed component.
* - 'parser_result': The parsed result of the whole Calendar.
* - 'feeds_source': Contains all the metadata about the configuration of this Feed.
* - 'property_key': The name of the property (e.g. DTSTART). Can be NULL.
* - 'calendar_component': The iCalcreator object (e.g VEVENT). Can be NULL.
* - 'calendar': The iCalcreater vcalendar object created from the feed.
* - 'feeds_source': A FeedsSource object with this feed's metadata.
* - 'feeds_detcher_result': The FeedsFeatcherResult for this import.
*
* If property_key and calendar_component are NULL, this is the X-WR-TIMEZONE
* string for the entire feed.
*/
function hook_date_ical_timezone_alter(&$tz_string, $context) {
function hook_date_ical_import_timezone_alter(&$tzid, $context) {
// Example of what might be done with this alter hook:
if ($tz_string == 'Eastern Standard Time') {
// "Eastern Standard Time" is a deprecated timezone string, which PHP doesn't
// recognize. It's (essentially) equivalent to "America/New_York", though,
// which PHP is fine with.
$tz_string = 'America/New_York';
if ($tzid == 'Eastern Standard Time') {
// "Eastern Standard Time" is a deprecated tzid, which PHP doesn't accept.
// However, it's equivalent to "America/New_York", which PHP is fine with.
$tzid = 'America/New_York';
}
}
name = Date iCal
description = Allows creation of iCal feeds using Views, and provides a Feeds plugin for parsing iCal feeds.
description = Enables users to export iCal feeds using Views, and import iCal feeds using Feeds.
package = Date/Time
php = 5.3
core = 7.x
......@@ -10,21 +10,15 @@ dependencies[] = libraries (>=7.x-2.0)
dependencies[] = date
dependencies[] = date_api
; Date iCal doesn't actually depend on Feeds, but it's iCal import functionality won't work without it.
; Date iCal doesn't actually depend on Feeds, but it's iCal import functionality won't be usable without it.
;dependencies[] = feeds
; Includes
; Includes for iCal feed export using Views
files[] = includes/date_ical_plugin_row_ical_entity.inc
files[] = includes/date_ical_plugin_row_ical_fields.inc
files[] = includes/date_ical_plugin_style_ical_feed.inc
; Includes for iCal feed import using Feeds
files[] = includes/DateIcalFeedsParser.inc
files[] = includes/DateIcalFeedsParserOld.inc
files[] = includes/DateIcalIcalcreatorParser.inc
files[] = includes/DateIcalDateModuleParser.inc
; Tests
files[] = tests/date_ical_parser.test
files[] = tests/date_ical_parser_text.test
files[] = tests/date_ical_parser_link.test
files[] = tests/date_ical_parser_date.test
files[] = tests/date_ical_parser_location.test
files[] = tests/date_ical_parser_categories.test
......@@ -3,21 +3,37 @@
/**
* @file
* Adds ical functionality to Views, and an iCal parser to Feeds.
*
* TODO Figure out how to incorporate VVENUE information into the parser.
*/
/**
* The version number of the current release. This is inserted into the PRODID
* value of the iCal feeds created by Date iCal.
*/
define('DATE_ICAL_VERSION', '2.13-dev');
define('DATE_ICAL_VERSION', '3.0-dev');
/**
* Exception for when the date field for a row in the ical_fields row plugin is blank.
*/
class BlankDateFieldException extends Exception { }
/**
* Generic DateIcalFeedsParser exceptions.
*/
class DateIcalException extends Exception {}
/**
* DateIcalFeedsParser failed to parse some part of iCal.
*/
class DateIcalParseException extends DateIcalException {}
/**
* Implements hook_hook_info().
*/
function date_ical_hook_info() {
// TODO: Finish this.
// Use two "groups": date_ical_parse and date_ical_output.
}
/**
* Implements hook_views_api().
*/
......@@ -134,7 +150,7 @@ function date_ical_libraries_info() {
}
/**
* Implementation of hook_ctools_plugin_api().
* Implements hook_ctools_plugin_api().
*/
function date_ical_ctools_plugin_api($owner, $api) {
if ($owner == 'feeds' && $api == 'plugins') {
......@@ -143,32 +159,41 @@ function date_ical_ctools_plugin_api($owner, $api) {
}
/**
* Implementation of ctools plugin for feeds hook_feeds_plugins().
* Implements hook_feeds_plugins().
*/
function date_ical_feeds_plugins() {
$path = drupal_get_path('module', 'date_ical') . '/includes';
$info = array();
$info['DateIcalFeedsParser'] = array(
$info['DateIcalFeedsParserOld'] = array(
'hidden' => TRUE,
'handler' => array(
'parent' => 'FeedsParser',
'class' => 'DateIcalFeedsParser',
'file' => 'DateIcalFeedsParser.inc',
'class' => 'DateIcalFeedsParserOld',
'file' => 'DateIcalFeedsParserOld.inc',
'path' => $path,
),
);
$info['DateIcalIcalcreatorParser'] = array(
'name' => 'iCal parser',
'name' => 'iCal parser (old)',
'description' => t('Use the iCalcreator library to parse iCal feeds.'),
'help' => 'Parse iCal feeds.',
'handler' => array(
'parent' => 'DateIcalFeedsParser',
'parent' => 'DateIcalFeedsParserOld',
'class' => 'DateIcalIcalcreatorParser',
'file' => 'DateIcalIcalcreatorParser.inc',
'path' => $path,
),
);
$info['DateiCalFeedsParser'] = array(
'name' => 'iCal parser',
'description' => t('Parse iCal feeds.'),
'handler' => array(
'parent' => 'FeedsParser',
'class' => 'DateiCalFeedsParser',
'file' => 'DateiCalFeedsParser.inc',
'path' => $path,
),
);
return $info;
}
......
......@@ -2,100 +2,425 @@
/**
* @file
* Basic classes.
* Classes implementing Date iCal's iCalcreator-based parser functionality.
*
* @TODO: Figure out how to parse VVENUE information.
*/
class DateiCalFeedsParser extends FeedsParser {
/**
* Implements FeedsParser::getMappingSources().
*/
public function getMappingSources() {
return parent::getMappingSources() + self::getiCalMappingSources();
}
/**
* Implements FeedsParser::parse().
*/
public function parse(FeedsSource $source, FeedsFetcherResult $fetcher_result) {
if (!libraries_load('iCalcreator')) {
throw new DateIcalException(t('Unable to load the iCalcreator library. Please ensure that you have installed the library correctly.'));
}
// Read the iCal feed into memory.
$ical_feed_contents = $fetcher_result->getRaw();
// Parse the feed into an iCalcreator vcalendar object.
$calendar = new vcalendar();
if ($calendar->parse($ical_feed_contents) === FALSE) {
$plugin = $source->importer->config['fetcher']['plugin_key'];
$url = $source->config[$plugin]['source'];
throw new DateIcalException(t('Parsing the data from %url failed. Please ensure that this URL leads to a valid iCal feed.', array('%url' => $url)));
}
// Allow modules to alter the vcalendar object before we interpret it.
$context = array(
'source' => $source,
'fetcher_result' => $fetcher_result,
);
drupal_alter('date_ical_import_calendar', $calendar, $context);
// We've got a vcalendar object created from the parsed feed data. Now we
// need to convert that vcalendar into an array of Feeds-compatible parsed
// data arrays. DateiCalCalendarParser does this conversion.
$parser = new DateiCalCalendarParser($calendar, $source, $fetcher_result);
return new FeedsParserResult($parser->parse());
}
public static function getiCalMappingSources() {
// NOTE TO MAINTAINERS:
// The order of these properties determines their parse order! Since we
// need to parse the DTSTART property before parsing DTEND, the DTSTART
// source *must* come before it in this function.
$sources = array();
$sources['SUMMARY'] = array(
'name' => t('Summary/Title'),
'description' => t('The SUMMARY property. A short summary (usually the title) of the event.'),
'date_ical_parse_handler' => 'parseTextProperty',
);
$sources['DESCRIPTION'] = array(
'name' => t('Description'),
'description' => t('The DESCRIPTION property. A more complete description of the event than what is provided by the Summary.'),
'date_ical_parse_handler' => 'parseTextProperty',
);
$sources['DTSTART'] = array(
'name' => t('Date: Start'),
'description' => t('The DTSTART property. The start time of each event in the feed.'),
'date_ical_parse_handler' => 'parseDateTimeProperty',
);
$sources['DTEND'] = array(
'name' => t('Date: End'),
'description' => t('THE DTEND or DURATION property. The end time (or duration) of each event in the feed.'),
'date_ical_parse_handler' => 'parseDateTimeProperty',
);
$sources['RRULE'] = array(
'name' => t('Repeat Rule'),
'description' => t('The RRULE property. Describes when and how often this event should repeat.
The date field for the target node must be configured to support repeating dates, using the Date Repeat Field module (a submodule of Date).'),
'date_ical_parse_handler' => 'parseRepeatProperty',
);
$sources['UID'] = array(
'name' => 'UID',
'description' => t('The UID property. Each event must have a UID if you wish for the import process to be able to update previously-imported nodes.
If used, this field MUST be set to Unique.'),
'date_ical_parse_handler' => 'parseTextProperty',
);
$sources['URL'] = array(
'name' => 'URL',
'description' => t('The URL property. Some feeds specify a URL for the event using this property.'),
'date_ical_parse_handler' => 'parseTextProperty',
);
$sources['LOCATION'] = array(
'name' => t('Location'),
'description' => t('The LOCATION property. Can be mapped to a text field, or the title of a referenced node.'),
'date_ical_parse_handler' => 'parseTextProperty',
);
$sources['LOCATION:ALTREP'] = array(
'name' => t('Location: ALTREP'),
'description' => t('The ALTREP value of the LOCATION property. Additional location information, usually a URL to a page with more info.'),
'date_ical_parse_handler' => 'parsePropertyParameter',
);
$sources['CATEGORIES'] = array(
'name' => t('Categories'),
'description' => t('The CATEGORIES property. Catagories that describe the event, which can be imported into taxonomy terms.'),
'date_ical_parse_handler' => 'parseMultivalueProperty',
);
return $sources;
}
}
/**
* Parent class for Feeds integration.
* Functionality to parse an iCalcreator vcalendar object into an array of
* Feeds-compatible data arrays.
*/
abstract class DateIcalFeedsParser extends FeedsParser {
class DateiCalCalendarParser {
protected $calendar;
protected $source;
protected $fetcher_result;
protected $timezones = array();
protected $xtimezone;
public function __construct($calendar, $source, $fetcher_result) {
$this->calendar = $calendar;
$this->source = $source;
$this->fetcher_result = $fetcher_result;
}
/**
* The output sources the parser offers.
* Parses the vcalendar object into an array of event data arrays.
*
* array(
* 'feeds_output_key' => array(
* 'name' => 'Human readable name of output source.',
* 'description' => 'Longer description of source.',
* 'date_ical_parse_handler' => 'Method callback for parsing source before handing to feeds.',
* ),
* );
* @return array
* An array keyed by the same property keys as returned by
* DateiCalFeedsParser::getiCalMappingSources().
*/
static protected $sources;
public function parse() {
// Sometimes, the feed will set a timezone for every event in the calendar
// using the non-standard X-WR-TIMEZONE property. Date iCal uses this
// timezone only if the date property is not in UTC and has no TZID.
$xtimezone = $this->calendar->getProperty('X-WR-TIMEZONE');
if (!empty($xtimezone[1])) {
// Allow modules to alter the timezone string before it gets converted
// into a DateTimeZone.
$context = array(
'property_key' => NULL,
'calendar_component' => NULL,
'calendar' => $this->calendar,
'feeeds_source' => $this->source,
'feeds_fetcher_result' => $this->fetcher_result,
);
drupal_alter('date_ical_import_timezone', $xtimezone[1], $context);
$this->xtimezone = $this->_tzid_to_datetimezone($xtimezone[1]);
}
// Collect the timezones into an array, for easier access.
while ($component = $this->calendar->getComponent('VTIMEZONE')) {
$this->timezones[] = $component;
}
// Parse each calendar component it into a Feeds-compatible data array.
$events = array();
$component_types = array('VEVENT', 'VTODO', 'VJOURNAL', 'VFREEBUSY', 'VALARM');
foreach ($component_types as $component_type) {
while ($vcalendar_component = $this->calendar->getComponent($component_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->fetcher_result,
);
drupal_alter('date_ical_import_component', $vcalendar_component, $context);
$parsed_component = array();
foreach (DateiCalFeedsParser::getiCalMappingSources() as $property_key => $data) {
$handler = $data['date_ical_parse_handler'];
$parsed_component[$property_key] = $this->$handler($property_key, $vcalendar_component);
}
$events[] = $parsed_component;
}
}
return $events;
}
/**
* Implementation of FeedsParser::getMappingSources().
* Parses text fields.
*
* @return string
*/
public function getMappingSources() {
// Quirky work around.
// Want to have the sources as a property of the class,
// but can't declare them with t().
$sources = $this::$sources;
foreach ($sources as &$source) {
foreach ($source as $key => &$value) {
if ($key == 'name' || $key == 'description') {
$value = t($value);
}
public function parseTextProperty($property_key, $vcalendar_component) {
$text = $vcalendar_component->getProperty($property_key);
if ($text === FALSE) {
if ($property_key == 'SUMMARY') {
$uid = $vcalendar_component->getProperty('UID');
throw new DateIcalParseException(t('The component with UID %uid is invalid because it has no SUMMARY (nodes require a title).', array('%uid' => $uid)));