X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=opac%2Fopac-search.pl;h=eb9ee51de9f55b2ba8ce788e7f53b9a2174a662a;hb=d91bb113f04149c020c851a904de69619b6e9dd8;hp=12baf3bd1ece13b1356c0bf2376cd4a524cdee03;hpb=c13d3f0043324ca9625128b25c9edba7b41ebd7f;p=koha_fer diff --git a/opac/opac-search.pl b/opac/opac-search.pl index 12baf3bd1e..eb9ee51de9 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -88,6 +88,14 @@ if ($template_name eq 'opac-results.tmpl') { $template->param('COinSinOPACResults' => C4::Context->preference('COinSinOPACResults')); } +# get biblionumbers stored in the cart +my @cart_list; + +if($cgi->cookie("bib_list")){ + my $cart_list = $cgi->cookie("bib_list"); + @cart_list = split(/\//, $cart_list); +} + if ($format eq 'rss2' or $format eq 'opensearchdescription' or $format eq 'atom') { $template->param($format => 1); $template->param(timestamp => strftime("%Y-%m-%dT%H:%M:%S-00:00", gmtime)) if ($format eq 'atom'); @@ -157,40 +165,47 @@ $template->param(search_languages_loop => $languages_limit_loop,); my $itemtypes = GetItemTypes; # the index parameter is different for item-level itemtypes my $itype_or_itemtype = (C4::Context->preference("item-level_itypes"))?'itype':'itemtype'; -my @itemtypesloop; -my $selected=1; +my @advancedsearchesloop; my $cnt; -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++, - ccl => "$itype_or_itemtype,phr", +my $advanced_search_types = C4::Context->preference("AdvancedSearchTypes") || "itemtypes"; +my @advanced_search_types = split(/\|/, $advanced_search_types); + +foreach my $advanced_srch_type (@advanced_search_types) { + if ($advanced_srch_type eq 'itemtypes') { + # itemtype is a special case, since it's not defined in authorized values + my @itypesloop; + foreach my $thisitemtype ( sort {$itemtypes->{$a}->{'description'} cmp $itemtypes->{$b}->{'description'} } keys %$itemtypes ) { + my %row =( number=>$cnt++, + ccl => "$itype_or_itemtype,phr", code => $thisitemtype, - selected => $selected, description => $itemtypes->{$thisitemtype}->{'description'}, - count5 => $cnt % 4, imageurl=> getitemtypeimagelocation( 'opac', $itemtypes->{$thisitemtype}->{'imageurl'} ), ); - $selected = 0; # set to zero after first pass through - push @itemtypesloop, \%row; - } -} else { - my $advsearchtypes = GetAuthorisedValues($advanced_search_types, '', 'opac'); - for my $thisitemtype (@$advsearchtypes) { - my %row =( - number=>$cnt++, - ccl => $advanced_search_types, + push @itypesloop, \%row; + } + my %search_code = ( advanced_search_type => $advanced_srch_type, + code_loop => \@itypesloop ); + push @advancedsearchesloop, \%search_code; + } else { + # covers all the other cases: non-itemtype authorized values + my $advsearchtypes = GetAuthorisedValues($advanced_srch_type, '', 'opac'); + my @authvalueloop; + for my $thisitemtype (@$advsearchtypes) { + my %row =( + number=>$cnt++, + ccl => $advanced_srch_type, code => $thisitemtype->{authorised_value}, - selected => $selected, - description => $thisitemtype->{'lib'}, - count5 => $cnt % 4, - imageurl=> getitemtypeimagelocation( 'opac', $thisitemtype->{'imageurl'} ), - ); - push @itemtypesloop, \%row; + description => $thisitemtype->{'lib_opac'} || $thisitemtype->{'lib'}, + imageurl => getitemtypeimagelocation( 'opac', $thisitemtype->{'imageurl'} ), + ); + push @authvalueloop, \%row; + } + my %search_code = ( advanced_search_type => $advanced_srch_type, + code_loop => \@authvalueloop ); + push @advancedsearchesloop, \%search_code; } } -$template->param(itemtypeloop => \@itemtypesloop); +$template->param(advancedsearchesloop => \@advancedsearchesloop); # # load the itypes (Called item types in the template -- just authorized values for searching) # my ($itypecount,@itype_loop) = GetCcodes(); @@ -485,18 +500,22 @@ for (my $i=0;$i<@servers;$i++) { # we want as specified by $offset and $results_per_page, # we need to set the offset parameter of searchResults to 0 my @group_results = searchResults( 'opac', $query_desc, $group->{'group_count'},$results_per_page, 0, $scan, - @{ $group->{"RECORDS"} }, C4::Context->preference('hidelostitems')); + $group->{"RECORDS"}); push @newresults, { group_label => $group->{'group_label'}, GROUP_RESULTS => \@group_results }; } } else { @newresults = searchResults('opac', $query_desc, $hits, $results_per_page, $offset, $scan, - @{$results_hashref->{$server}->{"RECORDS"}},, C4::Context->preference('hidelostitems')); + $results_hashref->{$server}->{"RECORDS"}); } # must define a value for size if not present in DB # in order to avoid problems generated by the default size value in TT foreach my $line (@newresults) { if ( not exists $line->{'size'} ) { $line->{'size'} = "" } + # while we're checking each line, see if item is in the cart + if ( grep {$_ eq $line->{'biblionumber'}} @cart_list) { + $line->{'incart'} = 1; + } } my $tag_quantity; @@ -613,9 +632,17 @@ for (my $i=0;$i<@servers;$i++) { } $template->param(stopwords_removed => "@$stopwords_removed") if $stopwords_removed; $template->param(results_per_page => $results_per_page); - $template->param(SEARCH_RESULTS => \@newresults, - OPACItemsResultsDisplay => (C4::Context->preference("OPACItemsResultsDisplay") eq "itemdetails"?1:0), + my $hide = C4::Context->preference('OpacHiddenItems'); + $hide = ($hide =~ m/\S/) if $hide; # Just in case it has some spaces/new lines + $template->param( + SEARCH_RESULTS => \@newresults, + OPACItemsResultsDisplay => (C4::Context->preference("OPACItemsResultsDisplay") eq "itemdetails"?1:0), + suppress_result_number => $hide, ); + if (C4::Context->preference("OPACLocalCoverImages")){ + $template->param(OPACLocalCoverImages => 1); + $template->param(OPACLocalCoverImagesPriority => C4::Context->preference("OPACLocalCoverImagesPriority")); + } ## Build the page numbers on the bottom of the page my @page_numbers; # total number of pages there will be