From 49ebf45525104410e1149c4e354936c878368b89 Mon Sep 17 00:00:00 2001 From: Jonathan Druart <jonathan.druart@biblibre.com> Date: Tue, 19 Feb 2013 14:49:20 +0100 Subject: [PATCH] Bug 9043: Changes to the advanced search page New syspref: OpacAdvSearch. This syspref is multivalued and you can add or remove some elements on the adv search page. --- installer/data/mysql/sysprefs.sql | 1 + installer/data/mysql/updatedatabase.pl | 7 +++++++ .../prog/en/modules/admin/preferences/opac.pref | 11 ++++++++++ .../opac-tmpl/prog/en/modules/opac-advsearch.tt | 21 ++++++++++++++++++-- opac/opac-search.pl | 5 ++++- 5 files changed, 42 insertions(+), 3 deletions(-) diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 46c2371..50c7e13 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -413,3 +413,4 @@ INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) V INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('IDreamBooksResults','0','Display IDreamBooks.com rating in search results','','YesNo'); INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('OPACNumbersPreferPhrase','0', NULL, 'Control the use of phr operator in callnumber and standard number OPAC searches', 'YesNo'); INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('IntranetNumbersPreferPhrase','0', NULL, 'Control the use of phr operator in callnumber and standard number staff client searches', 'YesNo'); +INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacAdvSearch','pubdate|itemtype|language|subtype|sorting|location','Show search options','pubdate|itemtype|language|subtype|sorting|location','multiple'); diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 15d900c..e00757f 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -6407,6 +6407,13 @@ if ( CheckVersion($DBversion) ) { SetVersion ($DBversion); } +$DBversion = "3.11.00.XXX"; +if ( CheckVersion($DBversion) ) { + $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacAdvSearch','pubdate|itemtype|language|subtype|sorting|location','Show search options','pubdate|itemtype|language|subtype|sorting|location','multiple');"); + print "Upgrade to $DBversion done (Bug 9043: Add OpacAdvSearch)\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 300c6e1..a2cd3e7 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 @@ -573,3 +573,14 @@ OPAC: - pref: PatronSelfRegistrationBorrowerUnwantedField class: multi - (separate columns with |) + Advanced Search Options: + - + - Show search options + - pref: OpacAdvSearch + multiple: + pubdate: Publication date + itemtype: Item types + language: Language + subtype: Subtypes + sorting: Sorting + location: Location diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-advsearch.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-advsearch.tt index 825e8be..7f738bf 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-advsearch.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-advsearch.tt @@ -142,6 +142,7 @@ <a href="/cgi-bin/koha/opac-search.pl?do=Clear">[New search]</a> <!-- /SEARCH BUTTONS --></div></div> +[% IF OpacAdvSearch.grep('pubdate').size > 0 %] <div class="yui-g"> <div id="pubrange" class="container"> <fieldset> @@ -153,7 +154,10 @@ <!-- /PUB RANGE OPTION --> </div> </div> +[% END %] + <div class="yui-g"> +[% IF OpacAdvSearch.grep('itemtype').size > 0 %] <div id="advsearches" class="toptabs"> <ul> [% FOREACH advsearchloo IN advancedsearchesloop %] @@ -185,6 +189,9 @@ </div> [% END %] </div> +[% END %] + +[% IF OpacAdvSearch.grep('language').size > 0 %] <div id="langfilter"> <fieldset><legend>Language</legend> <!-- LANGUAGE LIMIT --> @@ -202,7 +209,9 @@ <!-- /LANGUAGE LIMIT --> </fieldset> </div> -[% IF ( expanded_options ) %] +[% END %] + +[% IF OpacAdvSearch.grep('subtype').size > 0 && expanded_options %] [% IF ( usmarc ) %] <!-- SUBTYPE LIMITS --> <div id="subtypes" class="container"><fieldset> @@ -275,10 +284,11 @@ [% INCLUDE 'subtypes_unimarc.inc' %]</div> [% END %] [% END %] - </div> + <div class="yui-g"> +[% IF OpacAdvSearch.grep('location').size > 0 %] <div class="yui-u first"> <!-- AVAILABILITY LIMITS --> [% UNLESS ( singleBranchMode ) %] @@ -309,6 +319,9 @@ [% END %] <!-- /AVAILABILITY LIMITS --> </div> +[% END%] + +[% IF OpacAdvSearch.grep('sorting').size > 0 %] <div class="yui-u"> <!-- RANK LIMITS --> <div id="sortby" class="container"><fieldset><legend>Sorting: </legend> @@ -317,8 +330,10 @@ </select></fieldset></div> <!-- RANK LIMITS --> </div> +[% END %] </div> +[% IF OpacAdvSearch.size > 0 %] <div class="yui-g"><div class="container" style="text-align: center;"><!-- SEARCH BUTTONS --> <input class="submit" type="submit" accesskey="s" name="do" title="Search" value="Search" /> @@ -332,6 +347,8 @@ <!-- /SEARCH BUTTONS --></div></div> </form> </div> +[% END %] + <script type="text/javascript" language="javascript"> /* This function allows to display a new field to search. */ diff --git a/opac/opac-search.pl b/opac/opac-search.pl index 4744ac6..b0834cd 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -127,8 +127,11 @@ elsif (C4::Context->preference("marcflavour") eq "MARC21" ) { $template->param( 'AllowOnShelfHolds' => C4::Context->preference('AllowOnShelfHolds') ); $template->param( 'OPACNoResultsFound' => C4::Context->preference('OPACNoResultsFound') ); +my @advsearch_limits = split /\|/, C4::Context->preference('OpacAdvSearch'); $template->param( - OpacStarRatings => C4::Context->preference("OpacStarRatings") ); + OpacStarRatings => C4::Context->preference("OpacStarRatings"), + OpacAdvSearch => \@advsearch_limits, +); if (C4::Context->preference('BakerTaylorEnabled')) { $template->param( -- 1.7.10.4