From 41ae12b561ea08817cb6753680a8ce2950a39fcc Mon Sep 17 00:00:00 2001 From: Blou Date: Thu, 26 Sep 2013 15:45:32 -0400 Subject: [PATCH] Bug 6201: Add fields 1xx to marc2bibtex (for MARC21 and NORMARC) Modified Record::marc2bibtex to varlidate fields 100, 110 and 111 in non-UNIMARC flavours. Test plan: 1)Search any books in the OPAC with a main entry (1XX in MARC21, 700-720 in UNIMARC) 2)Export the record in the bibtex format ==>The output won't contain the main entry. 3)Apply the patch 4)Export the record ==>The record will contain the main entry Signed-off-by: Chris Cormack Signed-off-by: Katrin Fischer Fixes a long standing bug. Passes all tests and QA script. Tested with multiple records, seems to work well. Signed-off-by: Katrin Fischer Signed-off-by: Galen Charlton --- C4/Record.pm | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/C4/Record.pm b/C4/Record.pm index be1912c0d8..e727eb40fa 100644 --- a/C4/Record.pm +++ b/C4/Record.pm @@ -652,29 +652,19 @@ sub marc2bibtex { # Authors my $author; my @texauthors; - my ( $mintag, $maxtag, $fields_filter ); - if ( $marcflavour eq "UNIMARC" ) { - $mintag = "700"; - $maxtag = "712"; - $fields_filter = '7..'; - } - else { - $mintag = "700"; - $maxtag = "720"; - $fields_filter = '7..'; - } - foreach my $field ( $record->field($fields_filter) ) { - next unless $field->tag() >= $mintag && $field->tag() <= $maxtag; + my @authorFields = ('100','110','111','700','710','711'); + @authorFields = ('700','701','702','710','711','721') if ( $marcflavour eq "UNIMARC" ); + + foreach my $field ( @authorFields ) { # author formatted surname, firstname my $texauthor = ''; if ( $marcflavour eq "UNIMARC" ) { - $texauthor = join ', ', - ( $field->subfield('a'), $field->subfield('b') ); - } - else { - $texauthor = $field->subfield('a'); - } - push @texauthors, $texauthor if $texauthor; + $texauthor = join ', ', + ( $record->subfield($field,"a"), $record->subfield($field,"b") ); + } else { + $texauthor = $record->subfield($field,"a"); + } + push @texauthors, $texauthor if $texauthor; } $author = join ' and ', @texauthors; @@ -726,7 +716,7 @@ sub marc2bibtex { } $tex .= "\@book{"; - $tex .= join(",\n", $id, map { $bh{$_} ? qq(\t$_ = "$bh{$_}") : () } keys %bh); + $tex .= join(",\n", $id, map { $bh{$_} ? qq(\t$_ = {$bh{$_}}) : () } keys %bh); $tex .= "\n}\n"; return $tex; -- 2.39.5