getRaw()); if ($feed['cursor'] > 0) { $progress = round($feed['cursor'] / $feed['completeListSize'], 2); } else { $progress = 0.00; } $source->state(FEEDS_PARSE)->progress = $progress; if (!$feed) { // No items, return return $result; } // Check for items. if (is_array($feed['items'])) { // Add set name element to each of the items. $oai_endpoint_url = $source->config['FeedsOAIHTTPFetcher']['source']; $identify_response = feeds_oai_pmh_identify($oai_endpoint_url); if ($identify_response['repository']['sets']) { foreach ($feed['items'] as $index => $item) { foreach ($item['setspec_raw'] as $setspec) { $set_name = $identify_response['repository']['sets'][$setspec]['name']; $feed['items'][$index]['setspec_name'][] = $set_name; } // Return the items found in feed. $result->items[] = $item; } } } if (empty($feed['resumptionToken']) || $feed['resumptionToken'] == null) { $source->state(FEEDS_PARSE)->progress = 1; } return $result; } /** * Implementation of FeedsParser::clear(). * * Delete variables containing resumptionToken and from used in last fetch. */ public function clear(FeedsSource $source) { // Only if FeedsOAIHTTPFetcher was used as the fetcher. if ($source->config['FeedsOAIHTTPFetcher']) { $oai_endpoint_url = $source->config['FeedsOAIHTTPFetcher']['source']; $set = $source->config['FeedsOAIHTTPFetcher']['set']; variable_del('feeds_oai:resumptionToken:' . $set . ':' . $oai_endpoint_url); variable_del('feeds_oai:from:' . $set . ':' . $oai_endpoint_url); } parent::clear($source); } /** * Return mapping sources. */ public function getMappingSources() { self::loadMappers(); $sources = array(); drupal_alter('feeds_parser_sources', $sources, feeds_importer($this->id)->config['content_type']); $sources += array( 'guid' => array( 'name' => t('Repository Record identifier'), 'description' => t('A unique string per each metadata record, defined by the repository.'), ), 'timestamp' => array( 'name' => t('Record publication date'), 'description' => t("Date this metadata record was published on the repository. Different from the described item's publication date."), ), 'metadata_record_url' => array( 'name' => t('Raw metadata record URL'), 'description' => t("The URL to a GetRecord OAI request for the source metadata record. Note: This URL will return raw XML data."), ), 'url' => array( 'name' => t('URL to resource'), 'description' => t('All valid URLs detected in dc:identifier elements.'), ), 'none_url_identifier' => array( 'name' => t('None ID to resource'), 'description' => t('All others ID detected in dc:identifier elements (none url one).'), ), 'setspec_raw' => array( 'name' => t('Set: setSpec (raw value)'), 'description' => t("The set/setSpec from the record's header."), ), 'setspec_name' => array( 'name' => t('Set: name'), 'description' => t("The set name for this record, taken from the repository's identify response."), ), 'truncate_title' => array( 'name' => t('Metadata: dc:title truncate to 250 char'), 'description' => t("Sometime the title is too long for a drupal node title, so we have to truncate him."), ), ); // Add dublin core field to mapping sources $elements = array( 'title', 'type', 'subject', 'contributor', 'creator', 'description', 'publisher', 'date', 'format', 'identifier', 'source', 'language', 'relation', 'coverage', 'rights'); foreach ($elements as $element) { $sources[$element] = array( 'name' => t('Metadata: dc:@element', array('@element' => $element)), 'description' => t('From the metadata record.'), ); } return $sources; } }