Skip to content

Commit

Permalink
Kleine Anpassungen aus Begutachtung des PR#169
Browse files Browse the repository at this point in the history
  • Loading branch information
zuphilip committed Jan 7, 2025
1 parent e6f21dd commit a6294b2
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 49 deletions.
22 changes: 13 additions & 9 deletions isbn/alma-sru.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
include 'conf.php';
include 'lib.php';

if (isset($_GET['bibliothek'])) {
$file = file_get_contents('./srulibraries.json');
$json = json_decode($file, true);
$file = file_get_contents('./srulibraries.json');
$json = json_decode($file, true);
if (isset($_GET['bibliothek']) and isset($json[$_GET['bibliothek']])) {
$urlBase = $json[$_GET['bibliothek']]['sru'];
} else {
echo "Bibliothek nicht gefunden in der Liste der bekannten Alma-SRU-Schnittstellen.\n";
Expand Down Expand Up @@ -118,9 +118,16 @@
// Delete check value at the end for ISBN10
$testString = substr($testString, 0, -1);
}
}
if (strpos($foundValue, $testString) !== false) {
$foundMatch = true;
// for isbn, check that the test string is part of the found value
if (strpos($foundValue, $testString) !== false) {
$foundMatch = true;
}
} else {
// for ppn (or other ids), skip the possible prefix in paranthesis and then they need to be exactly the same
$foundValue = preg_replace('/^\(.*\)/', '', $foundValue);
if ($foundValue == $testString) {
$foundMatch = true;
}
}
}
}
Expand Down Expand Up @@ -187,9 +194,6 @@

$location = getValues($node->xpath('./subfield[@code="b"]')[0]);
$sublocation = getValues($node->xpath('./subfield[@code="c"]')[0]);
/*if (strpos($sublocation, "Lehrbuchsammlung") !== false) {
$location = "LBS";
}*/

$node_f = $node->xpath('./subfield[@code="f"]');
$number = count($node_f) ? getValues($node_f[0]) : 0;
Expand Down
46 changes: 12 additions & 34 deletions isbn/dnb.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,8 @@
* Sucht übergebene ISBN bzw. PPN in der SRU-Schnittstelle der DNB
* und gibt maximal 10 Ergebnisse als MARCXML oder JSON zurück.
*/

include 'conf.php';
include 'lib.php';

if (isset($_GET['ppn'])) {
$ppn = trim($_GET['ppn']);
$suchString = 'dnb.idn=' . $ppn;
}

/*

/*
Explain SRU
https://services.dnb.de/sru/dnb?version=1.1&operation=explain
Expand All @@ -40,12 +32,19 @@
*/

include 'conf.php';
include 'lib.php';

if (isset($_GET['ppn'])) {
$ppn = trim($_GET['ppn']);
$suchString = 'dnb.idn=' . $ppn;
}

$urlBase = 'https://services.dnb.de/sru/dnb?version=1.1&operation=searchRetrieve&recordSchema=MARC21-xml&query=';
if (isset($_GET['isbn'])) {
$n = trim($_GET['isbn']);
$nArray = preg_split("/\s*(or|,|;)\s*/i", $n, -1, PREG_SPLIT_NO_EMPTY);
$suchString = 'dnb.num=' . implode('+OR+dnb.num=', $nArray);
$suchStringSWB = implode(' or ', $nArray);
}

$result = file_get_contents($urlBase . $suchString, false);
Expand Down Expand Up @@ -75,29 +74,8 @@


foreach ($records as $record) {
// Filter out any other results which contain the ISBN but not in the 020 or 776 field
$foundMatch = false;
$foundIsbns = $xpath->query('.//datafield[@tag="020" or @tag="776"]/subfield', $record);
foreach ($foundIsbns as $foundNode) {
$foundValue = $foundNode->nodeValue;
foreach ($nArray as $queryValue) {
$testString = preg_replace('/[^0-9xX]/', '', $queryValue);
if (strlen($testString) == 13) {
// Delete the 978-prefix and the check value at the end for ISBN13
$testString = substr($testString, 3, -1);
} elseif (strlen($testString) == 10) {
// Delete check value at the end for ISBN10
$testString = substr($testString, 0, -1);
}
if (strpos(preg_replace('[^0-9xX]', '', $foundValue), $testString) !== false) {
$foundMatch = true;
}
}
}
if ($foundMatch) {
$outputString .= $doc->saveXML($record);
array_push($outputArray, $doc->saveXML($record));
}
$outputString .= $doc->saveXML($record);
array_push($outputArray, $doc->saveXML($record));
}
$outputString .= "</collection>";

Expand Down
12 changes: 6 additions & 6 deletions isbn/suche.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
alert("jQuery wurde nicht gefunden");
}
</script>
<script src="rendering.js"></script>
<script src="rendering.js?20250104"></script>
<script src="paketinfo.js"></script>
<script type="text/javascript">
function toggleHidden() {
Expand Down Expand Up @@ -226,6 +226,7 @@
});

var meinVerbund = getParameterByName("verbund").toLowerCase() || "k10plus";
document.querySelector("#selectPpn").value = meinVerbund;
//Damit werden die Variablen ueber HTML ausgewertet (so wie GET Variablen in PHP)
if (getParameterByName("isbn")) {
$('#eingabeIsbn').val(getParameterByName("isbn"));
Expand All @@ -234,7 +235,6 @@
} else if (getParameterByName("ppn")) {
$('#eingabePpn').val(getParameterByName("ppn"));
$('#eingabeIsbn').val('');
document.querySelector("#formPpn select").value = meinVerbund;
ppnEingabe(getParameterByName("ppn"), meinVerbund);
}

Expand Down Expand Up @@ -361,11 +361,11 @@
}
// Bestandsabgleich durchführen
$.get(url, function(data){
var holdingsMAN = pattern.exec(data);
if (holdingsMAN) {
var holdings = pattern.exec(data);
if (holdings) {
var detailsLink = $('<a/>').attr('href', url).attr('onclick', 'return toggleHidden()').text("Details");
var bestandsLine = $('<div/>').attr('style', "background-color:#ffbbbb")
.text(label + holdingsMAN[1]+ ' (')
.text(label + holdings[1]+ ' (')
.append(detailsLink)
.append(')<div id="detailsText" style="display: none;" class="hidden"><br/></div>');
$('#bestandsabgleich').append('<br/>').append(bestandsLine);
Expand Down Expand Up @@ -493,7 +493,7 @@ <h1>Unterstützungstool für Fachreferatsarbeit</h1>
<td id="idTD">
<form id="formPpn" name='formular' action="#">&nbsp; &nbsp; &nbsp;
<input id="eingabePpn" type="search" size="20" maxlength="30" placeholder="id...">
<select>
<select id="selectPpn">
<option type="radio" name="eingabeVerbund" value="k10plus">k10plus
<option type="radio" name="eingabeVerbund" value="swb">swb
<option type="radio" name="eingabeVerbund" value="b3kat">b3kat
Expand Down

0 comments on commit a6294b2

Please sign in to comment.