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

(-)a/C4/AuthoritiesMarc.pm (-14 / +45 lines)
Lines 953-959 sub BuildSummary { Link Here
953
# construct UNIMARC summary, that is quite different from MARC21 one
953
# construct UNIMARC summary, that is quite different from MARC21 one
954
# accepted form
954
# accepted form
955
        foreach my $field ($record->field('2..')) {
955
        foreach my $field ($record->field('2..')) {
956
            push @authorized, { heading => $field->as_string('abcdefghijlmnopqrstuvwxyz'), field => $field->tag() };
956
            push @authorized, {
957
                heading => $field->as_string('abcdefghijlmnopqrstuvwxyz'),
958
                hemain  => $field->subfield('a'),
959
                field   => $field->tag(),
960
            };
957
        }
961
        }
958
# rejected form(s)
962
# rejected form(s)
959
        foreach my $field ($record->field('3..')) {
963
        foreach my $field ($record->field('3..')) {
Lines 961-967 sub BuildSummary { Link Here
961
        }
965
        }
962
        foreach my $field ($record->field('4..')) {
966
        foreach my $field ($record->field('4..')) {
963
            my $thesaurus = $field->subfield('2') ? "thes. : ".$thesaurus{"$field->subfield('2')"}." : " : '';
967
            my $thesaurus = $field->subfield('2') ? "thes. : ".$thesaurus{"$field->subfield('2')"}." : " : '';
964
            push @seefrom, { heading => $thesaurus . $field->as_string('abcdefghijlmnopqrstuvwxyz'), type => 'seefrom', field => $field->tag() };
968
            push @seefrom, {
969
                heading => $thesaurus . $field->as_string('abcdefghijlmnopqrstuvwxyz'),
970
                hemain  => $field->subfield('a'),
971
                type    => 'seefrom',
972
                field   => $field->tag(),
973
            };
965
        }
974
        }
966
975
967
        # see :
976
        # see :
Lines 972-977 sub BuildSummary { Link Here
972
                field   => $_->tag,
981
                field   => $_->tag,
973
                type    => $type,
982
                type    => $type,
974
                heading => $heading,
983
                heading => $heading,
984
                hemain  => $_->subfield('a'),
975
                search  => $heading,
985
                search  => $heading,
976
                authid  => $_->subfield('9'),
986
                authid  => $_->subfield('9'),
977
            }
987
            }
Lines 1022-1030 sub BuildSummary { Link Here
1022
                $subfields_to_report = 'vxyz';
1032
                $subfields_to_report = 'vxyz';
1023
            }
1033
            }
1024
            if ($subfields_to_report) {
1034
            if ($subfields_to_report) {
1025
                push @authorized, { heading => $field->as_string($subfields_to_report), field => $tag };
1035
                push @authorized, {
1036
                    heading => $field->as_string($subfields_to_report),
1037
                    hemain  => $field->subfield( substr($subfields_to_report, 0, 1) ),
1038
                    field   => $tag,
1039
                };
1026
            } else {
1040
            } else {
1027
                push @authorized, { heading => $field->as_string(), field => $tag };
1041
                push @authorized, {
1042
                    heading => $field->as_string(),
1043
                    hemain  => $field->subfield('a'),
1044
                    field   => $tag,
1045
                };
1028
            }
1046
            }
1029
        }
1047
        }
1030
        foreach my $field ($record->field('4..')) { #See From
1048
        foreach my $field ($record->field('4..')) { #See From
Lines 1035-1043 sub BuildSummary { Link Here
1035
                $type = 'earlier' if $type && $type ne 'n';
1053
                $type = 'earlier' if $type && $type ne 'n';
1036
            }
1054
            }
1037
            if ($type eq 'subfi') {
1055
            if ($type eq 'subfi') {
1038
                push @seefrom, { heading => $field->as_string($marc21subfields), type => ($field->subfield('i') || ''), field => $field->tag() };
1056
                push @seefrom, {
1057
                    heading => $field->as_string($marc21subfields),
1058
                    hemain  => $field->subfield( substr($marc21subfields, 0, 1) ),
1059
                    type    => ($field->subfield('i') || ''),
1060
                    field   => $field->tag(),
1061
                };
1039
            } else {
1062
            } else {
1040
                push @seefrom, { heading => $field->as_string($marc21subfields), type => $type, field => $field->tag() };
1063
                push @seefrom, {
1064
                    heading => $field->as_string($marc21subfields),
1065
                    hemain  => $field->subfield( substr($marc21subfields, 0, 1) ),
1066
                    type    => $type,
1067
                    field   => $field->tag(),
1068
                };
1041
            }
1069
            }
1042
        }
1070
        }
