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

(-)a/C4/AuthoritiesMarc.pm (-26 / +27 lines)
Lines 915-948 sub BuildSummary { Link Here
915
#         feature will be enabled only for UNIMARC for backwards
915
#         feature will be enabled only for UNIMARC for backwards
916
#         compatibility.
916
#         compatibility.
917
    if ($summary{summary} and C4::Context->preference('marcflavour') eq 'UNIMARC') {
917
    if ($summary{summary} and C4::Context->preference('marcflavour') eq 'UNIMARC') {
918
        my @fields = $record->fields();
918
        my @matches = ($summary{summary} =~ m/\[(.*?)(\d{3})([\*a-z0-9])(.*?)\]/g);
919
#             $reported_tag = '$9'.$result[$counter];
919
        my (@textbefore, @tag, @subtag, @textafter);
920
        my @stringssummary;
920
        for(my $i = 0; $i < scalar @matches; $i++){
921
        foreach my $field (@fields) {
921
            push @textbefore, $matches[$i] if($i%4 == 0);
922
            my $tag = $field->tag();
922
            push @tag,        $matches[$i] if($i%4 == 1);
923
            my $tagvalue = $field->as_string();
923
            push @subtag,     $matches[$i] if($i%4 == 2);
924
            my $localsummary= $summary{summary};
924
            push @textafter,  $matches[$i] if($i%4 == 3);
925
            $localsummary =~ s/\[(.?.?.?.?)$tag\*(.*?)\]/$1$tagvalue$2\[$1$tag$2\]/g;
925
        }
926
            if ($tag<10) {
926
        for(my $i = scalar @tag; $i >= 0; $i--){
927
                if ($tag eq '001') {
927
            my $textbefore = $textbefore[$i] || '';
928
                    $reported_tag.='$3'.$field->data();
928
            my $tag = $tag[$i] || '';
929
                }
929
            my $subtag = $subtag[$i] || '';
930
            } else {
930
            my $textafter = $textafter[$i] || '';
931
                my @subf = $field->subfields;
931
            my $value = '';
932
                for my $i (0..$#subf) {
932
            my $field = $record->field($tag);
933
                    my $subfieldcode = $subf[$i][0];
933
            if ( $field ) {
934
                    my $subfieldvalue = $subf[$i][1];
934
                if($subtag eq '*') {
935
                    my $tagsubf = $tag.$subfieldcode;
935
                    if($tag < 10) {
936
                    $localsummary =~ s/\[(.?.?.?.?)$tagsubf(.*?)\]/$1$subfieldvalue$2\[$1$tagsubf$2\]/g;
936
                        $value = $textbefore . $field->data() . $textafter;
937
                    }
938
                } else {
939
                    my @subfields = $field->subfield($subtag);
940
                    if(@subfields > 0) {
941
                        $value = $textbefore . join (" - ", @subfields) . $textafter;
942
                    }
937
                }
943
                }
938
            }
944
            }
939
            push @stringssummary, $localsummary if ($localsummary ne $summary{summary});
945
            $summary{summary} =~ s/\[\Q$textbefore$tag$subtag$textafter\E\]/$value/;
940
        }
946
        }
941
        my $resultstring;
947
        $summary{summary} =~ s/\\n/<br \/>/g;
942
        $resultstring = join(" -- ",@stringssummary);
943
        $resultstring =~ s/\[(.*?)\]//g;
944
        $resultstring =~ s/\n/<br>/g;
945
        $summary{summary}      =  $resultstring;
946
    }
948
    }
947
    my @authorized;
949
    my @authorized;
948
    my @notes;
950
    my @notes;
949
- 

Return to bug 10985