[Koha-patches] [PATCH] BUGFIX : highlighting term fixes

paul.poulain at biblibre.com paul.poulain at biblibre.com
Mon Apr 14 18:55:52 CEST 2008


From: Paul POULAIN <paul.poulain at biblibre.com>

diff --git a/C4/Search.pm b/C4/Search.pm
index dc05673..a3ffc09 100644
--- a/C4/Search.pm
+++ b/C4/Search.pm
@@ -1316,7 +1316,10 @@ s/\[(.?.?.?.?)$tagsubf(.*?)]/$1$subfieldvalue$2\[$1$tagsubf$2]/g;
             $oldbiblio->{summary} = $summary;
         }
 
-# Add search-term highlighting to the whole record where they match using <span>s
+        # save an author with no <span> tag, for the <a href=search.pl?q=<!--tmpl_var name="author"-->> link
+        $oldbiblio->{'author_nospan'} = $oldbiblio->{'author'};
+        $oldbiblio->{'title_nospan'} = $oldbiblio->{'title'};
+        # Add search-term highlighting to the whole record where they match using <span>s
         if (C4::Context->preference("OpacHighlightedWords")){
             my $searchhighlightblob;
             for my $highlight_field ( $marcrecord->fields ) {
@@ -1339,31 +1342,29 @@ s/\[(.?.?.?.?)$tagsubf(.*?)]/$1$subfieldvalue$2\[$1$tagsubf$2]/g;
             }
             $searchhighlightblob = ' ... '.$searchhighlightblob if $searchhighlightblob;
             $oldbiblio->{'searchhighlightblob'} = $searchhighlightblob;
-        }
-# save an author with no <span> tag, for the <a href=search.pl?q=<!--tmpl_var name="author"-->> link
-        $oldbiblio->{'author_nospan'} = $oldbiblio->{'author'};
-
-        # Add search-term highlighting to the title, subtitle, etc. fields
-        for my $term ( keys %$span_terms_hashref ) {
-            my $old_term = $term;
-            if ( length($term) > 3 ) {
-                $term =~ s/(.*=|\)|\(|\+|\.|\?|\[|\]|\\|\*)//g;
-                $oldbiblio->{'title'} =~
-                  s/$term/<span class=\"term\">$&<\/span>/gi;
-                $oldbiblio->{'subtitle'} =~
-                  s/$term/<span class=\"term\">$&<\/span>/gi;
-                $oldbiblio->{'author'} =~
-                  s/$term/<span class=\"term\">$&<\/span>/gi;
-                $oldbiblio->{'publishercode'} =~
-                  s/$term/<span class=\"term\">$&<\/span>/gi;
-                $oldbiblio->{'place'} =~
-                  s/$term/<span class=\"term\">$&<\/span>/gi;
-                $oldbiblio->{'pages'} =~
-                  s/$term/<span class=\"term\">$&<\/span>/gi;
-                $oldbiblio->{'notes'} =~
-                  s/$term/<span class=\"term\">$&<\/span>/gi;
-                $oldbiblio->{'size'} =~
-                  s/$term/<span class=\"term\">$&<\/span>/gi;
+    
+            # Add search-term highlighting to the title, subtitle, etc. fields
+            for my $term ( keys %$span_terms_hashref ) {
+                my $old_term = $term;
+                if ( length($term) > 3 ) {
+                    $term =~ s/(.*=|\)|\(|\+|\.|\?|\[|\]|\\|\*)//g;
+                    $oldbiblio->{'title'} =~
+                    s/$term/<span class=\"term\">$&<\/span>/gi;
+                    $oldbiblio->{'subtitle'} =~
+                    s/$term/<span class=\"term\">$&<\/span>/gi;
+                    $oldbiblio->{'author'} =~
+                    s/$term/<span class=\"term\">$&<\/span>/gi;
+                    $oldbiblio->{'publishercode'} =~
+                    s/$term/<span class=\"term\">$&<\/span>/gi;
+                    $oldbiblio->{'place'} =~
+                    s/$term/<span class=\"term\">$&<\/span>/gi;
+                    $oldbiblio->{'pages'} =~
+                    s/$term/<span class=\"term\">$&<\/span>/gi;
+                    $oldbiblio->{'notes'} =~
+                    s/$term/<span class=\"term\">$&<\/span>/gi;
+                    $oldbiblio->{'size'} =~
+                    s/$term/<span class=\"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 3c9b707..f64f9cf 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tmpl
@@ -152,7 +152,7 @@ $(window).load(function() {
                     <tr>
                 <!-- /TMPL_IF -->
                         <td>
-                            <a href="/cgi-bin/koha/catalogue/search.pl?q=<!-- TMPL_VAR NAME="scan_use" escape="url" -->&quot;<!-- TMPL_VAR NAME="title" -->&quot;"><!-- TMPL_VAR NAME="title" --></a>
+                            <a href="/cgi-bin/koha/catalogue/search.pl?q=<!-- TMPL_VAR NAME="scan_use" escape="url" -->&quot;<!-- TMPL_VAR NAME="title_nospan" -->&quot;"><!-- TMPL_VAR NAME="title" --></a>
                         </td>
                         <td>
                             <!-- TMPL_VAR NAME="author" -->
-- 
1.5.3.2




More information about the Koha-patches mailing list