You are here

function feeds_ui_mapping_settings_form in Feeds 7.2

Same name and namespace in other branches
  1. 8.2 feeds_ui/feeds_ui.admin.inc \feeds_ui_mapping_settings_form()

Per mapper configuration form that is a part of feeds_ui_mapping_form().

1 call to feeds_ui_mapping_settings_form()
feeds_ui_mapping_form in feeds_ui/feeds_ui.admin.inc
Edit mapping.

File

feeds_ui/feeds_ui.admin.inc, line 632
Contains all page callbacks, forms and theming functions for Feeds administrative pages.

Code

function feeds_ui_mapping_settings_form($form, $form_state, $i, $mapping, $target) {
  $form_state += array(
    'mapping_settings_edit' => NULL,
    'mapping_settings' => array(),
  );
  $base_button = array(
    '#submit' => array(
      'feeds_ui_mapping_form_multistep_submit',
    ),
    '#ajax' => array(
      'callback' => 'feeds_ui_mapping_settings_form_callback',
      'wrapper' => 'feeds-ui-mapping-form-wrapper',
      'effect' => 'fade',
      'progress' => 'none',
    ),
    '#i' => $i,
  );
  if (isset($form_state['mapping_settings'][$i])) {
    $mapping = $form_state['mapping_settings'][$i] + $mapping;
  }
  if ($form_state['mapping_settings_edit'] === $i) {
    $settings_form = array();
    foreach ($target['form_callbacks'] as $callback) {
      $settings_form += call_user_func($callback, $mapping, $target, $form, $form_state);
    }

    // Merge in the optional unique form.
    $settings_form += feeds_ui_mapping_settings_optional_unique_form($mapping, $target, $form, $form_state);
    return array(
      '#type' => 'container',
      '#attributes' => array(
        'class' => array(
          'feeds-target-config',
        ),
      ),
      'settings' => $settings_form,
      'save_settings' => $base_button + array(
        '#type' => 'submit',
        '#name' => 'mapping_settings_update_' . $i,
        '#value' => t('Update'),
        '#op' => 'update',
      ),
      'cancel_settings' => $base_button + array(
        '#type' => 'submit',
        '#name' => 'mapping_settings_cancel_' . $i,
        '#value' => t('Cancel'),
        '#op' => 'cancel',
      ),
    );
  }
  else {

    // Build the summary.
    $summary = array();
    foreach ($target['summary_callbacks'] as $callback) {
      $summary[] = call_user_func($callback, $mapping, $target, $form, $form_state);
    }

    // Filter out empty summary values.
    $summary = implode('<br />', array_filter($summary));

    // Append the optional unique summary.
    if ($optional_unique_summary = feeds_ui_mapping_settings_optional_unique_summary($mapping, $target, $form, $form_state)) {
      $summary .= ' ' . $optional_unique_summary;
    }
    if ($summary) {
      return array(
        'summary' => array(
          '#prefix' => '<div>',
          '#markup' => $summary,
          '#suffix' => '</div>',
        ),
        'edit_settings' => $base_button + array(
          '#type' => 'image_button',
          '#name' => 'mapping_settings_edit_' . $i,
          '#src' => 'misc/configure.png',
          '#attributes' => array(
            'alt' => t('Edit'),
          ),
          '#op' => 'edit',
        ),
      );
    }
  }
  return array();
}