You are here

function nodereference_feeds_node_processor_targets_alter in Feeds 6

Implementation of hook_feeds_node_processor_targets_alter().

See also

FeedsNodeProcessor::getMappingTargets()

File

mappers/nodereference.inc, line 13
Implementation of Feeds API for mapping nodereference.module fields (CCK).

Code

function nodereference_feeds_node_processor_targets_alter(&$targets, $content_type) {
  $info = content_types($content_type);
  if (isset($info['fields']) && is_array($info['fields'])) {
    foreach ($info['fields'] as $field_name => $field) {
      if ($field['type'] == 'nodereference') {
        $field_label = !empty($field['widget']['label']) ? $field['widget']['label'] : $field_name;
        $targets[$field_name . ':title'] = array(
          'name' => t('@field_label (by title)', array(
            '@field_label' => $field_label,
          )),
          'callback' => 'nodereference_feeds_set_target',
          'description' => t('The CCK node reference @field_label of the node, matched by node title.', array(
            '@field_label' => $field_label,
          )),
          'real_target' => $field_name,
        );
        $targets[$field_name . ':nid'] = array(
          'name' => t('@field_label (by nid)', array(
            '@field_label' => $field_label,
          )),
          'callback' => 'nodereference_feeds_set_target',
          'description' => t('The CCK node reference @field_label of the node, matched by node ID.', array(
            '@field_label' => $field_label,
          )),
          'real_target' => $field_name,
        );
        $targets[$field_name . ':url'] = array(
          'name' => t('@field_label (by Feeds URL)', array(
            '@field_label' => $field_label,
          )),
          'callback' => 'nodereference_feeds_set_target',
          'description' => t('The CCK node reference @field_label of the node, matched by Feeds URL.', array(
            '@field_label' => $field_label,
          )),
          'real_target' => $field_name,
        );
        $targets[$field_name . ':guid'] = array(
          'name' => t('@field_label (by Feeds GUID)', array(
            '@field_label' => $field_label,
          )),
          'callback' => 'nodereference_feeds_set_target',
          'description' => t('The CCK node reference @field_label of the node, matched by Feeds GUID.', array(
            '@field_label' => $field_label,
          )),
          'real_target' => $field_name,
        );
      }
    }
  }
}