You are here

public function FeedsSQLParser::configForm in Feeds SQL 7

Build configuration form.

File

plugins/FeedsSQLParser.inc, line 83

Class

FeedsSQLParser
Parses data from an SQL database.

Code

public function configForm(&$form_state) {
  global $databases;
  $form = array();
  $form['description'] = array(
    '#type' => 'markup',
    '#markup' => t('Use this area to pre-fetch your intended query. This will allow you to test the query itself and to populate the mapping array.'),
  );
  $form['query'] = array(
    '#type' => 'textarea',
    '#title' => t('SQL query'),
    '#description' => t('Enter the SQL query which will fetch the data to be imported.'),
    '#default_value' => isset($this->config['query']) ? $this->config['query'] : '',
  );
  if (module_exists('token')) {
    $form['token_help'] = array(
      '#title' => t('Replacement patterns'),
      '#type' => 'fieldset',
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
    );
    $form['token_help']['help'] = array(
      '#theme' => 'token_tree',
      '#token_types' => array(),
    );
  }
  $form['database'] = array(
    '#type' => 'select',
    '#title' => t('Database'),
    '#description' => t('Select the database from which to fetch the data.'),
    '#options' => array_combine(array_keys($databases), array_keys($databases)),
    '#default_value' => isset($this->config['database']) ? $this->config['database'] : 'default',
    '#required' => TRUE,
  );
  $form['mapping'] = array(
    '#type' => 'hidden',
    '#value' => $this->config['mapping'],
  );
  if (!empty($this->config['results'])) {
    $form['results'] = array(
      '#type' => 'markup',
      '#markup' => $this->config['results'],
    );
    unset($this->config['results']);
    $this
      ->save();
  }
  return $form;
}