From f91a41970db17daccd631c627efbc4a80d53307b Mon Sep 17 00:00:00 2001
From: Henri-Damien LAURENT
Date: Fri, 25 Jan 2008 15:04:29 -0600
Subject: [PATCH] Adding OpacHighlightedWords system preference
Disable or Enable the display of query terms in the biblio.
Signed-off-by: Chris Cormack
Signed-off-by: Joshua Ferraro
---
C4/Search.pm | 37 ++++++++++---------
admin/systempreferences.pl | 1 +
.../data/mysql/en/mandatory/sysprefs.sql | 1 +
.../unimarc_standard_systemprefs.sql | 5 ++-
installer/data/mysql/updatedatabase.pl | 9 ++++-
.../prog/en/modules/opac-results.tmpl | 2 +-
kohaversion.pl | 2 +-
7 files changed, 34 insertions(+), 23 deletions(-)
diff --git a/C4/Search.pm b/C4/Search.pm
index cb652b685f..69868abfc6 100644
--- a/C4/Search.pm
+++ b/C4/Search.pm
@@ -1237,28 +1237,29 @@ s/\[(.?.?.?.?)$tagsubf(.*?)]/$1$subfieldvalue$2\[$1$tagsubf$2]/g;
}
# Add search-term highlighting to the whole record where they match using s
- my $searchhighlightblob;
- for my $highlight_field ( $marcrecord->fields ) {
-
- # FIXME: need to skip title, subtitle, author, etc., as they are handled below
- next if $highlight_field->tag() =~ /(^00)/; # skip fixed fields
- for my $subfield ($highlight_field->subfields()) {
- my $match;
- next if $subfield->[0] eq '9';
- my $field = $subfield->[1];
- for my $term ( keys %$span_terms_hashref ) {
- if ( ( $field =~ /$term/i ) && (( length($term) > 3 ) || ($field =~ / $term /i)) ) {
- $field =~ s/$term/$&<\/span>/gi;
- $match++;
+ if (C4::Context->preference("OpacHighlightedWords")){
+ my $searchhighlightblob;
+ for my $highlight_field ( $marcrecord->fields ) {
+
+ # FIXME: need to skip title, subtitle, author, etc., as they are handled below
+ next if $highlight_field->tag() =~ /(^00)/; # skip fixed fields
+ for my $subfield ($highlight_field->subfields()) {
+ my $match;
+ next if $subfield->[0] eq '9';
+ my $field = $subfield->[1];
+ for my $term ( keys %$span_terms_hashref ) {
+ if ( ( $field =~ /$term/i ) && (( length($term) > 3 ) || ($field =~ / $term /i)) ) {
+ $field =~ s/$term/$&<\/span>/gi;
+ $match++;
+ }
}
+ $searchhighlightblob .= $field . " ... " if $match;
}
- $searchhighlightblob .= $field . " ... " if $match;
+
}
-
+ $searchhighlightblob = ' ... '.$searchhighlightblob if $searchhighlightblob;
+ $oldbiblio->{'searchhighlightblob'} = $searchhighlightblob;
}
- $searchhighlightblob = ' ... '.$searchhighlightblob if $searchhighlightblob;
- $oldbiblio->{'searchhighlightblob'} = $searchhighlightblob;
-
# save an author with no tag, for the > link
$oldbiblio->{'author_nospan'} = $oldbiblio->{'author'};
diff --git a/admin/systempreferences.pl b/admin/systempreferences.pl
index 7f39a7af91..0f1cc69f05 100755
--- a/admin/systempreferences.pl
+++ b/admin/systempreferences.pl
@@ -228,6 +228,7 @@ my %tabsysprefs;
$tabsysprefs{OPACSubscriptionDisplay}="OPAC";
$tabsysprefs{OPACURLOpenInNewWindow}="OPAC";
$tabsysprefs{OPACUserCSS}="OPAC";
+ $tabsysprefs{OPACHighlightedWords}="OPAC";
$tabsysprefs{OPACViewOthersSuggestions}="OPAC";
$tabsysprefs{URLLinkText}="OPAC";
diff --git a/installer/data/mysql/en/mandatory/sysprefs.sql b/installer/data/mysql/en/mandatory/sysprefs.sql
index 57752c59fa..2219d706ab 100644
--- a/installer/data/mysql/en/mandatory/sysprefs.sql
+++ b/installer/data/mysql/en/mandatory/sysprefs.sql
@@ -173,3 +173,4 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OpacRenewalAllowed',0,'If ON, users can renew their issues directly from their OPAC account',NULL,'YesNo');
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('PatronsPerPage','20','Number of Patrons Per Page displayed by default','20','Integer');
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('HomeOrHoldingBranch','holdingbranch','Used by Circulation to determine which branch of an item to check with independent branches on ','holdingbranch|homebranch','Choice');
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OpacHighlightedWords','1','If Set, then queried words are higlighted in OPAC','','YesNo');
diff --git a/installer/data/mysql/fr/1-Obligatoire/unimarc_standard_systemprefs.sql b/installer/data/mysql/fr/1-Obligatoire/unimarc_standard_systemprefs.sql
index 56af849c5a..7ac77fe143 100644
--- a/installer/data/mysql/fr/1-Obligatoire/unimarc_standard_systemprefs.sql
+++ b/installer/data/mysql/fr/1-Obligatoire/unimarc_standard_systemprefs.sql
@@ -166,5 +166,6 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('emailPurchaseSuggestions',0,'If ON, patron suggestions are emailed rather than managed in Acquisitions',NULL,'YesNo');
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACItemsResultsDisplay',"statuses",'statuses : N''affiche que le statut des exemplaires dans la liste de résultat. . itemdetails : affiche la localisation complète des exemplaires (site+localisation+cote) comme dans l''interface professionnelle ',"statuses|itemdetails",'Choice');
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OPACBaseURL',NULL,'Specify the Base URL of the OPAC, e.g., opac.mylibrary.com, the http:// will be added automatically by Koha.',NULL,'Free');
-
-INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OpacRenewalAllowed',0,'Si activé, les utilisateurs peuvent renouveller leurs prêts directement depuis leur compte à l''OPAC',NULL,'YesNo');
\ No newline at end of file
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OpacRenewalAllowed',0,'Si activé, les utilisateurs peuvent renouveller leurs prêts directement depuis leur compte à l''OPAC',NULL,'YesNo');
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OpacRenewalAllowed',0,'Si activé, les utilisateurs peuvent renouveller leurs prêts directement depuis leur compte à l''OPAC',NULL,'YesNo');
+INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OpacHighlightedWords','0','Si activé, les mots recherchés dans la notices sont affichés dans l''OPAC','','YesNo');
diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl
index 13eb7c35cb..63c4634f36 100755
--- a/installer/data/mysql/updatedatabase.pl
+++ b/installer/data/mysql/updatedatabase.pl
@@ -962,13 +962,20 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
$DBversion = "3.00.00.049";
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
- $dbh->do("ALTER TABLE z3950servers
+ $dbh->do("ALTER TABLE `z3950servers`
ADD `encoding` text default NULL,
");
print "Upgrade to $DBversion done ( Added encoding field to z3950servers table )\n";
SetVersion ($DBversion);
}
+$DBversion = "3.00.00.050";
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('OpacHighlightedWords','0','If Set, query matched terms are highlighted in OPAC',NULL,'YesNo');");
+ print "Upgrade to $DBversion done ( Added OpacHighlightedWords syspref )\n";
+ SetVersion ($DBversion);
+}
+
=item DropAllForeignKeys($table)
Drop all foreign keys of the table $table
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tmpl b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tmpl
index fde1d0dd1f..43338a4264 100644
--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tmpl
+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tmpl
@@ -141,7 +141,7 @@ href="/cgi-bin/koha/opac-rss.pl? ;
(modified on )
-
+
Copies available at:
diff --git a/kohaversion.pl b/kohaversion.pl
index d35affa5c2..ed8037b7c8 100644
--- a/kohaversion.pl
+++ b/kohaversion.pl
@@ -10,7 +10,7 @@
use strict;
sub kohaversion {
- our $VERSION = "3.00.00.048";
+ our $VERSION = "3.00.00.050";
# version needs to be set this way
# so that it can be picked up by Makefile.PL
# during install
--
2.39.5