You are here

public function FeedsFileFetcher::sourceFormValidate in Feeds 6

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

Override parent::sourceFormValidate().

Overrides FeedsPlugin::sourceFormValidate

File

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

Class

FeedsFileFetcher
Fetches data via HTTP.

Code

public function sourceFormValidate(&$values) {
  $feed_dir = file_directory_path() . '/feeds';
  file_check_directory($feed_dir, TRUE);
  $values['source'] = trim($values['source']);

  // If there is a file uploaded, save it, otherwise validate input on
  // file.
  if ($file = file_save_upload('feeds', array(), $feed_dir)) {
    file_set_status($file, FILE_STATUS_PERMANENT);
    $values['source'] = $file->filepath;
  }
  elseif (empty($values['source'])) {
    form_set_error('feeds][source', t('Upload a file first.'));
  }
  elseif (!file_check_location($values['source'], file_directory_path())) {
    form_set_error('feeds][source', t('File needs to point to a file in your Drupal file system path.'));
  }
}