You are here

public function FeedsHTTPFetcher::sourceFormValidate in Feeds 7.2

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

Override parent::sourceFormValidate().

Overrides FeedsPlugin::sourceFormValidate

File

plugins/FeedsHTTPFetcher.inc, line 279

Class

FeedsHTTPFetcher
Fetches data via HTTP.

Code

public function sourceFormValidate(&$values) {
  $values['source'] = trim($values['source']);

  // Keep a copy for error messages.
  $original_url = $values['source'];
  $parts = parse_url($values['source']);
  if (empty($parts['scheme']) && $this->config['auto_scheme']) {
    $values['source'] = $this->config['auto_scheme'] . '://' . $values['source'];
  }
  if (!feeds_valid_url($values['source'], TRUE)) {
    $form_key = 'feeds][' . get_class($this) . '][source';
    form_set_error($form_key, t('The URL %source is invalid.', array(
      '%source' => $original_url,
    )));
  }
  elseif ($this->config['auto_detect_feeds']) {
    feeds_include_library('http_request.inc', 'http_request');
    $url = http_request_get_common_syndication($values['source'], array(
      'accept_invalid_cert' => $this->config['accept_invalid_cert'],
    ));
    if ($url) {
      $values['source'] = $url;
    }
  }
}