When groking the source to do a quick hack for #2203085: Add GEO import support i saw that we might make the parser more extensible:

In \ParserVcalendar::parse() we might add an alter hook after

$sources = DateiCalFeedsParser::getiCalMappingSources();

so other modules can hook in. (of course for the said issue it will be best to just include the feature in this module but there surely will be other cases where someone has special needs...)

For this to make sense we have to drop the assumption that the handler is a method of ParserVcalendar.
Also it might make sense to add a "additional_argument" value to $sources items to have the callback parametrized.

So we can do something like

function mymodule_date_ical_mapping_sources_alter(&$sources) {
    $sources['GEO-LON'] = array(
      'name' => t('GEO Longitude'),
      'description' => t('Geolocation Longitude.'),
      'date_ical_parse_callback' => 'mymodule_parse_delimited',
      'date_ical_parse_additional_argument' => array('delimiter' => ';', 'index' => 0),
    );
    $sources['GEO-LAT'] = array(
      'name' => t('GEO Latitude'),
      'description' => t('Geolocation Latitude.'),
      'date_ical_parse_callback' => 'mymodule_parse_delimited',
      'date_ical_parse_additional_argument' => array('delimiter' => ';', 'index' => 1),
    );
}

Do you think this is a direction to go?

Comments

coredumperror’s picture

This is a pretty good idea, though for some reason a memory is tickling the back of my mind about how this is probably already doable without making a hook. Like, I think Feeds already offers a way to hook into the sources array, perhaps? I like this idea, though, so once I get some time to dedicate to Date iCal again, I'll look into this.

Why split the GEO field into two different inputs, though? From what I can tell of the spec, it's just one field, GEO, containing two semicolon-separated floats. A parse function would easily handle both at the same time.

coredumperror’s picture

Status: Active » Fixed

I implemented this as part of the patch that implemented GEO Import support, from this issue: #2203085: Add GEO import support

Basically, Feeds already offers a way for other modules to hook into the list of sources, so I changed Date iCal to make it pay attention to that. Date iCal will warn users about trying to use sources that we don't recognize, since we can't parse them.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.