You are here

public function FeedsProcessor::configForm in Feeds 7.2

Returns configuration form for this object.

The keys of the configuration form must match the keys of the array returned by configDefaults().

Parameters

array $form_state: The current state of the form.

Return value

array FormAPI style form definition.

Overrides FeedsConfigurable::configForm

2 calls to FeedsProcessor::configForm()
FeedsNodeProcessor::configForm in plugins/FeedsNodeProcessor.inc
Override parent::configForm().
FeedsUserProcessor::configForm in plugins/FeedsUserProcessor.inc
Override parent::configForm().
2 methods override FeedsProcessor::configForm()
FeedsNodeProcessor::configForm in plugins/FeedsNodeProcessor.inc
Override parent::configForm().
FeedsUserProcessor::configForm in plugins/FeedsUserProcessor.inc
Override parent::configForm().

File

plugins/FeedsProcessor.inc, line 1038
Contains FeedsProcessor and related classes.

Class

FeedsProcessor
Abstract class, defines interface for processors.

Code

public function configForm(&$form_state) {
  $info = $this
    ->entityInfo();
  $form = array();
  if (!empty($info['entity keys']['bundle'])) {
    $bundle = $this
      ->bundle();
    $form['bundle'] = array(
      '#type' => 'select',
      '#options' => $this
        ->bundleOptions(),
      '#title' => !empty($info['bundle name']) ? $info['bundle name'] : t('Bundle'),
      '#required' => TRUE,
      '#default_value' => $bundle,
    );

    // Add default value as one of the options if not yet available.
    if (!isset($form['bundle']['#options'][$bundle])) {
      $form['bundle']['#options'][$bundle] = t('Unknown bundle: @bundle', array(
        '@bundle' => $bundle,
      ));
    }
  }
  else {
    $form['bundle'] = array(
      '#type' => 'value',
      '#value' => $this
        ->entityType(),
    );
  }
  if (module_exists('locale') && !empty($info['entity keys']['language'])) {
    $form['language'] = array(
      '#type' => 'select',
      '#options' => $this
        ->languageOptions(),
      '#title' => t('Language'),
      '#required' => TRUE,
      '#default_value' => $this->config['language'],
    );

    // Add default value as one of the options if not yet available.
    if (!isset($form['language']['#options'][$this->config['language']])) {
      $form['language']['#options'][$this->config['language']] = t('Unknown language: @language', array(
        '@language' => $this->config['language'],
      ));
    }
  }
  $tokens = array(
    '@entities' => strtolower($info['label plural']),
  );
  $form['insert_new'] = array(
    '#type' => 'radios',
    '#title' => t('Insert new @entities', $tokens),
    '#description' => t('New @entities will be determined using mappings that are a "unique target".', $tokens),
    '#options' => array(
      FEEDS_INSERT_NEW => t('Insert new @entities', $tokens),
      FEEDS_SKIP_NEW => t('Do not insert new @entities', $tokens),
    ),
    '#default_value' => $this->config['insert_new'],
  );
  $form['update_existing'] = array(
    '#type' => 'radios',
    '#title' => t('Update existing @entities', $tokens),
    '#description' => t('Existing @entities will be determined using mappings that are a "unique target".', $tokens),
    '#options' => array(
      FEEDS_SKIP_EXISTING => t('Do not update existing @entities', $tokens),
      FEEDS_REPLACE_EXISTING => t('Replace existing @entities', $tokens),
      FEEDS_UPDATE_EXISTING => t('Update existing @entities', $tokens),
    ),
    '#default_value' => $this->config['update_existing'],
    '#after_build' => array(
      'feeds_processor_config_form_update_existing_after_build',
    ),
    '#tokens' => $tokens,
  );
  global $user;
  $formats = filter_formats($user);
  foreach ($formats as $format) {
    $format_options[$format->format] = $format->name;
  }
  $form['skip_hash_check'] = array(
    '#type' => 'checkbox',
    '#title' => t('Skip hash check'),
    '#description' => t('Force update of items even if item source data did not change.'),
    '#default_value' => $this->config['skip_hash_check'],
  );
  $form['input_format'] = array(
    '#type' => 'select',
    '#title' => t('Text format'),
    '#description' => t('Select the default input format for the text fields of the nodes to be created.'),
    '#options' => $format_options,
    '#default_value' => isset($this->config['input_format']) ? $this->config['input_format'] : 'plain_text',
    '#required' => TRUE,
  );
  $form['update_non_existent'] = array(
    '#type' => 'radios',
    '#title' => t('Action to take when previously imported @entities are missing in the feed', $tokens),
    '#description' => t('Select how @entities previously imported and now missing in the feed should be updated.', $tokens),
    '#options' => array(
      FEEDS_SKIP_NON_EXISTENT => t('Skip non-existent @entities', $tokens),
      FEEDS_DELETE_NON_EXISTENT => t('Delete non-existent @entities', $tokens),
    ),
    '#default_value' => $this->config['update_non_existent'],
  );
  return $form;
}