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

(-)a/C4/AuthoritiesMarc.pm (-14 / +45 lines)
Lines 1021-1027 sub BuildSummary { Link Here
1021
# construct UNIMARC summary, that is quite different from MARC21 one
1021
# construct UNIMARC summary, that is quite different from MARC21 one
1022
# accepted form
1022
# accepted form
1023
        foreach my $field ($record->field('2..')) {
1023
        foreach my $field ($record->field('2..')) {
1024
            push @authorized, { heading => $field->as_string('abcdefghijlmnopqrstuvwxyz'), field => $field->tag() };
1024
            push @authorized, {
1025
                heading => $field->as_string('abcdefghijlmnopqrstuvwxyz'),
1026
                hemain  => $field->subfield('a'),
1027
                field   => $field->tag(),
1028
            };
1025
        }
1029
        }
1026
# rejected form(s)
1030
# rejected form(s)
1027
        foreach my $field ($record->field('3..')) {
1031
        foreach my $field ($record->field('3..')) {
Lines 1029-1035 sub BuildSummary { Link Here
1029
        }
1033
        }
1030
        foreach my $field ($record->field('4..')) {
1034
        foreach my $field ($record->field('4..')) {
1031
            my $thesaurus = $field->subfield('2') ? "thes. : ".$thesaurus{"$field->subfield('2')"}." : " : '';
1035
            my $thesaurus = $field->subfield('2') ? "thes. : ".$thesaurus{"$field->subfield('2')"}." : " : '';
1032
            push @seefrom, { heading => $thesaurus . $field->as_string('abcdefghijlmnopqrstuvwxyz'), type => 'seefrom', field => $field->tag() };
1036
            push @seefrom, { 
1037
                heading => $thesaurus . $field->as_string('abcdefghijlmnopqrstuvwxyz'),
1038
                hemain  => $field->subfield('a'),
1039
                type    => 'seefrom', 
1040
                field   => $field->tag(),
1041
            };
1033
        }
1042
        }
1034
1043
1035
        # see :
1044
        # see :
Lines 1040-1045 sub BuildSummary { Link Here
1040
                field   => $_->tag,
1049
                field   => $_->tag,
1041
                type    => $type,
1050
                type    => $type,
1042
                heading => $heading,
1051
                heading => $heading,
1052
                hemain  => $_->subfield('a'),
1043
                search  => $heading,
1053
                search  => $heading,
1044
                authid  => $_->subfield('9'),
1054
                authid  => $_->subfield('9'),
1045
            }
1055
            }
Lines 1090-1098 sub BuildSummary { Link Here
1090
                $subfields_to_report = 'vxyz';
1100
                $subfields_to_report = 'vxyz';
1091
            }
1101
            }
1092
            if ($subfields_to_report) {
1102
            if ($subfields_to_report) {
1093
                push @authorized, { heading => $field->as_string($subfields_to_report), field => $tag };
1103
                push @authorized, { 
1104
                    heading => $field->as_string($subfields_to_report),
1105
                    hemain  => $field->subfield( substr($subfields_to_report, 0, 1) ),
1106
                    field   => $tag,
1107
                };
1094
            } else {
1108
            } else {
1095
                push @authorized, { heading => $field->as_string(), field => $tag };
1109
                push @authorized, {
1110
                    heading => $field->as_string(),
1111
                    hemain  => $field->subfield('a'),
1112
                    field   => $tag,
1113
                };
1096
            }
1114
            }
1097
        }
1115
        }
1098
        foreach my $field ($record->field('4..')) { #See From
1116
        foreach my $field ($record->field('4..')) { #See From
Lines 1103-1111 sub BuildSummary { Link Here
1103
                $type = 'earlier' if $type && $type ne 'n';
1121
                $type = 'earlier' if $type && $type ne 'n';
1104
            }
1122
            }
1105
            if ($type eq 'subfi') {
1123
            if ($type eq 'subfi') {
1106
                push @seefrom, { heading => $field->as_string($marc21subfields), type => ($field->subfield('i') || ''), field => $field->tag() };
1124
                push @seefrom, {
1125
                    heading => $field->as_string($marc21subfields),
1126
                    hemain  => $field->subfield( substr($marc21subfields, 0, 1) ),
1127
                    type    => ($field->subfield('i') || ''),
1128
                    field   => $field->tag(),
1129
                };
1107
            } else {
1130
            } else {
1108
                push @seefrom, { heading => $field->as_string($marc21subfields), type => $type, field => $field->tag() };
1131
                push @seefrom, {
1132
                    heading => $field->as_string($marc21subfields),
1133
                    hemain  => $field->subfield( substr($marc21subfields, 0, 1) ),
1134
                    type    => $type,
1135
                    field   => $field->tag(),
1136
                };
1109
            }
1137
            }
1110
        }
1138
        }
1111
        foreach my $field ($record->field('5..')) { #See Also
1139
        foreach my $field ($record->field('5..')) { #See Also
Lines 1118-1135 sub BuildSummary { Link Here
1118
            if ($type eq 'subfi') {
1146
            if ($type eq 'subfi') {
1119
                push @seealso, {
1147
                push @seealso, {
1120
                    heading => $field->as_string($marc21subfields),
1148
                    heading => $field->as_string($marc21subfields),
1121
                    type => $field->subfield('i'),
1149
                    hemain  => $field->subfield( substr($marc21subfields, 0, 1) ),
1122
                    field => $field->tag(),
1150
                    type    => $field->subfield('i'),
1123
                    search => $field->as_string($marc21subfields) || '',
1151
                    field   => $field->tag(),
1124
                    authid => $field->subfield('9') || ''
1152
                    search  => $field->as_string($marc21subfields) || '',
1153
                    authid  => $field->subfield('9') || ''
1125
                };
1154
                };
1126
            } else {
1155
            } else {
1127
                push @seealso, {
1156
                push @seealso, {
1128
                    heading => $field->as_string($marc21subfields),
1157
                    heading => $field->as_string($marc21subfields),
1129
                    type => $type,
1158
                    hemain  => $field->subfield( substr($marc21subfields, 0, 1) ),
1130
                    field => $field->tag(),
1159
                    type    => $type,
1131
                    search => $field->as_string($marc21subfields) || '',
1160
                    field   => $field->tag(),
1132
                    authid => $field->subfield('9') || ''
1161
                    search  => $field->as_string($marc21subfields) || '',
1162
                    authid  => $field->subfield('9') || ''
1133
                };
1163
                };
1134
            }
1164
            }
1135
        }
1165
        }
Lines 1157-1162 sub BuildSummary { Link Here
1157
        }
1187
        }
1158
    }
1188
    }
1159
    $summary{mainentry} = $authorized[0]->{heading};
1189
    $summary{mainentry} = $authorized[0]->{heading};
1190
    $summary{mainmainentry} = $authorized[0]->{hemain};
1160
    $summary{authorized} = \@authorized;
1191
    $summary{authorized} = \@authorized;
1161
    $summary{notes} = \@notes;
1192
    $summary{notes} = \@notes;
1162
    $summary{seefrom} = \@seefrom;
1193
    $summary{seefrom} = \@seefrom;
(-)a/authorities/ysearch.pl (-15 / +27 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 63-80 if ( $auth_status ne "ok" ) { Link Here
63
    my $startfrom = 0;
67
    my $startfrom = 0;
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