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