Browse Source

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 <galen.charlton@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
3.0.x
Henri-Damien LAURENT 16 years ago
committed by Joshua Ferraro
parent
commit
65295e5e22
  1. 17
      C4/AuthoritiesMarc.pm
  2. 16
      authorities/authorities-home.pl

17
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 {

16
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

Loading…
Cancel
Save