Projet

Général

Profil

Révision 41cc1b08

Ajouté par Assos Assos il y a presque 9 ans

Update feeds 7.x-2.0-alpha9 -> 7.x-2.0-beta1

Install lib simplepie 1.3.1

Voir les différences:

drupal7/sites/all/modules/feeds/mappers/link.inc
6 6
 */
7 7

  
8 8
/**
9
 * Implements hook_feeds_processor_targets_alter().
10
 *
11
 * @see FeedsProcessor::getMappingTargets()
9
 * Implements hook_feeds_processor_targets().
12 10
 */
13
function link_feeds_processor_targets_alter(&$targets, $entity_type, $bundle_name) {
11
function link_feeds_processor_targets($entity_type, $bundle_name) {
12
  $targets = array();
13

  
14 14
  foreach (field_info_instances($entity_type, $bundle_name) as $name => $instance) {
15 15
    $info = field_info_field($name);
16 16
    if ($info['type'] == 'link_field') {
......
32 32
      }
33 33
    }
34 34
  }
35

  
36
  return $targets;
35 37
}
36 38

  
37 39
/**
38
 * Callback for mapping. Here is where the actual mapping happens.
39
 *
40
 * When the callback is invoked, $target contains the name of the field the
41
 * user has decided to map to and $value contains the value of the feed item
42
 * element the user has picked as a source.
40
 * Callback for mapping link fields.
43 41
 */
44
function link_feeds_set_target($source, $entity, $target, $value) {
45
  if (empty($value)) {
46
    return;
47
  }
48

  
49
  // Handle non-multiple value fields.
50
  if (!is_array($value)) {
51
    $value = array($value);
52
  }
53

  
54
  // Iterate over all values.
42
function link_feeds_set_target(FeedsSource $source, $entity, $target, array $values) {
55 43
  list($field_name, $column) = explode(':', $target);
56
  $info = field_info_field($field_name);
57 44

  
58
  $field = isset($entity->$field_name) ? $entity->$field_name : array();
45
  $field = isset($entity->$field_name) ? $entity->$field_name : array('und' => array());
59 46
  $delta = 0;
60 47

  
61
  foreach ($value as $v) {
62
    if ($info['cardinality'] == $delta) {
63
      break;
64
    }
65

  
66
    if (is_object($v) && ($v instanceof FeedsElement)) {
67
      $v = $v->getValue();
48
  foreach ($values as $value) {
49
    if (is_object($value) && ($value instanceof FeedsElement)) {
50
      $value = $value->getValue();
68 51
    }
69 52

  
70
    if (is_scalar($v)) {
71
      $field['und'][$delta][$column] = $v;
72
      $delta++;
53
    if (is_scalar($value)) {
54
      $field['und'][$delta][$column] = (string) $value;
73 55
    }
56
    $delta++;
74 57
  }
58

  
75 59
  $entity->$field_name = $field;
76 60
}

Formats disponibles : Unified diff