$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);
$newline{summary} = $summary;
$newline{authid} = $authid;
$newline{even} = $counter % 2;
- $finalresult[$counter]= \%newline;
+ push @finalresult, \%newline;
}
return (\@finalresult, $numbers);
} else {
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",
# 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