From 7a3e596813e01b8b56576e6a74ffdd2dae2c048f Mon Sep 17 00:00:00 2001 From: Joshua Ferraro Date: Tue, 18 Dec 2007 01:34:29 -0600 Subject: [PATCH] fix for bug 1658: in search terms Also, adds google-style search query highlighting anywhere in the record Need to check if this fix is in the OPAC Signed-off-by: Chris Cormack Signed-off-by: Joshua Ferraro --- C4/Search.pm | 27 ++++++++++++------- .../prog/en/modules/catalogue/results.tmpl | 1 + 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index a108525db2..a82e8c292a 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -1052,19 +1052,28 @@ sub searchResults { } # add spans to search term in results for search term highlighting # save a native author, for the > link + my $searchhighlightblob; + for my $highlight_field ($marcrecord->fields) { + next if $highlight_field->tag() =~ /(^00)/; # skip fixed fields + my $match; + my $field = $highlight_field->as_string(); + for my $term ( keys %$span_terms_hashref ) { + if (($field =~ /$term/) && (length($term) > 3)) { + $field =~ s/$term/$&<\/span>/gi; + $match++; + } + } + $searchhighlightblob .= $field." ... " if $match; + } + $oldbiblio->{'searchhighlightblob'} = $searchhighlightblob; + $oldbiblio->{'author_nospan'} = $oldbiblio->{'author'}; - foreach my $term ( keys %$span_terms_hashref ) { + for my $term ( keys %$span_terms_hashref ) { my $old_term = $term; if ( length($term) > 3 ) { - $term =~ s/(.*=|\)|\(|\+|\.|\?|\[|\])//g; - $term =~ s/\\//g; - $term =~ s/\*//g; - - #FIXME: is there a better way to do this? + $term =~ s/(.*=|\)|\(|\+|\.|\?|\[|\]|\\|\*)//g; $oldbiblio->{'title'} =~ s/$term/$&<\/span>/gi; - $oldbiblio->{'subtitle'} =~ - s/$term/$&<\/span>/gi; - + $oldbiblio->{'subtitle'} =~ s/$term/$&<\/span>/gi; $oldbiblio->{'author'} =~ s/$term/$&<\/span>/gi; $oldbiblio->{'publishercode'} =~ s/$term/$&<\/span>/gi; $oldbiblio->{'place'} =~ s/$term/$&<\/span>/gi; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tmpl index 85b01c5759..311e8a6f60 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tmpl @@ -290,6 +290,7 @@ $(window).load(function() { (modified on )

+

No holds allowed -- 2.39.5