From 65295e5e22a243f309f323296e5c489743922b63 Mon Sep 17 00:00:00 2001 From: Henri-Damien LAURENT Date: Thu, 13 Dec 2007 18:21:57 -0600 Subject: [PATCH] authorities result lists where badly paged. finalresult contained the whole list and not only the useful results. resultlist contained only 19 elements. adding one parameters passed through pages contained also empty parameters deleting them. Conflicts: C4/AuthoritiesMarc.pm Signed-off-by: Galen Charlton Signed-off-by: Joshua Ferraro --- C4/AuthoritiesMarc.pm | 17 +++++++++-------- authorities/authorities-home.pl | 16 +++++++++------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm index e336026b63..e440f1da50 100644 --- a/C4/AuthoritiesMarc.pm +++ b/C4/AuthoritiesMarc.pm @@ -146,30 +146,31 @@ sub SearchAuthorities { $result{$title.$authid}=$authid; } # sort the hash and return the same structure as GetRecords (Zebra querying) - my @finalresult = (); + my @listresult = (); my $numbers=0; if ($sortby eq 'HeadingDsc') { # sort by mainmainentry desc foreach my $key (sort {$b cmp $a} (keys %result)) { - push @finalresult, $result{$key}; + push @listresult, $result{$key}; # warn "push..."$#finalresult; $numbers++; } } else { # sort by mainmainentry ASC foreach my $key (sort (keys %result)) { - push @finalresult, $result{$key}; + push @listresult, $result{$key}; # warn "push..."$#finalresult; $numbers++; } } # limit the $results_per_page to result size if it's more - $length = $numbers-1 if $numbers < $length; + $length = $numbers-1-$offset if $numbers < ($offset+$length); # for the requested page, replace authid by the complete record # speed improvement : avoid reading too much things - for (my $counter=$offset;$counter<=$offset+$length;$counter++) { + my @finalresult; + for (my $counter=$offset;$counter<=$offset+$length-1;$counter++) { # $finalresult[$counter] = GetAuthority($finalresult[$counter])->as_usmarc; my $separator=C4::Context->preference('authoritysep'); - my $authrecord = MARC::File::USMARC::decode(GetAuthority($finalresult[$counter])->as_usmarc); - my $authid=$authrecord->field('001')->data(); + my $authrecord =GetAuthority($listresult[$counter]); + my $authid=$listresult[$counter]; my $summary=BuildSummary($authrecord,$authid,$authtypecode); my $query_auth_tag = "SELECT auth_tag_to_report FROM auth_types WHERE authtypecode=?"; my $sth = $dbh->prepare($query_auth_tag); @@ -180,7 +181,7 @@ sub SearchAuthorities { $newline{summary} = $summary; $newline{authid} = $authid; $newline{even} = $counter % 2; - $finalresult[$counter]= \%newline; + push @finalresult, \%newline; } return (\@finalresult, $numbers); } else { diff --git a/authorities/authorities-home.pl b/authorities/authorities-home.pl index cccab218d9..9ffd6e2ca5 100755 --- a/authorities/authorities-home.pl +++ b/authorities/authorities-home.pl @@ -61,13 +61,13 @@ if ( $op eq "do_search" ) { my @value = $query->param('value'); my $startfrom = $query->param('startfrom') || 1; - my $resultsperpage = $query->param('resultsperpage') || 19; + my $resultsperpage = $query->param('resultsperpage') || 20; my ( $results, $total ) = SearchAuthorities( \@marclist, \@and_or, \@excluding, \@operator, \@value, ( $startfrom - 1 ) * $resultsperpage, $resultsperpage, $authtypecode, $orderby ); - +# use Data::Dumper; warn Data::Dumper::Dumper(@$results); ( $template, $loggedinuser, $cookie ) = get_template_and_user( { template_name => "authorities/searchresultlist.tmpl", @@ -86,11 +86,13 @@ if ( $op eq "do_search" ) { # next/previous would not work anymore my @marclist_ini = $query->param('marclist'); for ( my $i = 0 ; $i <= $#marclist ; $i++ ) { - push @field_data, { term => "marclist", val => $marclist_ini[$i] }; - push @field_data, { term => "and_or", val => $and_or[$i] }; - push @field_data, { term => "excluding", val => $excluding[$i] }; - push @field_data, { term => "operator", val => $operator[$i] }; - push @field_data, { term => "value", val => $value[$i] }; + if ($value[$i]){ + push @field_data, { term => "marclist", val => $marclist_ini[$i] }; + push @field_data, { term => "and_or", val => $and_or[$i] }; + push @field_data, { term => "excluding", val => $excluding[$i] }; + push @field_data, { term => "operator", val => $operator[$i] }; + push @field_data, { term => "value", val => $value[$i] }; + } } # construction of the url of each page -- 2.39.5