function tripal_pub_PMID_range

1.x PMID.inc tripal_pub_PMID_range($search_array, $start = 0, $limit = 10)
1 string reference to 'tripal_pub_PMID_range'
tripal_pub_remote_search_PMID in tripal_pub/includes/importers/PMID.inc

File

tripal_pub/includes/importers/PMID.inc, line 149
Tripal Pub PubMed Interface

Code

function tripal_pub_PMID_range($search_array, $start = 0, $limit = 10) {
  $search_str = $search_array['search_string'];
  $limit = $search_array['limit'];

  $count = $_SESSION['tripal_pub_PMID_query'][$search_str]['Count'];
  if ($count == 0) {
    return array();
  }

  // get the query_key and the web_env from the previous count query.
  $query_key = $_SESSION['tripal_pub_PMID_query'][$search_str]['QueryKey'];
  $web_env = $_SESSION['tripal_pub_PMID_query'][$search_str]['WebEnv'];

  // if this function has been called without calling the count function
  // then we need to do the query.
  if (!$query_key) {
    $results = tripal_pub_PMID_search_init($search_str, $limit);
    $_SESSION['tripal_pub_PMID_query']['WebEnv'] = $results['WebEnv'];
    $_SESSION['tripal_pub_PMID_query']['QueryKey'] = $results['QueryKey'];
    $query_key = $results['QueryKey'];
    $web_env = $results['WebEnv'];
  }

  // now get the list of PMIDs from the previous search
  $pmids_txt = tripal_pub_PMID_fetch($query_key, $web_env, 'uilist', 'text', $start, $limit);

  // iterate through each PMID and get the publication record. This requires a new search and new fetch
  $pmids = explode("\n", trim($pmids_txt));
  $pubs = array();
  foreach ($pmids as $pmid) {
    // now retrieve the individual record
    $pub_xml = tripal_pub_PMID_fetch($query_key, $web_env, 'null', 'xml', 0, 1, array('id' => $pmid));
    $pub = tripal_pub_PMID_parse_pubxml($pub_xml);
    $pubs[] = $pub;
  }
  return $pubs;
}