BUGFIX : highlighting term fixes
[koha.git] / C4 / Search.pm
index cbff21f..a3ffc09 100644 (file)
@@ -967,10 +967,19 @@ sub buildQuery {
                         $remove_stopwords
                     ) = ( 0, 0, 0, 0, 0 );
                 }
+                # ISBN,ISSN,Standard Number, don't need special treatment
+                elsif ( $index eq 'nb' || $index eq 'ns' ) {
+                    $indexes_set++;
+                    (   
+                        $stemming,      $auto_truncation,
+                        $weight_fields, $fuzzy_enabled,
+                        $remove_stopwords
+                    ) = ( 0, 0, 0, 0, 0 );
 
+                }
                 # Set default structure attribute (word list)
                 my $struct_attr;
-                unless ( !$index || $index =~ /(st-|phr|ext|wrdl)/ ) {
+                unless ( $indexes_set || !$index || $index =~ /(st-|phr|ext|wrdl)/ ) {
                     $struct_attr = ",wrdl";
                 }
 
@@ -1307,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 ) {
@@ -1330,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;
+                }
             }
         }
 
@@ -1490,7 +1500,7 @@ s/\[(.?.?.?.?)$tagsubf(.*?)]/$1$subfieldvalue$2\[$1$tagsubf$2]/g;
 
         # XSLT processing of some stuff
         if (C4::Context->preference("XSLTResultsDisplay") ) {
-            my $newxmlrecord = XSLTParse4Display($oldbiblio->{biblionumber},'Results');
+            my $newxmlrecord = XSLTParse4Display($oldbiblio->{biblionumber},C4::Context->config('opachtdocs')."/prog/en/xslt/MARC21slim2OPACResults.xsl");
             $oldbiblio->{XSLTResultsRecord} = $newxmlrecord;
         }