You are here

public function FeedsOAIHTTPFetcher::fetch in Feeds OAI-PMH Fetcher and Parser 7

Same name and namespace in other branches
  1. 6 FeedsOAIHTTPFetcher.inc \FeedsOAIHTTPFetcher::fetch()

Fetch content from feed.

File

./FeedsOAIHTTPFetcher.inc, line 129

Class

FeedsOAIHTTPFetcher
Fetcher class for OAI-PMH repository webservices.

Code

public function fetch(FeedsSource $source) {
  $source_config = $source
    ->getConfigFor($this);
  $from_timestamp = FALSE;
  $until_timestamp = FALSE;

  // Fetching rules:
  // Whenever there is a resumption token, use that.
  // Else
  //   if limit by date == yes
  //     issue those
  //   else
  //     start from last known record creation date (from variable)
  $resumption_token = variable_get('feeds_oai:resumptionToken:' . $source_config['set'] . ':' . $source_config['source'], '');
  if (!$resumption_token) {
    if ($source_config['use_dates']) {
      $from_timestamp = $this
        ->dateFieldToTimestamp($source_config['dates']['from']);
      $until_timestamp = $this
        ->dateFieldToTimestamp($source_config['dates']['to']);
    }
    else {
      $from_timestamp = (int) variable_get('feeds_oai:from:' . $source_config['set'] . ':' . $source_config['source'], FALSE);
      if ($from_timestamp > 0) {
        $from_timestamp = $from_timestamp + 1;
      }
    }
  }

  // The setSpec to harvest from.
  $set = $source_config['set'];
  return new FeedsOAIHTTPFetcherResult($source_config['source'], $from_timestamp, $until_timestamp, $resumption_token, $set);
}