Bug 7337 - Followup - Correcting instances of "debar" that crept back in.
[koha.git] / opac / opac-search.pl
index 81b7ce6..aba23a8 100755 (executable)
@@ -198,7 +198,6 @@ $template->param(itemtypeloop => \@itemtypesloop);
 
 # The following should only be loaded if we're bringing up the advanced search template
 if ( $template_type && $template_type eq 'advsearch' ) {
-
     # load the servers (used for searching -- to do federated searching, etc.)
     my $primary_servers_loop;# = displayPrimaryServers();
     $template->param(outer_servers_loop =>  $primary_servers_loop,);
@@ -212,7 +211,7 @@ if ( $template_type && $template_type eq 'advsearch' ) {
         my $default_sort_by =
             C4::Context->preference('OPACdefaultSortField') . '_'
           . C4::Context->preference('OPACdefaultSortOrder');
-        $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
@@ -273,6 +272,21 @@ my $params = $cgi->Vars;
 my $tag;
 $tag = $params->{tag} if $params->{tag};
 
+
+# String with params with the search criteria for the paging in opac-detail
+my $pasarParams = '';
+my $j = 0;
+for (keys %$params) {
+    my @pasarParam = split("\0", $params->{$_});
+    for my $paramValue(@pasarParam) {
+        $pasarParams .= '&' if ($j > 0);
+        $pasarParams .= $_ . '=' . $paramValue;
+        $j++;
+    }
+}
+#
+
+
 # Params that can have more than one value
 # sort by is used to sort the query
 # in theory can have more than one but generally there's just one
@@ -374,7 +388,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, 'opac');
 ( $error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$stopwords_removed,$query_type) = buildQuery(\@operators,\@operands,\@indexes,\@limits,\@sort_by, 0, $lang);
 
 sub _input_cgi_parse ($) { 
@@ -406,6 +420,7 @@ if (C4::Context->preference('OpacSuppression')) {
 }
 
 $template->param ( LIMIT_INPUTS => \@limit_inputs );
+$template->param ( OPACResultsSidebar => C4::Context->preference('OPACResultsSidebar'));
 
 ## II. DO THE SEARCH AND GET THE RESULTS
 my $total = 0; # the total results for the whole set
@@ -434,6 +449,10 @@ elsif (C4::Context->preference('NoZebra')) {
         ($error, $results_hashref, $facets) = C4::Search::pazGetRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$query_type,$scan);
     };
 } else {
+    $pasarParams .= '&query=' . $query;
+    $pasarParams .= '&count=' . $results_per_page;
+    $pasarParams .= '&simple_query=' . $simple_query;
+    $pasarParams .= '&query_type=' . $query_type if ($query_type);
     eval {
         ($error, $results_hashref, $facets) = getRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$query_type,$scan);
     };
@@ -487,7 +506,8 @@ for (my $i=0;$i<@servers;$i++) {
                }
                 if (C4::Context->preference('COinSinOPACResults')) {
                    foreach (@newresults) {
-                     $_->{coins} = GetCOinSBiblio($_->{'biblionumber'});
+                      my $record = GetMarcBiblio($_->{'biblionumber'});
+                     $_->{coins} = GetCOinSBiblio($record);
                    }
                 }
       
@@ -555,6 +575,24 @@ for (my $i=0;$i<@servers;$i++) {
             exit;
         }
         if ($hits) {
+            if (!C4::Context->preference('NoZebra') && !$build_grouped_results) {
+                # We build the encrypted list of first OPACnumSearchResults biblios to pass with the search criteria for paging on opac-detail
+                $pasarParams .= '&amp;listBiblios=';
+                my $j = 0;
+                foreach (@newresults) {
+                    my $bibnum = ($_->{biblionumber})?$_->{biblionumber}:0;
+                    $pasarParams .= $bibnum . ',';
+                    $j++;
+                    last if ($j == $results_per_page);
+                }
+                chop $pasarParams if ($pasarParams =~ /,$/);
+                $pasarParams .= '&amp;total=' . int($total) if ($pasarParams !~ /total=(?:[0-9]+)?/);
+                if ($pasarParams) {
+                    my $session = get_session($cgi->cookie("CGISESSID"));
+                    $session->param('busc' => $pasarParams);
+                }
+                #
+            }
             $template->param(total => $hits);
             my $limit_cgi_not_availablity = $limit_cgi;
             $limit_cgi_not_availablity =~ s/&limit=available//g if defined $limit_cgi_not_availablity;