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

(-)a/C4/AuthoritiesMarc.pm (-26 / +30 lines)
Lines 908-913 sub BuildSummary { Link Here
908
        # for MARC21, the authority type summary displays a label meant for
908
        # for MARC21, the authority type summary displays a label meant for
909
        # display
909
        # display
910
        if (C4::Context->preference('marcflavour') ne 'UNIMARC') {
910
        if (C4::Context->preference('marcflavour') ne 'UNIMARC') {
911
            $summary{label} = $authref->{summary};
912
        } else {
911
            $summary{summary} = $authref->{summary};
913
            $summary{summary} = $authref->{summary};
912
        }
914
        }
913
    }
915
    }
Lines 942-976 sub BuildSummary { Link Here
942
#         suit the MARC21 version, so for now the "templating"
944
#         suit the MARC21 version, so for now the "templating"
943
#         feature will be enabled only for UNIMARC for backwards
945
#         feature will be enabled only for UNIMARC for backwards
944
#         compatibility.
946
#         compatibility.
945
    if ($summary_template and C4::Context->preference('marcflavour') eq 'UNIMARC') {
947
    if ($summary{summary} and C4::Context->preference('marcflavour') eq 'UNIMARC') {
946
        my @fields = $record->fields();
948
        my @matches = ($summary{summary} =~ m/\[(.*?)(\d{3})([\*a-z0-9])(.*?)\]/g);
947
#             $reported_tag = '$9'.$result[$counter];
949
        my (@textbefore, @tag, @subtag, @textafter);
948
        my @repets;
950
        for(my $i = 0; $i < scalar @matches; $i++){
949
        foreach my $field (@fields) {
951
            push @textbefore, $matches[$i] if($i%4 == 0);
950
            my $tag = $field->tag();
952
            push @tag,        $matches[$i] if($i%4 == 1);
951
            my $tagvalue = $field->as_string();
953
            push @subtag,     $matches[$i] if($i%4 == 2);
952
            my $localsummary= $summary_template;
954
            push @textafter,  $matches[$i] if($i%4 == 3);
953
            $localsummary =~ s/\[(.?.?.?.?)$tag\*(.*?)\]/$1$tagvalue$2\[$1$tag$2\]/g;
955
        }
954
            if ($tag<10) {
956
        for(my $i = scalar @tag; $i >= 0; $i--){
955
                if ($tag eq '001') {
957
            my $textbefore = $textbefore[$i] || '';
956
                    $reported_tag.='$3'.$field->data();
958
            my $tag = $tag[$i] || '';
957
                }
959
            my $subtag = $subtag[$i] || '';
958
            } else {
960
            my $textafter = $textafter[$i] || '';
959
                my @subf = $field->subfields;
961
            my $value = '';
960
                for my $i (0..$#subf) {
962
            my $field = $record->field($tag);
961
                    my $subfieldcode = $subf[$i][0];
963
            if ( $field ) {
962
                    my $subfieldvalue = $subf[$i][1];
964
                if($subtag eq '*') {
963
                    my $tagsubf = $tag.$subfieldcode;
965
                    if($tag < 10) {
964
                    $localsummary =~ s/\[(.?.?.?.?)$tagsubf(.*?)\]/$1$subfieldvalue$2\[$1$tagsubf$2\]/g;
966
                        $value = $textbefore . $field->data() . $textafter;
967
                    }
968
                } else {
969
                    my @subfields = $field->subfield($subtag);
970
                    if(@subfields > 0) {
971
                        $value = $textbefore . join (" - ", @subfields) . $textafter;
972
                    }
965
                }
973
                }
966
            }
974
            }
967
            if ($localsummary ne $summary_template) {
975
            $summary{summary} =~ s/\[\Q$textbefore$tag$subtag$textafter\E\]/$value/;
968
                $localsummary =~ s/\[(.*?)\]//g;
969
                $localsummary =~ s/\n/<br>/g;
970
                push @repets, $localsummary;
971
            }
972
        }
976
        }
973
        $summary{repets} = \@repets;
977
        $summary{summary} =~ s/\\n/<br \/>/g;
974
    }
978
    }
975
    my @authorized;
979
    my @authorized;
976
    my @notes;
980
    my @notes;
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/authorities-search-results.inc (-7 / +6 lines)
Lines 50-62 Link Here
50
    [% END %]
50
    [% END %]
51
[% END %]
51
[% END %]
52
[% BLOCK authresult %]
52
[% BLOCK authresult %]
53
    [% IF ( summary.summary ) %][% summary.summary | html %]:[% END %]
53
    [% IF ( summary.label ) %][% summary.label | html %]:[% END %]
54
    <div class="authres_repet">
54
    [% IF summary.summary %]
55
      [% FOREACH repet IN summary.repets %]
55
      <div class="authority-summary">
56
        <span>[% repet | html %]</span>
56
        [% summary.summary %]
57
        [% UNLESS loop.last %] | [% END %]
57
      </div>
58
      [% END %]
58
    [% END %]
59
    </div>
60
    [% UNLESS ( summary.summaryonly ) %]
59
    [% UNLESS ( summary.summaryonly ) %]
61
        <div class="authorizedheading">
60
        <div class="authorizedheading">
62
          [% FOREACH authorize IN summary.authorized %]
61
          [% FOREACH authorize IN summary.authorized %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist-auth.tt (-3 / +3 lines)
Lines 73-81 function doauth(authid, index, repet) Link Here
73
                        <td>[% PROCESS authresult summary=resul.summary %]</td>
73
                        <td>[% PROCESS authresult summary=resul.summary %]</td>
74
                        <td>[% resul.used %] times</td>
74
                        <td>[% resul.used %] times</td>
75
                        <td>
75
                        <td>
76
                          [% IF resul.summary && resul.summary.repets && resul.summary.repets.size > 1 %]
76
                          [% IF resul.summary && resul.summary.authorized && resul.summary.authorized.size > 1 %]
77
                            [% FOREACH repet IN resul.summary.repets %]
77
                            [% FOREACH authorized IN resul.summary.authorized %]
78
                            <a href="javascript:doauth('[% resul.authid %]', '[% index %]', '[% loop.count %]')" title="[% repet | html %]">[% loop.count %]</a>
78
                            <a href="javascript:doauth('[% resul.authid %]', '[% index %]', '[% loop.count %]')" title="[% authorized.heading | html %]">[% loop.count %]</a>
79
                            [% END %]
79
                            [% END %]
80
                          [% ELSE %]
80
                          [% ELSE %]
81
                            <a href="javascript:doauth('[% resul.authid %]', '[% index %]', '')">choose</a>
81
                            <a href="javascript:doauth('[% resul.authid %]', '[% index %]', '')">choose</a>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/authorities-search-results.inc (-7 / +6 lines)
Lines 50-62 Link Here
50
[% END # / BLOCK showreference %]
50
[% END # / BLOCK showreference %]
51
51
52
[% BLOCK authresult %]
52
[% BLOCK authresult %]
53
    [% IF ( summary.summary ) %][% summary.summary | html %]:[% END %]
53
    [% IF ( summary.label ) %][% summary.label | html %]:[% END %]
54
    <div class="authres_repet">
54
    [% IF summary.summary %]
55
        [% FOREACH repet IN summary.repets %]
55
        <div class="authority-summary">
56
            <span>[% repet | html %]</span>
56
            [% summary.summary %]
57
            [% UNLESS loop.last %] | [% END %]
57
        </div>
58
        [% END %]
58
    [% END %]
59
    </div>
60
    [% UNLESS ( summary.summaryonly ) %]
59
    [% UNLESS ( summary.summaryonly ) %]
61
        <div class="authorizedheading">
60
        <div class="authorizedheading">
62
            [% FOREACH authorize IN summary.authorized %]
61
            [% FOREACH authorize IN summary.authorized %]
(-)a/t/db_dependent/AuthoritiesMarc.t (-5 / +4 lines)
Lines 61-66 my $dbh = C4::Context->dbh; Link Here
61
$dbh->{AutoCommit} = 0;
61
$dbh->{AutoCommit} = 0;
62
$dbh->{RaiseError} = 1;
62
$dbh->{RaiseError} = 1;
63
63
64
t::lib::Mocks::mock_preference('marcflavour', 'MARC21');
65
64
is(BuildAuthHierarchies(3, 1), '1,2,3', "Built linked authtrees hierarchy string");
66
is(BuildAuthHierarchies(3, 1), '1,2,3', "Built linked authtrees hierarchy string");
65
67
66
my $expectedhierarchy = [ [ {
68
my $expectedhierarchy = [ [ {
Lines 135-141 my $expected_marc21_summary = { Link Here
135
                   }
137
                   }
136
                 ],
138
                 ],
137
    'seefrom' => [],
139
    'seefrom' => [],
138
    'summary' => 'Geographic Name',
140
    'label' => 'Geographic Name',
139
    'type' => 'Geographic Name'
141
    'type' => 'Geographic Name'
140
};
142
};
141
is_deeply(
143
is_deeply(
Lines 178-186 my $expected_unimarc_name_summary = { Link Here
178
    'otherscript' => [],
180
    'otherscript' => [],
179
    'seealso' => [],
181
    'seealso' => [],
180
    'seefrom' => [],
182
    'seefrom' => [],
181
    'repets' => [
183
    'summary' => 'Fossey, Brigitte',
182
        'Fossey, Brigitte'
183
    ],
184
    'type' => 'Auteur'
184
    'type' => 'Auteur'
185
};
185
};
186
186
187
- 

Return to bug 10985