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/path.inc
6 6
 */
7 7

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

  
14 14
  switch ($entity_type) {
15 15
    case 'node':
16 16
    case 'taxonomy_term':
......
19 19
        'name' => t('Path alias'),
20 20
        'description' => t('URL path alias of the node.'),
21 21
        'callback' => 'path_feeds_set_target',
22
        'summary_callback' => 'path_feeds_summary_callback',
23
        'form_callback' => 'path_feeds_form_callback',
22
        'summary_callbacks' => array('path_feeds_summary_callback'),
23
        'form_callbacks' => array('path_feeds_form_callback'),
24 24
      );
25 25
      break;
26 26
  }
27

  
28
  return $targets;
27 29
}
28 30

  
29 31
/**
30
 * Callback for mapping. Here is where the actual mapping happens.
31
 *
32
 * When the callback is invoked, $target contains the name of the field the
33
 * user has decided to map to and $value contains the value of the feed item
34
 * element the user has picked as a source.
32
 * Callback for mapping path aliases.
35 33
 */
36
function path_feeds_set_target($source, $entity, $target, $value, $mapping) {
37
  if (empty($value)) {
38
    $value = '';
39
  }
40

  
41
  // Path alias cannot be multi-valued, so use the first value.
42
  if (is_array($value)) {
43
    $value = $value[0];
34
function path_feeds_set_target(FeedsSource $source, $entity, $target, array $values, array $mapping) {
35
  $alias = FALSE;
36
  // Path alias cannot be multi-valued, so use the first non-empty value.
37
  foreach ($values as $value) {
38
    $value = ltrim(trim($value), '/');
39
    if (strlen($value)) {
40
      $alias = $value;
41
      break;
42
    }
44 43
  }
45 44

  
46 45
  $entity->path = array();
......
58 57
    }
59 58
  }
60 59

  
61
  $entity->path['pathauto'] = FALSE;
62
  // Allow pathauto to set the path alias if the option is set, and this value
63
  // is empty.
64
  if (!empty($mapping['pathauto_override']) && !$value) {
65
    $entity->path['pathauto'] = TRUE;
66
  }
67
  else {
68
    $entity->path['alias'] = ltrim($value, '/');
69
  }
60
  // Allow pathauto to set the path alias if the option is set, and the value is
61
  // empty.
62
  $entity->path['pathauto'] = !empty($mapping['pathauto_override']) && $alias === FALSE;
63

  
64
  $entity->path['alias'] = (string) $alias;
70 65
}
71 66

  
72 67
/**
73 68
 * Mapping configuration summary for path.module.
74
 *
75
 * @param $mapping
76
 *   Associative array of the mapping settings.
77
 * @param $target
78
 *   Array of target settings, as defined by the processor or
79
 *   hook_feeds_processor_targets_alter().
80
 * @param $form
81
 *   The whole mapping form.
82
 * @param $form_state
83
 *   The form state of the mapping form.
84
 *
85
 * @return
86
 *   Returns, as a string that may contain HTML, the summary to display while
87
 *   the full form isn't visible.
88
 *   If the return value is empty, no summary and no option to view the form
89
 *   will be displayed.
90 69
 */
91
function path_feeds_summary_callback($mapping, $target, $form, $form_state) {
70
function path_feeds_summary_callback(array $mapping, $target, array $form, array $form_state) {
92 71
  if (!module_exists('pathauto')) {
93 72
    return;
94 73
  }
......
104 83

  
105 84
/**
106 85
 * Settings form callback.
107
 *
108
 * @return
109
 *   The per mapping configuration form. Once the form is saved, $mapping will
110
 *   be populated with the form values.
111 86
 */
112
function path_feeds_form_callback($mapping, $target, $form, $form_state) {
87
function path_feeds_form_callback(array $mapping, $target, array $form, array $form_state) {
113 88
  return array(
114 89
    'pathauto_override' => array(
115 90
      '#type' => 'checkbox',

Formats disponibles : Unified diff