use C4::Context;
use List::MoreUtils q/any/;
use Try::Tiny;
-use YAML::XS;
+use Encode;
use Data::Dumper; # TODO remove
$builder = Koha::SearchEngine::QueryBuilder->new({index => 'biblios'});
$searcher = Koha::SearchEngine::Search->new({index => 'biblios'});
-use C4::Output;
-use C4::Auth qw(:DEFAULT get_session);
-use C4::Languages qw(getLanguages);
-use C4::Search;
+use C4::Output qw( output_html_with_http_headers pagination_bar output_with_http_headers );
+use C4::Auth qw( get_template_and_user get_session );
+use C4::Languages qw( getlanguage getLanguages );
+use C4::Search qw( searchResults );
use C4::Search::History;
-use C4::Biblio; # Unused here?
-use C4::Koha;
-use C4::Tags qw(get_tags);
+use C4::Biblio qw( GetXmlBiblio CountItemsIssued );
+use C4::Koha qw( GetItemTypesCategorized getitemtypeimagelocation GetAuthorisedValues );
+use C4::Tags qw( get_tags get_tag );
use C4::SocialData;
use C4::External::OverDrive;
use C4::External::BakerTaylor qw( image_url link_url );
my $branch_group_limit = $cgi->param("branch_group_limit");
if ( $branch_group_limit ) {
if ( $branch_group_limit =~ /^multibranchlimit-/ ) {
+ # branch_group_limit is deprecated, it should no longer be used
# For search groups we are going to convert this branch_group_limit CGI
- # parameter into a multibranchlimit CGI parameter for the purposes of
+ # parameter into a multibranchlimit limit CGI parameter for the purposes of
# actually performing the query
$cgi->param(
- -name => 'multibranchlimit',
- -values => substr($branch_group_limit, 17)
+ -name => 'limit',
+ -values => 'multibranchlimit:' . substr($branch_group_limit, 17)
);
} else {
$cgi->append(
if ($format =~ /(rss|atom|opensearchdescription)/) {
$template_name = 'opac-opensearch.tt';
}
-elsif ((@params>=1) || ($cgi->param("q")) || ($cgi->param('multibranchlimit')) || ($cgi->param('limit-yr')) || @searchCategories ) {
+elsif ((@params>=1) || (defined $cgi->param("q") && $cgi->param("q") ne "") || ($cgi->param('multibranchlimit')) || ($cgi->param('limit-yr')) || @searchCategories ) {
$template_name = 'opac-results.tt';
}
else {
my $advanced_search_types = C4::Context->preference("AdvancedSearchTypes") || "itemtypes";
my @advanced_search_types = split(/\|/, $advanced_search_types);
-my $hidingrules = {};
-my $yaml = C4::Context->preference('OpacHiddenItems');
-if ( $yaml =~ /\S/ ) {
- $yaml = "$yaml\n\n"; # YAML expects trailing newline. Surplus does not hurt.
- eval {
- $hidingrules = YAML::XS::Load($yaml);
- };
- if ($@) {
- warn "Unable to parse OpacHiddenItems syspref : $@";
- }
-}
+my $hidingrules = C4::Context->yaml_preference('OpacHiddenItems') // {};
my @sorted_itemtypes = sort { $itemtypes->{$a}->{translated_description} cmp $itemtypes->{$b}->{translated_description} } keys %$itemtypes;
foreach my $advanced_srch_type (@advanced_search_types) {
$template->param( sort_by => $default_sort_by );
}
- # determine what to display next to the search boxes (ie, boolean option
- # shouldn't appear on the first one, scan indexes should, adding a new
- # box should only appear on the last, etc.
- my @search_boxes_array;
- my $search_boxes_count = 3; # begin with 3 boxes
- $template->param( search_boxes_count => $search_boxes_count );
-
- if ($cgi->cookie("num_paragraph")){
- $search_boxes_count = $cgi->cookie("num_paragraph");
- }
-
- for (my $i=1;$i<=$search_boxes_count;$i++) {
- # if it's the first one, don't display boolean option, but show scan indexes
- if ($i==1) {
- push @search_boxes_array,
- {
- scan_index => 1,
- };
-
- }
- # if it's the last one, show the 'add field' box
- elsif ($i==$search_boxes_count) {
- push @search_boxes_array,
- {
- boolean => 1,
- add_field => 1,
- };
- }
- else {
- push @search_boxes_array,
- {
- boolean => 1,
- };
- }
-
- }
-
my @advsearch_limits = split /,/, C4::Context->preference('OpacAdvSearchOptions');
my @advsearch_more_limits = split /,/,
C4::Context->preference('OpacAdvSearchMoreOptions');
$template->param(
uc( C4::Context->preference("marcflavour") ) => 1, # we already did this for UNIMARC
advsearch => 1,
- search_boxes_loop => \@search_boxes_array,
OpacAdvSearchOptions => \@advsearch_limits,
OpacAdvSearchMoreOptions => \@advsearch_more_limits,
);
@limits = map { uri_unescape($_) } @limits;
-if($params->{'multibranchlimit'}) {
- my $search_group = Koha::Library::Groups->find( $params->{multibranchlimit} );
- my @libraries = $search_group->all_libraries;
- my $multibranch = '('.join( " OR ", map { 'homebranch: ' . $_->branchcode } @libraries ) .')';
- push @limits, $multibranch if ($multibranch ne '()');
-}
my $available;
foreach my $limit(@limits) {
my $taglist = get_tags({term=>$tag, approved=>1});
$results_hashref->{biblioserver}->{hits} = scalar (@$taglist);
my @marclist = map { C4::Biblio::GetXmlBiblio( $_->{biblionumber} ) } @$taglist;
- $DEBUG and printf STDERR "taglist (%s biblionumber)\nmarclist (%s records)\n", scalar(@$taglist), scalar(@marclist);
$results_hashref->{biblioserver}->{RECORDS} = \@marclist;
# FIXME: tag search and standard search should work together, not exclusively
# FIXME: Because search and standard search don't work together OpacHiddenItems
# use Data::Dumper; print STDERR "-" x 25, "\n", Dumper($results_hashref);
if (not $tag and ( $@ || $error)) {
- $template->param(query_error => $error.$@);
+ my $query_error = q{};
+ $query_error .= $error if $error;
+ $query_error .= $@ if $@;
+ $template->param(query_error => $query_error);
output_html_with_http_headers $cgi, $cookie, $template->output;
exit;
}
$template->param(searchdesc => 1);
}
$template->param(results_per_page => $results_per_page);
- my $hide = C4::Context->preference('OpacHiddenItems');
- $hide = ($hide =~ m/\S/) if $hide; # Just in case it has some spaces/new lines
- my $branch = '';
- if (C4::Context->userenv){
- $branch = C4::Context->userenv->{branch};
- }
- if ( C4::Context->preference('HighlightOwnItemsOnOPAC') ) {
- if (
- ( ( C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'PatronBranch' ) && $branch )
- ||
- C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'OpacURLBranch'
- ) {
- my $branchcode;
- if ( C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'PatronBranch' ) {
- $branchcode = $branch;
- }
- elsif ( C4::Context->preference('HighlightOwnItemsOnOPACWhich') eq 'OpacURLBranch' ) {
- $branchcode = $ENV{'BRANCHCODE'};
- }
-
- foreach my $res ( @newresults ) {
- my @new_loop;
- my @top_loop;
- my @old_loop = @{$res->{'available_items_loop'}};
- foreach my $item ( @old_loop ) {
- if ( $item->{'branchcode'} eq $branchcode ) {
- $item->{'this_branch'} = 1;
- push( @top_loop, $item );
- } else {
- push( @new_loop, $item );
- }
- }
- my @complete_loop = ( @top_loop, @new_loop );
- $res->{'available_items_loop'} = \@complete_loop;
- }
- }
- }
+ my $hide = ($hidingrules) ? 1 : 0;
$template->param(
SEARCH_RESULTS => \@newresults,
- OPACItemsResultsDisplay => (C4::Context->preference("OPACItemsResultsDisplay")),
suppress_result_number => $hide,
);
if (C4::Context->preference("OPACLocalCoverImages")){
if ($nohits and $nohits=~/{QUERY_KW}/){
# extracting keywords in case of relaunching search
(my $query_kw=$query_desc)=~s/ and|or / /g;
- my @query_kw=($query_kw=~ /([-\w]+\b)(?:[^,:]|$)/g);
+ my @query_kw=($query_kw=~ /([-\w]+\b)(?:[^:]|$)/g);
$query_kw=join('+',@query_kw);
$nohits=~s/{QUERY_KW}/$query_kw/g;
$template->param('OPACNoResultsFound' =>$nohits);
{
borrowernumber => $borrowernumber,
add_allowed => 1,
- category => 1,
+ public => 0,
}
);
my $some_public_shelves = Koha::Virtualshelves->get_some_shelves(
{
borrowernumber => $borrowernumber,
add_allowed => 1,
- category => 2,
+ public => 1,
}
);