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

(-)a/C4/Search.pm (-23 / +38 lines)
Lines 1434-1466 sub searchResults { Link Here
1434
        if ( $itemtypes{ $oldbiblio->{itemtype} }->{summary} ) {
1434
        if ( $itemtypes{ $oldbiblio->{itemtype} }->{summary} ) {
1435
            my $summary = $itemtypes{ $oldbiblio->{itemtype} }->{summary};
1435
            my $summary = $itemtypes{ $oldbiblio->{itemtype} }->{summary};
1436
            my @fields  = $marcrecord->fields();
1436
            my @fields  = $marcrecord->fields();
1437
            foreach my $field (@fields) {
1437
            
1438
                my $tag      = $field->tag();
1438
            my $newsummary;
1439
                my $tagvalue = $field->as_string();
1439
            foreach my $line ( "$summary\n" =~ /(.*)\n/g ){
1440
                if (! utf8::is_utf8($tagvalue)) {
1440
                my $tags = {};
1441
                    utf8::decode($tagvalue);
1441
                foreach my $tag ( $line =~ /\[(\d{3}[\w|\d])\]/ ) {
1442
                    $tag =~ /(.{3})(.)/;
1443
                    if($marcrecord->field($1)){
1444
                        my @abc = $marcrecord->field($1)->subfield($2);
1445
                        $tags->{$tag} = $#abc + 1 ;
1446
                    }
1442
                }
1447
                }
1443
1448
                
1444
                $summary =~
1449
                # We catch how many times to repeat this line
1445
                  s/\[(.?.?.?.?)$tag\*(.*?)]/$1$tagvalue$2\[$1$tag$2]/g;
1450
                my $max = 0;
1446
                unless ( $tag < 10 ) {
1451
                foreach my $tag (keys(%$tags)){
1447
                    my @subf = $field->subfields;
1452
                    $max = $tags->{$tag} if($tags->{$tag} > $max);
1448
                    for my $i ( 0 .. $#subf ) {
1453
                 }
1449
                        my $subfieldcode  = $subf[$i][0];
1454
                
1450
                        my $subfieldvalue = $subf[$i][1];
1455
                # we replace, and repeat each line
1451
                        if (! utf8::is_utf8($subfieldvalue)) {
1456
                for (my $i = 0 ; $i < $max ; $i++){
1452
                            utf8::decode($subfieldvalue);
1457
                    my $newline = $line;
1458
1459
                    foreach my $tag ( $newline =~ /\[(\d{3}[\w|\d])\]/g ) {
1460
                        $tag =~ /(.{3})(.)/;
1461
                        
1462
                        if($marcrecord->field($1)){
1463
                            my @repl = $marcrecord->field($1)->subfield($2);
1464
                            my $subfieldvalue = $repl[$i];
1465
                            
1466
                            if (! utf8::is_utf8($subfieldvalue)) {
1467
                                utf8::decode($subfieldvalue);
1468
                            }
1469
 
1470
                             $newline =~ s/\[$tag\]/$subfieldvalue/g;
1453
                        }
1471
                        }
1454
                        my $tagsubf       = $tag . $subfieldcode;
1455
                        $summary =~
1456
s/\[(.?.?.?.?)$tagsubf(.*?)]/$1$subfieldvalue$2\[$1$tagsubf$2]/g;
1457
                    }
1472
                    }
1473
                    $newsummary .= "$newline\n";
1458
                }
1474
                }
1459
            }
1475
            }
1460
            # FIXME: yuk
1476
1461
            $summary =~ s/\[(.*?)]//g;
1477
            $newsummary =~ s/\[(.*?)]//g;
1462
            $summary =~ s/\n/<br\/>/g;
1478
            $newsummary =~ s/\n/<br\/>/g;
1463
            $oldbiblio->{summary} = $summary;
1479
            $oldbiblio->{summary} = $newsummary;
1464
        }
1480
        }
1465
1481
1466
        # Pull out the items fields
1482
        # Pull out the items fields
1467
- 

Return to bug 3281