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