Bugzilla – Attachment 1195 Details for
Bug 3281
Item's summary parsing should be different
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
bugfix
0001--bug-3281-change-the-way-to-parse-item-s-summary.patch (text/plain), 3.83 KB, created by
Chris Cormack
on 2009-06-02 15:03:00 UTC
(
hide
)
Description:
bugfix
Filename:
MIME Type:
Creator:
Chris Cormack
Created:
2009-06-02 15:03:00 UTC
Size:
3.83 KB
patch
obsolete
>From 6a4d48a4ca88e08fe284440d75ef3ff4ede6c871 Mon Sep 17 00:00:00 2001 >From: Nahuel ANGELINETTI <nahuel.angelinetti@biblibre.com> >Date: Tue, 2 Jun 2009 16:55:52 +0200 >Subject: [PATCH] (bug #3281) change the way to parse item's summary >Content-Type: text/plain; charset="utf-8" > >This change how to calculate the item's summary, and fix the issue when you have repeated fields. >Now every line is repeated, still it have values in repeated fields(see bug report). >--- > C4/Search.pm | 59 +++++++++++++++++++++++++++++++++++++-------------------- > 1 files changed, 38 insertions(+), 21 deletions(-) > >diff --git a/C4/Search.pm b/C4/Search.pm >index 26aa031..2799d97 100644 >--- a/C4/Search.pm >+++ b/C4/Search.pm >@@ -1266,33 +1266,50 @@ sub searchResults { > if ( $itemtypes{ $oldbiblio->{itemtype} }->{summary} ) { > my $summary = $itemtypes{ $oldbiblio->{itemtype} }->{summary}; > my @fields = $marcrecord->fields(); >- foreach my $field (@fields) { >- my $tag = $field->tag(); >- my $tagvalue = $field->as_string(); >- if (! utf8::is_utf8($tagvalue)) { >- utf8::decode($tagvalue); >+ >+ my $newsummary; >+ foreach my $line ( "$summary\n" =~ /(.*)\n/g ){ >+ my $tags = {}; >+ foreach my $tag ( $line =~ /\[(\d{3}[\w|\d])\]/ ) { >+ $tag =~ /(.{3})(.)/; >+ if($marcrecord->field($1)){ >+ my @abc = $marcrecord->field($1)->subfield($2); >+ $tags->{$tag} = $#abc + 1 ; >+ } >+ } >+ >+ # We catch how many times to repeat this line >+ my $max = 0; >+ foreach my $tag (keys(%$tags)){ >+ $max = $tags->{$tag} if($tags->{$tag} > $max); > } >+ >+ # we replace, and repeat each line >+ for (my $i = 0 ; $i < $max ; $i++){ >+ my $newline = $line; >+ >+ foreach my $tag ( $newline =~ /\[(\d{3}[\w|\d])\]/g ) { >+ $tag =~ /(.{3})(.)/; >+ >+ if($marcrecord->field($1)){ >+ my @repl = $marcrecord->field($1)->subfield($2); >+ >+ my $subfieldvalue = @repl[$i]; >+ >+ if (! utf8::is_utf8($subfieldvalue)) { >+ utf8::decode($subfieldvalue); >+ } > >- $summary =~ >- s/\[(.?.?.?.?)$tag\*(.*?)]/$1$tagvalue$2\[$1$tag$2]/g; >- unless ( $tag < 10 ) { >- my @subf = $field->subfields; >- for my $i ( 0 .. $#subf ) { >- my $subfieldcode = $subf[$i][0]; >- my $subfieldvalue = $subf[$i][1]; >- if (! utf8::is_utf8($subfieldvalue)) { >- utf8::decode($subfieldvalue); >+ $newline =~ s/\[$tag\]/$subfieldvalue/g; > } >- my $tagsubf = $tag . $subfieldcode; >- $summary =~ >-s/\[(.?.?.?.?)$tagsubf(.*?)]/$1$subfieldvalue$2\[$1$tagsubf$2]/g; > } >+ $newsummary .= "$newline\n"; > } > } >- # FIXME: yuk >- $summary =~ s/\[(.*?)]//g; >- $summary =~ s/\n/<br\/>/g; >- $oldbiblio->{summary} = $summary; >+ >+ $newsummary =~ s/\[(.*?)]//g; >+ $newsummary =~ s/\n/<br\/>/g; >+ $oldbiblio->{summary} = $newsummary; > } > > # save an author with no <span> tag, for the <a href=search.pl?q=<!--tmpl_var name="author"-->> link >-- >1.6.0.4 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 3281
:
1195
|
1196
|
1197