Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Moreover, for the retrieval of data from the British National Library, you shoul

The easiest way for developing/changing code on linux or windows is to use the same docker image
from Dockerhub and additionally mount the current malibu directory into docker:
```
```bash
docker run -d -p 12345:80 -v `pwd`:/var/www/html/malibu-dev ubma/malibu
```
The development version of malibu can then be accessed at [http://localhost:12345/malibu-dev/isbn/suche.html](http://localhost:12345/malibu-dev/isbn/suche.html)
Expand Down
9 changes: 4 additions & 5 deletions isbn/alma-sru.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@
exit;
}

$suchString = '';

if (isset($_GET['ppn'])) {
$n = trim($_GET['ppn']);
$searchObject = "ppn";
Expand Down Expand Up @@ -151,7 +149,7 @@
// 0 zur Verlinkung mit der GND beginnend mit "(DE-588)". Aber unklar wie dies
// etwa bei Formschlagwörtern ohne Verlinkung aussieht.)
$map['sw'] = array(
'mainPart' => '//datafield[starts-with(@tag,"6") and (starts-with(subfield[@code="0"],"(DE-588)") or subfield[@code="2"]="gnd")]',
'mainPart' => '//datafield[(starts-with(@tag,"6") and (starts-with(subfield[@code="0"],"(DE-588)") or subfield[@code="2"]="gnd")) or (@tag="655" and @ind2="7" and subfield[@code="2"]="gnd-content")]',
'value' => './subfield[@code="a"]',
'subvalues' => './subfield[@code="b" or @code="t"]',
'additional' => './subfield[@code="g" or @code="z"]',
Expand All @@ -165,10 +163,11 @@
$outputXml = simplexml_load_string($outputString);

$outputMap = performMapping($map, $outputXml);

$outputIndividualMap = [];
for ($j = 0; $j < count($outputArray); $j++) {
$outputXml = simplexml_load_string($outputArray[$j]);
$outputSingleMap = performMapping($map, $outputXml);
$singleRecordXml = simplexml_load_string($outputArray[$j]);
$outputSingleMap = performMapping($map, $singleRecordXml);
array_push($outputIndividualMap, $outputSingleMap);
}
$outputMap["einzelaufnahmen"] = $outputIndividualMap;
Expand Down
2 changes: 1 addition & 1 deletion isbn/dnb.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
$map['sw']['additional'] = './subfield[@code="g" or @code="z"]';
// intellektuell vergebene Schlagwörter sind immer im Feld 689 und nur falls es dort keine gibt
// sollen die anderen Felder (mit automatisch vergebenen) Schlagwörter auch betrachtet werden
$map['sw']['mainPart'] = '//datafield[@tag="689" or (not(preceding-sibling::datafield[@tag="689"]) and not(following-sibling::datafield[@tag="689"]) and starts-with(@tag, "6") and (subfield[@code="2"]="gbv" or subfield[@code="2"]="gnd"))]';
$map['sw']['mainPart'] = '//datafield[@tag="689" or (not(preceding-sibling::datafield[@tag="689"]) and not(following-sibling::datafield[@tag="689"]) and ((starts-with(@tag, "6") and (subfield[@code="2"]="gbv" or subfield[@code="2"]="gnd")) or (@tag="655" and @ind2="7" and subfield[@code="2"]="gnd-content")))]';


if (!isset($_GET['format'])) {
Expand Down
68 changes: 65 additions & 3 deletions isbn/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
'rvk' => '//datafield[@tag="084" and contains(subfield[@code="2"], "rvk")]/subfield[@code="a"]',
'ddc' => '//datafield[@tag="082" and @ind2!="9"]/subfield[@code="a"]',
'sw' => [
'mainPart' => '//datafield[starts-with(@tag,"6") and (subfield[@code="2"]="gbv" or subfield[@code="2"]="gnd")]',
'mainPart' => '//datafield[(starts-with(@tag,"6") and (subfield[@code="2"]="gbv" or subfield[@code="2"]="gnd")) or (@tag="655" and @ind2="7" and subfield[@code="2"]="gnd-content")]',
'value' => './subfield[@code="a"]',
'subvalues' => './subfield[@code="b" or @code="t"]',
'additional' => './subfield[@code="9" or @code="g" or @code="z"]',
Expand Down Expand Up @@ -120,7 +120,14 @@ function performMapping($map, $outputXml)
$outputMap[$label] = $outputArray;
}
}
return cleanUp($outputMap);

$outputMap = cleanUp($outputMap);

if (isset($outputMap['ddc'])) {
$outputMap['ddc'] = extractDdcEntriesFromXml($outputXml);
}

return $outputMap;
}

function cleanUp($outputMap)
Expand Down Expand Up @@ -185,7 +192,14 @@ function cleanUp($outputMap)
}
if (is_array($outputMap['ddc'])) {
foreach ($outputMap['ddc'] as $i => $value) {
$outputMap['ddc'][$i] = preg_replace('/[^\d\.]/', '', $value); //str_replace('|', '', str_replace('/', '', $value));
if (is_array($value) && array_key_exists('notation', $value)) {
$outputMap['ddc'][$i]['notation'] = preg_replace('/[^\d\.]/', '', $value['notation']);
if (array_key_exists('source', $value)) {
$outputMap['ddc'][$i]['source'] = trim($value['source']);
}
} else {
$outputMap['ddc'][$i] = preg_replace('/[^\d\.]/', '', $value); //str_replace('|', '', str_replace('/', '', $value));
}
}
}
if (array_key_exists('oclcNr', $outputMap) && is_array($outputMap['oclcNr'])) {
Expand Down Expand Up @@ -214,6 +228,54 @@ function cleanUp($outputMap)
return $outputMap;
}

function extractDdcEntriesFromXml($xml)
{
$entries = [];
if (!$xml) {
return $entries;
}

$fields = $xml->xpath('//datafield[@tag="082" and @ind2!="9"]');
if (!$fields) {
return $entries;
}

$seen = [];
foreach ($fields as $field) {
$notationNodes = $field->xpath('./subfield[@code="a"]');
if (!$notationNodes) {
continue;
}

$source = '';
$sourceNodes = $field->xpath('./subfield[@code="2"]');
if ($sourceNodes) {
$source = trim(getValues($sourceNodes[0]));
}

foreach ($notationNodes as $notationNode) {
$notation = preg_replace('/[^\d\.]/', '', getValues($notationNode));
if ($notation === '') {
continue;
}

$key = $notation . '|' . $source;
if (isset($seen[$key])) {
continue;
}

$entry = ['notation' => $notation];
if ($source !== '') {
$entry['source'] = $source;
}
$entries[] = $entry;
$seen[$key] = true;
}
}

return $entries;
}


function getValues($xmlObject)
{
Expand Down
36 changes: 28 additions & 8 deletions isbn/rendering.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,36 @@ function renderDDC(ddcArray)
{
if (typeof ddcArray === 'string') {
return ddcArray;
} else {
for (var i=0; i<ddcArray.length; i++) {
var ddc = ddcArray[i];
//var ddcUrl = 'http://dewey.info/class/' + ddc + '/';
//var ddcUrl = 'https://deweysearchde.pansoft.de/webdeweysearch/executeSearch.html?lastScheduleRecord=' + ddc + '&lastTableRecord=&query=' + ddc;
var ddcUrl = 'https://coli-conc.gbv.de/cocoda/app/?fromScheme=http%3A%2F%2Fdewey.info%2Fscheme%2Fedition%2Fe23%2F&toScheme=http%3A%2F%2Furi.gbv.de%2Fterminology%2Frvk%2F&from=http%3A%2F%2Fdewey.info%2Fclass%2F' + ddc + '%2Fe23%2F';
ddcArray[i] = '<a href="' + ddcUrl + '" target="_blank">' + ddc + '</a>';
}
if (!Array.isArray(ddcArray)) {
return '';
}

var rendered = [];
for (var i = 0; i < ddcArray.length; i++) {
var entry = ddcArray[i];
var notation = entry;
var source = '';
if (typeof entry === 'object' && entry !== null) {
notation = entry.notation || '';
source = entry.source || '';
}
if (typeof notation !== 'string') {
notation = '';
}
notation = notation.trim();
if (notation.length === 0) {
continue;
}
var encodedNotation = encodeURIComponent(notation);
var ddcUrl = 'https://coli-conc.gbv.de/cocoda/app/?fromScheme=http%3A%2F%2Fdewey.info%2Fscheme%2Fedition%2Fe23%2F&toScheme=http%3A%2F%2Furi.gbv.de%2Fterminology%2Frvk%2F&from=http%3A%2F%2Fdewey.info%2Fclass%2F' + encodedNotation + '%2Fe23%2F';
var attributes = ' target="_blank"';
if (source && source.length > 0) {
attributes += ' title="' + htmlEscape(source) + '"';
}
return ddcArray.join(', ');
rendered.push('<a href="' + ddcUrl + '"' + attributes + '>' + notation + '</a>');
}
return rendered.join(', ');
}


Expand Down