You are here

function file_feeds_processor_targets in Feeds 7.2

Implements hook_feeds_processor_targets().

File

mappers/file.inc, line 32
On behalf implementation of Feeds mapping API for file.module and image.module.

Code

function file_feeds_processor_targets($entity_type, $bundle_name) {
  $targets = array();
  foreach (field_info_instances($entity_type, $bundle_name) as $name => $instance) {
    $info = field_info_field($name);
    if (in_array($info['type'], array(
      'file',
      'image',
    ))) {
      $targets[$name . ':uri'] = array(
        'name' => t('@label: URI', array(
          '@label' => $instance['label'],
        )),
        'callback' => 'file_feeds_set_target',
        'description' => t('The URI of the @label field.', array(
          '@label' => $instance['label'],
        )),
        'real_target' => $name,
        'summary_callbacks' => array(
          'file_feeds_summary_callback',
        ),
        'form_callbacks' => array(
          'file_feeds_form_callback',
        ),
      );

      // Keep the old target name for backwards compatibility, but hide it from
      // the UI.
      $targets[$name] = $targets[$name . ':uri'];
      $targets[$name]['deprecated'] = TRUE;
      if ($info['type'] == 'image') {
        $targets[$name . ':alt'] = array(
          'name' => t('@label: Alt', array(
            '@label' => $instance['label'],
          )),
          'callback' => 'file_feeds_set_target',
          'description' => t('The alt tag of the @label field.', array(
            '@label' => $instance['label'],
          )),
          'real_target' => $name,
        );
        $targets[$name . ':title'] = array(
          'name' => t('@label: Title', array(
            '@label' => $instance['label'],
          )),
          'callback' => 'file_feeds_set_target',
          'description' => t('The title of the @label field.', array(
            '@label' => $instance['label'],
          )),
          'real_target' => $name,
        );
      }
      elseif ($info['type'] === 'file') {
        $targets[$name . ':description'] = array(
          'name' => t('@label: Description', array(
            '@label' => $instance['label'],
          )),
          'callback' => 'file_feeds_set_target',
          'description' => t('The description of the @label field.', array(
            '@label' => $instance['label'],
          )),
          'real_target' => $name,
        );
      }
    }
  }
  return $targets;
}