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 1301-1348
sub GetCOinSBiblio {
Link Here
|
1301 |
my $record = shift; |
1302 |
my $record = shift; |
1302 |
|
1303 |
|
1303 |
# get the coin format |
1304 |
# get the coin format |
1304 |
if ( ! $record ) { |
1305 |
return unless ( $record ); |
1305 |
return; |
1306 |
|
1306 |
} |
|
|
1307 |
my $pos7 = substr $record->leader(), 7, 1; |
1307 |
my $pos7 = substr $record->leader(), 7, 1; |
1308 |
my $pos6 = substr $record->leader(), 6, 1; |
1308 |
my $pos6 = substr $record->leader(), 6, 1; |
1309 |
my $mtx; |
1309 |
my $mtx; |
1310 |
my $genre; |
1310 |
my $genre; |
1311 |
my ( $aulast, $aufirst ) = ( '', '' ); |
1311 |
my ( $aulast, $aufirst ) = ( '', '' ); |
1312 |
my $oauthors = ''; |
1312 |
my @authors; |
1313 |
my $title = ''; |
1313 |
my $title; |
1314 |
my $subtitle = ''; |
1314 |
my $hosttitle; |
1315 |
my $pubyear = ''; |
1315 |
my $pubyear = ''; |
1316 |
my $isbn = ''; |
1316 |
my $isbn = ''; |
1317 |
my $issn = ''; |
1317 |
my $issn = ''; |
1318 |
my $publisher = ''; |
1318 |
my $publisher = ''; |
1319 |
my $pages = ''; |
1319 |
my $pages = ''; |
1320 |
my $titletype = 'b'; |
1320 |
my $titletype = ''; |
1321 |
|
1321 |
|
1322 |
# For the purposes of generating COinS metadata, LDR/06-07 can be |
1322 |
# For the purposes of generating COinS metadata, LDR/06-07 can be |
1323 |
# considered the same for UNIMARC and MARC21 |
1323 |
# considered the same for UNIMARC and MARC21 |
1324 |
my $fmts6; |
1324 |
my $fmts6 = { |
1325 |
my $fmts7; |
1325 |
'a' => 'book', |
1326 |
%$fmts6 = ( |
1326 |
'b' => 'manuscript', |
1327 |
'a' => 'book', |
1327 |
'c' => 'book', |
1328 |
'b' => 'manuscript', |
1328 |
'd' => 'manuscript', |
1329 |
'c' => 'book', |
1329 |
'e' => 'map', |
1330 |
'd' => 'manuscript', |
1330 |
'f' => 'map', |
1331 |
'e' => 'map', |
1331 |
'g' => 'film', |
1332 |
'f' => 'map', |
1332 |
'i' => 'audioRecording', |
1333 |
'g' => 'film', |
1333 |
'j' => 'audioRecording', |
1334 |
'i' => 'audioRecording', |
1334 |
'k' => 'artwork', |
1335 |
'j' => 'audioRecording', |
1335 |
'l' => 'document', |
1336 |
'k' => 'artwork', |
1336 |
'm' => 'computerProgram', |
1337 |
'l' => 'document', |
1337 |
'o' => 'document', |
1338 |
'm' => 'computerProgram', |
1338 |
'r' => 'document', |
1339 |
'o' => 'document', |
1339 |
}; |
1340 |
'r' => 'document', |
1340 |
my $fmts7 = { |
1341 |
); |
1341 |
'a' => 'journalArticle', |
1342 |
%$fmts7 = ( |
1342 |
's' => 'journal', |
1343 |
'a' => 'journalArticle', |
1343 |
}; |
1344 |
's' => 'journal', |
|
|
1345 |
); |
1346 |
|
1344 |
|
1347 |
$genre = $fmts6->{$pos6} ? $fmts6->{$pos6} : 'book'; |
1345 |
$genre = $fmts6->{$pos6} ? $fmts6->{$pos6} : 'book'; |
1348 |
|
1346 |
|
Lines 1353-1358
sub GetCOinSBiblio {
Link Here
|
1353 |
##### We must transform mtx to a valable mtx and document type #### |
1351 |
##### We must transform mtx to a valable mtx and document type #### |
1354 |
if ( $genre eq 'book' ) { |
1352 |
if ( $genre eq 'book' ) { |
1355 |
$mtx = 'book'; |
1353 |
$mtx = 'book'; |
|
|
1354 |
$titletype = 'b'; |
1356 |
} elsif ( $genre eq 'journal' ) { |
1355 |
} elsif ( $genre eq 'journal' ) { |
1357 |
$mtx = 'journal'; |
1356 |
$mtx = 'journal'; |
1358 |
$titletype = 'j'; |
1357 |
$titletype = 'j'; |
Lines 1364-1389
sub GetCOinSBiblio {
Link Here
|
1364 |
$mtx = 'dc'; |
1363 |
$mtx = 'dc'; |
1365 |
} |
1364 |
} |
1366 |
|
1365 |
|
1367 |
$genre = ( $mtx eq 'dc' ) ? "&rft.type=$genre" : "&rft.genre=$genre"; |
|
|
1368 |
|
1369 |
if ( C4::Context->preference("marcflavour") eq "UNIMARC" ) { |
1366 |
if ( C4::Context->preference("marcflavour") eq "UNIMARC" ) { |
1370 |
|
1367 |
|
1371 |
# Setting datas |
1368 |
# Setting datas |
1372 |
$aulast = $record->subfield( '700', 'a' ) || ''; |
1369 |
$aulast = $record->subfield( '700', 'a' ) || ''; |
1373 |
$aufirst = $record->subfield( '700', 'b' ) || ''; |
1370 |
$aufirst = $record->subfield( '700', 'b' ) || ''; |
1374 |
$oauthors = "&rft.au=$aufirst $aulast"; |
1371 |
push @authors, "$aufirst $aulast" if ($aufirst or $aulast); |
1375 |
|
1372 |
|
1376 |
# others authors |
1373 |
# others authors |
1377 |
if ( $record->field('200') ) { |
1374 |
if ( $record->field('200') ) { |
1378 |
for my $au ( $record->field('200')->subfield('g') ) { |
1375 |
for my $au ( $record->field('200')->subfield('g') ) { |
1379 |
$oauthors .= "&rft.au=$au"; |
1376 |
push @authors, $au; |
1380 |
} |
1377 |
} |
1381 |
} |
1378 |
} |
1382 |
$title = |
1379 |
|
1383 |
( $mtx eq 'dc' ) |
1380 |
$title = $record->subfield( '200', 'a' ); |
1384 |
? "&rft.title=" . $record->subfield( '200', 'a' ) |
1381 |
my $subfield_210d = $record->subfield('210', 'd'); |
1385 |
: "&rft.title=" . $record->subfield( '200', 'a' ) . "&rft.btitle=" . $record->subfield( '200', 'a' ); |
1382 |
if ($subfield_210d and $subfield_210d =~ /(\d{4})/) { |
1386 |
$pubyear = $record->subfield( '210', 'd' ) || ''; |
1383 |
$pubyear = $1; |
|
|
1384 |
} |
1387 |
$publisher = $record->subfield( '210', 'c' ) || ''; |
1385 |
$publisher = $record->subfield( '210', 'c' ) || ''; |
1388 |
$isbn = $record->subfield( '010', 'a' ) || ''; |
1386 |
$isbn = $record->subfield( '010', 'a' ) || ''; |
1389 |
$issn = $record->subfield( '011', 'a' ) || ''; |
1387 |
$issn = $record->subfield( '011', 'a' ) || ''; |
Lines 1393-1426
sub GetCOinSBiblio {
Link Here
|
1393 |
|
1391 |
|
1394 |
# Setting datas |
1392 |
# Setting datas |
1395 |
if ( $record->field('100') ) { |
1393 |
if ( $record->field('100') ) { |
1396 |
$oauthors .= "&rft.au=" . $record->subfield( '100', 'a' ); |
1394 |
push @authors, $record->subfield( '100', 'a' ); |
1397 |
} |
1395 |
} |
1398 |
|
1396 |
|
1399 |
# others authors |
1397 |
# others authors |
1400 |
if ( $record->field('700') ) { |
1398 |
if ( $record->field('700') ) { |
1401 |
for my $au ( $record->field('700')->subfield('a') ) { |
1399 |
for my $au ( $record->field('700')->subfield('a') ) { |
1402 |
$oauthors .= "&rft.au=$au"; |
1400 |
push @authors, $au; |
1403 |
} |
1401 |
} |
1404 |
} |
1402 |
} |
1405 |
$title = "&rft." . $titletype . "title=" . $record->subfield( '245', 'a' ); |
1403 |
$title = $record->subfield( '245', 'a' ) . $record->subfield( '245', 'b' ); |
1406 |
$subtitle = $record->subfield( '245', 'b' ) || ''; |
|
|
1407 |
$title .= $subtitle; |
1408 |
if ($titletype eq 'a') { |
1404 |
if ($titletype eq 'a') { |
1409 |
$pubyear = $record->field('008') || ''; |
1405 |
$pubyear = $record->field('008') || ''; |
1410 |
$pubyear = substr($pubyear->data(), 7, 4) if $pubyear; |
1406 |
$pubyear = substr($pubyear->data(), 7, 4) if $pubyear; |
1411 |
$isbn = $record->subfield( '773', 'z' ) || ''; |
1407 |
$isbn = $record->subfield( '773', 'z' ) || ''; |
1412 |
$issn = $record->subfield( '773', 'x' ) || ''; |
1408 |
$issn = $record->subfield( '773', 'x' ) || ''; |
1413 |
if ($mtx eq 'journal') { |
1409 |
$hosttitle = $record->subfield( '773', 't' ) || $record->subfield( '773', 'a'); |
1414 |
$title .= "&rft.title=" . (($record->subfield( '773', 't' ) || $record->subfield( '773', 'a'))); |
1410 |
my @rels = $record->subfield( '773', 'g' ); |
1415 |
} else { |
1411 |
$pages = join(', ', @rels); |
1416 |
$title .= "&rft.btitle=" . (($record->subfield( '773', 't' ) || $record->subfield( '773', 'a')) || ''); |
|
|
1417 |
} |
1418 |
foreach my $rel ($record->subfield( '773', 'g' )) { |
1419 |
if ($pages) { |
1420 |
$pages .= ', '; |
1421 |
} |
1422 |
$pages .= $rel; |
1423 |
} |
1424 |
} else { |
1412 |
} else { |
1425 |
$pubyear = $record->subfield( '260', 'c' ) || ''; |
1413 |
$pubyear = $record->subfield( '260', 'c' ) || ''; |
1426 |
$publisher = $record->subfield( '260', 'b' ) || ''; |
1414 |
$publisher = $record->subfield( '260', 'b' ) || ''; |
Lines 1429-1440
sub GetCOinSBiblio {
Link Here
|
1429 |
} |
1417 |
} |
1430 |
|
1418 |
|
1431 |
} |
1419 |
} |
1432 |
my $coins_value = |
|
|
1433 |
"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"; |
1434 |
$coins_value =~ s/(\ |&[^a])/\+/g; |
1435 |
$coins_value =~ s/\"/\"\;/g; |
1436 |
|
1420 |
|
1437 |
#<!-- 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=" |
1421 |
my @params = ( |
|
|
1422 |
[ 'ctx_ver', 'Z39.88-2004' ], |
1423 |
[ 'rft_val_fmt', "info:ofi/fmt:kev:mtx:$mtx" ], |
1424 |
[ ($mtx eq 'dc' ? 'rft.type' : 'rft.genre'), $genre ], |
1425 |
[ "rft.${titletype}title", $title ], |
1426 |
); |
1427 |
|
1428 |
# rft.title is authorized only once, so by checking $titletype |
1429 |
# we ensure that rft.title is not already in the list. |
1430 |
if ($hosttitle and $titletype) { |
1431 |
push @params, [ 'rft.title', $hosttitle ]; |
1432 |
} |
1433 |
|
1434 |
push @params, ( |
1435 |
[ 'rft.isbn', $isbn ], |
1436 |
[ 'rft.issn', $issn ], |
1437 |
); |
1438 |
|
1439 |
# If it's a subscription, these informations have no meaning. |
1440 |
if ($genre ne 'journal') { |
1441 |
push @params, ( |
1442 |
[ 'rft.aulast', $aulast ], |
1443 |
[ 'rft.aufirst', $aufirst ], |
1444 |
(map { [ 'rft.au', $_ ] } @authors), |
1445 |
[ 'rft.pub', $publisher ], |
1446 |
[ 'rft.date', $pubyear ], |
1447 |
[ 'rft.pages', $pages ], |
1448 |
); |
1449 |
} |
1450 |
|
1451 |
my $coins_value = join( '&', |
1452 |
map { $$_[1] ? $$_[0] . '=' . uri_escape( $$_[1] ) : () } @params ); |
1438 |
|
1453 |
|
1439 |
return $coins_value; |
1454 |
return $coins_value; |
1440 |
} |
1455 |
} |