Lines 1266-1298
sub searchResults {
Link Here
|
1266 |
if ( $itemtypes{ $oldbiblio->{itemtype} }->{summary} ) { |
1266 |
if ( $itemtypes{ $oldbiblio->{itemtype} }->{summary} ) { |
1267 |
my $summary = $itemtypes{ $oldbiblio->{itemtype} }->{summary}; |
1267 |
my $summary = $itemtypes{ $oldbiblio->{itemtype} }->{summary}; |
1268 |
my @fields = $marcrecord->fields(); |
1268 |
my @fields = $marcrecord->fields(); |
1269 |
foreach my $field (@fields) { |
1269 |
|
1270 |
my $tag = $field->tag(); |
1270 |
my $newsummary; |
1271 |
my $tagvalue = $field->as_string(); |
1271 |
foreach my $line ( "$summary\n" =~ /(.*)\n/g ){ |
1272 |
if (! utf8::is_utf8($tagvalue)) { |
1272 |
my $tags = {}; |
1273 |
utf8::decode($tagvalue); |
1273 |
foreach my $tag ( $line =~ /\[(\d{3}[\w|\d])\]/ ) { |
|
|
1274 |
$tag =~ /(.{3})(.)/; |
1275 |
if($marcrecord->field($1)){ |
1276 |
my @abc = $marcrecord->field($1)->subfield($2); |
1277 |
$tags->{$tag} = $#abc + 1 ; |
1278 |
} |
1279 |
} |
1280 |
|
1281 |
# We catch how many times to repeat this line |
1282 |
my $max = 0; |
1283 |
foreach my $tag (keys(%$tags)){ |
1284 |
$max = $tags->{$tag} if($tags->{$tag} > $max); |
1274 |
} |
1285 |
} |
|
|
1286 |
|
1287 |
# we replace, and repeat each line |
1288 |
for (my $i = 0 ; $i < $max ; $i++){ |
1289 |
my $newline = $line; |
1290 |
|
1291 |
foreach my $tag ( $newline =~ /\[(\d{3}[\w|\d])\]/g ) { |
1292 |
$tag =~ /(.{3})(.)/; |
1293 |
|
1294 |
if($marcrecord->field($1)){ |
1295 |
my @repl = $marcrecord->field($1)->subfield($2); |
1296 |
|
1297 |
my $subfieldvalue = @repl[$i]; |
1298 |
|
1299 |
if (! utf8::is_utf8($subfieldvalue)) { |
1300 |
utf8::decode($subfieldvalue); |
1301 |
} |
1275 |
|
1302 |
|
1276 |
$summary =~ |
1303 |
$newline =~ s/\[$tag\]/$subfieldvalue/g; |
1277 |
s/\[(.?.?.?.?)$tag\*(.*?)]/$1$tagvalue$2\[$1$tag$2]/g; |
|
|
1278 |
unless ( $tag < 10 ) { |
1279 |
my @subf = $field->subfields; |
1280 |
for my $i ( 0 .. $#subf ) { |
1281 |
my $subfieldcode = $subf[$i][0]; |
1282 |
my $subfieldvalue = $subf[$i][1]; |
1283 |
if (! utf8::is_utf8($subfieldvalue)) { |
1284 |
utf8::decode($subfieldvalue); |
1285 |
} |
1304 |
} |
1286 |
my $tagsubf = $tag . $subfieldcode; |
|
|
1287 |
$summary =~ |
1288 |
s/\[(.?.?.?.?)$tagsubf(.*?)]/$1$subfieldvalue$2\[$1$tagsubf$2]/g; |
1289 |
} |
1305 |
} |
|
|
1306 |
$newsummary .= "$newline\n"; |
1290 |
} |
1307 |
} |
1291 |
} |
1308 |
} |
1292 |
# FIXME: yuk |
1309 |
|
1293 |
$summary =~ s/\[(.*?)]//g; |
1310 |
$newsummary =~ s/\[(.*?)]//g; |
1294 |
$summary =~ s/\n/<br\/>/g; |
1311 |
$newsummary =~ s/\n/<br\/>/g; |
1295 |
$oldbiblio->{summary} = $summary; |
1312 |
$oldbiblio->{summary} = $newsummary; |
1296 |
} |
1313 |
} |
1297 |
|
1314 |
|
1298 |
# save an author with no <span> tag, for the <a href=search.pl?q=<!--tmpl_var name="author"-->> link |
1315 |
# save an author with no <span> tag, for the <a href=search.pl?q=<!--tmpl_var name="author"-->> link |
1299 |
- |
|
|