You are here

public function ParserIcalDateTimeElement::buildDateField in iCal feed parser 7

Same name and namespace in other branches
  1. 6.2 includes/ParserIcalFeedsParser.inc \ParserIcalDateTimeElement::buildDateField()

Build a node's date CCK field from our object.

File

includes/ParserIcalFeedsParser.inc, line 86

Class

ParserIcalDateTimeElement
Overridden version of FeedsDateTimeElement that supports iCal specific parsing and repetition.

Code

public function buildDateField($node, $field_name) {
  parent::buildDateField($node, $field_name);
  if (empty($this->repeat_vals)) {
    return;
  }
  if (module_exists('date') && module_exists('date_repeat')) {
    require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'date_repeat') . '/date_repeat_calc.inc';
    require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'date') . '/date_repeat.inc';

    // @TODO this really really needs review!
    // NB there is no date repeating UI at the moment.
    // merge!?
    $field = field_info_field($field_name);

    // is it always 'und' why is it 'und'?
    $node_field = $node->{$field_name}['und'][0];
    $values = date_repeat_build_dates(NULL, $this->repeat_vals, $field, $node_field);
    foreach ($values as $value) {
      $node->{$field_name}['und'][] = $value;
    }
  }
}