From 6c9b83fbdc0be86edeb50ecb81fd0680e724ab37 Mon Sep 17 00:00:00 2001 From: Joshua Ferraro Date: Wed, 18 Jun 2008 13:01:20 -0500 Subject: [PATCH] Resolves bug 2250: RFC: New System Preference to Determine which 'Types' and associated icons to display in advanced Search For documentation, please indicate that as part of profiling, staff can refer to the AdvancedSearchTypes system preference to choose where to draw the advanced search 'Types' from. Currently this is implemented as a choice, between itemtypes and ccodes, but it's been designed to work with any authorised value so long as an index exists for searching by that authorised value. By default, and if this syspref doesn't exist, it will pull from itemtypes as before. --- catalogue/search.pl | 34 ++++++++++++++----- .../data/mysql/en/mandatory/sysprefs.sql | 2 +- .../unimarc_standard_systemprefs.sql | 1 + installer/data/mysql/updatedatabase.pl | 6 ++++ .../prog/en/modules/catalogue/advsearch.tmpl | 4 +-- .../prog/en/modules/opac-advsearch.tmpl | 4 +-- kohaversion.pl | 2 +- opac/opac-search.pl | 29 +++++++++++++--- 8 files changed, 62 insertions(+), 20 deletions(-) diff --git a/catalogue/search.pl b/catalogue/search.pl index 10ec0e39a6..101fd68535 100755 --- a/catalogue/search.pl +++ b/catalogue/search.pl @@ -216,28 +216,44 @@ my $categories = GetBranchCategories(undef,'searchdomain'); $template->param(branchloop => \@branch_loop, searchdomainloop => $categories); -# load the itemtypes +# load the Type stuff +# load the Type stuff my $itemtypes = GetItemTypes; my @itemtypesloop; my $selected=1; my $cnt; my $imgdir = getitemtypeimagesrc('intranet'); -foreach my $thisitemtype ( sort {$itemtypes->{$a}->{'description'} cmp $itemtypes->{$b}->{'description'} } keys %$itemtypes ) { +my $advanced_search_types = C4::Context->preference("AdvancedSearchTypes"); + +if (!$advanced_search_types or $advanced_search_types eq 'itemtypes') { foreach my $thisitemtype ( sort {$itemtypes->{$a}->{'description'} cmp $itemtypes->{$b}->{'description'} } keys %$itemtypes ) { my %row =( number=>$cnt++, imageurl=> $itemtypes->{$thisitemtype}->{'imageurl'}?($imgdir."/".$itemtypes->{$thisitemtype}->{'imageurl'}):"", + ccl => 'itemtype', code => $thisitemtype, selected => $selected, description => $itemtypes->{$thisitemtype}->{'description'}, count5 => $cnt % 4, ); - $selected = 0 if ($selected) ; - push @itemtypesloop, \%row; + $selected = 0 if ($selected) ; + push @itemtypesloop, \%row; + } + $template->param(itemtypeloop => \@itemtypesloop); +} else { + my $advsearchtypes = GetAuthorisedValues($advanced_search_types); + for my $thisitemtype (@$advsearchtypes) { + my %row =( + number=>$cnt++, + imageurl=> $imgdir."/".$thisitemtype->{'imageurl'}, + ccl => $advanced_search_types, + code => $thisitemtype->{authorised_value}, + selected => $selected, + description => $thisitemtype->{'lib'}, + count5 => $cnt % 4, + ); + push @itemtypesloop, \%row; + } + $template->param(itemtypeloop => \@itemtypesloop); } -$template->param(itemtypeloop => \@itemtypesloop); - -# load the ccodes -# my ($ccodecount,@ccode_loop) = GetCcodes(); -# $template->param(ccodeloop=>\@ccode_loop,); # The following should only be loaded if we're bringing up the advanced search template if ( $template_type eq 'advsearch' ) { diff --git a/installer/data/mysql/en/mandatory/sysprefs.sql b/installer/data/mysql/en/mandatory/sysprefs.sql index 9313f0fcfb..9282a7f850 100755 --- a/installer/data/mysql/en/mandatory/sysprefs.sql +++ b/installer/data/mysql/en/mandatory/sysprefs.sql @@ -209,5 +209,5 @@ INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES ('XSLTDetailsDisplay','0','','Enable XSL stylesheet control over details page display on OPAC WARNING: MARC21 Only','YesNo'), ('XSLTResultsDisplay','0','','Enable XSL stylesheet control over results page display on OPAC WARNING: MARC21 Only','YesNo'); - +INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES('AdvancedSearchTypes','itemtypes','itemtypes|ccode','Select which set of fields comprise the Type limit in the advanced search','Choice'); -- FIXME: add FrameworksLoaded, noOPACUserLogin, ReadingHistory ? diff --git a/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql b/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql index fbfddfcd80..ad6242c3d9 100755 --- a/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql +++ b/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql @@ -209,3 +209,4 @@ INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES('OPACShelfBrowser','1','','Active le parcours des rayonnages sur la page de détail','YesNo'); INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES('XSLTDetailsDisplay','0','','Enable XSL stylesheet control over details page display on OPAC WARNING: MARC21 Only','YesNo'); INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES('XSLTResultsDisplay','0','','Enable XSL stylesheet control over results page display on OPAC WARNING: MARC21 Only','YesNo'); +INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES('AdvancedSearchTypes','itemtypes','itemtypes|ccode','Select which set of fields comprise the Type limit in the advanced search','Choice'); diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 3b273a15c6..df5b8cb666 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -1622,6 +1622,12 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion ($DBversion); } +$DBversion = "3.00.00.089"; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $dbh->do("INSERT INTO `systempreferences` (variable,value,options,explanation,type) VALUES('AdvancedSearchTypes','itemtypes','itemtypes|ccode','Select which set of fields comprise the Type limit in the advanced search','Choice')"); + print "Upgrade to $DBversion done (added new AdvancedSearchTypes syspref)\n"; + SetVersion ($DBversion); +} =item DropAllForeignKeys($table) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tmpl index 4511761ecf..d58ad06290 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tmpl @@ -91,8 +91,8 @@ " alt="" /> - " name="limit" value="mc:" />  - + -" name="limit" value=":" />  + diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-advsearch.tmpl b/koha-tmpl/opac-tmpl/prog/en/modules/opac-advsearch.tmpl index 03679fba94..a9194d6d0f 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-advsearch.tmpl +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-advsearch.tmpl @@ -191,11 +191,11 @@
-

