From 18889f588d2386f3f847b57aacf13bb80080a087 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 19 Feb 2013 14:49:20 +0100 Subject: [PATCH] Bug 9043: Changes to the advanced search page This patch adds 2 new sysprefs: OpacAdvSearchOptions and OpacAdvSearchMoreOptions. These sysprefs are multivalued and you can add or remove some elements on the adv search page. This patch allows to display/hide some entries in the advanced search page at the OPAC. On this way, it is possible to configure the search options to display. Test plan: 1/ Fill OpacAdvSearchOptions with Item types and Languages. Fill OpacAdvSearchMoreOptions with Item types, Languages and Location. On the advanced search page, verify the Location is only displayed for the "More options" view. 2/ Try different settings for these prefs 3/ Remove all entries for the OpacAdvSearchMoreOptions and verify that the "More options" does not displayed additional options. 4/ Remove all entries for the OpacAdvSearchOptions and verify that the "normal view" does not displayed any options. Note that this patch only affects the bootstrap theme. --- installer/data/mysql/sysprefs.sql | 2 ++ installer/data/mysql/updatedatabase.pl | 13 ++++++++++++ .../prog/en/modules/admin/preferences/opac.pref | 21 ++++++++++++++++++++ .../bootstrap/en/modules/opac-advsearch.tt | 21 ++++++++++++++++---- opac/opac-search.pl | 14 ++++++++++--- 5 files changed, 64 insertions(+), 7 deletions(-) diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 05a0031..91b50b4 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -206,6 +206,8 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('OAI-PMH:MaxCount','50',NULL,'OAI-PMH maximum number of records by answer to ListRecords and ListIdentifiers queries','Integer'), ('OCLCAffiliateID','','','Use with FRBRizeEditions and XISBN. You can sign up for an AffiliateID here: http://www.worldcat.org/wcpa/do/AffiliateUserServices?method=initSelfRegister','free'), ('OpacAddMastheadLibraryPulldown','0','','Adds a pulldown menu to select the library to search on the opac masthead.','YesNo'), +('OpacAdvSearchMoreOptions','pubdate|itemtype|language|subtype|sorting|location','Show search options for the expanded view (More options)','pubdate|itemtype|language|subtype|sorting|location','multiple'), +('OpacAdvSearchOptions','pubdate|itemtype|language|sorting|location','Show search options','pubdate|itemtype|language|subtype|sorting|location','multiple'), ('OPACAllowHoldDateInFuture','0','','If set, along with the AllowHoldDateInFuture system preference, OPAC users can set the date of a hold to be in the future.','YesNo'), ('OpacAllowPublicListCreation','1',NULL,'If set, allows opac users to create public lists','YesNo'), ('OpacAllowSharingPrivateLists','0',NULL,'If set, allows opac users to share private lists with other patrons','YesNo'), diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 8917081..921bd1b 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -8202,6 +8202,19 @@ if ( CheckVersion($DBversion) ) { SetVersion($DBversion); } +$DBversion = "3.15.00.XXX"; +if ( CheckVersion($DBversion) ) { + $dbh->do(q{ + INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacAdvSearchOptions','pubdate|itemtype|language|sorting|location','Show search options','pubdate|itemtype|language|subtype|sorting|location','multiple'); + }); + + $dbh->do(q{ + INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacAdvSearchMoreOptions','pubdate|itemtype|language|subtype|sorting|location','Show search options for the expanded view (More options)','pubdate|itemtype|language|subtype|sorting|location','multiple'); + }); + print "Upgrade to $DBversion done (Bug 9043: Add system preference OpacAdvSearchOptions and OpacAdvSearchMoreOptions)\n"; + SetVersion ($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($table) 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 5483e0a..3f5c9e3 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 @@ -639,3 +639,24 @@ OPAC: - pref: PatronSelfRegistrationAdditionalInstructions type: textarea class: html + Advanced Search Options: + - + - Show search options + - pref: OpacAdvSearchOptions + multiple: + pubdate: Publication date + itemtype: Item types + language: Language + subtype: Subtypes + sorting: Sorting + location: Location + - + - Show search options for the expanded view + - pref: OpacAdvSearchMoreOptions + multiple: + pubdate: Publication date + itemtype: Item types + language: Language + subtype: Subtypes + sorting: Sorting + location: Location diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt index c55eccc..3083695 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt @@ -121,6 +121,7 @@
+ [% IF ( ( OpacAdvSearchOptions.grep('itemtype').size > 0 and not expanded_options ) or ( OpacAdvSearchMoreOptions.grep('itemtype').size > 0 and expanded_options ) ) %]
    @@ -151,8 +152,10 @@ [% END # / FOREACH advancedsearchesloop %]
+ [% END %]
+ [% IF ( ( OpacAdvSearchOptions.grep('pubdate').size > 0 and not expanded_options ) or ( OpacAdvSearchMoreOptions.grep('pubdate').size > 0 and expanded_options ) ) %]
@@ -165,7 +168,9 @@
+ [% END %] + [% IF ( ( OpacAdvSearchOptions.grep('language').size > 0 and not expanded_options ) or ( OpacAdvSearchMoreOptions.grep('language').size > 0 and expanded_options ) ) %]
@@ -188,7 +193,9 @@
+ [% END %] + [% IF ( ( OpacAdvSearchOptions.grep('location').size > 0 and not expanded_options ) or ( OpacAdvSearchMoreOptions.grep('location').size > 0 and expanded_options ) ) %] [% UNLESS ( singleBranchMode ) %]
@@ -224,7 +231,9 @@
[% END # / UNLESS singleBranchMode %] + [% END %] + [% IF ( ( OpacAdvSearchOptions.grep('sorting').size > 0 and not expanded_options ) or ( OpacAdvSearchMoreOptions.grep('sorting').size > 0 and expanded_options ) ) %]
@@ -238,9 +247,10 @@
+ [% END %]
- [% IF ( expanded_options ) %] + [% IF ( ( OpacAdvSearchOptions.grep('subtype').size > 0 and not expanded_options ) or ( OpacAdvSearchMoreOptions.grep('subtype').size > 0 and expanded_options ) ) %]
[% IF ( usmarc ) %] @@ -341,6 +351,7 @@
+ [% IF ( OpacAdvSearchMoreOptions.size > 0 and expanded_options ) or ( OpacAdvSearchOptions.size > 0 and not expanded_options ) %]
@@ -352,15 +363,17 @@
+ [% END %] [% INCLUDE 'opac-bottom.inc' %] [% BLOCK searchbuttons %]

- [% IF ( expanded_options ) %] + + [% IF expanded_options %] [Fewer options] - [% ELSE %] + [% ELSIF not expanded_options %] [More options] [% END %] [New search] @@ -392,4 +405,4 @@ }); //]]> -[% END %] \ No newline at end of file +[% END %] diff --git a/opac/opac-search.pl b/opac/opac-search.pl index 83f16d8..d58685c 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -295,9 +295,17 @@ if ( $template_type && $template_type eq 'advsearch' ) { } } - $template->param(uc( C4::Context->preference("marcflavour")) => 1, # we already did this for UNIMARC - advsearch => 1, - search_boxes_loop => \@search_boxes_array); + + my @advsearch_limits = split /\|/, C4::Context->preference('OpacAdvSearchOptions'); + my @advsearch_more_limits = split /\|/, + C4::Context->preference('OpacAdvSearchMoreOptions'); + $template->param( + uc( C4::Context->preference("marcflavour") ) => 1, # we already did this for UNIMARC + advsearch => 1, + search_boxes_loop => \@search_boxes_array, + OpacAdvSearchOptions => \@advsearch_limits, + OpacAdvSearchMoreOptions => \@advsearch_more_limits, + ); # use the global setting by default if ( C4::Context->preference("expandedSearchOption") == 1 ) { -- 1.7.10.4