function date_ical_feeds_set_rrule in Date iCal 7.3
Same name and namespace in other branches
- 7.2 date_ical.module \date_ical_feeds_set_rrule()
Callback specified in date_ical_feeds_processor_targets_alter() for RRULEs.
Parameters
object $source: The FeedsSource object.
object $entity: The node that's being built from the iCal element that's being parsed.
string $target: The machine name of the field into which this RRULE shall be parsed, with ":rrule" appended to the end.
string|array $repeat_rule: The repeat rule string, formatted like "$rrule|$rdate|$exrule|$exdate". Newer versions of Feeds send this value as an array containing the string.
1 string reference to 'date_ical_feeds_set_rrule'
File
- ./
date_ical.module, line 256 - Adds ical functionality to Views, and an iCal parser to Feeds.
Code
function date_ical_feeds_set_rrule($source, $entity, $target, $repeat_rule) {
if (is_array($repeat_rule)) {
// Newer versions of Feeds return $repeat_rule as an array containing the
// string we returned from ParseVcalendar::parseRepeatProperty().
$repeat_rule = reset($repeat_rule);
}
if (empty($repeat_rule)) {
// Don't alter the entity if there's no repeat rule.
return;
}
// $target looks like <field_name>:rrule, but we only need <field_name>.
$field_name = current(explode(':', $target, 2));
// Parse the repeat rule into RRULE, RDATE, EXRULE, and EXDATE strings.
$repeat_data = array_combine(array(
'RRULE',
'RDATE',
'EXRULE',
'EXDATE',
), explode('|', $repeat_rule));
module_load_include('inc', 'date_ical', 'date_ical.utils');
// This "loop" is really just to make sure we get the right array keys. It
// shouldn't ever execute more than once.
foreach ($entity->{$field_name} as $lang => $date_values) {
$values = _date_ical_get_repeat_dates($field_name, $repeat_data, $date_values[0], $source);
foreach ($values as $key => $value) {
$entity->{$field_name}[$lang][$key] = $value;
}
}
}