Commit e7c93074 authored by cdmo's avatar cdmo Committed by Robert Rollins

Issue #2325649: Added hook for modules to create custom mapping sources.

This patch is courtesy of Drupal user cdmo.
parent fda25132
......@@ -221,3 +221,32 @@ function hook_date_ical_import_timezone_alter(&$tzid, $context) {
$tzid = 'America/New_York';
}
}
/**
* Add an additional custom source to be mapped by a feed.
*
* This is useful when you need to map fields from an iCal feed which
* the Date iCal module does not currently support.
*
* @param array $sources
* An associative array containing the source's properties, as follows:
* name: The name that will appear in the feed importer Mapping page.
* description: The description of this field shown in the Mapping page.
* date_ical_parse_handler: The function in the ParserVcalendar class
* which should be used to parse this iCal property into a Drupal field.
*/
function hook_date_ical_mapping_sources_alter(&$sources) {
// Example of what might be done with this alter hook:
// Add the "ATTENDEE" iCal property to the mapping sources.
$sources['ATTENDEE'] = array(
'name' => t('Attendee'),
'description' => t('The ATTENDEE property.'),
'date_ical_parse_handler' => 'parseTextProperty',
);
// Add "ATTENDEE:CN" parameter to the mapping sources.
$sources['ATTENDEE:CN'] = array(
'name' => t('Attendee: CN'),
'description' => t("The CN parameter of the ATTENDEE property: the attendee's Common Name."),
'date_ical_parse_handler' => 'parsePropertyParameter',
);
}
......@@ -196,6 +196,10 @@ class DateiCalFeedsParser extends FeedsParser {
'description' => t('The CATEGORIES property. Catagories that describe the event, which can be imported into taxonomy terms.'),
'date_ical_parse_handler' => 'parseMultivalueProperty',
);
// Allow other modules to add custom source fields.
drupal_alter('date_ical_mapping_sources', $sources);
return $sources;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment