Projet

Général

Profil

Révision a192dc0b

Ajouté par Assos Assos il y a environ 8 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/feeds/mappers/file.inc
23 23
        'real_target' => $name,
24 24
      );
25 25

  
26
      // Keep the old target name for backwards compatibility, but hide it from
27
      // the UI.
28
      $targets[$name] = $targets[$name . ':uri'];
29
      $targets[$name]['deprecated'] = TRUE;
30

  
26 31
      if ($info['type'] == 'image') {
27 32
        $targets[$name . ':alt'] = array(
28 33
          'name' => t('@label: Alt', array('@label' => $instance['label'])),
......
54 59
/**
55 60
 * Callback for mapping file fields.
56 61
 */
57
function file_feeds_set_target(FeedsSource $source, $entity, $target, array $values) {
62
function file_feeds_set_target(FeedsSource $source, $entity, $target, array $values, array $mapping) {
63
  $language = $mapping['language'];
64

  
58 65
  // Add default of uri for backwards compatibility.
59 66
  list($field_name, $sub_field) = explode(':', $target . ':uri');
60 67
  $info = field_info_field($field_name);
......
74 81
      }
75 82
    }
76 83

  
77
    $entity_type = $source->importer->processor->entityType();
78
    $bundle = $source->importer->processor->bundle();
79

  
84
    if ($entity instanceof Entity) {
85
      $entity_type = $entity->entityType();
86
      $bundle = $entity->bundle();
87
    }
88
    else {
89
      $entity_type = $source->importer->processor->entityType();
90
      $bundle = $source->importer->processor->bundle();
91
    }
80 92
    $instance_info = field_info_instance($entity_type, $field_name, $bundle);
81 93

  
82 94
    // Determine file destination.
......
90 102
  }
91 103

  
92 104
  // Populate entity.
93
  $field = isset($entity->$field_name) ? $entity->$field_name : array(LANGUAGE_NONE => array());
105
  $field = isset($entity->$field_name) ? $entity->$field_name : array($language => array());
94 106
  $delta = 0;
95 107
  foreach ($values as $v) {
96 108
    if ($info['cardinality'] == $delta) {
97 109
      break;
98 110
    }
99 111

  
100
    if (!isset($field[LANGUAGE_NONE][$delta])) {
101
      $field[LANGUAGE_NONE][$delta] = array();
112
    if (!isset($field[$language][$delta])) {
113
      $field[$language][$delta] = array();
102 114
    }
103 115

  
104 116
    switch ($sub_field) {
105 117
      case 'alt':
106 118
      case 'title':
107 119
      case 'description':
108
        $field[LANGUAGE_NONE][$delta][$sub_field] = $v;
120
        $field[$language][$delta][$sub_field] = $v;
109 121
        break;
110 122

  
111 123
      case 'uri':
112 124
        if ($v) {
113 125
          try {
114 126
            $v->setAllowedExtensions($instance_info['settings']['file_extensions']);
115
            $field[LANGUAGE_NONE][$delta] += (array) $v->getFile($destination);
127
            $field[$language][$delta] += (array) $v->getFile($destination);
116 128
            // @todo: Figure out how to properly populate this field.
117
            $field[LANGUAGE_NONE][$delta]['display'] = 1;
129
            $field[$language][$delta]['display'] = 1;
118 130
          }
119 131
          catch (Exception $e) {
120 132
            watchdog('feeds', check_plain($e->getMessage()));

Formats disponibles : Unified diff