(bug #2956) fix 4xx plugin pagination
authorNahuel ANGELINETTI <nahuel.angelinetti@biblibre.com>
Thu, 12 Feb 2009 14:38:52 +0000 (15:38 +0100)
committerHenri-Damien LAURENT <henridamien.laurent@biblibre.com>
Wed, 4 Mar 2009 11:45:36 +0000 (12:45 +0100)
this patch rework the calculation of the pagination and of results

cataloguing/value_builder/unimarc_field_4XX.pl

index 3148601..4cdc4ec 100755 (executable)
@@ -349,17 +349,15 @@ sub plugin {
         # multi page display gestion
         my $displaynext = 0;
         my $displayprev = $startfrom;
-        if ( ( $total - ( ( $startfrom + 1 ) * ($resultsperpage) ) ) > 0 ) {
+
+        if( ( $total_hits - ( ( $startfrom + 1 ) * ($resultsperpage) ) ) > 0 ) {
             $displaynext = 1;
         }
         my @arrayresults;
         my @field_data = ($search);
          for (
-             my $i = $startfrom * $resultsperpage ;
-             $i < (( $startfrom * $resultsperpage + $resultsperpage  < scalar(@$results))
-                 ? $startfrom * $resultsperpage + $resultsperpage
-                 : scalar(@$results)
-             ) ;
+             my $i = 0 ;
+             $i < $resultsperpage ;
              $i++
            )
          {
@@ -444,7 +442,7 @@ sub plugin {
             startfromnext  => $startfrom + 1,
             startfromprev  => $startfrom - 1,
             searchdata     => \@field_data,
-            total          => $total,
+            total          => $total_hits,
             from           => $from,
             to             => $to,
             numbers        => \@numbers,