X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=catalogue%2Fsearch.pl;h=49e63bcb712e17643ea980840799f81f9dcc90d6;hb=706712dd1edebb6eed8b632ca8db4dcd9df39b56;hp=e49507e4a0c2d540a5dd1fb7d472f73c2b90cc54;hpb=129d97df979f94ba13b264243d6e766a780a922d;p=koha_gimpoz diff --git a/catalogue/search.pl b/catalogue/search.pl index e49507e4a0..49e63bcb71 100755 --- a/catalogue/search.pl +++ b/catalogue/search.pl @@ -294,7 +294,7 @@ if ( $template_type eq 'advsearch' ) { my $default_sort_by = C4::Context->preference('defaultSortField') . '_' . C4::Context->preference('defaultSortOrder'); - $template->param( $default_sort_by => 1 ); + $template->param( sort_by => $default_sort_by ); } # determine what to display next to the search boxes (ie, boolean option @@ -331,13 +331,13 @@ if ( $template_type eq 'advsearch' ) { my $languages_limit_loop = getAllLanguages(); $template->param(search_languages_loop => $languages_limit_loop,); - # use the global setting by default - if ( C4::Context->preference("expandedSearchOption") == 1) { - $template->param( expanded_options => C4::Context->preference("expandedSearchOption") ); - } - # but let the user override it - if ( ($cgi->param('expanded_options') == 0) || ($cgi->param('expanded_options') == 1 ) ) { - $template->param( expanded_options => $cgi->param('expanded_options')); + # Expanded search options in advanced search: + # use the global setting by default, but let the user override it + { + my $expanded = $cgi->param('expanded_options'); + $expanded = C4::Context->preference("expandedSearchOption") || 0 + if !defined($expanded) || $expanded !~ /^0|1$/; + $template->param( expanded_options => $expanded ); } $template->param(virtualshelves => C4::Context->preference("virtualshelves")); @@ -369,7 +369,7 @@ if ( C4::Context->preference('defaultSortField') @sort_by = split("\0",$params->{'sort_by'}) if $params->{'sort_by'}; $sort_by[0] = $default_sort_by unless $sort_by[0]; foreach my $sort (@sort_by) { - $template->param($sort => 1); + $template->param($sort => 1) if $sort; } $template->param('sort_by' => $sort_by[0]); @@ -440,18 +440,18 @@ if ($params->{'limit-yr'}) { # $ %z3950p will be a hash ref if the indexes are present (advacned search), otherwise undef my $z3950par; my $indexes2z3950 = { - kw=>'title', au=>'author', 'au,phr'=>'author', nb=>'isbn', ns=>'issn', - 'lcn,phr'=>'dewey', su=>'subject', 'su,phr'=>'subject', - ti=>'title', 'ti,phr'=>'title', se=>'title' + kw=>'title', au=>'author', 'au,phr'=>'author', nb=>'isbn', ns=>'issn', + 'lcn,phr'=>'dewey', su=>'subject', 'su,phr'=>'subject', + ti=>'title', 'ti,phr'=>'title', se=>'title' }; for (my $ii = 0; $ii < @operands; ++$ii) { - my $name = $indexes2z3950->{$indexes[$ii]}; - if (defined $name && defined $operands[$ii]) - { - $z3950par ||= {}; - $z3950par->{$name} = $operands[$ii] if !exists $z3950par->{$name}; - } + my $name = $indexes2z3950->{$indexes[$ii]}; + if (defined $name && defined $operands[$ii]) + { + $z3950par ||= {}; + $z3950par->{$name} = $operands[$ii] if !exists $z3950par->{$name}; + } } @@ -471,7 +471,7 @@ my ( $error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit my @results; ## I. BUILD THE QUERY -my $lang = C4::Output::getlanguagecookie($cgi); +my $lang = C4::Templates::getlanguage($cgi, 'intranet'); ( $error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$stopwords_removed,$query_type) = buildQuery(\@operators,\@operands,\@indexes,\@limits,\@sort_by,$scan,$lang); ## parse the query_cgi string and put it into a form suitable for s @@ -484,9 +484,9 @@ for my $this_cgi ( split('&',$query_cgi) ) { my $input_name = $1; my $input_value = $2; push @query_inputs, { input_name => $input_name, input_value => $input_value }; - if ($input_name eq 'idx') { - $scan_index_to_use = $input_value; # unless $scan_index_to_use; - } + if ($input_name eq 'idx') { + $scan_index_to_use = $input_value; # unless $scan_index_to_use; + } } $template->param ( QUERY_INPUTS => \@query_inputs, scan_index_to_use => $scan_index_to_use ); @@ -547,13 +547,13 @@ for (my $i=0;$i<@servers;$i++) { $hits = $results_hashref->{$server}->{"hits"}; my $page = $cgi->param('page') || 0; my @newresults = searchResults('intranet', $query_desc, $hits, $results_per_page, $offset, $scan, - @{$results_hashref->{$server}->{"RECORDS"}}); + $results_hashref->{$server}->{"RECORDS"}); $total = $total + $results_hashref->{$server}->{"hits"}; ## If there's just one result, redirect to the detail page if ($total == 1) { my $biblionumber = $newresults[0]->{biblionumber}; - my $defaultview = C4::Context->preference('IntranetBiblioDefaultView'); - my $views = { C4::Search::enabled_staff_search_views }; + my $defaultview = C4::Context->preference('IntranetBiblioDefaultView'); + my $views = { C4::Search::enabled_staff_search_views }; if ($defaultview eq 'isbd' && $views->{can_view_ISBD}) { print $cgi->redirect("/cgi-bin/koha/catalogue/ISBDdetail.pl?biblionumber=$biblionumber"); } elsif ($defaultview eq 'marc' && $views->{can_view_MARC}) { @@ -578,14 +578,18 @@ for (my $i=0;$i<@servers;$i++) { $template->param(limit_desc => $limit_desc); $template->param(offset => $offset); $template->param(DisplayMultiPlaceHold => $DisplayMultiPlaceHold); - $template->param (z3950_search_params => C4::Search::z3950_search_args($query_desc)); + $template->param (z3950_search_params => C4::Search::z3950_search_args($query_desc)); if ($query_desc || $limit_desc) { $template->param(searchdesc => 1); } $template->param(stopwords_removed => "@$stopwords_removed") if $stopwords_removed; $template->param(results_per_page => $results_per_page); + # 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'} = "" } + } $template->param(SEARCH_RESULTS => \@newresults); - ## FIXME: add a global function for this, it's better than the current global one ## Build the page numbers on the bottom of the page my @page_numbers; @@ -649,7 +653,7 @@ for (my $i=0;$i<@servers;$i++) { # no hits else { $template->param(searchdesc => 1,query_desc => $query_desc,limit_desc => $limit_desc); - $template->param (z3950_search_params => C4::Search::z3950_search_args($z3950par || $query_desc)); + $template->param (z3950_search_params => C4::Search::z3950_search_args($z3950par || $query_desc)); } } # end of the if local @@ -679,7 +683,7 @@ $template->param( total => $total, opacfacets => 1, facets_loop => $facets, - displayFacetCount=> C4::Context->preference('displayFacetCount')||0, + displayFacetCount=> C4::Context->preference('displayFacetCount')||0, scan => $scan, search_error => $error, );