Ejemplo n.º 1
0
function import($reference)
{
    global $year_found;
    global $year_actual;
    global $year_roman;
    global $html;
    print_r($reference);
    if (!array_key_exists($reference->year, $year_actual)) {
        $html[$reference->year] = '<html><body>';
        $html[$reference->year] .= '<h1>' . $reference->year . '</h1>';
        $year_actual[$reference->year] = 0;
        $year_found[$reference->year] = 0;
        $year_roman[$reference->year] = 0;
    }
    // Articles published this year
    $year_actual[$reference->year]++;
    if (is_numeric($reference->spage)) {
        $openurl = reference2openurl($reference);
        //echo $openurl . "\n";
        $biostor_id = import_from_openurl($openurl);
        if ($biostor_id != 0) {
            $found = true;
            // Articles found this year
            $year_found[$reference->year]++;
            $reference->url = 'http://biostor.org/reference/' . $biostor_id;
            $url = $reference->url . '.json';
            $json = get($url);
            $j = json_decode($json);
            //print_r($j);
            //echo "---\n";
            $PageID = $j->bhl_pages[0];
            //echo $PageID . "\n";
            $html[$reference->year] .= '<div>';
            $html[$reference->year] .= '<a href="' . $reference->url . '" target="_new"><img src="http://biostor.org/bhl_image.php?PageID=' . $PageID . '&amp;thumbnail" /></a><br/>';
            $html[$reference->year] .= '<a href="http://www.biodiversitylibrary.org/page/' . $PageID . '" target="_new">' . $PageID . '</a><br/>';
            $html[$reference->year] .= $reference->title . '<br/>';
            $html[$reference->year] .= '</div>';
        }
    } else {
        $year_roman[$reference->year]++;
    }
}
Ejemplo n.º 2
0
function postprocess_citations($reference_id, $citations)
{
    global $db;
    $citation_count = 0;
    // Avoid duplications
    if ($reference_id != 0) {
        $sql = 'DELETE FROM rdmp_reference_cites WHERE (reference_id=' . $reference_id . ')';
        $result = $db->Execute($sql);
        if ($result == false) {
            die("failed [" . __FILE__ . ":" . __LINE__ . "]: " . $sql);
        }
    }
    foreach ($citations as $citation) {
        $citation_reference_id = 0;
        if (isset($citation->genre)) {
            // Lookup articles
            if ($citation->genre == 'article') {
                $citation_reference_id = 0;
                // Do we have this already in BioStor?
                $citation_reference_id = db_find_article($citation);
                if ($citation_reference_id == 0) {
                    // Try BioStor OpenURL search
                    $citation_reference_id = import_from_openurl(reference_to_openurl($citation));
                }
                if ($citation_reference_id == 0) {
                    // Try bioGUID
                    if (bioguid_openurl_search($citation)) {
                        $citation_reference_id = db_store_article($citation);
                    }
                }
            }
        }
        // At this stage if citation_reference_id is 0 we haven't found it
        // 1. store citation string (we are building a list of all such strings)
        $citation_string_id = store_citation_string($citation);
        // 2. If we've found it in BioStor, record link between citation string and reference id
        if ($citation_reference_id != 0) {
            $sql = 'DELETE FROM rdmp_reference_citation_string_joiner WHERE(reference_id=' . $citation_reference_id . ')
			AND (citation_string_id=' . $citation_string_id . ')';
            $result = $db->Execute($sql);
            if ($result == false) {
                die("failed [" . __FILE__ . ":" . __LINE__ . "]: " . $sql);
            }
            $sql = 'INSERT INTO rdmp_reference_citation_string_joiner (reference_id,citation_string_id)
			VALUES(' . $citation_reference_id . ',' . $citation_string_id . ')';
            $result = $db->Execute($sql);
            if ($result == false) {
                die("failed [" . __FILE__ . ":" . __LINE__ . "]: " . $sql);
            }
        }
        // 3. Store link between source reference and citation string (which we will use to display literature cited)
        if ($reference_id != 0) {
            $sql = 'INSERT INTO rdmp_reference_cites (reference_id, citation_string_id, citation_order)
			VALUES(' . $reference_id . ',' . $citation_string_id . ',' . $citation_count . ')';
            $result = $db->Execute($sql);
            if ($result == false) {
                die("failed [" . __FILE__ . ":" . __LINE__ . "]: " . $sql);
            }
            $citation_count++;
        }
    }
}
Ejemplo n.º 3
0
while (!feof($file_handle)) {
    $line = fgets($file_handle);
    $parts = explode("\t", $line);
    $parts[1] = trim($parts[1]);
    if (preg_match('/(?<authorstring>.*)\\s*(?<year>[0-9]{4})\\.\\s+(?<title>.*)\\s+<em>(?<journal>.*)<\\/em>\\s+(?<series>.*)?\\s*<strong>(?<volume>\\d+)<\\/strong>(\\((?<issue>\\d+)\\))?:\\s+(?<spage>\\d+)([–|-](?<epage>\\d+))\\b/Uu', $parts[1], $m)) {
        //print_r($m);
        $matched = true;
        $reference = reference_from_matches($m);
        //print_r($reference);
        $reference->id = $parts[0];
        $reference->keywords[] = $parts[0];
        $openurl = reference2openurl($reference);
        //echo $openurl . "\n";
        bioguid($reference);
        if (isset($reference->epage)) {
            $biostor_id = import_from_openurl($openurl);
            if ($biostor_id != 0) {
                $found = true;
                $reference->url = 'http://biostor.org/reference/' . $biostor_id;
            }
        }
        //print_r($reference);
        echo reference2ris($reference);
    } else {
        /*
        //echo $parts[1]. "\n";
        
        // Book?
        if (preg_match('/(?<authorstring>.*)\s+(?<year>[0-9]{4})\.\s+<em>(?<title>.*)<\/em>\.\s+(?<publoc>.*)\s*:(?<publisher>.*)\s*((?<frontmatter>[i|v|x]+)\s*)?(?<pages>\d+)\s+pp\.(\s*(?<extra>.*))?$/Uu', $parts[1], $m))
        {
        	print_r($m);