1043
        foreach my $field ($record->field('5..')) { #See Also
1071
        foreach my $field ($record->field('5..')) { #See Also
Lines 1050-1067 sub BuildSummary { Link Here
1050
            if ($type eq 'subfi') {
1078
            if ($type eq 'subfi') {
1051
                push @seealso, {
1079
                push @seealso, {
1052
                    heading => $field->as_string($marc21subfields),
1080
                    heading => $field->as_string($marc21subfields),
1053
                    type => $field->subfield('i'),
1081
                    hemain  => $field->subfield( substr($marc21subfields, 0, 1) ),
1054
                    field => $field->tag(),
1082
                    type    => $field->subfield('i'),
1055
                    search => $field->as_string($marc21subfields) || '',
1083
                    field   => $field->tag(),
1056
                    authid => $field->subfield('9') || ''
1084
                    search  => $field->as_string($marc21subfields) || '',
1085
                    authid  => $field->subfield('9') || ''
1057
                };
1086
                };
1058
            } else {
1087
            } else {
1059
                push @seealso, {
1088
                push @seealso, {
1060
                    heading => $field->as_string($marc21subfields),
1089
                    heading => $field->as_string($marc21subfields),
1061
                    type => $type,
1090
                    hemain  => $field->subfield( substr($marc21subfields, 0, 1) ),
1062
                    field => $field->tag(),
1091
                    type    => $type,
1063
                    search => $field->as_string($marc21subfields) || '',
1092
                    field   => $field->tag(),
1064
                    authid => $field->subfield('9') || ''
1093
                    search  => $field->as_string($marc21subfields) || '',
1094
                    authid  => $field->subfield('9') || ''
1065
                };
1095
                };
1066
            }
1096
            }
1067
        }
1097
        }
Lines 1089-1094 sub BuildSummary { Link Here
1089
        }
1119
        }
1090
    }
1120
    }
1091
    $summary{mainentry} = $authorized[0]->{heading};
1121
    $summary{mainentry} = $authorized[0]->{heading};
1122
    $summary{mainmainentry} = $authorized[0]->{hemain};
1092
    $summary{authorized} = \@authorized;
1123
    $summary{authorized} = \@authorized;
1093
    $summary{notes} = \@notes;
1124
    $summary{notes} = \@notes;
1094
    $summary{seefrom} = \@seefrom;
1125
    $summary{seefrom} = \@seefrom;
(-)a/authorities/ysearch.pl (-14 / +26 lines)
Lines 29-46 This script allows ajax call for dynamic authorities search Link Here
29
29
30
use CGI;
30
use CGI;
31
use Modern::Perl;
31
use Modern::Perl;
32
use JSON;
33
32
use C4::Context;
34
use C4::Context;
33
use C4::Charset;
35
use C4::Charset;
34
use C4::AuthoritiesMarc;
36
use C4::AuthoritiesMarc;
35
use C4::Auth qw/check_cookie_auth/;
37
use C4::Auth qw/check_cookie_auth/;
38
use C4::Output;
36
39
37
my $query = new CGI;
40
my $query = new CGI;
38
41
39
binmode STDOUT, ':encoding(UTF-8)';
42
my ( $auth_status, $sessionID ) = check_cookie_auth( $query->cookie('CGISESSID'), { catalogue => 1 } );
40
print $query->header( -type => 'text/plain', -charset => 'UTF-8' );
41
43
42
my ( $auth_status, $sessionID ) = check_cookie_auth( $query->cookie('CGISESSID'), { } );
43
if ( $auth_status ne "ok" ) {
44
if ( $auth_status ne "ok" ) {
45
    # send empty response
46
    my $reply = CGI->new("");
47
    print $reply->header(-type => 'text/html');
44
    exit 0;
48
    exit 0;
45
}
49
}
46
50
Lines 64-80 if ( $auth_status ne "ok" ) { Link Here
64
68
65
    my ( $results, $total ) = SearchAuthorities( \@marclist, \@and_or, \@excluding, \@operator, \@value, $startfrom * $resultsperpage, $resultsperpage, $authtypecode, $orderby );
69
    my ( $results, $total ) = SearchAuthorities( \@marclist, \@and_or, \@excluding, \@operator, \@value, $startfrom * $resultsperpage, $resultsperpage, $authtypecode, $orderby );
66
70
67
print "[";
71
    my %used_summaries; # hash to avoid duplicates
68
my $i = 0;
72
    my @summaries;
69
    foreach my $result (@$results) {
73
    foreach my $result (@$results) {
70
        if($i > 0){ print ","; }
71
        my $value = '';
72
        my $authorized = $result->{'summary'}->{'authorized'};
74
        my $authorized = $result->{'summary'}->{'authorized'};
73
        foreach my $heading (@$authorized) {
75
        my $summary    = join(
74
            $value .= $heading->{'heading'} . ' ';
76
            ' ',
77
            map {
78
                ( $searchtype eq 'mainmainentry' )
79
                  ? $_->{'hemain'}
80
                  : $_->{'heading'}
81
              } @$authorized
82
        );
83
        $summary =~ s/^\s+//;
84
        $summary =~ s/\s+$//;
85
        $summary = nsb_clean($summary);
86
        # test if already added ignoring case
87
        unless ( exists $used_summaries{ lc($summary) } ) {
88
            push @summaries, { 'summary' => $summary };
89
            $used_summaries{ lc($summary) } = 1;
75
        }
90
        }
76
        $value = "{\"summary\":\"" . $value . "\"" . "}";
77
        print nsb_clean($value) . "\n";
78
        $i++;
79
    }
91
    }
80
print "]";
92
93
output_with_http_headers $query, undef, to_json(\@summaries, { utf8 => 1 }), 'json';
81
- 

Return to bug 9282