Projet

Général

Profil

Révision d808fa20

Ajouté par Assos Assos il y a plus de 6 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/feeds_tamper/feeds_tamper.inc
166 166
    }
167 167
    // Filter disabled and only pull plugins that actually have a corresponding
168 168
    // source since we don't delete them with a mapping.
169
    if (($disabled || empty($i->disabled)) && in_array($i->source, $sources) && function_exists($plugins[$i->plugin_id]['callback'])) {
169
    if (($disabled || empty($i->disabled)) && in_array($i->source, $sources) && isset($plugins[$i->plugin_id]) && function_exists($plugins[$i->plugin_id]['callback'])) {
170 170
      $instances[$i->source][] = $i;
171 171
    }
172 172
  }
......
318 318
function feeds_tamper_form_feeds_ui_mapping_form_alter(array &$form, array &$form_state) {
319 319
  $form['#submit'][] = 'feeds_tamper_form_feeds_ui_mapping_form_submit';
320 320

  
321
  // Don't alter the form for parsers that use manual input.
322
  if ($form['source']['#type'] == 'textfield') {
323
    return;
324
  }
321
  // Don't alter the sources on the form for parsers that use manual input.
322
  $manual_source_input = ($form['source']['#type'] == 'textfield');
323

  
325 324
  $max_source = 0;
326 325
  $max_target = 0;
327 326
  foreach ($form['#mappings'] as $mapping) {
328
    if (strpos($mapping['source'], 'Blank source ') === 0) {
327
    if (!$manual_source_input && strpos($mapping['source'], 'Blank source ') === 0) {
329 328
      list(, , $source_value) = explode(' ', $mapping['source']);
330 329
      if ($source_value > $max_source) {
331 330
        $max_source = $source_value;
......
338 337
      }
339 338
    }
340 339
  }
341
  if ($max_source) {
342
    unset($form['source']['#options']['Blank source 1']);
343
    $form['source']['#options']['Blank source ' . ++$max_source] = 'Blank source';
344
  }
345
  else {
346
    $form['source']['#options']['Blank source 1'] = 'Blank source';
340

  
341
  if (!$manual_source_input) {
342
    if ($max_source) {
343
      unset($form['source']['#options']['Blank source 1']);
344
      $form['source']['#options']['Blank source ' . ++$max_source] = 'Blank source';
345

  
346
      // Declare extra mapping sources.
347
      for ($i = 2; $i <= $max_source; $i++) {
348
        $form['#feeds_sources']['Blank source ' . $i] = $form['#feeds_sources']['Blank source 1'];
349
      }
350
    }
351
    else {
352
      $form['source']['#options']['Blank source 1'] = 'Blank source';
353
    }
347 354
  }
355

  
348 356
  if ($max_target) {
349 357
    unset($form['target']['#options']['Temporary target 1']);
350 358
    $form['target']['#options']['Temporary target ' . ++$max_target] = 'Temporary target';
359

  
360
    // Declare extra mapping targets.
361
    for ($i = 2; $i <= $max_target; $i++) {
362
      $form['#feeds_targets']['Temporary target ' . $i] = $form['#feeds_targets']['Temporary target 1'];
363
    }
351 364
  }
352 365
  else {
353 366
    $form['target']['#options']['Temporary target 1'] = 'Temporary target';

Formats disponibles : Unified diff