Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This file works with the Summon1-use360LinkApi.js to get the licesne links for each database and add the links to Summon 1.0.
<?php
/*
* A simple example function using 360Link API to make a pop-up window to display all the databases
* for a full text article in Summon 1.0
* and assign license links which are created in Mondo License Grinder
* Made and modified by Jenny Jing, Qinqin Lin
* Last Modified: Dec. 16, 2014
*/
function get_xml_result($url) { //this function is copied online: http://journal.code4lib.org/articles/108
// Initialize our cURL handle
$ch = curl_init();
// Set the URL
curl_setopt($ch, CURLOPT_URL, $url); //config.php: CURLOPT_URL
// Set the user agent
$user_agent = $_SERVER['HTTP_USER_AGENT'];
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
// We don't want the HTTP header, we just want the XML
curl_setopt($ch, CURLOPT_HEADER, 0);
// This makes the curl_exec call return a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// Follow any location headers
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
// Set some sane timeouts
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
// Attempt to fetch the XML
$result = curl_exec($ch);
// Make sure we don't have whitespace at the beginning
$result = trim($result);
// Check to see if we were successful
if (curl_errno($ch) != 0) {
$result = false;
// We're not using this, but this is how to get the error message:
$error_message = curl_error($ch);
}
// Close our cURL handle
curl_close($ch);
return $result;
}
// Grab the data
$issn = (isset($_POST['issn']))?$_POST['issn']:'';
$volumn= (isset($_POST['volumn']))?$_POST['volumn']:'';
$title = (isset($_POST['title']))?$_POST['title']:'';
$doi = (isset($_POST['doi']))?$_POST['doi']:'';
$queensUrl= (You can find this in your 360Link documentation provided by ProQuest);
$baseUrl = (You can find this in your 360Link documentation provided by ProQuest);
$key=(You can find this in your 360Link documentation provided by ProQuest);
$mandatoryFields = array('version' => '1.0');
$optionalFields = array('issn' => $issn, 'volumn' => $volumn, 'doi' =>$doi); //
$fields = array_merge($mandatoryFields, $optionalFields);
$queryString = http_build_query($fields);
$url = $baseUrl.'?'.$queryString;
$xml = get_xml_result($url);
$xmldomdoc = new DOMDocument();
$xmldomdoc->loadXML($xml);
$results = array();
if ($xmldomdoc)
{
$group_container = $xmldomdoc->getElementsByTagName('linkGroup')->item(0);
if(!empty($group_container)) {
$counter = 0;
foreach ($xmldomdoc->getElementsByTagName('linkGroup') as $dataGroup)
{
$article_url = '';
$url_elements = $dataGroup->getElementsByTagName('url');
$results[$counter]['journal_url'] = '';
$results[$counter]['article_url'] = '';
foreach($url_elements as $element) {
if($element->getAttribute('type') == 'article') {
$results[$counter]['article_url'] = $element->nodeValue;
}
if($element->getAttribute('type') == 'journal') {
$results[$counter]['journal_url'] = $element->nodeValue;
}
}
$data=$dataGroup->getElementsByTagName('holdingData')->item(0);
$urldata=$dataGroup->getElementsByTagName('url');
//var_dump($data);
//var_dump($urldata);
$results[$counter]['databaseName'] = $data->getElementsByTagName('databaseName')->item(0)->nodeValue;
$startDate = $data->getElementsByTagName('startDate')->item(0)->nodeValue;
$endDate = ($data->getElementsByTagName('endDate')->item(0))?($data->getElementsByTagName('endDate')->item(0)->nodeValue):'';
$results[$counter]['dateAvailable'] = ($startDate. '-' .$endDate);
$results[$counter]['databaseId'] = $data->getElementsByTagName('databaseId')->item(0)->nodeValue;
$results[$counter]['source']="";
$results[$counter]['journal']="";
foreach ($urldata as $nodedata)
{
$urlType = $nodedata->getAttribute('type');
if (!empty($urlType) && $urlType=='source'){
$results[$counter]['source'] ='&U='.$nodedata->nodeValue;
//echo $source;
}
if (!empty($urlType) && $urlType=='journal'){
$results[$counter]['journal'] = $nodedata->nodeValue;
//echo $source;
}
}
$counter++;
}
}
else {
?>
Title <b><?= $title?></b> is not available please use ILL form below
<?php
}
}
?>
<div class="preview " id="177255960" style="display: block;">
<div class="box">
<div class="titleBar bgh-dialog-header">
<table cellspacing="0" cellpadding="0" style="height: 100%; width: 100%;">
<tbody>
<tr>
<td> <strong><center><a target="_blank" class="documentLink gvsuTest" href="http://<?php echo $key;?>.scholar.serialssolutions.com/?sid=google&id=doi:<?php echo $doi; ?>" data-click="1/previewLink/1/">See All Resources</a></center></strong></td>
<td class="close">
<div class="theme-close"></div>
</td>
<td></td>
</tr>
</tbody>
</table>
</div>
<div class="main">
<table cellspacing="0" cellpadding="0" class="summary" style="height: 100%; width: 100%;">
<tbody>
<tr>
<td>
<div class="previewDocumentContent">
<div class="content-type">
<table border="0" class="WideNoBorder PadEastWest" id="JournalLinkTable" summary="Table provides links to article, publication and resource and displays coverage range.">
<tbody>
<tr>
<td align="center" scope="col" class="ContentHeading">
<span class="SS_ContentHeading"><strong>Article</strong></span>
</td>
<td align="center" scope="col" class="ContentHeading">
<span class="SS_ContentHeading"><strong>Journal</strong></span>
</td>
<td scope="col" class="ContentHeading">
<span class="SS_ContentHeading"><strong>Holdings</strong></span>
</td>
<td scope="col" class="ContentHeading">
<span class="SS_ContentHeading"><strong>Database</strong></span>
</td>
<td scope="col" class="ContentHeading">
<span class="SS_ContentHeading"><strong>License</strong></span>
</td>
</tr>
<?php
foreach ($results as $result) //going through the array
{
//var_dump($result);
?>
<tr>
<td valign="middle" align="center" class="c1">
<div class="cl" id="ArticleCL">
<a target="_blank" href="http://<?php echo $key;?>.scholar.serialssolutions.com/log?L=<?php echo $key;?>&D=<?php echo $result['databaseId'];?>&P=Link&U=<?php echo $result['article_url']; ?>"><img src="http://library.queensu.ca/images/xxx/article-sm.png"></a>
</div>
</td>
<td valign="middle" align="center" class="ResultsRow">
<div class="cl" id="JournalCL">
<a target="_blank" href="http://<?php echo $key;?>.scholar.serialssolutions.com/log?L=<?php echo $key;?>&D=<?php echo $result['databaseId'];?>&P=Link&U=<?php echo $result['journal_url'];?>"><img src="http://library.queensu.ca/images/xxxx/journal-sm.png"></a>
</div>
</td>
<td valign="middle" class="c1" class="ResultsRow">
<span><?php echo $result['dateAvailable'];?></span>
</td>
<td valign="middle" class="ResultsRow">
<div class="cl" id="DatabaseCL">
<span><a href="http://<?php echo $key;?>.scholar.serialssolutions.com/log?L=<?php echo $key;?>&D=<?php echo $result['databaseId'];?>&P=Link<?php echo $result['source'];?>"><?php echo $result['databaseName'];?></a>
</div>
</td>
<td valign="middle" class="ResultsRow">
<span><?php echo $result['License Information'];?></span>
<span><a href="https://xxxx/license/?name=<?php echo rawurlencode($result['databaseName']);?>">License Information</a></span>
</div>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="buffer">
</div>
<div class="preview-pointer-down theme-preview-arrow-down" style="display: none;">
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.