You are here

function date_feeds_node_processor_targets_alter in Feeds 7

Same name and namespace in other branches
  1. 6 mappers/date.inc \date_feeds_node_processor_targets_alter()

Implements hook_feeds_node_processor_targets_alter().

@todo Only provides "end date" target if field allows it.

See also

FeedsNodeProcessor::getMappingTargets().

File

mappers/date.inc, line 15
On behalf implementation of Feeds mapping API for date

Code

function date_feeds_node_processor_targets_alter(&$targets, $content_type) {
  $info = content_types($content_type);
  if (isset($info['fields']) && count($info['fields'])) {
    foreach ($info['fields'] as $field_name => $field) {
      if (in_array($field['type'], array(
        'date',
        'datestamp',
        'datetime',
      ))) {
        $name = isset($field['widget']['label']) ? $field['widget']['label'] : $field_name;
        $targets[$field_name . ':start'] = array(
          'name' => $name . ': Start',
          'callback' => 'date_feeds_set_target',
          'description' => t('The start date for the !name field. Also use if mapping both start and end.', array(
            '!name' => $name,
          )),
          'real_target' => $field_name,
        );
        $targets[$field_name . ':end'] = array(
          'name' => $name . ': End',
          'callback' => 'date_feeds_set_target',
          'description' => t('The end date for the @name field.', array(
            '@name' => $name,
          )),
          'real_target' => $field_name,
        );
      }
    }
  }
}