You are here

public function FeedsFileFetcher::sourceForm in Feeds 6

Same name and namespace in other branches
  1. 7.2 plugins/FeedsFileFetcher.inc \FeedsFileFetcher::sourceForm()
  2. 7 plugins/FeedsFileFetcher.inc \FeedsFileFetcher::sourceForm()

Source form.

Overrides FeedsPlugin::sourceForm

File

plugins/FeedsFileFetcher.inc, line 57
Home of the FeedsFileFetcher and related classes.

Class

FeedsFileFetcher
Fetches data via HTTP.

Code

public function sourceForm($source_config) {
  $form = $info = array();
  if (!empty($source_config['source']) && file_exists($source_config['source'])) {
    $info = array(
      'path' => $source_config['source'],
      'size' => filesize(realpath($source_config['source'])),
    );
    if (module_exists('mimedetect')) {
      $file = new stdClass();
      $file->filepath = realpath($source_config['source']);
      $info['mime'] = mimedetect_mime($file);
    }
  }
  $form['source'] = array(
    '#type' => empty($this->config['direct']) ? 'value' : 'textfield',
    '#title' => t('File'),
    '#description' => t('Specify a file in the site\'s file system path or upload a file below.'),
    '#default_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 the file to be imported from your local system.') : t('Select a different file to be imported from your local system.'),
    '#theme' => 'feeds_upload',
    '#file_info' => $info,
    '#size' => 10,
  );
  return $form;
}