Ejemplo n.º 1
0
/**
 * @brief Create a COinS (ContextObjects in Spans) for a reference
 *
 * COinS encodes an OpenURL in a <span> tag. See http://ocoins.info/.
 *
 * @param reference Reference object to be encoded
 *
 * @return HTML <span> tag containing a COinS
 */
function reference_to_coins($reference)
{
    global $config;
    $coins = '<span class="Z3988" title="' . reference_to_openurl($reference) . '"></span>';
    return $coins;
}
Ejemplo n.º 2
0
/**
 * @brief Create a COinS (ContextObjects in Spans) for a reference
 *
 * COinS encodes an OpenURL in a <span> tag. See http://ocoins.info/.
 *
 * @param reference Reference object to be encoded
 *
 * @return HTML <span> tag containing a COinS
 */
function reference_to_coins($reference)
{
    global $config;
    $coins = '';
    switch ($reference->genre) {
        case 'article':
            $coins .= '<span class="Z3988" title="';
            $coins .= reference_to_openurl($reference);
            $coins .= '">';
            $coins .= '</span>';
            break;
        default:
            break;
    }
    return $coins;
}
Ejemplo n.º 3
0
/**
 * @brief Pass refrence object to bioGUID openURL resolver to find it and add any identifiers found
 *
 * @param reference Reference object, this gets populated with additional fields (such as DOI) if found
 *
 * @return True if found in bioGUID, false otherwise.
 */
