You are here

public function FeedsFileFetcher::sourceForm in Feeds 8.2

Source form.

Overrides FeedsPlugin::sourceForm

File

lib/Drupal/feeds/Plugin/feeds/fetcher/FeedsFileFetcher.php, line 84
Home of the FeedsFileFetcher and related classes.

Class

FeedsFileFetcher
Defines a file fetcher.

Namespace

Drupal\feeds\Plugin\feeds\fetcher

Code

public function sourceForm($source_config) {
  $form = array();
  $form['fid'] = array(
    '#type' => 'value',
    '#value' => empty($source_config['fid']) ? 0 : $source_config['fid'],
  );
  if (empty($this->config['direct'])) {
    $form['source'] = array(
      '#type' => 'value',
      '#value' => empty($source_config['source']) ? '' : $source_config['source'],
    );
    $form['upload'] = array(
      '#type' => 'file',
      '#title' => empty($this->config['direct']) ? t('File') : NULL,
      '#description' => empty($source_config['source']) ? t('Select a file from your local system.') : t('Select a different file from your local system.'),
      '#theme' => 'feeds_upload',
      '#file_info' => empty($source_config['fid']) ? NULL : file_load($source_config['fid']),
      '#size' => 10,
    );
  }
  else {
    $form['source'] = array(
      '#type' => 'textfield',
      '#title' => t('File'),
      '#description' => t('Specify a path to a file or a directory. Prefix the path with a scheme. Available schemes: @schemes.', array(
        '@schemes' => implode(', ', $this->config['allowed_schemes']),
      )),
      '#default_value' => empty($source_config['source']) ? '' : $source_config['source'],
    );
  }
  return $form;
}