View | Details | Raw Unified | Return to bug 38832
Collapse All | Expand All

(-)a/catalogue/search.pl (-40 / +4 lines)
Lines 358-370 foreach my $sort (@sort_by) { Link Here
358
}
358
}
359
$template->param('sort_by' => $sort_by[0]);
359
$template->param('sort_by' => $sort_by[0]);
360
360
361
# Use the servers defined, or just search our local catalog(default)
362
my @servers = $cgi->multi_param('server');
363
unless (@servers) {
364
    #FIXME: this should be handled using Context.pm
365
    @servers = ("biblioserver");
366
    # @servers = C4::Context->config("biblioserver");
367
}
368
# operators include boolean and proximity operators and are used
361
# operators include boolean and proximity operators and are used
369
# to evaluate multiple operands
362
# to evaluate multiple operands
370
my @operators = map uri_unescape($_), $cgi->multi_param('op');
363
my @operators = map uri_unescape($_), $cgi->multi_param('op');
Lines 523-532 my $total = 0; # the total results for the whole set Link Here
523
my $facets; # this object stores the faceted results that display on the left-hand of the results page
516
my $facets; # this object stores the faceted results that display on the left-hand of the results page
524
my $results_hashref;
517
my $results_hashref;
525
518
519
my $server = 'biblioserver';
526
eval {
520
eval {
527
    my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
521
    my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
528
    ( $error, $results_hashref, $facets ) = $searcher->search_compat(
522
    ( $error, $results_hashref, $facets ) = $searcher->search_compat(
529
        $query,            $simple_query, \@sort_by,       \@servers,
523
        $query,            $simple_query, \@sort_by,       [$server],
530
        $results_per_page, $offset,       undef,           $itemtypes,
524
        $results_per_page, $offset,       undef,           $itemtypes,
531
        $query_type,       $scan
525
        $query_type,       $scan
532
    );
526
    );
Lines 541-552 if ($@ || $error) { Link Here
541
    exit;
535
    exit;
542
}
536
}
543
537
544
# At this point, each server has given us a result set
545
# now we build that set for template display
546
my @sup_results_array;
547
for (my $i=0;$i<@servers;$i++) {
548
    my $server = $servers[$i];
549
    if ($server =~/biblioserver/) { # this is the local bibliographic server
550
        my $hits = $results_hashref->{$server}->{"hits"} // 0;
538
        my $hits = $results_hashref->{$server}->{"hits"} // 0;
551
        if ( $hits == 0 && $basic_search ){
539
        if ( $hits == 0 && $basic_search ){
552
            $operands[0] = '"'.$operands[0].'"'; #quote it
540
            $operands[0] = '"'.$operands[0].'"'; #quote it
Lines 562-575 for (my $i=0;$i<@servers;$i++) { Link Here
562
            eval {
550
            eval {
563
                my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
551
                my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
564
                ( $error, $quoted_results_hashref, $facets ) = $searcher->search_compat(
552
                ( $error, $quoted_results_hashref, $facets ) = $searcher->search_compat(
565
                    $query,            $simple_query, \@sort_by,       ['biblioserver'],
553
                    $query,            $simple_query, \@sort_by,       [$server],
566
                    $results_per_page, $offset,       undef,           $itemtypes,
554
                    $results_per_page, $offset,       undef,           $itemtypes,
567
                    $query_type,       $scan
555
                    $query_type,       $scan
568
                );
556
                );
569
            };
557
            };
570
            my $quoted_hits = $quoted_results_hashref->{$server}->{"hits"} // 0;
558
            my $quoted_hits = $quoted_results_hashref->{$server}->{"hits"} // 0;
571
            if ( $quoted_hits ){
559
            if ( $quoted_hits ){
572
                $results_hashref->{'biblioserver'} = $quoted_results_hashref->{'biblioserver'};
560
                $results_hashref->{$server} = $quoted_results_hashref->{$server};
573
                $hits = $quoted_hits;
561
                $hits = $quoted_hits;
574
            }
562
            }
575
        }
563
        }
Lines 689-718 for (my $i=0;$i<@servers;$i++) { Link Here
689
            $template->param(searchdesc => 1,query_desc => $query_desc,limit_desc => $limit_desc);
677
            $template->param(searchdesc => 1,query_desc => $query_desc,limit_desc => $limit_desc);
690
        }
678
        }
691
679
692
    } # end of the if local
693
694
    # asynchronously search the authority server
695
    elsif ($server =~/authorityserver/) { # this is the local authority server
696
        my @inner_sup_results_array;
697
        for my $sup_record ( @{$results_hashref->{$server}->{"RECORDS"}} ) {
698
            my $marc_record_object = C4::Search::new_record_from_zebra(
699
                'authorityserver',
700
                $sup_record
701
            );
702
            # warn "Authority Found: ".$marc_record_object->as_formatted();
703
            push @inner_sup_results_array, {
704
                'title' => $marc_record_object->field(100)->subfield('a'),
705
                'link' => "&amp;idx=an&amp;q=".$marc_record_object->field('001')->as_string(),
706
            };
707
        }
708
        push @sup_results_array, {  servername => $server, 
709
                                    inner_sup_results_loop => \@inner_sup_results_array} if @inner_sup_results_array;
710
    }
711
    # FIXME: can add support for other targets as needed here
712
    $template->param(           outer_sup_results_loop => \@sup_results_array);
713
} #/end of the for loop
714
#$template->param(FEDERATED_RESULTS => \@results_array);
715
716
my $gotonumber = $cgi->param('gotoNumber');
680
my $gotonumber = $cgi->param('gotoNumber');
717
if ( $gotonumber && ( $gotonumber eq 'last' || $gotonumber eq 'first' ) ) {
681
if ( $gotonumber && ( $gotonumber eq 'last' || $gotonumber eq 'first' ) ) {
718
    $template->{'VARS'}->{'gotoNumber'} = $gotonumber;
682
    $template->{'VARS'}->{'gotoNumber'} = $gotonumber;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt (-23 lines)
Lines 73-83 Link Here
73
73
74
            <h1>Search results</h1>
74
            <h1>Search results</h1>
75
75
76
                [% IF ( outer_sup_results_loop ) %]
77
                    <div class="row">
78
                        <div class="col-sm-8">
79
                [% END %]
80
81
                [% IF ( total ) %]
76
                [% IF ( total ) %]
82
77
83
                    <h3>
78
                    <h3>
Lines 722-744 Link Here
722
                    <!-- No Results Found -->
717
                    <!-- No Results Found -->
723
                [% END #/IF total %]
718
                [% END #/IF total %]
724
719
725
                [% IF ( outer_sup_results_loop ) %]
726
                    </div>
727
                    <div class="col-sm-4">
728
                        [% FOREACH outer_sup_results_loo IN outer_sup_results_loop %]
729
                            [% IF ( outer_sup_results_loo.inner_sup_results_loop ) %]
730
                                [% outer_sup_results_loo.servername | html %]
731
                                [% FOREACH inner_sup_results_loo IN outer_sup_results_loo.inner_sup_results_loop %]
732
                                    <div>
733
                                        <a href="/cgi-bin/koha/catalogue/search.pl?[% inner_sup_results_loo.query_cgi | $raw %][% inner_sup_results_loo.limit_cgi | $raw %][% inner_sup_results_loo.sort_by | uri %][% inner_sup_results_loo.link | uri %]">[% inner_sup_results_loo.title | html %]</a>
734
                                    </div>
735
                                [% END %]
736
                            [% END %]
737
                        [% END # FOREACH outer_sup_results_loo %]
738
                    </div> <!-- /.col-sm-4 -->
739
                </div>
740
                [% END #/IF outer_sup_results_loop %]
741
742
                [% IF ( Koha.Preference('SavedSearchFilters') && CAN_user_parameters_manage_search_filters ) %]
720
                [% IF ( Koha.Preference('SavedSearchFilters') && CAN_user_parameters_manage_search_filters ) %]
743
                    <div id="search_filters_modal" class="modal" role="dialog" aria-hidden="true">
721
                    <div id="search_filters_modal" class="modal" role="dialog" aria-hidden="true">
744
                        <div class="modal-dialog">
722
                        <div class="modal-dialog">
745
- 

Return to bug 38832