View | Details | Raw Unified | Return to bug 35099
Collapse All | Expand All

(-)a/Koha/Biblio.pm (-15 / +23 lines)
Lines 669-680 Returns a query which can be used to search for all component parts of MARC21 bi Link Here
669
sub get_components_query {
669
sub get_components_query {
670
    my ($self) = @_;
670
    my ($self) = @_;
671
671
672
    my $builder = Koha::SearchEngine::QueryBuilder->new(
672
    # MARC21 Only for now
673
        { index => $Koha::SearchEngine::BIBLIOS_INDEX } );
673
    return if ( C4::Context->preference('marcflavour') ne 'MARC21' );
674
    my $marc = $self->metadata->record;
674
675
    # If the marc cannot be loaded, do not build the query
676
    # the staff interface should already be displaying an error message in this case
677
    # so we don't need to return the error
678
    my $marc;
679
    eval { $marc = $self->metadata->record };
680
    return unless $marc;
681
682
    my $builder              = Koha::SearchEngine::QueryBuilder->new( { index => $Koha::SearchEngine::BIBLIOS_INDEX } );
675
    my $component_sort_field = C4::Context->preference('ComponentSortField') // "title";
683
    my $component_sort_field = C4::Context->preference('ComponentSortField') // "title";
676
    my $component_sort_order = C4::Context->preference('ComponentSortOrder') // "asc";
684
    my $component_sort_order = C4::Context->preference('ComponentSortOrder') // "asc";
677
    my $sort = $component_sort_field . "_" . $component_sort_order;
685
    my $sort                 = $component_sort_field . "_" . $component_sort_order;
678
686
679
    my $searchstr;
687
    my $searchstr;
680
    if ( C4::Context->preference('UseControlNumber') ) {
688
    if ( C4::Context->preference('UseControlNumber') ) {
Lines 685-695 sub get_components_query { Link Here
685
            my $pf003 = $marc->field('003') || undef;
693
            my $pf003 = $marc->field('003') || undef;
686
694
687
            if ( !defined($pf003) ) {
695
            if ( !defined($pf003) ) {
696
688
                # search for 773$w='Host001'
697
                # search for 773$w='Host001'
689
                $searchstr .= "rcn:\"" . $pf001->data()."\"";
698
                $searchstr .= "rcn:\"" . $pf001->data() . "\"";
690
            }
699
            } else {
691
            else {
692
                $searchstr .= "(";
700
                $searchstr .= "(";
701
693
                # search for (773$w='Host001' and 003='Host003') or 773$w='(Host003)Host001'
702
                # search for (773$w='Host001' and 003='Host003') or 773$w='(Host003)Host001'
694
                $searchstr .= "(rcn:\"" . $pf001->data() . "\" AND cni:\"" . $pf003->data() . "\")";
703
                $searchstr .= "(rcn:\"" . $pf001->data() . "\" AND cni:\"" . $pf003->data() . "\")";
695
                $searchstr .= " OR rcn:\"" . $pf003->data() . " " . $pf001->data() . "\"";
704
                $searchstr .= " OR rcn:\"" . $pf003->data() . " " . $pf001->data() . "\"";
Lines 700-719 sub get_components_query { Link Here
700
            $searchstr .= " AND (bib-level:a OR bib-level:b)";
709
            $searchstr .= " AND (bib-level:a OR bib-level:b)";
701
            $searchstr .= ")";
710
            $searchstr .= ")";
702
        }
711
        }
703
    }
712
    } else {
704
    else {
713
        my $cleaned_title = $marc->subfield( '245', "a" );
705
        my $cleaned_title = $marc->subfield('245', "a");
706
        $cleaned_title =~ tr|/||;
714
        $cleaned_title =~ tr|/||;
707
        $cleaned_title = $builder->clean_search_term($cleaned_title);
715
        $cleaned_title = $builder->clean_search_term($cleaned_title);
708
        $searchstr = qq#Host-item:("$cleaned_title")#;
716
        $searchstr     = qq#Host-item:("$cleaned_title")#;
709
    }
717
    }
710
    my ($error, $query ,$query_str) = $builder->build_query_compat( undef, [$searchstr], undef, undef, [$sort], 0 );
718
    my ( $error, $query, $query_str ) = $builder->build_query_compat( undef, [$searchstr], undef, undef, [$sort], 0 );
711
    if( $error ){
719
    if ($error) {
712
        warn $error;
720
        warn $error;
713
        return;
721
        return;
714
    }
722
    }
715
723
716
    return ($query, $query_str, $sort);
724
    return ( $query, $query_str, $sort );
717
}
725
}
718
726
719
=head3 get_marc_volumes
727
=head3 get_marc_volumes
Lines 771-777 sub get_volumes_query { Link Here
771
    # the staff interface should already be displaying an error message in this case
779
    # the staff interface should already be displaying an error message in this case
772
    # so we don't need to return the error
780
    # so we don't need to return the error
773
    my $marc;
781
    my $marc;
774
    eval { $marc = $self->metadata->record;};
782
    eval { $marc = $self->metadata->record; };
775
    return unless $marc;
783
    return unless $marc;
776
784
777
    # Only build volumes query if we're in a 'Set' record
785
    # Only build volumes query if we're in a 'Set' record
(-)a/catalogue/detail.pl (-2 / +1 lines)
Lines 270-276 if ( $showcomp eq 'both' || $showcomp eq 'staff' ) { Link Here
270
}
270
}
271
271
272
# Display volumes link
272
# Display volumes link
273
my $show_volumes = @{ $biblio->get_marc_volumes(1) } ? 1 : 0;
273
my $show_volumes = ( !$invalid_marc_record && @{ $biblio->get_marc_volumes(1) } ) ? 1 : 0;
274
274
275
# XSLT processing of some stuff
275
# XSLT processing of some stuff
276
my $xslt_variables = {
276
my $xslt_variables = {
277
- 

Return to bug 35099