use C4::Languages qw(getAllLanguages);
use C4::Koha;
use C4::Members qw(GetMember);
-use C4::VirtualShelves qw(GetRecentShelves);
+use C4::VirtualShelves;
+use URI::Escape;
use POSIX qw(ceil floor);
+use String::Random;
use C4::Branch; # GetBranches
my $DisplayMultiPlaceHold = C4::Context->preference("DisplayMultiPlaceHold");
my $cgi = new CGI;
my ($template,$borrowernumber,$cookie);
-
+my $lang = C4::Templates::getlanguage($cgi, 'intranet');
# decide which template to use
my $template_name;
my $template_type;
if (C4::Context->preference("marcflavour") eq "UNIMARC" ) {
$template->param('UNIMARC' => 1);
}
+if (C4::Context->preference("IntranetNumbersPreferPhrase")) {
+ $template->param('numbersphr' => 1);
+}
if($cgi->cookie("holdfor")){
my $holdfor_patron = GetMember('borrowernumber' => $cgi->cookie("holdfor"));
my $branches = GetBranches();
# Populate branch_loop with all branches sorted by their name. If
-# independantbranches is activated, set the default branch to the borrower
+# IndependentBranches is activated, set the default branch to the borrower
# branch, except for superlibrarian who need to search all libraries.
my $user = C4::Context->userenv;
my @branch_loop = map {
$branches->{$a}->{branchname} cmp $branches->{$b}->{branchname}
} keys %$branches;
-my $categories = GetBranchCategories(undef,'searchdomain');
+my $categories = GetBranchCategories('searchdomain');
$template->param(branchloop => \@branch_loop, searchdomainloop => $categories);
search_boxes_loop => \@search_boxes_array);
# load the language limits (for search)
- my $languages_limit_loop = getAllLanguages();
+ my $languages_limit_loop = getAllLanguages($lang);
$template->param(search_languages_loop => $languages_limit_loop,);
# Expanded search options in advanced search:
. C4::Context->preference('defaultSortOrder');
}
-@sort_by = split("\0",$params->{'sort_by'}) if $params->{'sort_by'};
+@sort_by = $cgi->param('sort_by');
$sort_by[0] = $default_sort_by unless $sort_by[0];
foreach my $sort (@sort_by) {
$template->param($sort => 1) if $sort;
$template->param('sort_by' => $sort_by[0]);
# Use the servers defined, or just search our local catalog(default)
-my @servers;
-@servers = split("\0",$params->{'server'}) if $params->{'server'};
+my @servers = $cgi->param('server');
unless (@servers) {
#FIXME: this should be handled using Context.pm
@servers = ("biblioserver");
}
# operators include boolean and proximity operators and are used
# to evaluate multiple operands
-my @operators;
-@operators = split("\0",$params->{'op'}) if $params->{'op'};
+my @operators = map uri_unescape($_), $cgi->param('op');
# indexes are query qualifiers, like 'title', 'author', etc. They
# can be single or multiple parameters separated by comma: kw,right-Truncation
-my @indexes;
-@indexes = split("\0",$params->{'idx'});
+my @indexes = map uri_unescape($_), $cgi->param('idx');
# if a simple index (only one) display the index used in the top search box
if ($indexes[0] && (!$indexes[1] || $params->{'scan'})) {
$template->param($idx => 1);
}
-
# an operand can be a single term, a phrase, or a complete ccl query
-my @operands;
-@operands = split("\0",$params->{'q'}) if $params->{'q'};
+my @operands = map uri_unescape($_), $cgi->param('q');
# limits are use to limit to results to a pre-defined category such as branch or language
-my @limits;
-@limits = split("\0",$params->{'limit'}) if $params->{'limit'};
+my @limits = map uri_unescape($_), $cgi->param('limit');
if($params->{'multibranchlimit'}) {
- push @limits, '('.join( " or ", map { "branch: $_ " } @{ GetBranchesInCategory( $params->{'multibranchlimit'} ) } ).')';
+ my $multibranch = '('.join( " or ", map { "branch: $_ " } @{ GetBranchesInCategory( $params->{'multibranchlimit'} ) } ).')';
+ push @limits, $multibranch if ($multibranch ne '()');
}
my $available;
my @results;
## I. BUILD THE QUERY
-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 <input>s
my @results_array;
my $results_hashref;
-if (C4::Context->preference('NoZebra')) {
- $query=~s/yr(:|=)\s*([\d]{1,4})-([\d]{1,4})/(yr>=$2 and yr<=$3)/g;
- $simple_query=~s/yr\s*(:|=)([\d]{1,4})-([\d]{1,4})/(yr>=$2 and yr<=$3)/g;
- # warn $query;
- eval {
- ($error, $results_hashref, $facets) = NZgetRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$query_type,$scan);
- };
-} else {
- eval {
- ($error, $results_hashref, $facets) = getRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$query_type,$scan);
- };
-}
+eval {
+ ($error, $results_hashref, $facets) = getRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$itemtypes,$query_type,$scan);
+};
+
# This sorts the facets into alphabetical order
if ($facets) {
foreach my $f (@$facets) {
} #/end of the for loop
#$template->param(FEDERATED_RESULTS => \@results_array);
+$template->{'VARS'}->{'searchid'} = $cgi->param('searchid')
+ || String::Random::random_string('ssssssss');
+my $gotonumber = $cgi->param('gotoNumber');
+if ($gotonumber eq 'last' || $gotonumber eq 'first') {
+ $template->{'VARS'}->{'gotoNumber'} = $gotonumber;
+}
+$template->{'VARS'}->{'gotoPage'} = 'detail.pl';
+my $gotopage = $cgi->param('gotoPage');
+$template->{'VARS'}->{'gotoPage'} = $gotopage
+ if $gotopage =~ m/^(ISBD|labeledMARC|MARC|more)?detail.pl$/;
$template->param(
#classlist => $classlist,
# VI. BUILD THE TEMPLATE
# Build drop-down list for 'Add To:' menu...
-
-my $row_count = 10; # FIXME:This probably should be a syspref
-my ($pubshelves, $total) = GetRecentShelves(2, $row_count, undef);
-my ($barshelves, $total) = GetRecentShelves(1, $row_count, $borrowernumber);
-
-if (@{$pubshelves}) {
- $template->param( addpubshelves => scalar @{$pubshelves});
- $template->param( addpubshelvesloop => $pubshelves);
-}
-
-if (@{$barshelves}) {
- $template->param( addbarshelves => scalar @{$barshelves});
- $template->param( addbarshelvesloop => $barshelves);
-}
-
-
+my ($totalref, $pubshelves, $barshelves)=
+ C4::VirtualShelves::GetSomeShelfNames($borrowernumber,'COMBO',1);
+$template->param(
+ addbarshelves => $totalref->{bartotal},
+ addbarshelvesloop => $barshelves,
+ addpubshelves => $totalref->{pubtotal},
+ addpubshelvesloop => $pubshelves,
+ );
output_html_with_http_headers $cgi, $cookie, $template->output;