Bug 8071: link between bib and authorities with the authid
Do not automatically populate $9 in bibliographic headings when the $9 is set in the authorized heading field of the authority record. Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com> Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
This commit is contained in:
parent
0acebb8fc6
commit
2ca3663687
|
|
@ -1410,12 +1410,13 @@ sub merge {
|
|||
foreach my $tagfield (@tags_using_authtype){
|
||||
# warn "tagfield : $tagfield ";
|
||||
foreach my $field ($marcrecord->field($tagfield)){
|
||||
# biblio is linked to authority with $9 subfield containing authid
|
||||
my $auth_number=$field->subfield("9");
|
||||
my $tag=$field->tag();
|
||||
if ($auth_number==$mergefrom) {
|
||||
my $field_to=MARC::Field->new(($tag_to?$tag_to:$tag),$field->indicator(1),$field->indicator(2),"9"=>$mergeto);
|
||||
my $exclude='9';
|
||||
foreach my $subfield (@record_to) {
|
||||
foreach my $subfield (grep {$_->[0] ne '9'} @record_to) {
|
||||
$field_to->add_subfields($subfield->[0] =>$subfield->[1]);
|
||||
$exclude.= $subfield->[0];
|
||||
}
|
||||
|
|
|
|||
207
C4/Biblio.pm
207
C4/Biblio.pm
|
|
@ -1682,62 +1682,67 @@ The subjects are stored in different fields depending on MARC flavour
|
|||
|
||||
sub GetMarcSubjects {
|
||||
my ( $record, $marcflavour ) = @_;
|
||||
my ( $mintag, $maxtag );
|
||||
my ( $mintag, $maxtag, $fields_filter );
|
||||
if ( $marcflavour eq "UNIMARC" ) {
|
||||
$mintag = "600";
|
||||
$maxtag = "611";
|
||||
} else { # assume marc21 if not unimarc
|
||||
$fields_filter = '6..';
|
||||
} else { # marc21/normarc
|
||||
$mintag = "600";
|
||||
$maxtag = "699";
|
||||
$fields_filter = '6..';
|
||||
}
|
||||
|
||||
my @marcsubjects;
|
||||
my $subject = "";
|
||||
my $subfield = "";
|
||||
my $marcsubject;
|
||||
|
||||
my $subject_limit = C4::Context->preference("TraceCompleteSubfields") ? 'su,complete-subfield' : 'su';
|
||||
my $authoritysep = C4::Context->preference('authoritysep');
|
||||
|
||||
foreach my $field ( $record->field('6..') ) {
|
||||
next unless $field->tag() >= $mintag && $field->tag() <= $maxtag;
|
||||
foreach my $field ( $record->field($fields_filter) ) {
|
||||
next unless ($field->tag() >= $mintag && $field->tag() <= $maxtag);
|
||||
my @subfields_loop;
|
||||
my @subfields = $field->subfields();
|
||||
my $counter = 0;
|
||||
my @link_loop;
|
||||
|
||||
# if there is an authority link, build the link with an= subfield9
|
||||
my $found9 = 0;
|
||||
# if there is an authority link, build the links with an= subfield9
|
||||
my $subfield9 = $field->subfield('9');
|
||||
if ($subfield9) {
|
||||
my $linkvalue = $subfield9;
|
||||
$linkvalue =~ s/(\(|\))//g;
|
||||
@link_loop = ( { limit => 'an', 'link' => $linkvalue } );
|
||||
}
|
||||
|
||||
# other subfields
|
||||
for my $subject_subfield (@subfields) {
|
||||
next if ( $subject_subfield->[0] eq '9' );
|
||||
|
||||
# don't load unimarc subfields 3,4,5
|
||||
next if ( ( $marcflavour eq "UNIMARC" ) and ( $subject_subfield->[0] =~ /2|3|4|5/ ) );
|
||||
|
||||
# don't load MARC21 subfields 2 (FIXME: any more subfields??)
|
||||
next if ( ( $marcflavour eq "MARC21" ) and ( $subject_subfield->[0] =~ /2/ ) );
|
||||
|
||||
my $code = $subject_subfield->[0];
|
||||
my $value = $subject_subfield->[1];
|
||||
my $linkvalue = $value;
|
||||
$linkvalue =~ s/(\(|\))//g;
|
||||
my $operator;
|
||||
if ( $counter != 0 ) {
|
||||
$operator = ' and ';
|
||||
# if no authority link, build a search query
|
||||
unless ($subfield9) {
|
||||
push @link_loop, {
|
||||
limit => $subject_limit,
|
||||
'link' => $linkvalue,
|
||||
operator => (scalar @link_loop) ? ' and ' : undef
|
||||
};
|
||||
}
|
||||
if ( $code eq 9 ) {
|
||||
$found9 = 1;
|
||||
@link_loop = ( { 'limit' => 'an', link => "$linkvalue" } );
|
||||
}
|
||||
if ( not $found9 ) {
|
||||
push @link_loop, { 'limit' => $subject_limit, link => $linkvalue, operator => $operator };
|
||||
}
|
||||
my $separator;
|
||||
if ( $counter != 0 ) {
|
||||
$separator = C4::Context->preference('authoritysep');
|
||||
}
|
||||
|
||||
# ignore $9
|
||||
my @this_link_loop = @link_loop;
|
||||
push @subfields_loop, { code => $code, value => $value, link_loop => \@this_link_loop, separator => $separator } unless ( $subject_subfield->[0] eq 9 || $subject_subfield->[0] eq '0' );
|
||||
$counter++;
|
||||
# do not display $0
|
||||
unless ( $code eq '0' ) {
|
||||
push @subfields_loop, {
|
||||
code => $code,
|
||||
value => $value,
|
||||
link_loop => \@this_link_loop,
|
||||
separator => (scalar @subfields_loop) ? $authoritysep : ''
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
push @marcsubjects, { MARCSUBJECT_SUBFIELDS_LOOP => \@subfields_loop };
|
||||
|
|
@ -1757,7 +1762,7 @@ The authors are stored in different fields depending on MARC flavour
|
|||
|
||||
sub GetMarcAuthors {
|
||||
my ( $record, $marcflavour ) = @_;
|
||||
my ( $mintag, $maxtag );
|
||||
my ( $mintag, $maxtag, $fields_filter );
|
||||
|
||||
# tagslib useful for UNIMARC author reponsabilities
|
||||
my $tagslib =
|
||||
|
|
@ -1765,15 +1770,17 @@ sub GetMarcAuthors {
|
|||
if ( $marcflavour eq "UNIMARC" ) {
|
||||
$mintag = "700";
|
||||
$maxtag = "712";
|
||||
} elsif ( $marcflavour eq "MARC21" || $marcflavour eq "NORMARC" ) { # assume marc21 or normarc if not unimarc
|
||||
$fields_filter = '7..';
|
||||
} else { # marc21/normarc
|
||||
$mintag = "700";
|
||||
$maxtag = "720";
|
||||
} else {
|
||||
return;
|
||||
$fields_filter = '7..';
|
||||
}
|
||||
my @marcauthors;
|
||||
|
||||
foreach my $field ( $record->fields ) {
|
||||
my @marcauthors;
|
||||
my $authoritysep = C4::Context->preference('authoritysep');
|
||||
|
||||
foreach my $field ( $record->field($fields_filter) ) {
|
||||
next unless $field->tag() >= $mintag && $field->tag() <= $maxtag;
|
||||
my @subfields_loop;
|
||||
my @link_loop;
|
||||
|
|
@ -1782,46 +1789,47 @@ sub GetMarcAuthors {
|
|||
|
||||
# if there is an authority link, build the link with Koha-Auth-Number: subfield9
|
||||
my $subfield9 = $field->subfield('9');
|
||||
if ($subfield9) {
|
||||
my $linkvalue = $subfield9;
|
||||
$linkvalue =~ s/(\(|\))//g;
|
||||
@link_loop = ( { 'limit' => 'an', 'link' => $linkvalue } );
|
||||
}
|
||||
|
||||
# other subfields
|
||||
for my $authors_subfield (@subfields) {
|
||||
next if ( $authors_subfield->[0] eq '9' );
|
||||
|
||||
# don't load unimarc subfields 3, 5
|
||||
next if ( $marcflavour eq 'UNIMARC' and ( $authors_subfield->[0] =~ /3|5/ ) );
|
||||
my $subfieldcode = $authors_subfield->[0];
|
||||
|
||||
my $code = $authors_subfield->[0];
|
||||
my $value = $authors_subfield->[1];
|
||||
my $linkvalue = $value;
|
||||
$linkvalue =~ s/(\(|\))//g;
|
||||
my $operator;
|
||||
if ( $count_auth != 0 ) {
|
||||
$operator = ' and ';
|
||||
# UNIMARC author responsibility
|
||||
if ( $marcflavour eq 'UNIMARC' and $code eq '4' ) {
|
||||
$value = GetAuthorisedValueDesc( $field->tag(), $code, $value, '', $tagslib );
|
||||
$linkvalue = "($value)";
|
||||
}
|
||||
|
||||
# if we have an authority link, use that as the link, otherwise use standard searching
|
||||
if ($subfield9) {
|
||||
@link_loop = ( { 'limit' => 'an', link => "$subfield9" } );
|
||||
} else {
|
||||
|
||||
# reset $linkvalue if UNIMARC author responsibility
|
||||
if ( $marcflavour eq 'UNIMARC' and ( $authors_subfield->[0] eq "4" ) ) {
|
||||
$linkvalue = "(" . GetAuthorisedValueDesc( $field->tag(), $authors_subfield->[0], $authors_subfield->[1], '', $tagslib ) . ")";
|
||||
}
|
||||
push @link_loop, { 'limit' => 'au', link => $linkvalue, operator => $operator };
|
||||
# if no authority link, build a search query
|
||||
unless ($subfield9) {
|
||||
push @link_loop, {
|
||||
limit => 'au',
|
||||
'link' => $linkvalue,
|
||||
operator => (scalar @link_loop) ? ' and ' : undef
|
||||
};
|
||||
}
|
||||
$value = GetAuthorisedValueDesc( $field->tag(), $authors_subfield->[0], $authors_subfield->[1], '', $tagslib )
|
||||
if ( $marcflavour eq 'UNIMARC' and ( $authors_subfield->[0] =~ /4/ ) );
|
||||
my @this_link_loop = @link_loop;
|
||||
my $separator;
|
||||
if ( $count_auth != 0 ) {
|
||||
$separator = C4::Context->preference('authoritysep');
|
||||
# do not display $0
|
||||
unless ( $code eq '0') {
|
||||
push @subfields_loop, {
|
||||
tag => $field->tag(),
|
||||
code => $code,
|
||||
value => $value,
|
||||
link_loop => \@this_link_loop,
|
||||
separator => (scalar @subfields_loop) ? $authoritysep : ''
|
||||
};
|
||||
}
|
||||
push @subfields_loop,
|
||||
{ tag => $field->tag(),
|
||||
code => $subfieldcode,
|
||||
value => $value,
|
||||
link_loop => \@this_link_loop,
|
||||
separator => $separator
|
||||
}
|
||||
unless ( $authors_subfield->[0] eq '9' || $authors_subfield->[0] eq '0');
|
||||
$count_auth++;
|
||||
}
|
||||
push @marcauthors, { MARCAUTHOR_SUBFIELDS_LOOP => \@subfields_loop };
|
||||
}
|
||||
|
|
@ -1894,76 +1902,63 @@ The series are stored in different fields depending on MARC flavour
|
|||
|
||||
sub GetMarcSeries {
|
||||
my ( $record, $marcflavour ) = @_;
|
||||
my ( $mintag, $maxtag );
|
||||
my ( $mintag, $maxtag, $fields_filter );
|
||||
if ( $marcflavour eq "UNIMARC" ) {
|
||||
$mintag = "600";
|
||||
$maxtag = "619";
|
||||
} else { # assume marc21 if not unimarc
|
||||
$fields_filter = '6..';
|
||||
} else { # marc21/normarc
|
||||
$mintag = "440";
|
||||
$maxtag = "490";
|
||||
$fields_filter = '4..';
|
||||
}
|
||||
|
||||
my @marcseries;
|
||||
my $subjct = "";
|
||||
my $subfield = "";
|
||||
my $marcsubjct;
|
||||
my $authoritysep = C4::Context->preference('authoritysep');
|
||||
|
||||
foreach my $field ( $record->field('440'), $record->field('490') ) {
|
||||
foreach my $field ( $record->field($fields_filter) ) {
|
||||
next unless $field->tag() >= $mintag && $field->tag() <= $maxtag;
|
||||
my @subfields_loop;
|
||||
|
||||
#my $value = $field->subfield('a');
|
||||
#$marcsubjct = {MARCSUBJCT => $value,};
|
||||
my @subfields = $field->subfields();
|
||||
|
||||
#warn "subfields:".join " ", @$subfields;
|
||||
my $counter = 0;
|
||||
my @link_loop;
|
||||
|
||||
for my $series_subfield (@subfields) {
|
||||
|
||||
# ignore $9, used for authority link
|
||||
next if ( $series_subfield->[0] eq '9' );
|
||||
|
||||
my $volume_number;
|
||||
undef $volume_number;
|
||||
|
||||
# see if this is an instance of a volume
|
||||
if ( $series_subfield->[0] eq 'v' ) {
|
||||
$volume_number = 1;
|
||||
}
|
||||
|
||||
my $code = $series_subfield->[0];
|
||||
my $value = $series_subfield->[1];
|
||||
my $linkvalue = $value;
|
||||
$linkvalue =~ s/(\(|\))//g;
|
||||
if ( $counter != 0 ) {
|
||||
push @link_loop, { link => $linkvalue, operator => ' and ', };
|
||||
} else {
|
||||
push @link_loop, { link => $linkvalue, operator => undef, };
|
||||
}
|
||||
my $separator;
|
||||
if ( $counter != 0 ) {
|
||||
$separator = C4::Context->preference('authoritysep');
|
||||
|
||||
# see if this is an instance of a volume
|
||||
if ( $code eq 'v' ) {
|
||||
$volume_number = 1;
|
||||
}
|
||||
|
||||
push @link_loop, {
|
||||
'link' => $linkvalue,
|
||||
operator => (scalar @link_loop) ? ' and ' : undef
|
||||
};
|
||||
|
||||
if ($volume_number) {
|
||||
push @subfields_loop, { volumenum => $value };
|
||||
} else {
|
||||
if ( $series_subfield->[0] ne '9' ) {
|
||||
push @subfields_loop, {
|
||||
code => $code,
|
||||
value => $value,
|
||||
link_loop => \@link_loop,
|
||||
separator => $separator,
|
||||
volumenum => $volume_number,
|
||||
};
|
||||
push @subfields_loop, {
|
||||
code => $code,
|
||||
value => $value,
|
||||
link_loop => \@link_loop,
|
||||
separator => (scalar @subfields_loop) ? $authoritysep : '',
|
||||
volumenum => $volume_number,
|
||||
}
|
||||
}
|
||||
$counter++;
|
||||
}
|
||||
push @marcseries, { MARCSERIES_SUBFIELDS_LOOP => \@subfields_loop };
|
||||
|
||||
#$marcsubjct = {MARCSUBJCT => $field->as_string(),};
|
||||
#push @marcsubjcts, $marcsubjct;
|
||||
#$subjct = $value;
|
||||
|
||||
}
|
||||
my $marcseriessarray = \@marcseries;
|
||||
return $marcseriessarray;
|
||||
return \@marcseries;
|
||||
} #end getMARCseriess
|
||||
|
||||
=head2 GetMarcHosts
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@ if ($authid) {
|
|||
# Get all values for each distinct subfield
|
||||
my %subfields;
|
||||
for ( $field->subfields ) {
|
||||
next if $_->[0] == "9"; # $9 will be set with authid value
|
||||
my $letter = $_->[0];
|
||||
next if defined $subfields{$letter};
|
||||
my @values = $field->subfield($letter);
|
||||
|
|
|
|||
|
|
@ -13,24 +13,6 @@
|
|||
}
|
||||
|
||||
var field_start = whichfield.parentNode.parentNode;
|
||||
|
||||
// browse all its subfields (clear and $9)
|
||||
var subfields = field_start.getElementsByTagName('input');
|
||||
var re = /^tag_\d*_code_/;
|
||||
for(var i=0, len = subfields.length ; i< len ; i++) { // browse all subfields
|
||||
if(subfields[i].getAttribute('name').match(re)){ // it s a subfield
|
||||
var code = subfields[i]; // code is the first input
|
||||
var subfield = subfields[i+1]; // subfield the second
|
||||
|
||||
[% IF ( clear ) %]
|
||||
if (subfield){subfield.value="" ;}
|
||||
[% ELSE %]
|
||||
if(code.value=='9'){
|
||||
subfield.value = "[% authid |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]";
|
||||
}
|
||||
[% END %]
|
||||
}
|
||||
}
|
||||
|
||||
// Sets the good number of form fields for the specified subfield
|
||||
// Returns false if the cloning failed
|
||||
|
|
@ -90,6 +72,7 @@
|
|||
});
|
||||
}
|
||||
|
||||
[% UNLESS ( clear ) %]
|
||||
[% FOREACH SUBFIELD_LOO IN SUBFIELD_LOOP %]
|
||||
SetSubfieldValues(
|
||||
"[% tag_number |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %][% SUBFIELD_LOO.marc_subfield |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]"
|
||||
|
|
@ -98,6 +81,26 @@
|
|||
[% END %]
|
||||
);
|
||||
[% END %]
|
||||
[% END %]
|
||||
|
||||
// browse all its subfields (clear and $9)
|
||||
var subfields = field_start.getElementsByTagName('input');
|
||||
var re = /^tag_\d*_code_/;
|
||||
for(var i=0, len = subfields.length ; i< len ; i++) { // browse all subfields
|
||||
if(subfields[i].getAttribute('name').match(re)){ // it s a subfield
|
||||
var code = subfields[i]; // code is the first input
|
||||
var subfield = subfields[i+1]; // subfield the second
|
||||
|
||||
[% IF ( clear ) %]
|
||||
if (subfield){subfield.value="" ;}
|
||||
[% ELSE %]
|
||||
if(code.value=='9'){
|
||||
subfield.value = "[% authid |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]";
|
||||
break;
|
||||
}
|
||||
[% END %]
|
||||
}
|
||||
}
|
||||
|
||||
opener.close();
|
||||
window.close();
|
||||
|
|
|
|||
Loading…
Reference in New Issue