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

(-)a/catalogue/search.pl (-32 / +38 lines)
Lines 170-175 my $template_type; Link Here
170
my @params = $cgi->multi_param("limit");
170
my @params = $cgi->multi_param("limit");
171
if ((@params>=1) || ($cgi->param("q")) || ($cgi->param('multibranchlimit')) || ($cgi->param('limit-yr')) ) {
171
if ((@params>=1) || ($cgi->param("q")) || ($cgi->param('multibranchlimit')) || ($cgi->param('limit-yr')) ) {
172
    $template_name = 'catalogue/results.tt';
172
    $template_name = 'catalogue/results.tt';
173
    $template_type = 'results';
173
}
174
}
174
else {
175
else {
175
    $template_name = 'catalogue/advsearch.tt';
176
    $template_name = 'catalogue/advsearch.tt';
Lines 449-455 my $offset = $params->{'offset'} || 0; Link Here
449
$offset = 0 if $offset < 0;
450
$offset = 0 if $offset < 0;
450
my $page = $cgi->param('page') || 1;
451
my $page = $cgi->param('page') || 1;
451
#my $offset = ($page-1)*$results_per_page;
452
#my $offset = ($page-1)*$results_per_page;
452
my $hits;
453
my $expanded_facet = $params->{'expand'};
453
my $expanded_facet = $params->{'expand'};
454
454
455
# Define some global variables
455
# Define some global variables
Lines 474-515 my @query_inputs; Link Here
474
my $scan_index_to_use;
474
my $scan_index_to_use;
475
my $scan_search_term_to_use;
475
my $scan_search_term_to_use;
476
476
477
for my $this_cgi ( split('&',$query_cgi) ) {
477
if ($query_cgi) {
478
    next unless $this_cgi;
478
    for my $this_cgi ( split('&', $query_cgi) ) {
479
    $this_cgi =~ m/(.*?)=(.*)/;
479
        next unless $this_cgi;
480
    my $input_name = $1;
480
        $this_cgi =~ m/(.*?)=(.*)/;
481
    my $input_value = $2;
481
        my $input_name = $1;
482
    push @query_inputs, { input_name => $input_name, input_value => Encode::decode_utf8( uri_unescape( $input_value ) ) };
482
        my $input_value = $2;
483
    if ($input_name eq 'idx') {
483
        push @query_inputs, { input_name => $input_name, input_value => Encode::decode_utf8( uri_unescape( $input_value ) ) };
484
        $scan_index_to_use = $input_value; # unless $scan_index_to_use;
484
        if ($input_name eq 'idx') {
485
    }
485
            $scan_index_to_use = $input_value; # unless $scan_index_to_use;
486
    if ($input_name eq 'q') {
486
        }
487
        $scan_search_term_to_use = Encode::decode_utf8( uri_unescape( $input_value ));
487
        if ($input_name eq 'q') {
488
            $scan_search_term_to_use = Encode::decode_utf8( uri_unescape( $input_value ));
489
        }
488
    }
490
    }
489
}
491
}
492
490
$template->param ( QUERY_INPUTS => \@query_inputs,
493
$template->param ( QUERY_INPUTS => \@query_inputs,
491
                   scan_index_to_use => $scan_index_to_use,
494
                   scan_index_to_use => $scan_index_to_use,
492
                   scan_search_term_to_use => $scan_search_term_to_use );
495
                   scan_search_term_to_use => $scan_search_term_to_use );
493
496
494
## parse the limit_cgi string and put it into a form suitable for <input>s
497
## parse the limit_cgi string and put it into a form suitable for <input>s
495
my @limit_inputs;
498
my @limit_inputs;
496
for my $this_cgi ( split('&',$limit_cgi) ) {
499
if ($limit_cgi) {
497
    next unless $this_cgi;
500
    for my $this_cgi ( split('&', $limit_cgi) ) {
498
    # handle special case limit-yr
501
        next unless $this_cgi;
499
    if ($this_cgi =~ /yr,st-numeric/) {
502
        # handle special case limit-yr
500
        push @limit_inputs, { input_name => 'limit-yr', input_value => $limit_yr_value };   
503
        if ($this_cgi =~ /yr,st-numeric/) {
501
        next;
504
            push @limit_inputs, { input_name => 'limit-yr', input_value => $limit_yr_value };
505
            next;
506
        }
507
        $this_cgi =~ m/(.*=)(.*)/;
508
        my $input_name = $1;
509
        my $input_value = $2;
510
        $input_name =~ s/=$//;
511
        push @limit_inputs, { input_name => $input_name, input_value => Encode::decode_utf8( uri_unescape($input_value) ) };
502
    }
512
    }
503
    $this_cgi =~ m/(.*=)(.*)/;
504
    my $input_name = $1;
505
    my $input_value = $2;
506
    $input_name =~ s/=$//;
507
    push @limit_inputs, { input_name => $input_name, input_value => Encode::decode_utf8( uri_unescape($input_value) ) };
508
}
513
}
509
$template->param ( LIMIT_INPUTS => \@limit_inputs );
514
$template->param ( LIMIT_INPUTS => \@limit_inputs );
510
515
511
## II. DO THE SEARCH AND GET THE RESULTS
516
## II. DO THE SEARCH AND GET THE RESULTS
512
my $total; # the total results for the whole set
517
my $total = 0; # the total results for the whole set
513
my $facets; # this object stores the faceted results that display on the left-hand of the results page
518
my $facets; # this object stores the faceted results that display on the left-hand of the results page
514
my $results_hashref;
519
my $results_hashref;
515
520
Lines 534-544 my @sup_results_array; Link Here
534
for (my $i=0;$i<@servers;$i++) {
539
for (my $i=0;$i<@servers;$i++) {
535
    my $server = $servers[$i];
540
    my $server = $servers[$i];
536
    if ($server =~/biblioserver/) { # this is the local bibliographic server
541
    if ($server =~/biblioserver/) { # this is the local bibliographic server
537
        $hits = $results_hashref->{$server}->{"hits"};
542
        my $hits = $results_hashref->{$server}->{"hits"} // 0;
538
        my $page = $cgi->param('page') || 0;
543
        my $page = $cgi->param('page') || 0;
539
        my @newresults = searchResults('intranet', $query_desc, $hits, $results_per_page, $offset, $scan,
544
        my @newresults = searchResults('intranet', $query_desc, $hits, $results_per_page, $offset, $scan,
540
                                       $results_hashref->{$server}->{"RECORDS"});
545
                                       $results_hashref->{$server}->{"RECORDS"});
541
        $total = $total + $results_hashref->{$server}->{"hits"};
546
        $total = $total + $hits;
542
547
543
        # Search history
548
        # Search history
544
        if (C4::Context->preference('EnableSearchHistory')) {
549
        if (C4::Context->preference('EnableSearchHistory')) {
Lines 586-594 for (my $i=0;$i<@servers;$i++) { Link Here
586
591
587
        if ($hits) {
592
        if ($hits) {
588
            $template->param(total => $hits);
593
            $template->param(total => $hits);
589
            my $limit_cgi_not_availablity = $limit_cgi;
594
            if ($limit_cgi) {
590
            $limit_cgi_not_availablity =~ s/&limit=available//g;
595
                my $limit_cgi_not_availablity = $limit_cgi;
591
            $template->param(limit_cgi_not_availablity => $limit_cgi_not_availablity);
596
                $limit_cgi_not_availablity =~ s/&limit=available//g;
597
                $template->param(limit_cgi_not_availablity => $limit_cgi_not_availablity);
598
            }
592
            $template->param(limit_cgi => $limit_cgi);
599
            $template->param(limit_cgi => $limit_cgi);
593
            $template->param(query_cgi => $query_cgi);
600
            $template->param(query_cgi => $query_cgi);
594
            $template->param(query_desc => $query_desc);
601
            $template->param(query_desc => $query_desc);
Lines 703-715 for (my $i=0;$i<@servers;$i++) { Link Here
703
$template->{'VARS'}->{'searchid'} = $cgi->param('searchid');
710
$template->{'VARS'}->{'searchid'} = $cgi->param('searchid');
704
711
705
my $gotonumber = $cgi->param('gotoNumber');
712
my $gotonumber = $cgi->param('gotoNumber');
706
if ($gotonumber eq 'last' || $gotonumber eq 'first') {
713
if ( $gotonumber && ( $gotonumber eq 'last' || $gotonumber eq 'first' ) ) {
707
    $template->{'VARS'}->{'gotoNumber'} = $gotonumber;
714
    $template->{'VARS'}->{'gotoNumber'} = $gotonumber;
708
}
715
}
709
$template->{'VARS'}->{'gotoPage'}   = 'detail.pl';
716
$template->{'VARS'}->{'gotoPage'}   = 'detail.pl';
710
my $gotopage = $cgi->param('gotoPage');
717
my $gotopage = $cgi->param('gotoPage');
711
$template->{'VARS'}->{'gotoPage'} = $gotopage
718
$template->{'VARS'}->{'gotoPage'} = $gotopage
712
  if $gotopage =~ m/^(ISBD|labeledMARC|MARC|more)?detail.pl$/;
719
  if $gotopage && $gotopage =~ m/^(ISBD|labeledMARC|MARC|more)?detail.pl$/;
713
720
714
for my $facet ( @$facets ) {
721
for my $facet ( @$facets ) {
715
    for my $entry ( @{ $facet->{facets} } ) {
722
    for my $entry ( @{ $facet->{facets} } ) {
716
- 

Return to bug 20539