Bug 34481: Tidy altered code
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
parent
cb085034ff
commit
52f94659c1
3 changed files with 53 additions and 41 deletions
|
@ -86,13 +86,13 @@ include in facets, sorting, or suggestion fields)
|
|||
|
||||
=cut
|
||||
sub fields {
|
||||
my ($self, $record) = @_;
|
||||
my ( $self, $record ) = @_;
|
||||
|
||||
my $params = $self->params;
|
||||
my $other_headings = $params->{options}->{other_headings} || [ 'see_from' ];
|
||||
my $params = $self->params;
|
||||
my $other_headings = $params->{options}->{other_headings} || ['see_from'];
|
||||
|
||||
my @auth_others;
|
||||
foreach my $other_heading ( @$other_headings ) {
|
||||
foreach my $other_heading (@$other_headings) {
|
||||
if ( $other_heading eq 'see_from' ) {
|
||||
push @auth_others, '4..';
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ sub fields {
|
|||
}
|
||||
}
|
||||
|
||||
my ($item_tag) = GetMarcFromKohaField( "items.itemnumber" );
|
||||
my ($item_tag) = GetMarcFromKohaField("items.itemnumber");
|
||||
$item_tag ||= '';
|
||||
|
||||
my @newfields;
|
||||
|
@ -114,21 +114,23 @@ sub fields {
|
|||
|
||||
my $authority = Koha::MetadataRecord::Authority->get_from_authid($authid);
|
||||
next unless $authority;
|
||||
my $auth_marc = $authority->record;
|
||||
my $auth_marc = $authority->record;
|
||||
my @authfields = $auth_marc->field(@auth_others);
|
||||
foreach my $authfield (@authfields) {
|
||||
my $tag = substr($field->tag(), 0, 1) . substr($authfield->tag(), 1, 2);
|
||||
my $tag = substr( $field->tag(), 0, 1 ) . substr( $authfield->tag(), 1, 2 );
|
||||
next if MARC::Field->is_controlfield_tag($tag);
|
||||
my $newfield = MARC::Field->new($tag,
|
||||
'z',
|
||||
$authfield->indicator(2) || ' ',
|
||||
'9' => '1');
|
||||
foreach my $sub ($authfield->subfields()) {
|
||||
my ($code,$val) = @$sub;
|
||||
my $newfield = MARC::Field->new(
|
||||
$tag,
|
||||
'z',
|
||||
$authfield->indicator(2) || ' ',
|
||||
'9' => '1'
|
||||
);
|
||||
foreach my $sub ( $authfield->subfields() ) {
|
||||
my ( $code, $val ) = @$sub;
|
||||
$newfield->add_subfields( $code => $val );
|
||||
}
|
||||
$newfield->delete_subfield( code => '9' );
|
||||
push @newfields, $newfield if (scalar($newfield->subfields()) > 0);
|
||||
push @newfields, $newfield if ( scalar( $newfield->subfields() ) > 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -664,7 +664,12 @@ sub marc_records_to_documents {
|
|||
}
|
||||
}
|
||||
|
||||
if ( $self->index eq $BIBLIOS_INDEX and ( C4::Context->preference('IncludeSeeFromInSearches') || C4::Context->preference('IncludeSeeAlsoFromInSearches') ) ) {
|
||||
if (
|
||||
$self->index eq $BIBLIOS_INDEX
|
||||
and ( C4::Context->preference('IncludeSeeFromInSearches')
|
||||
|| C4::Context->preference('IncludeSeeAlsoFromInSearches') )
|
||||
)
|
||||
{
|
||||
my $marc_filter = Koha::Filter::MARC::EmbedSeeFromHeadings->new;
|
||||
my @other_headings;
|
||||
if ( C4::Context->preference('IncludeSeeFromInSearches') ) {
|
||||
|
@ -673,30 +678,29 @@ sub marc_records_to_documents {
|
|||
if ( C4::Context->preference('IncludeSeeAlsoFromInSearches') ) {
|
||||
push @other_headings, 'see_also_from';
|
||||
}
|
||||
$marc_filter->initialize(
|
||||
{
|
||||
options => {
|
||||
other_headings => \@other_headings
|
||||
}
|
||||
}
|
||||
);
|
||||
foreach my $field ($marc_filter->fields($record)) {
|
||||
my $data_field_rules = $data_fields_rules->{$field->tag()};
|
||||
$marc_filter->initialize( { options => { other_headings => \@other_headings } } );
|
||||
foreach my $field ( $marc_filter->fields($record) ) {
|
||||
my $data_field_rules = $data_fields_rules->{ $field->tag() };
|
||||
if ($data_field_rules) {
|
||||
my $subfields_mappings = $data_field_rules->{subfields};
|
||||
my $wildcard_mappings = $subfields_mappings->{'*'};
|
||||
foreach my $subfield ($field->subfields()) {
|
||||
my ($code, $data) = @{$subfield};
|
||||
my $wildcard_mappings = $subfields_mappings->{'*'};
|
||||
foreach my $subfield ( $field->subfields() ) {
|
||||
my ( $code, $data ) = @{$subfield};
|
||||
my @mappings;
|
||||
push @mappings, @{ $subfields_mappings->{$code} } if $subfields_mappings->{$code};
|
||||
push @mappings, @$wildcard_mappings if $wildcard_mappings;
|
||||
push @mappings, @$wildcard_mappings if $wildcard_mappings;
|
||||
|
||||
# Do not include "see from" into these kind of fields
|
||||
@mappings = grep { $_->[0] !~ /__(sort|facet|suggestion)$/ } @mappings;
|
||||
if (@mappings) {
|
||||
$self->_process_mappings(\@mappings, $data, $record_document, {
|
||||
$self->_process_mappings(
|
||||
\@mappings,
|
||||
$data,
|
||||
$record_document,
|
||||
{
|
||||
data_source => 'subfield',
|
||||
code => $code,
|
||||
field => $field
|
||||
code => $code,
|
||||
field => $field
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -704,19 +708,25 @@ sub marc_records_to_documents {
|
|||
|
||||
my $subfields_join_mappings = $data_field_rules->{subfields_join};
|
||||
if ($subfields_join_mappings) {
|
||||
foreach my $subfields_group (keys %{$subfields_join_mappings}) {
|
||||
foreach my $subfields_group ( keys %{$subfields_join_mappings} ) {
|
||||
my $data_field = $field->clone;
|
||||
|
||||
# remove empty subfields, otherwise they are printed as a space
|
||||
$data_field->delete_subfield(match => qr/^$/);
|
||||
my $data = $data_field->as_string( $subfields_group );
|
||||
$data_field->delete_subfield( match => qr/^$/ );
|
||||
my $data = $data_field->as_string($subfields_group);
|
||||
if ($data) {
|
||||
my @mappings = @{ $subfields_join_mappings->{$subfields_group} };
|
||||
|
||||
# Do not include "see from" into these kind of fields
|
||||
@mappings = grep { $_->[0] !~ /__(sort|facet|suggestion)$/ } @mappings;
|
||||
$self->_process_mappings(\@mappings, $data, $record_document, {
|
||||
$self->_process_mappings(
|
||||
\@mappings,
|
||||
$data,
|
||||
$record_document,
|
||||
{
|
||||
data_source => 'subfields_group',
|
||||
codes => $subfields_group,
|
||||
field => $field
|
||||
codes => $subfields_group,
|
||||
field => $field
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -662,7 +662,9 @@ sub get_corrected_marc_record {
|
|||
my @filters;
|
||||
my @other_headings;
|
||||
push @filters, 'EmbedItemsAvailability';
|
||||
if ( C4::Context->preference('IncludeSeeFromInSearches') || C4::Context->preference('IncludeSeeAlsoFromInSearches') ){
|
||||
if ( C4::Context->preference('IncludeSeeFromInSearches')
|
||||
|| C4::Context->preference('IncludeSeeAlsoFromInSearches') )
|
||||
{
|
||||
push @filters, 'EmbedSeeFromHeadings';
|
||||
if ( C4::Context->preference('IncludeSeeFromInSearches') ) {
|
||||
push @other_headings, 'see_from';
|
||||
|
@ -675,9 +677,7 @@ sub get_corrected_marc_record {
|
|||
my $normalizer = Koha::RecordProcessor->new(
|
||||
{
|
||||
filters => \@filters,
|
||||
options => {
|
||||
other_headings => \@other_headings
|
||||
}
|
||||
options => { other_headings => \@other_headings }
|
||||
}
|
||||
);
|
||||
$marc = $normalizer->process($marc);
|
||||
|
|
Loading…
Reference in a new issue