Itemtype limit to any of the following:

+

Limit type to: match any of the following:

- diff --git a/kohaversion.pl b/kohaversion.pl index bbb64c22f1..5f23daa6de 100644 --- a/kohaversion.pl +++ b/kohaversion.pl @@ -10,7 +10,7 @@ use strict; sub kohaversion { - our $VERSION = "3.00.00.088"; + our $VERSION = "3.00.00.089"; # version needs to be set this way # so that it can be picked up by Makefile.PL # during install diff --git a/opac/opac-search.pl b/opac/opac-search.pl index dd545b3bd8..45d03faed5 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -125,25 +125,44 @@ my $categories = GetBranchCategories(undef,'searchdomain'); $template->param(branchloop => \@branch_loop, searchdomainloop => $categories); -# load the itemtypes +# load the Type stuff my $itemtypes = GetItemTypes; my @itemtypesloop; my $selected=1; my $cnt; my $imgdir = getitemtypeimagesrc('opac'); +my $advanced_search_types = C4::Context->preference("AdvancedSearchTypes"); -foreach my $thisitemtype ( sort {$itemtypes->{$a}->{'description'} cmp $itemtypes->{$b}->{'description'} } keys %$itemtypes ) { +if (!$advanced_search_types or $advanced_search_types eq 'itemtypes') { + foreach my $thisitemtype ( sort {$itemtypes->{$a}->{'description'} cmp $itemtypes->{$b}->{'description'} } keys %$itemtypes ) { my %row =( number=>$cnt++, imageurl=> $itemtypes->{$thisitemtype}->{'imageurl'}?($imgdir."/".$itemtypes->{$thisitemtype}->{'imageurl'}):"", + ccl => 'itemtype', code => $thisitemtype, selected => $selected, description => $itemtypes->{$thisitemtype}->{'description'}, count5 => $cnt % 4, ); - $selected = 0 if ($selected) ; - push @itemtypesloop, \%row; + $selected = 0 if ($selected) ; + push @itemtypesloop, \%row; + } + $template->param(itemtypeloop => \@itemtypesloop); +} else { + my $advsearchtypes = GetAuthorisedValues($advanced_search_types); + for my $thisitemtype (@$advsearchtypes) { + my %row =( + number=>$cnt++, + imageurl=> $imgdir."/".$thisitemtype->{'imageurl'}, + ccl => $advanced_search_types, + code => $thisitemtype->{authorised_value}, + selected => $selected, + description => $thisitemtype->{'lib'}, + count5 => $cnt % 4, + ); + push @itemtypesloop, \%row; + } + $template->param(itemtypeloop => \@itemtypesloop); } -$template->param(itemtypeloop => \@itemtypesloop); # # load the itypes (Called item types in the template -- just authorized values for searching) # my ($itypecount,@itype_loop) = GetCcodes(); -- 2.39.5
" name="limit" value="mc:"/>" alt="" />  + -" name="limit" value=":"/>" alt="" />