@@ -, +, @@ --- C4/AuthoritiesMarc.pm | 71 ++++-------------------- C4/Heading.pm | 19 +++++- t/Heading_MARC21.t | 8 ++- t/db_dependent/lib/KohaTest/AuthoritiesMarc.pm | 1 - 4 files changed, 33 insertions(+), 66 deletions(-) --- a/C4/AuthoritiesMarc.pm +++ a/C4/AuthoritiesMarc.pm @@ -17,9 +17,8 @@ package C4::AuthoritiesMarc; # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. use strict; -#use warnings; FIXME - Bug 2505 +use warnings; use C4::Context; -use C4::Koha; use MARC::Record; use C4::Biblio; use C4::Search; @@ -41,7 +40,6 @@ BEGIN { &GetAuthType &GetAuthTypeCode &GetAuthMARCFromKohaField - &AUTHhtml2marc &AddAuthority &ModAuthority @@ -251,7 +249,7 @@ sub SearchAuthorities { }#if value } ##Add how many queries generated - if ($query=~/\S+/){ + if (defined $query && $query=~/\S+/){ $query= $and x $attr_cnt . $query . $q2; } else { $query= $q2; @@ -854,53 +852,6 @@ sub GetAuthType { } -sub AUTHhtml2marc { - my ($rtags,$rsubfields,$rvalues,%indicators) = @_; - my $dbh=C4::Context->dbh; - my $prevtag = -1; - my $record = MARC::Record->new(); -#---- TODO : the leader is missing - -# my %subfieldlist=(); - my $prevvalue; # if tag <10 - my $field; # if tag >=10 - for (my $i=0; $i< @$rtags; $i++) { - # rebuild MARC::Record - if (@$rtags[$i] ne $prevtag) { - if ($prevtag < 10) { - if ($prevvalue) { - $record->add_fields((sprintf "%03s",$prevtag),$prevvalue); - } - } else { - if ($field) { - $record->add_fields($field); - } - } - $indicators{@$rtags[$i]}.=' '; - if (@$rtags[$i] <10) { - $prevvalue= @$rvalues[$i]; - undef $field; - } else { - undef $prevvalue; - $field = MARC::Field->new( (sprintf "%03s",@$rtags[$i]), substr($indicators{@$rtags[$i]},0,1),substr($indicators{@$rtags[$i]},1,1), @$rsubfields[$i] => @$rvalues[$i]); - } - $prevtag = @$rtags[$i]; - } else { - if (@$rtags[$i] <10) { - $prevvalue=@$rvalues[$i]; - } else { - if (length(@$rvalues[$i])>0) { - $field->add_subfields(@$rsubfields[$i] => @$rvalues[$i]); - } - } - $prevtag= @$rtags[$i]; - } - } - # the last has not been included inside the loop... do it now ! - $record->add_fields($field) if $field; - return $record; -} - =head2 FindDuplicateAuthority $record= &FindDuplicateAuthority( $record, $authtypecode) @@ -1015,14 +966,14 @@ sub BuildSummary{ $resultstring =~ s/\n/
/g; $summary = $resultstring; } else { - my $heading; - my $altheading; - my $seealso; - my $broaderterms; - my $narrowerterms; - my $see; - my $seeheading; - my $notes; + my $heading = ''; + my $altheading = ''; + my $seealso = ''; + my $broaderterms = ''; + my $narrowerterms = ''; + my $see = ''; + my $seeheading = ''; + my $notes = ''; my @fields = $record->fields(); if (C4::Context->preference('marcflavour') eq 'UNIMARC') { # construct UNIMARC summary, that is quite different from MARC21 one @@ -1471,7 +1422,7 @@ sub get_auth_type_location { my $auth_type_code = @_ ? shift : ''; my ($tag, $subfield) = GetAuthMARCFromKohaField('auth_header.authtypecode', $auth_type_code); - if (defined $tag and defined $subfield and $tag != 0 and $subfield != 0) { + if (defined $tag and defined $subfield and $tag != 0 and $subfield ne '' and $subfield ne ' ') { return ($tag, $subfield); } else { if (C4::Context->preference('marcflavour') eq "MARC21") { --- a/C4/Heading.pm +++ a/C4/Heading.pm @@ -18,7 +18,7 @@ package C4::Heading; # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. use strict; -#use warnings; FIXME - Bug 2505 +use warnings; use MARC::Record; use MARC::Field; use C4::Context; @@ -38,8 +38,8 @@ C4::Heading my $heading = C4::Heading->new_from_bib_field($field); my $thesaurus = $heading->thesaurus(); my $type = $heading->type(); - my $display_heading = $heading->display(); - my $search_string = $heading->search_string(); + my $display_heading = $heading->display_form(); + my $search_form = $heading->search_form(); =head1 DESCRIPTION @@ -96,6 +96,19 @@ sub display_form { return $self->{'display_form'}; } +=head2 search_form + + my $search_form = $heading->search_form(); + +Return the "canonical" search form of the heading. + +=cut + +sub search_form { + my $self = shift; + return $self->{'search_form'}; +} + =head2 authorities my $authorities = $heading->authorities; --- a/t/Heading_MARC21.t +++ a/t/Heading_MARC21.t @@ -6,9 +6,13 @@ use strict; use warnings; -use Test::More tests => 1; +use Test::More tests => 3; BEGIN { - use_ok('C4::External::Amazon'); + use_ok('C4::Heading'); } +my $field = MARC::Field->new( '650', ' ', '0', a => 'Uncles', x => 'Fiction' ); +my $heading = C4::Heading->new_from_bib_field($field); +is($heading->display_form(), 'Uncles--Fiction', 'Display form generation'); +is($heading->search_form(), 'Uncles generalsubdiv Fiction', 'Search form generation'); --- a/t/db_dependent/lib/KohaTest/AuthoritiesMarc.pm +++ a/t/db_dependent/lib/KohaTest/AuthoritiesMarc.pm @@ -24,7 +24,6 @@ sub methods : Test( 1 ) { GetAuthorityXML GetAuthority GetAuthType - AUTHhtml2marc FindDuplicateAuthority BuildSummary BuildUnimarcHierarchies --