Lines 29-34
use MARC::File::USMARC;
Link Here
|
29 |
use MARC::File::XML; |
29 |
use MARC::File::XML; |
30 |
use POSIX qw(strftime); |
30 |
use POSIX qw(strftime); |
31 |
use Module::Load::Conditional qw(can_load); |
31 |
use Module::Load::Conditional qw(can_load); |
|
|
32 |
use URI::Escape; # GetCOinSBiblio |
32 |
|
33 |
|
33 |
use C4::Koha; |
34 |
use C4::Koha; |
34 |
use C4::Dates qw/format_date/; |
35 |
use C4::Dates qw/format_date/; |
Lines 1332-1376
sub GetCOinSBiblio {
Link Here
|
1332 |
carp 'GetCOinSBiblio called with undefined record'; |
1333 |
carp 'GetCOinSBiblio called with undefined record'; |
1333 |
return; |
1334 |
return; |
1334 |
} |
1335 |
} |
|
|
1336 |
|
1335 |
my $pos7 = substr $record->leader(), 7, 1; |
1337 |
my $pos7 = substr $record->leader(), 7, 1; |
1336 |
my $pos6 = substr $record->leader(), 6, 1; |
1338 |
my $pos6 = substr $record->leader(), 6, 1; |
1337 |
my $mtx; |
1339 |
my $mtx; |
1338 |
my $genre; |
1340 |
my $genre; |
1339 |
my ( $aulast, $aufirst ) = ( '', '' ); |
1341 |
my ( $aulast, $aufirst ) = ( '', '' ); |
1340 |
my $oauthors = ''; |
1342 |
my @authors; |
1341 |
my $title = ''; |
1343 |
my $title; |
1342 |
my $subtitle = ''; |
1344 |
my $hosttitle; |
1343 |
my $pubyear = ''; |
1345 |
my $pubyear = ''; |
1344 |
my $isbn = ''; |
1346 |
my $isbn = ''; |
1345 |
my $issn = ''; |
1347 |
my $issn = ''; |
1346 |
my $publisher = ''; |
1348 |
my $publisher = ''; |
1347 |
my $pages = ''; |
1349 |
my $pages = ''; |
1348 |
my $titletype = 'b'; |
1350 |
my $titletype = ''; |
1349 |
|
1351 |
|
1350 |
# For the purposes of generating COinS metadata, LDR/06-07 can be |
1352 |
# For the purposes of generating COinS metadata, LDR/06-07 can be |
1351 |
# considered the same for UNIMARC and MARC21 |
1353 |
# considered the same for UNIMARC and MARC21 |
1352 |
my $fmts6; |
1354 |
my $fmts6 = { |
1353 |
my $fmts7; |
1355 |
'a' => 'book', |
1354 |
%$fmts6 = ( |
1356 |
'b' => 'manuscript', |
1355 |
'a' => 'book', |
1357 |
'c' => 'book', |
1356 |
'b' => 'manuscript', |
1358 |
'd' => 'manuscript', |
1357 |
'c' => 'book', |
1359 |
'e' => 'map', |
1358 |
'd' => 'manuscript', |
1360 |
'f' => 'map', |
1359 |
'e' => 'map', |
1361 |
'g' => 'film', |
1360 |
'f' => 'map', |
1362 |
'i' => 'audioRecording', |
1361 |
'g' => 'film', |
1363 |
'j' => 'audioRecording', |
1362 |
'i' => 'audioRecording', |
1364 |
'k' => 'artwork', |
1363 |
'j' => 'audioRecording', |
1365 |
'l' => 'document', |
1364 |
'k' => 'artwork', |
1366 |
'm' => 'computerProgram', |
1365 |
'l' => 'document', |
1367 |
'o' => 'document', |
1366 |
'm' => 'computerProgram', |
1368 |
'r' => 'document', |
1367 |
'o' => 'document', |
1369 |
}; |
1368 |
'r' => 'document', |
1370 |
my $fmts7 = { |
1369 |
); |
1371 |
'a' => 'journalArticle', |
1370 |
%$fmts7 = ( |
1372 |
's' => 'journal', |
1371 |
'a' => 'journalArticle', |
1373 |
}; |
1372 |
's' => 'journal', |
|
|
1373 |
); |
1374 |
|
1374 |
|
1375 |
$genre = $fmts6->{$pos6} ? $fmts6->{$pos6} : 'book'; |
1375 |
$genre = $fmts6->{$pos6} ? $fmts6->{$pos6} : 'book'; |
1376 |
|
1376 |
|
Lines 1381-1386
sub GetCOinSBiblio {
Link Here
|
1381 |
##### We must transform mtx to a valable mtx and document type #### |
1381 |
##### We must transform mtx to a valable mtx and document type #### |
1382 |
if ( $genre eq 'book' ) { |
1382 |
if ( $genre eq 'book' ) { |
1383 |
$mtx = 'book'; |
1383 |
$mtx = 'book'; |
|
|
1384 |
$titletype = 'b'; |
1384 |
} elsif ( $genre eq 'journal' ) { |
1385 |
} elsif ( $genre eq 'journal' ) { |
1385 |
$mtx = 'journal'; |
1386 |
$mtx = 'journal'; |
1386 |
$titletype = 'j'; |
1387 |
$titletype = 'j'; |
Lines 1392-1417
sub GetCOinSBiblio {
Link Here
|
1392 |
$mtx = 'dc'; |
1393 |
$mtx = 'dc'; |
1393 |
} |
1394 |
} |
1394 |
|
1395 |
|
1395 |
$genre = ( $mtx eq 'dc' ) ? "&rft.type=$genre" : "&rft.genre=$genre"; |
|
|
1396 |
|
1397 |
if ( C4::Context->preference("marcflavour") eq "UNIMARC" ) { |
1396 |
if ( C4::Context->preference("marcflavour") eq "UNIMARC" ) { |
1398 |
|
1397 |
|
1399 |
# Setting datas |
1398 |
# Setting datas |
1400 |
$aulast = $record->subfield( '700', 'a' ) || ''; |
1399 |
$aulast = $record->subfield( '700', 'a' ) || ''; |
1401 |
$aufirst = $record->subfield( '700', 'b' ) || ''; |
1400 |
$aufirst = $record->subfield( '700', 'b' ) || ''; |
1402 |
$oauthors = "&rft.au=$aufirst $aulast"; |
1401 |
push @authors, "$aufirst $aulast" if ($aufirst or $aulast); |
1403 |
|
1402 |
|
1404 |
# others authors |
1403 |
# others authors |
1405 |
if ( $record->field('200') ) { |
1404 |
if ( $record->field('200') ) { |
1406 |
for my $au ( $record->field('200')->subfield('g') ) { |
1405 |
for my $au ( $record->field('200')->subfield('g') ) { |
1407 |
$oauthors .= "&rft.au=$au"; |
1406 |
push @authors, $au; |
1408 |
} |
1407 |
} |
1409 |
} |
1408 |
} |
1410 |
$title = |
1409 |
|
1411 |
( $mtx eq 'dc' ) |
1410 |
$title = $record->subfield( '200', 'a' ); |
1412 |
? "&rft.title=" . $record->subfield( '200', 'a' ) |
1411 |
my $subfield_210d = $record->subfield('210', 'd'); |
1413 |
: "&rft.title=" . $record->subfield( '200', 'a' ) . "&rft.btitle=" . $record->subfield( '200', 'a' ); |
1412 |
if ($subfield_210d and $subfield_210d =~ /(\d{4})/) { |
1414 |
$pubyear = $record->subfield( '210', 'd' ) || ''; |
1413 |
$pubyear = $1; |
|
|
1414 |
} |
1415 |
$publisher = $record->subfield( '210', 'c' ) || ''; |
1415 |
$publisher = $record->subfield( '210', 'c' ) || ''; |
1416 |
$isbn = $record->subfield( '010', 'a' ) || ''; |
1416 |
$isbn = $record->subfield( '010', 'a' ) || ''; |
1417 |
$issn = $record->subfield( '011', 'a' ) || ''; |
1417 |
$issn = $record->subfield( '011', 'a' ) || ''; |
Lines 1421-1454
sub GetCOinSBiblio {
Link Here
|
1421 |
|
1421 |
|
1422 |
# Setting datas |
1422 |
# Setting datas |
1423 |
if ( $record->field('100') ) { |
1423 |
if ( $record->field('100') ) { |
1424 |
$oauthors .= "&rft.au=" . $record->subfield( '100', 'a' ); |
1424 |
push @authors, $record->subfield( '100', 'a' ); |
1425 |
} |
1425 |
} |
1426 |
|
1426 |
|
1427 |
# others authors |
1427 |
# others authors |
1428 |
if ( $record->field('700') ) { |
1428 |
if ( $record->field('700') ) { |
1429 |
for my $au ( $record->field('700')->subfield('a') ) { |
1429 |
for my $au ( $record->field('700')->subfield('a') ) { |
1430 |
$oauthors .= "&rft.au=$au"; |
1430 |
push @authors, $au; |
1431 |
} |
1431 |
} |
1432 |
} |
1432 |
} |
1433 |
$title = "&rft." . $titletype . "title=" . $record->subfield( '245', 'a' ); |
1433 |
$title = $record->subfield( '245', 'a' ) . $record->subfield( '245', 'b' ); |
1434 |
$subtitle = $record->subfield( '245', 'b' ) || ''; |
|
|
1435 |
$title .= $subtitle; |
1436 |
if ($titletype eq 'a') { |
1434 |
if ($titletype eq 'a') { |
1437 |
$pubyear = $record->field('008') || ''; |
1435 |
$pubyear = $record->field('008') || ''; |
1438 |
$pubyear = substr($pubyear->data(), 7, 4) if $pubyear; |
1436 |
$pubyear = substr($pubyear->data(), 7, 4) if $pubyear; |
1439 |
$isbn = $record->subfield( '773', 'z' ) || ''; |
1437 |
$isbn = $record->subfield( '773', 'z' ) || ''; |
1440 |
$issn = $record->subfield( '773', 'x' ) || ''; |
1438 |
$issn = $record->subfield( '773', 'x' ) || ''; |
1441 |
if ($mtx eq 'journal') { |
1439 |
$hosttitle = $record->subfield( '773', 't' ) || $record->subfield( '773', 'a'); |
1442 |
$title .= "&rft.title=" . (($record->subfield( '773', 't' ) || $record->subfield( '773', 'a'))); |
1440 |
my @rels = $record->subfield( '773', 'g' ); |
1443 |
} else { |
1441 |
$pages = join(', ', @rels); |
1444 |
$title .= "&rft.btitle=" . (($record->subfield( '773', 't' ) || $record->subfield( '773', 'a')) || ''); |
|
|
1445 |
} |
1446 |
foreach my $rel ($record->subfield( '773', 'g' )) { |
1447 |
if ($pages) { |
1448 |
$pages .= ', '; |
1449 |
} |
1450 |
$pages .= $rel; |
1451 |
} |
1452 |
} else { |
1442 |
} else { |
1453 |
$pubyear = $record->subfield( '260', 'c' ) || ''; |
1443 |
$pubyear = $record->subfield( '260', 'c' ) || ''; |
1454 |
$publisher = $record->subfield( '260', 'b' ) || ''; |
1444 |
$publisher = $record->subfield( '260', 'b' ) || ''; |
Lines 1457-1468
sub GetCOinSBiblio {
Link Here
|
1457 |
} |
1447 |
} |
1458 |
|
1448 |
|
1459 |
} |
1449 |
} |
1460 |
my $coins_value = |
|
|
1461 |
"ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3A$mtx$genre$title&rft.isbn=$isbn&rft.issn=$issn&rft.aulast=$aulast&rft.aufirst=$aufirst$oauthors&rft.pub=$publisher&rft.date=$pubyear&rft.pages=$pages"; |
1462 |
$coins_value =~ s/(\ |&[^a])/\+/g; |
1463 |
$coins_value =~ s/\"/\"\;/g; |
1464 |
|
1450 |
|
1465 |
#<!-- TMPL_VAR NAME="ocoins_format" -->&rft.au=<!-- TMPL_VAR NAME="author" -->&rft.btitle=<!-- TMPL_VAR NAME="title" -->&rft.date=<!-- TMPL_VAR NAME="publicationyear" -->&rft.pages=<!-- TMPL_VAR NAME="pages" -->&rft.isbn=<!-- TMPL_VAR NAME=amazonisbn -->&rft.aucorp=&rft.place=<!-- TMPL_VAR NAME="place" -->&rft.pub=<!-- TMPL_VAR NAME="publishercode" -->&rft.edition=<!-- TMPL_VAR NAME="edition" -->&rft.series=<!-- TMPL_VAR NAME="series" -->&rft.genre=" |
1451 |
my @params = ( |
|
|
1452 |
[ 'ctx_ver', 'Z39.88-2004' ], |
1453 |
[ 'rft_val_fmt', "info:ofi/fmt:kev:mtx:$mtx" ], |
1454 |
[ ($mtx eq 'dc' ? 'rft.type' : 'rft.genre'), $genre ], |
1455 |
[ "rft.${titletype}title", $title ], |
1456 |
); |
1457 |
|
1458 |
# rft.title is authorized only once, so by checking $titletype |
1459 |
# we ensure that rft.title is not already in the list. |
1460 |
if ($hosttitle and $titletype) { |
1461 |
push @params, [ 'rft.title', $hosttitle ]; |
1462 |
} |
1463 |
|
1464 |
push @params, ( |
1465 |
[ 'rft.isbn', $isbn ], |
1466 |
[ 'rft.issn', $issn ], |
1467 |
); |
1468 |
|
1469 |
# If it's a subscription, these informations have no meaning. |
1470 |
if ($genre ne 'journal') { |
1471 |
push @params, ( |
1472 |
[ 'rft.aulast', $aulast ], |
1473 |
[ 'rft.aufirst', $aufirst ], |
1474 |
(map { [ 'rft.au', $_ ] } @authors), |
1475 |
[ 'rft.pub', $publisher ], |
1476 |
[ 'rft.date', $pubyear ], |
1477 |
[ 'rft.pages', $pages ], |
1478 |
); |
1479 |
} |
1480 |
|
1481 |
my $coins_value = join( '&', |
1482 |
map { $$_[1] ? $$_[0] . '=' . uri_escape( $$_[1] ) : () } @params ); |
1466 |
|
1483 |
|
1467 |
return $coins_value; |
1484 |
return $coins_value; |
1468 |
} |
1485 |
} |