|
Lines 715-720
sub get_components_query {
Link Here
|
| 715 |
return ($query, $query_str, $sort); |
715 |
return ($query, $query_str, $sort); |
| 716 |
} |
716 |
} |
| 717 |
|
717 |
|
|
|
718 |
=head3 get_marc_volumes |
| 719 |
|
| 720 |
my $volumes = $self->get_marc_volumes(); |
| 721 |
|
| 722 |
Returns an array of MARCXML data, which are volumes parts of |
| 723 |
this object (MARC21 773$w points to this) |
| 724 |
|
| 725 |
=cut |
| 726 |
|
| 727 |
sub get_marc_volumes { |
| 728 |
my ( $self, $max_results ) = @_; |
| 729 |
|
| 730 |
return $self->{_volumes} if defined( $self->{_volumes} ); |
| 731 |
|
| 732 |
my $searchstr = $self->get_volumes_query; |
| 733 |
|
| 734 |
if ( defined($searchstr) ) { |
| 735 |
my $searcher = Koha::SearchEngine::Search->new( { index => $Koha::SearchEngine::BIBLIOS_INDEX } ); |
| 736 |
my ( $errors, $results, $total_hits ) = $searcher->simple_search_compat( $searchstr, 0, $max_results ); |
| 737 |
$self->{_volumes} = |
| 738 |
( defined($results) && scalar(@$results) ) ? $results : []; |
| 739 |
} else { |
| 740 |
$self->{_volumes} = []; |
| 741 |
} |
| 742 |
|
| 743 |
return $self->{_volumes}; |
| 744 |
} |
| 745 |
|
| 746 |
=head2 get_volumes_query |
| 747 |
|
| 748 |
Returns a query which can be used to search for all component parts of MARC21 biblios |
| 749 |
|
| 750 |
=cut |
| 751 |
|
| 752 |
sub get_volumes_query { |
| 753 |
my ($self) = @_; |
| 754 |
|
| 755 |
# MARC21 Only for now |
| 756 |
return if ( C4::Context->preference('marcflavour') ne 'MARC21' ); |
| 757 |
|
| 758 |
my $marc = $self->metadata->record; |
| 759 |
|
| 760 |
# Only build volumes query if we're in a 'Set' record |
| 761 |
# or we have a monographic series. |
| 762 |
my $leader19 = substr( $marc->leader, 19, 1 ); |
| 763 |
my $pf008 = $marc->field('008') || ''; |
| 764 |
my $mseries = ( $pf008 && substr( $pf008->data(), 21, 1 ) eq 'm' ) ? 1 : 0; |
| 765 |
return unless ( $leader19 eq 'a' || $mseries ); |
| 766 |
|
| 767 |
my $builder = Koha::SearchEngine::QueryBuilder->new( { index => $Koha::SearchEngine::BIBLIOS_INDEX } ); |
| 768 |
|
| 769 |
my $searchstr; |
| 770 |
if ( C4::Context->preference('UseControlNumber') ) { |
| 771 |
my $pf001 = $marc->field('001') || undef; |
| 772 |
|
| 773 |
if ( defined($pf001) ) { |
| 774 |
$searchstr = "("; |
| 775 |
my $pf003 = $marc->field('003') || undef; |
| 776 |
|
| 777 |
if ( !defined($pf003) ) { |
| 778 |
|
| 779 |
# search for 773$w='Host001' |
| 780 |
$searchstr .= "rcn:" . $pf001->data(); |
| 781 |
} else { |
| 782 |
$searchstr .= "("; |
| 783 |
|
| 784 |
# search for (773$w='Host001' and 003='Host003') or 773$w='(Host003)Host001' |
| 785 |
$searchstr .= "(rcn:" . $pf001->data() . " AND cni:" . $pf003->data() . ")"; |
| 786 |
$searchstr .= " OR rcn:\"" . $pf003->data() . " " . $pf001->data() . "\""; |
| 787 |
$searchstr .= ")"; |
| 788 |
} |
| 789 |
|
| 790 |
# exclude monograph and serial component part records |
| 791 |
$searchstr .= " NOT (bib-level:a OR bib-level:b)"; |
| 792 |
$searchstr .= ")"; |
| 793 |
} |
| 794 |
} else { |
| 795 |
my $cleaned_title = $marc->subfield( '245', "a" ); |
| 796 |
$cleaned_title =~ tr|/||; |
| 797 |
$cleaned_title = $builder->clean_search_term($cleaned_title); |
| 798 |
$searchstr = "ti,phr:($cleaned_title)"; |
| 799 |
} |
| 800 |
|
| 801 |
return $searchstr; |
| 802 |
} |
| 803 |
|
| 718 |
=head3 subscriptions |
804 |
=head3 subscriptions |
| 719 |
|
805 |
|
| 720 |
my $subscriptions = $self->subscriptions |
806 |
my $subscriptions = $self->subscriptions |
|
Lines 1615-1693
sub opac_summary_html {
Link Here
|
| 1615 |
return $summary_html; |
1701 |
return $summary_html; |
| 1616 |
} |
1702 |
} |
| 1617 |
|
1703 |
|
| 1618 |
=head3 get_marc_volumes |
|
|
| 1619 |
|
| 1620 |
my $volumes = $self->get_marc_volumes(); |
| 1621 |
|
| 1622 |
Returns an array of MARCXML data, which are volumes parts of |
| 1623 |
this object (MARC21 773$w points to this) |
| 1624 |
|
| 1625 |
=cut |
| 1626 |
|
| 1627 |
sub get_marc_volumes { |
| 1628 |
my ($self, $max_results) = @_; |
| 1629 |
|
| 1630 |
return [] if (C4::Context->preference('marcflavour') ne 'MARC21'); |
| 1631 |
|
| 1632 |
my $searchstr = $self->get_volumes_query; |
| 1633 |
|
| 1634 |
if (defined($searchstr)) { |
| 1635 |
my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX}); |
| 1636 |
my ( $errors, $results, $total_hits ) = $searcher->simple_search_compat( $searchstr, 0, $max_results ); |
| 1637 |
$self->{_volumes} = $results if ( defined($results) && scalar(@$results) ); |
| 1638 |
} |
| 1639 |
|
| 1640 |
return $self->{_volumes} || []; |
| 1641 |
} |
| 1642 |
|
| 1643 |
=head2 get_volumes_query |
| 1644 |
|
| 1645 |
Returns a query which can be used to search for all component parts of MARC21 biblios |
| 1646 |
|
| 1647 |
=cut |
| 1648 |
|
| 1649 |
sub get_volumes_query { |
| 1650 |
my ($self) = @_; |
| 1651 |
|
| 1652 |
my $builder = Koha::SearchEngine::QueryBuilder->new( |
| 1653 |
{ index => $Koha::SearchEngine::BIBLIOS_INDEX } ); |
| 1654 |
my $marc = $self->metadata->record; |
| 1655 |
|
| 1656 |
my $searchstr; |
| 1657 |
if ( C4::Context->preference('UseControlNumber') ) { |
| 1658 |
my $pf001 = $marc->field('001') || undef; |
| 1659 |
|
| 1660 |
if ( defined($pf001) ) { |
| 1661 |
$searchstr = "("; |
| 1662 |
my $pf003 = $marc->field('003') || undef; |
| 1663 |
|
| 1664 |
if ( !defined($pf003) ) { |
| 1665 |
# search for 773$w='Host001' |
| 1666 |
$searchstr .= "rcn:" . $pf001->data(); |
| 1667 |
} |
| 1668 |
else { |
| 1669 |
$searchstr .= "("; |
| 1670 |
# search for (773$w='Host001' and 003='Host003') or 773$w='(Host003)Host001' |
| 1671 |
$searchstr .= "(rcn:" . $pf001->data() . " AND cni:" . $pf003->data() . ")"; |
| 1672 |
$searchstr .= " OR rcn:\"" . $pf003->data() . " " . $pf001->data() . "\""; |
| 1673 |
$searchstr .= ")"; |
| 1674 |
} |
| 1675 |
|
| 1676 |
# exclude monograph and serial component part records |
| 1677 |
$searchstr .= " NOT (bib-level:a OR bib-level:b)"; |
| 1678 |
$searchstr .= ")"; |
| 1679 |
} |
| 1680 |
} |
| 1681 |
else { |
| 1682 |
my $cleaned_title = $marc->subfield('245', "a"); |
| 1683 |
$cleaned_title =~ tr|/||; |
| 1684 |
$cleaned_title = $builder->clean_search_term($cleaned_title); |
| 1685 |
$searchstr = "ti,phr:($cleaned_title)"; |
| 1686 |
} |
| 1687 |
|
| 1688 |
return $searchstr; |
| 1689 |
} |
| 1690 |
|
| 1691 |
=head2 Internal methods |
1704 |
=head2 Internal methods |
| 1692 |
|
1705 |
|
| 1693 |
=head3 type |
1706 |
=head3 type |