You are here

public function FeedsSQLFetcher::sourceForm in Feeds SQL 7

Override parent::sourceForm().

File

plugins/FeedsSQLFetcher.inc, line 82
Fetches data from an SQL database.

Class

FeedsSQLFetcher
Fetches data via pdo connection.

Code

public function sourceForm($source_config) {
  $config = $this
    ->getConfig();
  $databases = array();
  foreach ($config['databases'] as $database) {
    if ($database) {
      $databases[$database] = $database;
    }
  }
  $form = 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($source_config['query']) ? $source_config['query'] : '',
    '#required' => TRUE,
  );
  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' => $databases,
    '#default_value' => isset($source_config['database']) ? $source_config['database'] : 'default',
    '#required' => TRUE,
  );
  return $form;
}