You are here

public function FeedsImporter::configForm in Feeds 7.2

Same name and namespace in other branches
  1. 6 includes/FeedsImporter.inc \FeedsImporter::configForm()
  2. 7 includes/FeedsImporter.inc \FeedsImporter::configForm()

Overrides parent::configForm().

Parameters

array $form_state: The current state of the form.

Return value

array The form definition.

Overrides FeedsConfigurable::configForm

File

includes/FeedsImporter.inc, line 317
FeedsImporter class and related.

Class

FeedsImporter
Class for a Feeds importer.

Code

public function configForm(&$form_state) {
  $config = $this
    ->getConfig();
  $form = array();
  $form['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Name'),
    '#description' => t('A human readable name of this importer.'),
    '#default_value' => $config['name'],
    '#required' => TRUE,
  );
  $form['description'] = array(
    '#type' => 'textfield',
    '#title' => t('Description'),
    '#description' => t('A description of this importer.'),
    '#default_value' => $config['description'],
  );
  $node_types = node_type_get_names();
  array_walk($node_types, 'check_plain');
  $form['content_type'] = array(
    '#type' => 'select',
    '#title' => t('Attach to content type'),
    '#description' => '<p>' . t('If "Use standalone form" is selected, a source is imported by using a form under !import_form. If a content type is selected, a source is imported by creating a node of that content type.', array(
      '!import_form' => l(url('import', array(
        'absolute' => TRUE,
      )), 'import', array(
        'attributes' => array(
          'target' => '_new',
        ),
      )),
    )) . '</p>',
    '#options' => array(
      '' => t('Use standalone form'),
    ) + $node_types,
    '#default_value' => $config['content_type'],
  );
  $cron_required = ' ' . l(t('Requires cron to be configured.'), 'http://drupal.org/cron', array(
    'attributes' => array(
      'target' => '_new',
    ),
  ));
  $period = drupal_map_assoc(array(
    900,
    1800,
    3600,
    10800,
    21600,
    43200,
    86400,
    259200,
    604800,
    2419200,
  ), 'format_interval');
  foreach ($period as &$p) {
    $p = t('Every !p', array(
      '!p' => $p,
    ));
  }
  $period = array(
    FEEDS_SCHEDULE_NEVER => t('Off'),
    0 => t('As often as possible'),
  ) + $period;
  $form['import_period'] = array(
    '#type' => 'select',
    '#title' => t('Periodic import'),
    '#options' => $period,
    '#description' => t('Choose how often a source should be imported periodically.') . $cron_required,
    '#default_value' => $config['import_period'],
  );
  $form['import_on_create'] = array(
    '#type' => 'checkbox',
    '#title' => t('Import on submission'),
    '#description' => t('Check if import should be started at the moment a standalone form or node form is submitted. If not checked and when using the standalone form, be sure to configure periodic import.'),
    '#default_value' => $config['import_on_create'],
  );
  $form['process_in_background'] = array(
    '#type' => 'checkbox',
    '#title' => t('Process in background'),
    '#description' => t('For very large imports. If checked, import and delete tasks started from the web UI will be handled by a cron task in the background rather than by the browser. This does not affect periodic imports, they are handled by a cron task in any case.') . $cron_required,
    '#default_value' => $config['process_in_background'],
  );
  return $form;
}