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::Log; # logaction |
35 |
use C4::Log; # logaction |
Lines 1385-1429
sub GetCOinSBiblio {
Link Here
|
1385 |
carp 'GetCOinSBiblio called with undefined record'; |
1386 |
carp 'GetCOinSBiblio called with undefined record'; |
1386 |
return; |
1387 |
return; |
1387 |
} |
1388 |
} |
|
|
1389 |
|
1388 |
my $pos7 = substr $record->leader(), 7, 1; |
1390 |
my $pos7 = substr $record->leader(), 7, 1; |
1389 |
my $pos6 = substr $record->leader(), 6, 1; |
1391 |
my $pos6 = substr $record->leader(), 6, 1; |
1390 |
my $mtx; |
1392 |
my $mtx; |
1391 |
my $genre; |
1393 |
my $genre; |
1392 |
my ( $aulast, $aufirst ) = ( '', '' ); |
1394 |
my ( $aulast, $aufirst ) = ( '', '' ); |
1393 |
my $oauthors = ''; |
1395 |
my @authors; |
1394 |
my $title = ''; |
1396 |
my $title; |
1395 |
my $subtitle = ''; |
1397 |
my $hosttitle; |
1396 |
my $pubyear = ''; |
1398 |
my $pubyear = ''; |
1397 |
my $isbn = ''; |
1399 |
my $isbn = ''; |
1398 |
my $issn = ''; |
1400 |
my $issn = ''; |
1399 |
my $publisher = ''; |
1401 |
my $publisher = ''; |
1400 |
my $pages = ''; |
1402 |
my $pages = ''; |
1401 |
my $titletype = 'b'; |
1403 |
my $titletype = ''; |
1402 |
|
1404 |
|
1403 |
# For the purposes of generating COinS metadata, LDR/06-07 can be |
1405 |
# For the purposes of generating COinS metadata, LDR/06-07 can be |
1404 |
# considered the same for UNIMARC and MARC21 |
1406 |
# considered the same for UNIMARC and MARC21 |
1405 |
my $fmts6; |
1407 |
my $fmts6 = { |
1406 |
my $fmts7; |
1408 |
'a' => 'book', |
1407 |
%$fmts6 = ( |
1409 |
'b' => 'manuscript', |
1408 |
'a' => 'book', |
1410 |
'c' => 'book', |
1409 |
'b' => 'manuscript', |
1411 |
'd' => 'manuscript', |
1410 |
'c' => 'book', |
1412 |
'e' => 'map', |
1411 |
'd' => 'manuscript', |
1413 |
'f' => 'map', |
1412 |
'e' => 'map', |
1414 |
'g' => 'film', |
1413 |
'f' => 'map', |
1415 |
'i' => 'audioRecording', |
1414 |
'g' => 'film', |
1416 |
'j' => 'audioRecording', |
1415 |
'i' => 'audioRecording', |
1417 |
'k' => 'artwork', |
1416 |
'j' => 'audioRecording', |
1418 |
'l' => 'document', |
1417 |
'k' => 'artwork', |
1419 |
'm' => 'computerProgram', |
1418 |
'l' => 'document', |
1420 |
'o' => 'document', |
1419 |
'm' => 'computerProgram', |
1421 |
'r' => 'document', |
1420 |
'o' => 'document', |
1422 |
}; |
1421 |
'r' => 'document', |
1423 |
my $fmts7 = { |
1422 |
); |
1424 |
'a' => 'journalArticle', |
1423 |
%$fmts7 = ( |
1425 |
's' => 'journal', |
1424 |
'a' => 'journalArticle', |
1426 |
}; |
1425 |
's' => 'journal', |
|
|
1426 |
); |
1427 |
|
1427 |
|
1428 |
$genre = $fmts6->{$pos6} ? $fmts6->{$pos6} : 'book'; |
1428 |
$genre = $fmts6->{$pos6} ? $fmts6->{$pos6} : 'book'; |
1429 |
|
1429 |
|
Lines 1434-1439
sub GetCOinSBiblio {
Link Here
|
1434 |
##### We must transform mtx to a valable mtx and document type #### |
1434 |
##### We must transform mtx to a valable mtx and document type #### |
1435 |
if ( $genre eq 'book' ) { |
1435 |
if ( $genre eq 'book' ) { |
1436 |
$mtx = 'book'; |
1436 |
$mtx = 'book'; |
|
|
1437 |
$titletype = 'b'; |
1437 |
} elsif ( $genre eq 'journal' ) { |
1438 |
} elsif ( $genre eq 'journal' ) { |
1438 |
$mtx = 'journal'; |
1439 |
$mtx = 'journal'; |
1439 |
$titletype = 'j'; |
1440 |
$titletype = 'j'; |
Lines 1445-1470
sub GetCOinSBiblio {
Link Here
|
1445 |
$mtx = 'dc'; |
1446 |
$mtx = 'dc'; |
1446 |
} |
1447 |
} |
1447 |
|
1448 |
|
1448 |
$genre = ( $mtx eq 'dc' ) ? "&rft.type=$genre" : "&rft.genre=$genre"; |
|
|
1449 |
|
1450 |
if ( C4::Context->preference("marcflavour") eq "UNIMARC" ) { |
1449 |
if ( C4::Context->preference("marcflavour") eq "UNIMARC" ) { |
1451 |
|
1450 |
|
1452 |
# Setting datas |
1451 |
# Setting datas |
1453 |
$aulast = $record->subfield( '700', 'a' ) || ''; |
1452 |
$aulast = $record->subfield( '700', 'a' ) || ''; |
1454 |
$aufirst = $record->subfield( '700', 'b' ) || ''; |
1453 |
$aufirst = $record->subfield( '700', 'b' ) || ''; |
1455 |
$oauthors = "&rft.au=$aufirst $aulast"; |
1454 |
push @authors, "$aufirst $aulast" if ($aufirst or $aulast); |
1456 |
|
1455 |
|
1457 |
# others authors |
1456 |
# others authors |
1458 |
if ( $record->field('200') ) { |
1457 |
if ( $record->field('200') ) { |
1459 |
for my $au ( $record->field('200')->subfield('g') ) { |
1458 |
for my $au ( $record->field('200')->subfield('g') ) { |
1460 |
$oauthors .= "&rft.au=$au"; |
1459 |
push @authors, $au; |
1461 |
} |
1460 |
} |
1462 |
} |
1461 |
} |
1463 |
$title = |
1462 |
|
1464 |
( $mtx eq 'dc' ) |
1463 |
$title = $record->subfield( '200', 'a' ); |
1465 |
? "&rft.title=" . $record->subfield( '200', 'a' ) |
1464 |
my $subfield_210d = $record->subfield('210', 'd'); |
1466 |
: "&rft.title=" . $record->subfield( '200', 'a' ) . "&rft.btitle=" . $record->subfield( '200', 'a' ); |
1465 |
if ($subfield_210d and $subfield_210d =~ /(\d{4})/) { |
1467 |
$pubyear = $record->subfield( '210', 'd' ) || ''; |
1466 |
$pubyear = $1; |
|
|
1467 |
} |
1468 |
$publisher = $record->subfield( '210', 'c' ) || ''; |
1468 |
$publisher = $record->subfield( '210', 'c' ) || ''; |
1469 |
$isbn = $record->subfield( '010', 'a' ) || ''; |
1469 |
$isbn = $record->subfield( '010', 'a' ) || ''; |
1470 |
$issn = $record->subfield( '011', 'a' ) || ''; |
1470 |
$issn = $record->subfield( '011', 'a' ) || ''; |
Lines 1474-1507
sub GetCOinSBiblio {
Link Here
|
1474 |
|
1474 |
|
1475 |
# Setting datas |
1475 |
# Setting datas |
1476 |
if ( $record->field('100') ) { |
1476 |
if ( $record->field('100') ) { |
1477 |
$oauthors .= "&rft.au=" . $record->subfield( '100', 'a' ); |
1477 |
push @authors, $record->subfield( '100', 'a' ); |
1478 |
} |
1478 |
} |
1479 |
|
1479 |
|
1480 |
# others authors |
1480 |
# others authors |
1481 |
if ( $record->field('700') ) { |
1481 |
if ( $record->field('700') ) { |
1482 |
for my $au ( $record->field('700')->subfield('a') ) { |
1482 |
for my $au ( $record->field('700')->subfield('a') ) { |
1483 |
$oauthors .= "&rft.au=$au"; |
1483 |
push @authors, $au; |
1484 |
} |
1484 |
} |
1485 |
} |
1485 |
} |
1486 |
$title = "&rft." . $titletype . "title=" . $record->subfield( '245', 'a' ); |
1486 |
$title = $record->subfield( '245', 'a' ) . $record->subfield( '245', 'b' ); |
1487 |
$subtitle = $record->subfield( '245', 'b' ) || ''; |
|
|
1488 |
$title .= $subtitle; |
1489 |
if ($titletype eq 'a') { |
1487 |
if ($titletype eq 'a') { |
1490 |
$pubyear = $record->field('008') || ''; |
1488 |
$pubyear = $record->field('008') || ''; |
1491 |
$pubyear = substr($pubyear->data(), 7, 4) if $pubyear; |
1489 |
$pubyear = substr($pubyear->data(), 7, 4) if $pubyear; |
1492 |
$isbn = $record->subfield( '773', 'z' ) || ''; |
1490 |
$isbn = $record->subfield( '773', 'z' ) || ''; |
1493 |
$issn = $record->subfield( '773', 'x' ) || ''; |
1491 |
$issn = $record->subfield( '773', 'x' ) || ''; |
1494 |
if ($mtx eq 'journal') { |
1492 |
$hosttitle = $record->subfield( '773', 't' ) || $record->subfield( '773', 'a'); |
1495 |
$title .= "&rft.title=" . (($record->subfield( '773', 't' ) || $record->subfield( '773', 'a'))); |
1493 |
my @rels = $record->subfield( '773', 'g' ); |
1496 |
} else { |
1494 |
$pages = join(', ', @rels); |
1497 |
$title .= "&rft.btitle=" . (($record->subfield( '773', 't' ) || $record->subfield( '773', 'a')) || ''); |
|
|
1498 |
} |
1499 |
foreach my $rel ($record->subfield( '773', 'g' )) { |
1500 |
if ($pages) { |
1501 |
$pages .= ', '; |
1502 |
} |
1503 |
$pages .= $rel; |
1504 |
} |
1505 |
} else { |
1495 |
} else { |
1506 |
$pubyear = $record->subfield( '260', 'c' ) || ''; |
1496 |
$pubyear = $record->subfield( '260', 'c' ) || ''; |
1507 |
$publisher = $record->subfield( '260', 'b' ) || ''; |
1497 |
$publisher = $record->subfield( '260', 'b' ) || ''; |
Lines 1510-1521
sub GetCOinSBiblio {
Link Here
|
1510 |
} |
1500 |
} |
1511 |
|
1501 |
|
1512 |
} |
1502 |
} |
1513 |
my $coins_value = |
|
|
1514 |
"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"; |
1515 |
$coins_value =~ s/(\ |&[^a])/\+/g; |
1516 |
$coins_value =~ s/\"/\"\;/g; |
1517 |
|
1503 |
|
1518 |
#<!-- 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=" |
1504 |
my @params = ( |
|
|
1505 |
[ 'ctx_ver', 'Z39.88-2004' ], |
1506 |
[ 'rft_val_fmt', "info:ofi/fmt:kev:mtx:$mtx" ], |
1507 |
[ ($mtx eq 'dc' ? 'rft.type' : 'rft.genre'), $genre ], |
1508 |
[ "rft.${titletype}title", $title ], |
1509 |
); |
1510 |
|
1511 |
# rft.title is authorized only once, so by checking $titletype |
1512 |
# we ensure that rft.title is not already in the list. |
1513 |
if ($hosttitle and $titletype) { |
1514 |
push @params, [ 'rft.title', $hosttitle ]; |
1515 |
} |
1516 |
|
1517 |
push @params, ( |
1518 |
[ 'rft.isbn', $isbn ], |
1519 |
[ 'rft.issn', $issn ], |
1520 |
); |
1521 |
|
1522 |
# If it's a subscription, these informations have no meaning. |
1523 |
if ($genre ne 'journal') { |
1524 |
push @params, ( |
1525 |
[ 'rft.aulast', $aulast ], |
1526 |
[ 'rft.aufirst', $aufirst ], |
1527 |
(map { [ 'rft.au', $_ ] } @authors), |
1528 |
[ 'rft.pub', $publisher ], |
1529 |
[ 'rft.date', $pubyear ], |
1530 |
[ 'rft.pages', $pages ], |
1531 |
); |
1532 |
} |
1533 |
|
1534 |
my $coins_value = join( '&', |
1535 |
map { $$_[1] ? $$_[0] . '=' . uri_escape_utf8( $$_[1] ) : () } @params ); |
1519 |
|
1536 |
|
1520 |
return $coins_value; |
1537 |
return $coins_value; |
1521 |
} |
1538 |
} |