Lines 455-462
for (my $i=0;$i<@servers;$i++) {
Link Here
|
455 |
push @newresults, { group_label => $group->{'group_label'}, GROUP_RESULTS => \@group_results }; |
455 |
push @newresults, { group_label => $group->{'group_label'}, GROUP_RESULTS => \@group_results }; |
456 |
} |
456 |
} |
457 |
} else { |
457 |
} else { |
458 |
@newresults = searchResults('opac', $query_desc, $hits, $results_per_page, $offset, $scan, |
458 |
@newresults = |
459 |
@{$results_hashref->{$server}->{"RECORDS"}},, C4::Context->preference('hidelostitems')); |
459 |
searchResults( $query_desc, $hits, $results_per_page, $offset, $scan, @{ $results_hashref->{$server}->{"RECORDS"} },, C4::Context->preference('hidelostitems') ); |
460 |
} |
460 |
} |
461 |
my $tag_quantity; |
461 |
my $tag_quantity; |
462 |
if (C4::Context->preference('TagsEnabled') and |
462 |
if (C4::Context->preference('TagsEnabled') and |
Lines 526-531
for (my $i=0;$i<@servers;$i++) {
Link Here
|
526 |
&& $format ne 'opensearchdescription' && $format ne 'atom') { |
526 |
&& $format ne 'opensearchdescription' && $format ne 'atom') { |
527 |
my $biblionumber=$newresults[0]->{biblionumber}; |
527 |
my $biblionumber=$newresults[0]->{biblionumber}; |
528 |
if (C4::Context->preference('BiblioDefaultView') eq 'isbd') { |
528 |
if (C4::Context->preference('BiblioDefaultView') eq 'isbd') { |
|
|
529 |
my $tag_quantity; |
530 |
if ( C4::Context->preference('TagsEnabled') |
531 |
and $tag_quantity = C4::Context->preference('TagsShowOnList') ) { |
532 |
foreach (@newresults) { |
533 |
my $bibnum = $_->{biblionumber} or next; |
534 |
$_->{itemsissued} = CountItemsIssued($bibnum); |
535 |
$_->{'TagLoop'} = get_tags( |
536 |
{ biblionumber => $bibnum, |
537 |
approved => 1, |
538 |
'sort' => '-weight', |
539 |
limit => $tag_quantity |
540 |
} |
541 |
); |
542 |
} |
543 |
} |
544 |
foreach (@newresults) { |
545 |
$_->{coins} = GetCOinSBiblio( $_->{'biblionumber'} ); |
546 |
} |
547 |
|
548 |
if ( $results_hashref->{$server}->{"hits"} ) { |
549 |
$total = $total + $results_hashref->{$server}->{"hits"}; |
550 |
} |
551 |
|
552 |
# Opac search history |
553 |
my $newsearchcookie; |
554 |
if ( C4::Context->preference('EnableOpacSearchHistory') ) { |
555 |
my @recentSearches; |
556 |
|
557 |
# Getting the (maybe) already sent cookie |
558 |
my $searchcookie = $cgi->cookie('KohaOpacRecentSearches'); |
559 |
if ($searchcookie) { |
560 |
$searchcookie = uri_unescape($searchcookie); |
561 |
if ( thaw($searchcookie) ) { |
562 |
@recentSearches = @{ thaw($searchcookie) }; |
563 |
} |
564 |
} |
565 |
|
566 |
# Adding the new search if needed |
567 |
if ( not defined $borrowernumber or $borrowernumber eq '' ) { |
568 |
|
569 |
# To a cookie (the user is not logged in) |
570 |
|
571 |
if ( not defined $params->{'offset'} or $params->{'offset'} eq '' ) { |
572 |
push @recentSearches, |
573 |
{ "query_desc" => $query_desc || "unknown", |
574 |
"query_cgi" => $query_cgi || "unknown", |
575 |
"limit_desc" => $limit_desc, |
576 |
"limit_cgi" => $limit_cgi, |
577 |
"time" => time(), |
578 |
"total" => $total |
579 |
}; |
580 |
$template->param( ShowOpacRecentSearchLink => 1 ); |
581 |
} |
582 |
|
583 |
# Only the 15 more recent searches are kept |
584 |
# TODO: This has been done because of cookies' max size, which is |
585 |
# usually 4KB. A real check on cookie actual size would be better |
586 |
# than setting an arbitrary limit on the number of searches |
587 |
shift @recentSearches if (@recentSearches > 15); |
588 |
|
589 |
# Pushing the cookie back |
590 |
$newsearchcookie = $cgi->cookie( |
591 |
-name => 'KohaOpacRecentSearches', |
592 |
|
593 |
# We uri_escape the whole freezed structure so we're sure we won't have any encoding problems |
594 |
-value => uri_escape( freeze( \@recentSearches ) ), |
595 |
-expires => '' |
596 |
); |
597 |
$cookie = [ $cookie, $newsearchcookie ]; |
598 |
} else { |
599 |
|
600 |
# To the session (the user is logged in) |
601 |
if ( not defined $params->{'offset'} or $params->{'offset'} eq '' ) { |
602 |
AddSearchHistory( $borrowernumber, $cgi->cookie("CGISESSID"), $query_desc, $query_cgi, $limit_desc, $limit_cgi, $total ); |
603 |
$template->param( ShowOpacRecentSearchLink => 1 ); |
604 |
} |
605 |
} |
606 |
} |
607 |
## If there's just one result, redirect to the detail page |
608 |
if ( $total == 1 |
609 |
&& $format ne 'rss2' |
610 |
&& $format ne 'opensearchdescription' |
611 |
&& $format ne 'atom' ) { |
612 |
my $biblionumber = $newresults[0]->{biblionumber}; |
613 |
if ( C4::Context->preference('BiblioDefaultView') eq 'isbd' ) { |
529 |
print $cgi->redirect("/cgi-bin/koha/opac-ISBDdetail.pl?biblionumber=$biblionumber"); |
614 |
print $cgi->redirect("/cgi-bin/koha/opac-ISBDdetail.pl?biblionumber=$biblionumber"); |
530 |
} elsif (C4::Context->preference('BiblioDefaultView') eq 'marc') { |
615 |
} elsif (C4::Context->preference('BiblioDefaultView') eq 'marc') { |
531 |
print $cgi->redirect("/cgi-bin/koha/opac-MARCdetail.pl?biblionumber=$biblionumber"); |
616 |
print $cgi->redirect("/cgi-bin/koha/opac-MARCdetail.pl?biblionumber=$biblionumber"); |
532 |
- |
|
|