3 # Copyright 2008 Garry Collum and the Koha Koha Development team
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 # Script to perform searching
21 # Mostly copied from search.pl, see POD there
22 use strict
; # always use
25 ## STEP 1. Load things that are used in both search page and
26 # results page and decide which template to load, operations
31 use C4
::Auth
qw(:DEFAULT get_session);
32 use C4
::Languages
qw(getAllLanguages);
34 use C4
::Biblio
; # GetBiblioData
36 use C4
::Tags
qw(get_tags);
37 use C4
::Branch
; # GetBranches
38 use POSIX
qw(ceil floor strftime);
40 use Storable
qw(thaw freeze);
43 my $DisplayMultiPlaceHold = C4
::Context
->preference("DisplayMultiPlaceHold");
44 # create a new CGI object
45 # FIXME: no_undef_params needs to be tested
46 use CGI
qw('-no_undef_params');
50 if (C4
::Context
->preference('BakerTaylorEnabled')) {
51 require C4
::External
::BakerTaylor
;
52 import C4
::External
::BakerTaylor
qw(&image_url &link_url);
56 my ($template,$borrowernumber,$cookie);
58 # decide which template to use
60 my $template_type = 'basic';
61 my @params = $cgi->param("limit");
63 my $format = $cgi->param("format") || '';
64 my $build_grouped_results = C4
::Context
->preference('OPACGroupResults');
65 if ($format =~ /(rss|atom|opensearchdescription)/) {
66 $template_name = 'opac-opensearch.tmpl';
68 elsif ($build_grouped_results) {
69 $template_name = 'opac-results-grouped.tmpl';
71 elsif ((@params>=1) || ($cgi->param("q")) || ($cgi->param('multibranchlimit')) || ($cgi->param('limit-yr')) ) {
72 $template_name = 'opac-results.tmpl';
75 $template_name = 'opac-advsearch.tmpl';
76 $template_type = 'advsearch';
79 ($template, $borrowernumber, $cookie) = get_template_and_user
({
80 template_name
=> $template_name,
87 if ($format eq 'rss2' or $format eq 'opensearchdescription' or $format eq 'atom') {
88 $template->param($format => 1);
89 $template->param(timestamp
=> strftime
("%Y-%m-%dT%H:%M:%S-00:00", gmtime)) if ($format eq 'atom');
90 # FIXME - the timestamp is a hack - the biblio update timestamp should be used for each
91 # entry, but not sure if that's worth an extra database query for each bib
93 if (C4
::Context
->preference("marcflavour") eq "UNIMARC" ) {
94 $template->param('UNIMARC' => 1);
96 elsif (C4
::Context
->preference("marcflavour") eq "MARC21" ) {
97 $template->param('usmarc' => 1);
99 $template->param( 'AllowOnShelfHolds' => C4
::Context
->preference('AllowOnShelfHolds') );
101 if (C4
::Context
->preference('BakerTaylorEnabled')) {
103 BakerTaylorEnabled
=> 1,
104 BakerTaylorImageURL
=> &image_url
(),
105 BakerTaylorLinkURL
=> &link_url
(),
106 BakerTaylorBookstoreURL
=> C4
::Context
->preference('BakerTaylorBookstoreURL'),
109 if (C4
::Context
->preference('TagsEnabled')) {
110 $template->param(TagsEnabled
=> 1);
111 foreach (qw(TagsShowOnList TagsInputOnList)) {
112 C4
::Context
->preference($_) and $template->param($_ => 1);
117 # Deprecated, but preserved because it's interesting :-)
118 # The same thing can be accomplished with mod_rewrite in
122 #my $uri = $cgi->url(-base => 1);
123 #my $relative_url = $cgi->url(-relative=>1);
124 #$uri.="/".$relative_url."?";
126 #my @cgi_params_list = $cgi->param();
127 #my $url_params = $cgi->Vars;
129 #for my $each_param_set (@cgi_params_list) {
130 # $uri.= join "", map "\&$each_param_set=".$_, split("\0",$url_params->{$each_param_set}) if $url_params->{$each_param_set};
132 #warn "New URI:$uri";
133 # Only re-write a URI if there are params or if it already hasn't been re-written
134 #unless (($cgi->param('r')) || (!$cgi->param()) ) {
135 # print $cgi->redirect( -uri=>$uri."&r=1",
136 # -cookie => $cookie);
141 my $mybranch = ( C4
::Context
->preference('SearchMyLibraryFirst') && C4
::Context
->userenv && C4
::Context
->userenv->{branch
} ) ? C4
::Context
->userenv->{branch
} : '';
142 my $branches = GetBranches
(); # used later in *getRecords, probably should be internalized by those functions after caching in C4::Branch is established
144 branchloop
=> GetBranchesLoop
($mybranch, 0),
145 searchdomainloop
=> GetBranchCategories
(undef,'searchdomain'),
148 # load the language limits (for search)
149 my $languages_limit_loop = getAllLanguages
();
150 $template->param(search_languages_loop
=> $languages_limit_loop,);
152 # load the Type stuff
153 my $itemtypes = GetItemTypes
;
154 # the index parameter is different for item-level itemtypes
155 my $itype_or_itemtype = (C4
::Context
->preference("item-level_itypes"))?
'itype':'itemtype';
159 my $advanced_search_types = C4
::Context
->preference("AdvancedSearchTypes");
161 if (!$advanced_search_types or $advanced_search_types eq 'itemtypes') {
162 foreach my $thisitemtype ( sort {$itemtypes->{$a}->{'description'} cmp $itemtypes->{$b}->{'description'} } keys %$itemtypes ) {
163 my %row =( number
=>$cnt++,
164 ccl
=> $itype_or_itemtype,
165 code
=> $thisitemtype,
166 selected
=> $selected,
167 description
=> $itemtypes->{$thisitemtype}->{'description'},
169 imageurl
=> getitemtypeimagelocation
( 'opac', $itemtypes->{$thisitemtype}->{'imageurl'} ),
171 $selected = 0; # set to zero after first pass through
172 push @itemtypesloop, \
%row;
175 my $advsearchtypes = GetAuthorisedValues
($advanced_search_types, '', 'opac');
176 for my $thisitemtype (@
$advsearchtypes) {
179 ccl
=> $advanced_search_types,
180 code
=> $thisitemtype->{authorised_value
},
181 selected
=> $selected,
182 description
=> $thisitemtype->{'lib'},
184 imageurl
=> getitemtypeimagelocation
( 'opac', $thisitemtype->{'imageurl'} ),
186 push @itemtypesloop, \
%row;
189 $template->param(itemtypeloop
=> \
@itemtypesloop);
191 # # load the itypes (Called item types in the template -- just authorized values for searching)
192 # my ($itypecount,@itype_loop) = GetCcodes();
193 # $template->param(itypeloop=>\@itype_loop,);
195 # The following should only be loaded if we're bringing up the advanced search template
196 if ( $template_type && $template_type eq 'advsearch' ) {
198 # load the servers (used for searching -- to do federated searching, etc.)
199 my $primary_servers_loop;# = displayPrimaryServers();
200 $template->param(outer_servers_loop
=> $primary_servers_loop,);
202 my $secondary_servers_loop;
203 $template->param(outer_sup_servers_loop
=> $secondary_servers_loop,);
205 # set the default sorting
206 my $default_sort_by = C4
::Context
->preference('OPACdefaultSortField')."_".C4
::Context
->preference('OPACdefaultSortOrder')
207 if (C4
::Context
->preference('OPACdefaultSortField') && C4
::Context
->preference('OPACdefaultSortOrder'));
208 $template->param($default_sort_by => 1);
210 # determine what to display next to the search boxes (ie, boolean option
211 # shouldn't appear on the first one, scan indexes should, adding a new
212 # box should only appear on the last, etc.
213 my @search_boxes_array;
214 my $search_boxes_count = C4
::Context
->preference("OPACAdvSearchInputCount") || 3;
215 for (my $i=1;$i<=$search_boxes_count;$i++) {
216 # if it's the first one, don't display boolean option, but show scan indexes
218 push @search_boxes_array,
224 # if it's the last one, show the 'add field' box
225 elsif ($i==$search_boxes_count) {
226 push @search_boxes_array,
233 push @search_boxes_array,
240 $template->param(uc(C4
::Context
->preference("marcflavour")) => 1, # we already did this for UNIMARC
242 search_boxes_loop
=> \
@search_boxes_array);
244 # use the global setting by default
245 if ( C4
::Context
->preference("expandedSearchOption") == 1 ) {
246 $template->param( expanded_options
=> C4
::Context
->preference("expandedSearchOption") );
248 # but let the user override it
249 if (defined $cgi->param('expanded_options')) {
250 if ( ($cgi->param('expanded_options') == 0) || ($cgi->param('expanded_options') == 1 ) ) {
251 $template->param( expanded_options
=> $cgi->param('expanded_options'));
254 output_html_with_http_headers
$cgi, $cookie, $template->output;
258 ### OK, if we're this far, we're performing an actual search
260 # Fetch the paramater list as a hash in scalar context:
261 # * returns paramater list as tied hash ref
262 # * we can edit the values by changing the key
263 # * multivalued CGI paramaters are returned as a packaged string separated by "\0" (null)
264 my $params = $cgi->Vars;
266 $tag = $params->{tag
} if $params->{tag
};
268 # Params that can have more than one value
269 # sort by is used to sort the query
270 # in theory can have more than one but generally there's just one
272 my $default_sort_by = C4
::Context
->preference('OPACdefaultSortField')."_".C4
::Context
->preference('OPACdefaultSortOrder')
273 if (C4
::Context
->preference('OPACdefaultSortField') && C4
::Context
->preference('OPACdefaultSortOrder'));
275 @sort_by = split("\0",$params->{'sort_by'}) if $params->{'sort_by'};
276 $sort_by[0] = $default_sort_by if !$sort_by[0] && defined($default_sort_by);
277 foreach my $sort (@sort_by) {
278 $template->param($sort => 1); # FIXME: security hole. can set any TMPL_VAR here
280 $template->param('sort_by' => $sort_by[0]);
282 # Use the servers defined, or just search our local catalog(default)
284 @servers = split("\0",$params->{'server'}) if $params->{'server'};
286 #FIXME: this should be handled using Context.pm
287 @servers = ("biblioserver");
288 # @servers = C4::Context->config("biblioserver");
291 # operators include boolean and proximity operators and are used
292 # to evaluate multiple operands
294 @operators = split("\0",$params->{'op'}) if $params->{'op'};
296 # indexes are query qualifiers, like 'title', 'author', etc. They
297 # can be single or multiple parameters separated by comma: kw,right-Truncation
299 @indexes = split("\0",$params->{'idx'}) if $params->{'idx'};
301 # if a simple index (only one) display the index used in the top search box
302 if ($indexes[0] && !$indexes[1]) {
303 $template->param("ms_".$indexes[0] => 1);
305 # an operand can be a single term, a phrase, or a complete ccl query
307 @operands = split("\0",$params->{'q'}) if $params->{'q'};
309 # if a simple search, display the value in the search box
310 if ($operands[0] && !$operands[1]) {
311 $template->param(ms_value
=> $operands[0]);
314 # limits are use to limit to results to a pre-defined category such as branch or language
316 @limits = split("\0",$params->{'limit'}) if $params->{'limit'};
318 if($params->{'multibranchlimit'}) {
319 push @limits, join(" or ", map { "branch: $_ "} @
{GetBranchesInCategory
($params->{'multibranchlimit'})}) ;
323 foreach my $limit(@limits) {
324 if ($limit =~/available/) {
328 $template->param(available
=> $available);
330 # append year limits if they exist
331 if ($params->{'limit-yr'}) {
332 if ($params->{'limit-yr'} =~ /\d{4}-\d{4}/) {
333 my ($yr1,$yr2) = split(/-/, $params->{'limit-yr'});
334 push @limits, "yr,st-numeric,ge=$yr1 and yr,st-numeric,le=$yr2";
336 elsif ($params->{'limit-yr'} =~ /\d{4}/) {
337 push @limits, "yr,st-numeric=$params->{'limit-yr'}";
340 #FIXME: Should return a error to the user, incorect date format specified
344 # Params that can only have one value
345 my $scan = $params->{'scan'};
346 my $count = C4
::Context
->preference('OPACnumSearchResults') || 20;
347 my $results_per_page = $params->{'count'} || $count;
348 my $offset = $params->{'offset'} || 0;
349 my $page = $cgi->param('page') || 1;
350 $offset = ($page-1)*$results_per_page if $page>1;
352 my $expanded_facet = $params->{'expand'};
354 # Define some global variables
355 my ($error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$stopwords_removed,$query_type);
359 ## I. BUILD THE QUERY
360 my $lang = C4
::Output
::getlanguagecookie
($cgi);
361 ( $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);
363 sub _input_cgi_parse
($) {
365 for my $this_cgi ( split('&',shift) ) {
366 next unless $this_cgi;
367 $this_cgi =~ /(.*?)=(.*)/;
368 push @elements, { input_name
=> $1, input_value
=> $2 };
373 ## parse the query_cgi string and put it into a form suitable for <input>s
374 my @query_inputs = _input_cgi_parse
($query_cgi);
375 $template->param ( QUERY_INPUTS
=> \
@query_inputs );
377 ## parse the limit_cgi string and put it into a form suitable for <input>s
378 my @limit_inputs = $limit_cgi ? _input_cgi_parse
($limit_cgi) : ();
380 # add OPAC 'hidelostitems'
381 #if (C4::Context->preference('hidelostitems') == 1) {
382 # # either lost ge 0 or no value in the lost register
383 # $query ="($query) and ( (lost,st-numeric <= 0) or ( allrecords,AlwaysMatches='' not lost,AlwaysMatches='') )";
386 # add OPAC suppression - requires at least one item indexed with Suppress
387 if (C4
::Context
->preference('OpacSuppression')) {
388 $query = "($query) not Suppress=1";
391 $template->param ( LIMIT_INPUTS
=> \
@limit_inputs );
393 ## II. DO THE SEARCH AND GET THE RESULTS
394 my $total = 0; # the total results for the whole set
395 my $facets; # this object stores the faceted results that display on the left-hand of the results page
401 $query_cgi = "tag=" .$tag . "&" . $query_cgi;
402 my $taglist = get_tags
({term
=>$tag, approved
=>1});
403 $results_hashref->{biblioserver
}->{hits
} = scalar (@
$taglist);
404 my @biblist = (map {GetBiblioData
($_->{biblionumber
})} @
$taglist);
405 my @marclist = (map {$_->{marc
}} @biblist );
406 $DEBUG and printf STDERR
"taglist (%s biblionumber)\nmarclist (%s records)\n", scalar(@
$taglist), scalar(@marclist);
407 $results_hashref->{biblioserver
}->{RECORDS
} = \
@marclist;
408 # FIXME: tag search and standard search should work together, not exclusively
409 # FIXME: No facets for tags search.
411 elsif (C4
::Context
->preference('NoZebra')) {
413 ($error, $results_hashref, $facets) = NZgetRecords
($query,$simple_query,\
@sort_by,\
@servers,$results_per_page,$offset,$expanded_facet,$branches,$query_type,$scan);
415 } elsif ($build_grouped_results) {
417 ($error, $results_hashref, $facets) = C4
::Search
::pazGetRecords
($query,$simple_query,\
@sort_by,\
@servers,$results_per_page,$offset,$expanded_facet,$branches,$query_type,$scan);
421 ($error, $results_hashref, $facets) = getRecords
($query,$simple_query,\
@sort_by,\
@servers,$results_per_page,$offset,$expanded_facet,$branches,$query_type,$scan);
424 # use Data::Dumper; print STDERR "-" x 25, "\n", Dumper($results_hashref);
426 $template->param(query_error
=> $error.$@
);
427 output_html_with_http_headers
$cgi, $cookie, $template->output;
431 # At this point, each server has given us a result set
432 # now we build that set for template display
433 my @sup_results_array;
434 for (my $i=0;$i<=@servers;$i++) {
435 my $server = $servers[$i];
436 if ($server && $server =~/biblioserver/) { # this is the local bibliographic server
437 $hits = $results_hashref->{$server}->{"hits"};
438 my $page = $cgi->param('page') || 0;
440 if ($build_grouped_results) {
441 foreach my $group (@
{ $results_hashref->{$server}->{"GROUPS"} }) {
442 # because pazGetRecords handles retieving only the records
443 # we want as specified by $offset and $results_per_page,
444 # we need to set the offset parameter of searchResults to 0
445 my @group_results = searchResults
( 'opac', $query_desc, $group->{'group_count'},$results_per_page, 0, $scan,
446 @
{ $group->{"RECORDS"} }, C4
::Context
->preference('hidelostitems'));
447 push @newresults, { group_label
=> $group->{'group_label'}, GROUP_RESULTS
=> \
@group_results };
450 @newresults = searchResults
('opac', $query_desc, $hits, $results_per_page, $offset, $scan,
451 @
{$results_hashref->{$server}->{"RECORDS"}},, C4
::Context
->preference('hidelostitems'));
454 if (C4
::Context
->preference('TagsEnabled') and
455 $tag_quantity = C4
::Context
->preference('TagsShowOnList')) {
456 foreach (@newresults) {
457 my $bibnum = $_->{biblionumber
} or next;
458 $_->{itemsissued
} = CountItemsIssued
( $bibnum );
459 $_ ->{'TagLoop'} = get_tags
({biblionumber
=>$bibnum, approved
=>1, 'sort'=>'-weight',
460 limit
=>$tag_quantity });
463 foreach (@newresults) {
464 $_->{coins
} = GetCOinSBiblio
($_->{'biblionumber'});
467 if ($results_hashref->{$server}->{"hits"}){
468 $total = $total + $results_hashref->{$server}->{"hits"};
470 # Opac search history
472 if (C4
::Context
->preference('EnableOpacSearchHistory')) {
475 # Getting the (maybe) already sent cookie
476 my $searchcookie = $cgi->cookie('KohaOpacRecentSearches');
478 $searchcookie = uri_unescape
($searchcookie);
479 if (thaw
($searchcookie)) {
480 @recentSearches = @
{thaw
($searchcookie)};
484 # Adding the new search if needed
485 if ($borrowernumber eq '') {
486 # To a cookie (the user is not logged in)
488 if ($params->{'offset'} eq '') {
490 push @recentSearches, {
491 "query_desc" => $query_desc || "unknown",
492 "query_cgi" => $query_cgi || "unknown",
496 $template->param(ShowOpacRecentSearchLink
=> 1);
499 # Pushing the cookie back
500 $newsearchcookie = $cgi->cookie(
501 -name
=> 'KohaOpacRecentSearches',
502 # We uri_escape the whole freezed structure so we're sure we won't have any encoding problems
503 -value
=> uri_escape
(freeze
(\
@recentSearches)),
506 $cookie = [$cookie, $newsearchcookie];
509 # To the session (the user is logged in)
510 if ($params->{'offset'} eq '') {
511 AddSearchHistory
($borrowernumber, $cgi->cookie("CGISESSID"), $query_desc, $query_cgi, $total);
512 $template->param(ShowOpacRecentSearchLink
=> 1);
516 ## If there's just one result, redirect to the detail page
517 if ($total == 1 && $format ne 'rss2'
518 && $format ne 'opensearchdescription' && $format ne 'atom') {
519 my $biblionumber=$newresults[0]->{biblionumber
};
520 if (C4
::Context
->preference('BiblioDefaultView') eq 'isbd') {
521 print $cgi->redirect("/cgi-bin/koha/opac-ISBDdetail.pl?biblionumber=$biblionumber");
522 } elsif (C4
::Context
->preference('BiblioDefaultView') eq 'marc') {
523 print $cgi->redirect("/cgi-bin/koha/opac-MARCdetail.pl?biblionumber=$biblionumber");
525 print $cgi->redirect("/cgi-bin/koha/opac-detail.pl?biblionumber=$biblionumber");
530 $template->param(total
=> $hits);
531 my $limit_cgi_not_availablity = $limit_cgi;
532 $limit_cgi_not_availablity =~ s/&limit=available//g if defined $limit_cgi_not_availablity;
533 $template->param(limit_cgi_not_availablity
=> $limit_cgi_not_availablity);
534 $template->param(limit_cgi
=> $limit_cgi);
535 $template->param(query_cgi
=> $query_cgi);
536 $template->param(query_desc
=> $query_desc);
537 $template->param(limit_desc
=> $limit_desc);
538 $template->param(DisplayMultiPlaceHold
=> $DisplayMultiPlaceHold);
539 if ($query_desc || $limit_desc) {
540 $template->param(searchdesc
=> 1);
542 $template->param(stopwords_removed
=> "@$stopwords_removed") if $stopwords_removed;
543 $template->param(results_per_page
=> $results_per_page);
544 $template->param(SEARCH_RESULTS
=> \
@newresults,
545 OPACItemsResultsDisplay
=> (C4
::Context
->preference("OPACItemsResultsDisplay") eq "itemdetails"?
1:0),
547 ## Build the page numbers on the bottom of the page
549 # total number of pages there will be
550 my $pages = ceil
($hits / $results_per_page);
551 # default page number
552 my $current_page_number = 1;
553 $current_page_number = ($offset / $results_per_page + 1) if $offset;
554 my $previous_page_offset = $offset - $results_per_page unless ($offset - $results_per_page <0);
555 my $next_page_offset = $offset + $results_per_page;
556 # If we're within the first 10 pages, keep it simple
557 #warn "current page:".$current_page_number;
558 if ($current_page_number < 10) {
559 # just show the first 10 pages
560 # Loop through the pages
561 my $pages_to_show = 10;
562 $pages_to_show = $pages if $pages<10;
563 for ($i=1; $i<=$pages_to_show;$i++) {
564 # the offset for this page
565 my $this_offset = (($i*$results_per_page)-$results_per_page);
566 # the page number for this page
567 my $this_page_number = $i;
568 # it should only be highlighted if it's the current page
569 my $highlight = 1 if ($this_page_number == $current_page_number);
570 # put it in the array
571 push @page_numbers, { offset
=> $this_offset, pg
=> $this_page_number, highlight
=> $highlight, sort_by
=> join " ",@sort_by };
576 # now, show twenty pages, with the current one smack in the middle
578 for ($i=$current_page_number; $i<=($current_page_number + 20 );$i++) {
579 my $this_offset = ((($i-9)*$results_per_page)-$results_per_page);
580 my $this_page_number = $i-9;
581 my $highlight = 1 if ($this_page_number == $current_page_number);
582 if ($this_page_number <= $pages) {
583 push @page_numbers, { offset
=> $this_offset, pg
=> $this_page_number, highlight
=> $highlight, sort_by
=> join " ",@sort_by };
588 $template->param( PAGE_NUMBERS
=> \
@page_numbers,
589 previous_page_offset
=> $previous_page_offset) unless $pages < 2;
590 $template->param(next_page_offset
=> $next_page_offset) unless $pages eq $current_page_number;
594 $template->param(searchdesc
=> 1,query_desc
=> $query_desc,limit_desc
=> $limit_desc);
596 } # end of the if local
597 # asynchronously search the authority server
598 elsif ($server && $server =~/authorityserver/) { # this is the local authority server
599 my @inner_sup_results_array;
600 for my $sup_record ( @
{$results_hashref->{$server}->{"RECORDS"}} ) {
601 my $marc_record_object = MARC
::Record
->new_from_usmarc($sup_record);
602 my $title_field = $marc_record_object->field(100);
603 push @inner_sup_results_array, {
604 'title' => $title_field->subfield('a'),
605 'link' => "&idx=an&q=".$marc_record_object->field('001')->as_string(),
608 my $servername = $server;
609 push @sup_results_array, { servername
=> $servername,
610 inner_sup_results_loop
=> \
@inner_sup_results_array} if @inner_sup_results_array;
612 # FIXME: can add support for other targets as needed here
613 $template->param( outer_sup_results_loop
=> \
@sup_results_array);
614 } #/end of the for loop
615 #$template->param(FEDERATED_RESULTS => \@results_array);
618 #classlist => $classlist,
621 facets_loop
=> $facets,
623 search_error
=> $error,
626 if ($query_desc || $limit_desc) {
627 $template->param(searchdesc
=> 1);
630 # VI. BUILD THE TEMPLATE
631 # Build drop-down list for 'Add To:' menu...
632 my $session = get_session
($cgi->cookie("CGISESSID"));
634 my $pubshelves = $session->param('pubshelves');
635 my $barshelves = $session->param('barshelves');
636 foreach my $shelf (@
$pubshelves) {
637 next if ( ($shelf->{'owner'} != ($borrowernumber ?
$borrowernumber : -1)) && ($shelf->{'category'} < 3) );
638 push (@addpubshelves, $shelf);
641 if (@addpubshelves) {
642 $template->param( addpubshelves
=> scalar (@addpubshelves));
643 $template->param( addpubshelvesloop
=> \
@addpubshelves);
646 if (defined $barshelves) {
647 $template->param( addbarshelves
=> scalar (@
$barshelves));
648 $template->param( addbarshelvesloop
=> $barshelves);
651 my $content_type = ($format eq 'rss' or $format eq 'atom') ?
$format : 'html';
653 # If GoogleIndicTransliteration system preference is On Set paramter to load Google's javascript in OPAC search screens
654 if (C4
::Context
->preference('GoogleIndicTransliteration')) {
655 $template->param('GoogleIndicTransliteration' => 1);
658 output_with_http_headers
$cgi, $cookie, $template->output, $content_type;