function bioguid_openurl_search(&$reference)
{
    $found = false;
    $url = 'http://bioguid.info/openurl.php?' . str_replace('&amp;', '&', reference_to_openurl($reference)) . '&display=json';
    //echo $url . "\n";
    $json = get($url);
    if ($json != '') {
        $obj = json_decode($json);
        $found = $obj->status == 'ok';
        if ($found) {
            // Flesh out
            // Abstract
            if (isset($obj->abstract)) {
                if (!isset($reference->abstract)) {
                    $reference->abstract = $obj->abstract;
                }
            }
            // epage
            if (isset($obj->epage)) {
                if (!isset($reference->epage)) {
                    $reference->epage = $obj->epage;
                }
            }
            // ISSN
            if (isset($obj->issn)) {
                if (!isset($reference->issn)) {
                    $reference->issn = $obj->issn;
                }
            }
            // DOI
            if (isset($obj->doi)) {
                if (!isset($reference->doi)) {
                    $reference->doi = $obj->doi;
                }
            }
            // PMID
            if (isset($obj->pmid)) {
                if (!isset($reference->pmid)) {
                    $reference->pmid = $obj->pmid;
                }
            }
            // Handle
            if (isset($obj->hdl)) {
                if (!isset($reference->hdl)) {
                    $reference->hdl = $obj->hdl;
                }
            }
            // URL
            if (isset($obj->url)) {
                if (!isset($reference->url)) {
                    $reference->url = $obj->url;
                }
            }
            // PDF
            if (isset($obj->pdf)) {
                if (!isset($reference->pdf)) {
                    $reference->pdf = $obj->pdf;
                }
            }
            // Authors
            if (isset($obj->authors)) {
                if (count($reference->authors == 0)) {
                    foreach ($obj->authors as $author) {
                        $reference->authors[] = $author;
                    }
                }
            }
        }
    }
    return $found;
}
Ejemplo n.º 4
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.º 5
0
function display_publication($publication)
{
    global $couch;
    global $config;
    echo html_html_open();
    echo html_head_open();
    echo html_title($publication->title . ' - ' . $config['site_name']);
    echo html_include_css('css/main.css');
    echo html_include_css('css/viewer.css');
    echo html_include_script('js/jquery-1.4.4.min.js');
    echo html_include_script('js/viewer.js');
    echo html_head_close();
    echo html_body_open();
    if (1) {
        echo '<div style="position:relative;">';
        // Metadata
        echo '<div style="position:absolute;top:0px;left:620px;padding:10px;">';
        echo '<div><span><a href="' . $config['web_root'] . '">' . $config['site_name'] . '</a></span></div>';
        echo '<p></p>';
        echo '<span style="font-weight:bold;font-size:18px;">' . $publication->title . '</span>';
        echo '<div>' . 'by ' . reference_authors_to_text_string($publication->authors, false, true) . '</div>';
        $outlet = $publication->publication_outlet;
        // This ensures we double urlencode "&"
        $outlet = str_replace("&", urlencode("&"), $outlet);
        echo '<div>' . '<a href="' . $config['web_root'] . 'publication_outlet/' . urlencode($outlet) . '">' . '<i>' . $publication->publication_outlet . '</i>' . '</a>' . ' ' . $publication->volume . ':' . $publication->pages . ' (' . $publication->year . ')' . '</div>';
        // External links ---------------------------------------------------------------------------------------
        echo '<div>';
        echo '<ul>';
        if ($publication->_id) {
            echo '<li><a href="http://lsid.tdwg.org/summary/urn:lsid:biodiversity.org.au:afd.publication:' . $publication->_id . '" target="_new">urn:lsid:biodiversity.org.au:afd.publication:' . $publication->_id . '</li>';
        }
        if (isset($publication->identifiers)) {
            if (isset($publication->identifiers->doi)) {
                echo '<li>' . '<a href="http://dx.doi.org/' . $publication->identifiers->doi . '" target="_new">doi:' . $publication->identifiers->doi . '</a></li>';
            }
            if (isset($publication->identifiers->hdl)) {
                echo '<li>' . '<a href="http://hdl.handle.net/' . $publication->identifiers->hdl . '" target="_new">hdl:' . $publication->identifiers->hdl . '</a></li>';
            }
            if (isset($publication->identifiers->biostor)) {
                echo '<li>' . '<a href="http://biostor.org/reference/' . $publication->identifiers->biostor . '" target="_new">BioStor</a></li>';
            }
            if (isset($publication->pageIdentifiers)) {
                echo '<li>' . '<a href="http://biodiversitylibrary.org/page/' . $publication->pageIdentifiers[0] . '" target="_new">BHL</a></li>';
            }
        }
        if (isset($publication->urls)) {
            foreach ($publication->urls as $url) {
                if (preg_match('/http:\\/\\/ci.nii.ac.jp\\/naid\\//', $url)) {
                    echo '<li>' . '<a href="' . $url . '" target="_new">' . $url . '</a></li>';
                }
                if (preg_match('/http:\\/\\/gallica.bnf.fr\\//', $url)) {
                    echo '<li>' . '<a href="' . $url . '" target="_new">' . $url . '</a></li>';
                }
                if (preg_match('/http:\\/\\/www.jstor.org\\//', $url)) {
                    echo '<li>' . '<a href="' . $url . '" target="_new">' . $url . '</a></li>';
                }
            }
        }
        echo '</div>';
        echo reference_to_coins($publication);
        echo '<div><a href="http://biostor.org/openurlhook.php?' . reference_to_openurl($publication) . '&amp;webhook=' . urlencode($config['web_server'] . $config['web_root'] . 'webhook.php') . '" target="_new">OpenURL Hook</a></div>';
        //------------------------------------------------------------------------------------------
        // Names
        $resp = $couch->send("GET", "/" . $config['couchdb'] . "/_design/publication/_view/taxonNames?key=" . urlencode('"' . $publication->_id . '"'));
        $names = json_decode($resp);
        if (count($names->rows) > 0) {
            echo '<h3>Names published</h3>';
            echo '<ul>';
            foreach ($names->rows as $row) {
                echo '<li>' . '<a href="id/' . $row->value->_id . '">' . $row->value->taxonName . '</a></li>';
            }
            echo '</ul>';
        }
        echo '</div>';
        // --- end metadata
        // Viewer
        echo '<div style="position:absolute;top:0px;left:0px;width:600px;">';
        $has_fulltext = isset($publication->identifiers->biostor) || isset($publication->pdf);
        if (!$has_fulltext) {
            if (isset($publication->identifiers->doi)) {
                $url = 'http://dx.doi.org/' . $publication->identifiers->doi;
                echo '<div style="width:600px;height:800px;border:1px solid rgb(192,192,192);">';
                echo '<iframe src="' . $url . '" width="600" height="800" style="border: none;">';
                echo '</iframe>';
                echo '</div>';
            } else {
                if (count($publication->urls) > 0) {
                    $display_url = '';
                    foreach ($publication->urls as $url) {
                        if (preg_match('/http:\\/\\/ci.nii.ac.jp\\/naid\\//', $url)) {
                            $display_url = $url;
                            break;
                        }
                        if (preg_match('/http:\\/\\/gallica.bnf.fr\\//', $url)) {
                            $display_url = $url;
                            break;
                        }
                        if (preg_match('/http:\\/\\/www.jstor.org\\//', $url)) {
                            $display_url = $url;
                            break;
                        }
                    }
                    if ($display_url != '') {
                        echo '<div style="width:600px;height:800px;border:1px solid rgb(192,192,192);">';
                        echo '<iframe src="' . $display_url . '" width="600" height="800" style="border: none;">';
                        echo '</iframe>';
                        echo '</div>';
                    }
                } else {
                    echo '<div style="width:600px;height:800px;border:1px solid rgb(192,192,192);">
					<div style="position:absolute;top:300px;left:0px;width:600px;color:rgb(192,192,192);text-align:center;font-size:72px;">No content</div>
					</div>';
                }
            }
        } else {
            // PDF
            if (isset($publication->pdf)) {
                echo '<div>';
                echo '<iframe src="http://docs.google.com/viewer?url=';
                echo str_replace(' ', '%20', $publication->pdf) . '&embedded=true" width="600" height="800" style="border: none;">';
                echo '</iframe>';
                echo '</div>';
            } else {
                // BioStor
                if (isset($publication->identifiers->biostor)) {
                    echo '<script> pages=[' . join(",", $publication->pageIdentifiers) . ']; </script>';
                    echo '				
	<div style="position:relative;width:600px;height:800px;">
		<div id="header" >
			<div style="float:right;padding:8px;margin-right:10px;">
				<span id="page_counter">1/?</span>
				<span>&nbsp;</span>
				<span>&nbsp;</span>
				<img id="previous_page" src="images/previous.png" border="0" onclick="previous();" title="Show previous page">
				<span>&nbsp;</span>
				<img id="next_page" src="images/next.png" border="0" onclick="next();" title="Show next page">
				<span>&nbsp;</span>
				<span>&nbsp;</span>
				<span>&nbsp;</span>
				<img src="images/fourpages.png" border="0" onclick="show_all_pages();" title="Show all pages">
				<span>&nbsp;</span>
				<img src="images/onepage.png" border="0" onclick="show_page(-1);"  title="Fit page to viewer">
			</div>
		</div>
	
		<div id="page_container">
			<img id="page_image" />
			<div id="all_pages" ></div>
		</div>
	</div>
	
	<script>
	show_page(0);
	</script>';
                }
            }
        }
        echo '</div>
		</div>';
    } else {
        //----------------------------------------------------------------------------------------------
        // Home
        echo '<span><a href="' . $config['web_root'] . '">' . $config['site_name'] . '</a></span>';
        echo html_search_box();
        //----------------------------------------------------------------------------------------------
        // Object
        echo '<div>';
        echo '<h1>' . $publication->title . '</h1>';
        echo '<div>' . 'by ' . reference_authors_to_text_string($publication->authors, false, true) . '</div>';
        echo '<div>' . '<i>' . $publication->publication_outlet . '</i>' . ' ' . $publication->volume . ':' . $publication->pages . ' (' . $publication->year . ')' . '</div>';
        //echo '<div>' . $publication->_id . '</div>';
        /*
        if (isset($publication->abstract))
        {
        	echo '<div>' . $publication->abstract . '</div>';				
        }
        */
        // External links
        echo '<ul>';
        if (isset($publication->identifiers)) {
            if (isset($publication->identifiers->doi)) {
                echo '<li>' . '<a href="http://dx.doi.org/' . $publication->identifiers->doi . '" target="_new">doi:' . $publication->identifiers->doi . '</a></li>';
            }
            if (isset($publication->identifiers->hdl)) {
                echo '<li>' . '<a href="http://hdl.handle.net/' . $publication->identifiers->hdl . '" target="_new">hdl:' . $publication->identifiers->hdl . '</a></li>';
            }
            if (isset($publication->identifiers->biostor)) {
                echo '<li>' . '<a href="http://biostor.org/reference/' . $publication->identifiers->biostor . '" target="_new">BioStor</a></li>';
            }
            if (isset($publication->pageIdentifiers)) {
                echo '<li>' . '<a href="http://biodiversitylibrary.org/page/' . $publication->pageIdentifiers[0] . '" target="_new">BHL</a></li>';
            }
        }
        if (isset($publication->urls)) {
            foreach ($publication->urls as $url) {
                if (preg_match('/http:\\/\\/ci.nii.ac.jp\\/naid\\//', $url)) {
                    echo '<li>' . '<a href="' . $url . '" target="_new">' . $url . '</a></li>';
                }
            }
        }
        echo '</ul>';
        echo '</div>';
        //----------------------------------------------------------------------------------------------
        // Names
        $resp = $couch->send("GET", "/" . $config['couchdb'] . "/_design/publication/_view/taxonNames?key=" . urlencode('"' . $publication->_id . '"'));
        $names = json_decode($resp);
        if (count($names->rows) > 0) {
            echo '<h2>Names published</h2>';
            echo '<ul>';
            foreach ($names->rows as $row) {
                echo '<li>' . '<a href="id/' . $row->value->_id . '">' . $row->value->taxonName . '</a></li>';
            }
            echo '</ul>';
        }
        //----------------------------------------------------------------------------------------------
        // Content
        echo '<h2>Content</h2>';
        $has_fulltext = isset($publication->identifiers->biostor) || isset($publication->pdf);
        if (!$has_fulltext) {
            if (isset($publication->identifiers->doi)) {
                $url = 'http://dx.doi.org/' . $publication->identifiers->doi;
                echo '<div>';
                echo '<iframe src="' . $url . '" width="100%" height="700" style="border: none;">';
                echo '</iframe>';
                echo '</div>';
            }
        } else {
            // PDF
            if (isset($publication->pdf)) {
                echo '<div>';
                echo '<iframe src="http://docs.google.com/viewer?url=';
                echo urlencode($publication->pdf) . '&embedded=true" width="700" height="700" style="border: none;">';
                echo '</iframe>';
                echo '</div>';
            } else {
                // BioStor
                if (isset($publication->identifiers->biostor)) {
                    echo '<script> pages=[' . join(",", $publication->pageIdentifiers) . ']; </script>';
                    echo '				
<div style="position:relative;width:700px;height:700px;">
	<div id="header" >
		<div style="float:right;padding:8px;margin-right:10px;">
			<span id="page_counter">1/?</span>
			<span>&nbsp;</span>
			<span>&nbsp;</span>
			<img id="previous_page" src="images/previous.png" border="0" onclick="previous();" title="Show previous page">
			<span>&nbsp;</span>
			<img id="next_page" src="images/next.png" border="0" onclick="next();" title="Show next page">
			<span>&nbsp;</span>
			<span>&nbsp;</span>
			<span>&nbsp;</span>
			<img src="images/fourpages.png" border="0" onclick="show_all_pages();" title="Show all pages">
			<span>&nbsp;</span>
			<img src="images/onepage.png" border="0" onclick="show_page(-1);"  title="Fit page to viewer">
		</div>
	</div>

	<div id="page_container">
		<img id="page_image" />
		<div id="all_pages" ></div>
	</div>
</div>

<script>
show_page(0);
</script>';
                }
            }
        }
    }
    echo html_body_close();
    echo html_html_close();
}