Ejemplo n.º 1
0
function export_ris($id)
{
    $item = retrieve_from_db($id);
    $ris = "TY  - JOUR\n";
    $ris .= "TI  - " . $item->atitle . "\n";
    foreach ($item->authors as $a) {
        $ris .= 'AU  - ';
        $ris .= $a->lastname;
        $ris .= ", " . $a->forename;
        if (isset($a->suffix)) {
            $ris .= ", " . $a->suffix;
        }
        $ris .= "\n";
    }
    $ris .= "SN  - " . $item->issn . "\n";
    $ris .= "JF  - " . $item->title . "\n";
    $ris .= "VL  - " . $item->volume . "\n";
    $ris .= "IS  - " . $item->issue . "\n";
    $ris .= "SP  - " . $item->spage . "\n";
    if (isset($item->epage)) {
        $ris .= "EP  - " . $item->epage . "\n";
    }
    if (isset($item->year)) {
        $ris .= "Y1  - " . $item->year . "\n";
    }
    if (isset($item->date)) {
        $ris .= "PY  - " . $item->date . "\n";
    }
    if (isset($item->url)) {
        $ris .= "UR  - " . $item->url . "\n";
    }
    if (isset($item->pdf)) {
        $ris .= "L1  - " . $item->pdf . "\n";
    }
    if (isset($item->doi)) {
        $ris .= "M3  - http://dx.doi.org/" . $item->doi . "\n";
    }
    if (isset($item->abstract)) {
        $ris .= "N2  - " . $item->abstract . "\n";
    }
    $ris .= "ER  - \n\n";
    return $ris;
}
Ejemplo n.º 2
0
 function find_article_from_page($values, &$item)
 {
     global $debug;
     $found = false;
     // Is it in our cache?
     $tmp_item = new stdClass();
     $tmp_item->issn = $values['issn'];
     $tmp_item->volume = $values['volume'];
     $tmp_item->pages = $values['pages'];
     $cache_id = find_in_cache_from_page($tmp_item);
     if ($cache_id != 0) {
         $item = retrieve_from_db($cache_id);
         $found = true;
     } else {
         // Off to the Cloud...
         // For now limit ourselves to CrossRef
         $year = '';
         if (array_key_exists('date', $values)) {
             $year = $values['date'];
         }
         if (in_crossref($values['issn'], $year, $values['volume'])) {
             //echo 'Should be in CrossRef';
             $max_tries = 50;
             $doi = '';
             $page = $values['pages'];
             $upper_bound = $page;
             // save the original starting page
             $count = 0;
             while (!$found && $count < $max_tries && $page >= 0) {
                 if ($debug) {
                     echo $count, '.';
                 }
                 $doi = search_for_doi($values['issn'], $values['volume'], $page, $values['genre'], $item);
                 if ($doi == '') {
                     // Decrease page
                     $page--;
                     // We might now be in the range of a previously found range
                     $tmp_item->issn = $values['issn'];
                     $tmp_item->volume = $values['volume'];
                     $tmp_item->pages = $page;
                     $cache_id = find_in_cache_from_page($tmp_item);
                     if ($cache_id != 0) {
                         $item = retrieve_from_db($cache_id);
                         $found = true;
                         // Update upper bound
                         update_page_upperbound($cache_id, $upper_bound);
                     }
                 } else {
                     $found = true;
                     $cache_id = find_in_cache($item);
                     if ($cache_id == 0) {
                         $cache_id = store_in_cache($item);
                     }
                     // Update upper bound
                     update_page_upperbound($cache_id, $upper_bound);
                     //echo 'got it!';
                 }
                 $count++;
             }
         }
         // OK, try JSTOR (gulp)
         if (!$found) {
             if ($debug) {
                 echo '<p>Trying JSTOR ' . $values['issn'] . '</p>';
                 if (in_jstor($values['issn'], $values['date'])) {
                     echo "in JSTOR\n";
                 }
             }
             if (enough_for_jstor_lookup($values) && in_jstor($values['issn'], $values['date'])) {
                 $max_tries = 20;
                 $page = $values['pages'];
                 $upper_bound = $page;
                 // save the original starting page
                 $temp_values = $values;
                 $count = 0;
                 while (!$found && $count < $max_tries && $page >= 0) {
                     if ($debug) {
                         echo $count, '.';
                     }
                     $temp_values['spage'] = $page;
                     $sici = sici_from_meta($temp_values);
                     if ($debug) {
                         print_r($temp_values);
                         echo urlencode($sici);
                     }
                     $found = jstor_metadata($sici, $item);
                     if (!$found) {
                         // Decrease page
                         $page--;
                         $temp_values['spage'] = $page;
                         // We might now be in the range of a previously found range
                         $tmp_item->issn = $values['issn'];
                         $tmp_item->volume = $values['volume'];
                         $tmp_item->pages = $page;
                         $cache_id = find_in_cache_from_page($tmp_item);
                         if ($cache_id != 0) {
                             $item = retrieve_from_db($cache_id);
                             $found = true;
                             // Update upper bound
                             update_page_upperbound($cache_id, $upper_bound);
                         }
                     } else {
                         $cache_id = find_in_cache($item);
                         if ($cache_id == 0) {
                             $cache_id = store_in_cache($item);
                         }
                         // Update upper bound
                         update_page_upperbound($cache_id, $upper_bound);
                         //echo 'got it!';
                     }
                     $count++;
                 }
             } else {
                 if ($debug) {
                     echo '<p>Not enough for JSTOR lookup, or out of range ' . $values['issn'] . ' ' . $values['date'] . '</p>';
                 }
             }
         }
     }
     return $found;
 }