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

(-)a/C4/AuthoritiesMarc.pm (-60 / +11 lines)
Lines 17-25 package C4::AuthoritiesMarc; Link Here
17
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
18
19
use strict;
19
use strict;
20
#use warnings; FIXME - Bug 2505
20
use warnings;
21
use C4::Context;
21
use C4::Context;
22
use C4::Koha;
23
use MARC::Record;
22
use MARC::Record;
24
use C4::Biblio;
23
use C4::Biblio;
25
use C4::Search;
24
use C4::Search;
Lines 41-47 BEGIN { Link Here
41
	    &GetAuthType
40
	    &GetAuthType
42
	    &GetAuthTypeCode
41
	    &GetAuthTypeCode
43
    	&GetAuthMARCFromKohaField 
42
    	&GetAuthMARCFromKohaField 
44
    	&AUTHhtml2marc
45
43
46
    	&AddAuthority
44
    	&AddAuthority
47
    	&ModAuthority
45
    	&ModAuthority
Lines 251-257 sub SearchAuthorities { Link Here
251
            }#if value
249
            }#if value
252
        }
250
        }
253
        ##Add how many queries generated
251
        ##Add how many queries generated
254
        if ($query=~/\S+/){
252
        if (defined $query && $query=~/\S+/){
255
          $query= $and x $attr_cnt . $query . $q2;
253
          $query= $and x $attr_cnt . $query . $q2;
256
        } else {
254
        } else {
257
          $query= $q2;
255
          $query= $q2;
Lines 854-906 sub GetAuthType { Link Here
854
}
852
}
855
853
856
854
857
sub AUTHhtml2marc {
858
    my ($rtags,$rsubfields,$rvalues,%indicators) = @_;
859
    my $dbh=C4::Context->dbh;
860
    my $prevtag = -1;
861
    my $record = MARC::Record->new();
862
#---- TODO : the leader is missing
863
864
#     my %subfieldlist=();
865
    my $prevvalue; # if tag <10
866
    my $field; # if tag >=10
867
    for (my $i=0; $i< @$rtags; $i++) {
868
        # rebuild MARC::Record
869
        if (@$rtags[$i] ne $prevtag) {
870
            if ($prevtag < 10) {
871
                if ($prevvalue) {
872
                    $record->add_fields((sprintf "%03s",$prevtag),$prevvalue);
873
                }
874
            } else {
875
                if ($field) {
876
                    $record->add_fields($field);
877
                }
878
            }
879
            $indicators{@$rtags[$i]}.='  ';
880
            if (@$rtags[$i] <10) {
881
                $prevvalue= @$rvalues[$i];
882
                undef $field;
883
            } else {
884
                undef $prevvalue;
885
                $field = MARC::Field->new( (sprintf "%03s",@$rtags[$i]), substr($indicators{@$rtags[$i]},0,1),substr($indicators{@$rtags[$i]},1,1), @$rsubfields[$i] => @$rvalues[$i]);
886
            }
887
            $prevtag = @$rtags[$i];
888
        } else {
889
            if (@$rtags[$i] <10) {
890
                $prevvalue=@$rvalues[$i];
891
            } else {
892
                if (length(@$rvalues[$i])>0) {
893
                    $field->add_subfields(@$rsubfields[$i] => @$rvalues[$i]);
894
                }
895
            }
896
            $prevtag= @$rtags[$i];
897
        }
898
    }
899
    # the last has not been included inside the loop... do it now !
900
    $record->add_fields($field) if $field;
901
    return $record;
902
}
903
904
=head2 FindDuplicateAuthority
855
=head2 FindDuplicateAuthority
905
856
906
  $record= &FindDuplicateAuthority( $record, $authtypecode)
857
  $record= &FindDuplicateAuthority( $record, $authtypecode)
Lines 1015-1028 sub BuildSummary{ Link Here
1015
    $resultstring =~ s/\n/<br>/g;
966
    $resultstring =~ s/\n/<br>/g;
1016
	$summary      =  $resultstring;
967
	$summary      =  $resultstring;
1017
  } else {
968
  } else {
1018
    my $heading; 
969
    my $heading = '';
1019
    my $altheading;
970
    my $altheading = '';
1020
    my $seealso;
971
    my $seealso = '';
1021
    my $broaderterms;
972
    my $broaderterms = '';
1022
    my $narrowerterms;
973
    my $narrowerterms = '';
1023
    my $see;
974
    my $see = '';
1024
    my $seeheading;
975
    my $seeheading = '';
1025
        my $notes;
976
    my $notes = '';
1026
    my @fields = $record->fields();
977
    my @fields = $record->fields();
1027
    if (C4::Context->preference('marcflavour') eq 'UNIMARC') {
978
    if (C4::Context->preference('marcflavour') eq 'UNIMARC') {
1028
    # construct UNIMARC summary, that is quite different from MARC21 one
979
    # construct UNIMARC summary, that is quite different from MARC21 one
Lines 1471-1477 sub get_auth_type_location { Link Here
1471
    my $auth_type_code = @_ ? shift : '';
1422
    my $auth_type_code = @_ ? shift : '';
1472
1423
1473
    my ($tag, $subfield) = GetAuthMARCFromKohaField('auth_header.authtypecode', $auth_type_code);
1424
    my ($tag, $subfield) = GetAuthMARCFromKohaField('auth_header.authtypecode', $auth_type_code);
1474
    if (defined $tag and defined $subfield and $tag != 0 and $subfield != 0) {
1425
    if (defined $tag and defined $subfield and $tag != 0 and $subfield ne '' and $subfield ne ' ') {
1475
        return ($tag, $subfield);
1426
        return ($tag, $subfield);
1476
    } else {
1427
    } else {
1477
        if (C4::Context->preference('marcflavour') eq "MARC21")  {
1428
        if (C4::Context->preference('marcflavour') eq "MARC21")  {
(-)a/C4/Heading.pm (-3 / +16 lines)
Lines 18-24 package C4::Heading; Link Here
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
19
20
use strict;
20
use strict;
21
#use warnings; FIXME - Bug 2505
21
use warnings;
22
use MARC::Record;
22
use MARC::Record;
23
use MARC::Field;
23
use MARC::Field;
24
use C4::Context;
24
use C4::Context;
Lines 38-45 C4::Heading Link Here
38
 my $heading = C4::Heading->new_from_bib_field($field);
38
 my $heading = C4::Heading->new_from_bib_field($field);
39
 my $thesaurus = $heading->thesaurus();
39
 my $thesaurus = $heading->thesaurus();
40
 my $type = $heading->type();
40
 my $type = $heading->type();
41
 my $display_heading = $heading->display();
41
 my $display_heading = $heading->display_form();
42
 my $search_string = $heading->search_string();
42
 my $search_form = $heading->search_form();
43
43
44
=head1 DESCRIPTION
44
=head1 DESCRIPTION
45
45
Lines 96-101 sub display_form { Link Here
96
    return $self->{'display_form'};
96
    return $self->{'display_form'};
97
}
97
}
98
98
99
=head2 search_form
100
101
  my $search_form = $heading->search_form();
102
103
Return the "canonical" search form of the heading.
104
105
=cut
106
107
sub search_form {
108
    my $self = shift;
109
    return $self->{'search_form'};
110
}
111
99
=head2 authorities
112
=head2 authorities
100
113
101
  my $authorities = $heading->authorities;
114
  my $authorities = $heading->authorities;
(-)a/t/Heading_MARC21.t (-2 / +6 lines)
Lines 6-14 Link Here
6
use strict;
6
use strict;
7
use warnings;
7
use warnings;
8
8
9
use Test::More tests => 1;
9
use Test::More tests => 3;
10
10
11
BEGIN {
11
BEGIN {
12
        use_ok('C4::External::Amazon');
12
        use_ok('C4::Heading');
13
}
13
}
14
14
15
my $field = MARC::Field->new( '650', ' ', '0', a => 'Uncles', x => 'Fiction' );
16
my $heading = C4::Heading->new_from_bib_field($field);
17
is($heading->display_form(), 'Uncles--Fiction', 'Display form generation');
18
is($heading->search_form(), 'Uncles generalsubdiv Fiction', 'Search form generation');
(-)a/t/db_dependent/lib/KohaTest/AuthoritiesMarc.pm (-2 lines)
Lines 24-30 sub methods : Test( 1 ) { Link Here
24
                      GetAuthorityXML 
24
                      GetAuthorityXML 
25
                      GetAuthority 
25
                      GetAuthority 
26
                      GetAuthType 
26
                      GetAuthType 
27
                      AUTHhtml2marc 
28
                      FindDuplicateAuthority 
27
                      FindDuplicateAuthority 
29
                      BuildSummary
28
                      BuildSummary
30
                      BuildUnimarcHierarchies
29
                      BuildUnimarcHierarchies
31
- 

Return to bug 7284