Bugzilla – Attachment 30842 Details for
Bug 6149
Operator Highlighted in Search Results
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[PASSED QA] Bug 6149 - Stopwords for Result Highlighting
PASSED-QA-Bug-6149---Stopwords-for-Result-Highligh.patch (text/plain), 7.71 KB, created by
Katrin Fischer
on 2014-08-15 15:46:52 UTC
(
hide
)
Description:
[PASSED QA] Bug 6149 - Stopwords for Result Highlighting
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2014-08-15 15:46:52 UTC
Size:
7.71 KB
patch
obsolete
>From e7d3e55ab6cea8b38cd3395a792cf30e8b18b593 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Fri, 9 Aug 2013 14:42:00 +0100 >Subject: [PATCH] [PASSED QA] Bug 6149 - Stopwords for Result Highlighting > >This patch adds a system preference to control stopwords used to >prevent operators and other 'minor' words from being highlighted >in search results when the OpacHighlightWords syspref is enabled > >Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> > >Works as advertised, I fixed the updatedatabase to use XXX so it won't >clash as much > >Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de> >Fixed a conflict in updatedatabase.pl. >Also fixed tabs in opac-detail.tt > >Feature passes all tests and QA script now. >Tested in intranet and OPAC with different words and searches. >Works on results pages and OPAC detail page. >Highlighting and unhighlighting still works correctly. > >Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com> >Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de> >Passes all tests and QA script, works as expected. >--- > installer/data/mysql/sysprefs.sql | 1 + > installer/data/mysql/updatedatabase.pl | 9 +++++++++ > .../prog/en/modules/admin/preferences/opac.pref | 5 ++++- > koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt | 5 ++++- > koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt | 12 ++++++++---- > koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt | 4 +++- > 6 files changed, 29 insertions(+), 7 deletions(-) > >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index 03a3f1e..99a7169 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -238,6 +238,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('opacheader','','70|10','Add HTML to be included as a custom header in the OPAC','Textarea'), > ('OpacHiddenItems','','','This syspref allows to define custom rules for hiding specific items at opac. See docs/opac/OpacHiddenItems.txt for more informations.','Textarea'), > ('OpacHighlightedWords','1','','If Set, then queried words are higlighted in OPAC','YesNo'), >+('OpacHighlightedStopWords','and|And|or|Or',NULL,'List of words to NOT highlight when OpacHitHighlight is enabled','free'), > ('OpacHoldNotes','0','','Show hold notes on OPAC','YesNo'), > ('OPACItemHolds','1','0|1|force','Allow OPAC users to place hold on specific items. If No, users can only request next available copy. If Yes, users can choose between next available and specific copy. If Force, users *must* choose a specific copy.','Choice'), > ('OpacItemLocation','callnum','callnum|ccode|location','Show the shelving location of items in the opac','Choice'), >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 3f1af57..7a8df7a 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -8600,6 +8600,15 @@ $DBversion = "3.17.00.013"; > if ( CheckVersion($DBversion) ) { > $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('maxreserves',50,'System-wide maximum number of holds a patron can place','','Integer')"); > print "Upgrade to $DBversion done (Re-add system preference maxreserves)\n"; >+ SetVersion ($DBversion); >+} >+ >+ >+$DBversion = "3.17.00.XXX"; >+if ( CheckVersion($DBversion) ) { >+ $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OpacHighlightedStopWords','and|And|or|Or',NULL,'List of words to NOT highlight when OpacHitHighlight is enabled','free')" >+ ); >+ print "Upgrade to $DBversion done (Bug 6149: Operator highlighted in search results)\n"; > SetVersion($DBversion); > } > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >index 739abb3..91b5d62 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >@@ -151,7 +151,10 @@ OPAC: > choices: > yes: Highlight > no: "Don't highlight" >- - words the patron searched for in their search results and detail pages. >+ - words the patron searched for in their search results and detail pages; To prevent certain words from ever being highlighted, enter a list of stopwords here >+ - pref: OpacHighlightedStopWords >+ class: multi >+ - (separate columns with |) > - > - pref: AuthorisedValueImages > choices: >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >index 34296b6..2e39f63 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >@@ -1,3 +1,4 @@ >+[% USE Koha %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Catalog › [% IF ( searchdesc ) %]Results of search [% IF ( query_desc ) %]for '[% query_desc | html %]'[% END %][% IF ( limit_desc ) %] with limit(s): '[% limit_desc | html %]'[% END %][% ELSE %]You did not specify any search criteria[% END %]</title> > [% INCLUDE 'doc-head-close.inc' %] >@@ -162,7 +163,9 @@ $('#sort_by').change(function() { > function highlightOn() { > var x; > for (x in q_array) { >- if ( q_array[x].length > 0 ) { >+ q_array[x] = q_array[x].toLowerCase(); >+ var myStopwords = "[% Koha.Preference('OpacHighlightedStopWords') %]".toLowerCase().split('|'); >+ if ( (q_array[x].length > 0) && ($.inArray(q_array[x], myStopwords) == -1) ) { > toHighlight.highlight(q_array[x]); > } > } >diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt >index baaec0b..d06ab65 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt >+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt >@@ -70,11 +70,15 @@ > } > function highlightOn() { > var x; >- for (x in q_array) { >+ for (x in q_array) { > q_array[x] = q_array[x].replace(/\w*:([\w])/, "$1"); >- $(".title").highlight(q_array[x]); >- $(".author").highlight(q_array[x]); >- $(".results_summary").highlight(q_array[x]); >+ q_array[x] = q_array[x].toLowerCase(); >+ var myStopwords = "[% Koha.Preference('OpacHighlightedStopWords') %]".toLowerCase().split('|'); >+ if( $.inArray(q_array[x], myStopwords) == -1 ) { >+ $(".title").highlight(q_array[x]); >+ $(".author").highlight(q_array[x]); >+ $(".results_summary").highlight(q_array[x]); >+ } > } > $(".highlight_toggle").toggle(); > } >diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt >index 8ba8ff3..42d9ca4 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt >+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt >@@ -100,7 +100,9 @@ function highlightOn() { > var x; > for (x in q_array) { > q_array[x] = q_array[x].replace(/\w*:([\w])/, "$1"); >- if ( q_array[x].length > 0 ) { >+ q_array[x] = q_array[x].toLowerCase(); >+ var myStopwords = "[% Koha.Preference('OpacHighlightedStopWords') %]".toLowerCase().split('|'); >+ if ( (q_array[x].length > 0) && ($.inArray(q_array[x], myStopwords) == -1) ) { > $(".title").highlight(q_array[x]); > $(".author").highlight(q_array[x]); > $(".results_summary").highlight(q_array[x]); >-- >1.9.1
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 6149
:
20240
|
20469
|
20540
|
20543
|
20715
|
20802
|
21168
|
21582
|
21831
|
22448
|
22463
|
22466
|
22505
|
22511
|
23005
|
23025
|
23027
|
23064
|
23065
|
23066
|
26051
|
30136
|
30137
|
30138
|
30139
|
30140
|
30141
|
30142
|
30143
|
30144
|
30835
| 30842 |
30843
|
30844
|
30845
|
30846
|
31403