Código PHP:
Ver original
function paginate_three($reload, $page, $tpages, $adjacents) { $prevlabel = "‹ Prev"; $nextlabel = "Next ›"; $out = "<div class=\"pagin\">\n"; // previous if($page==1) { $out.= "<span>" . $prevlabel . "</span>\n"; } elseif($page==2) { $out.= "<a href=\"" . $reload . "\">" . $prevlabel . "</a>\n"; } else { $out.= "<a href=\"" . $reload . "&page=" . ($page-1) . "\">" . $prevlabel . "</a>\n"; } // first if($page>($adjacents+1)) { $out.= "<a href=\"" . $reload . "\">1</a>\n"; } // interval if($page>($adjacents+2)) { $out.= "...\n"; } // pages $pmin = ($page>$adjacents) ? ($page-$adjacents) : 1; $pmax = ($page<($tpages-$adjacents)) ? ($page+$adjacents) : $tpages; for($i=$pmin; $i<=$pmax; $i++) { if($i==$page) { $out.= "<span class=\"current\">" . $i . "</span>\n"; } elseif($i==1) { $out.= "<a href=\"" . $reload . "\">" . $i . "</a>\n"; } else { $out.= "<a href=\"" . $reload . "&page=" . $i . "\">" . $i . "</a>\n"; } } // interval if($page<($tpages-$adjacents-1)) { $out.= "...\n"; } // last if($page<($tpages-$adjacents)) { $out.= "<a href=\"" . $reload . "&page=" . $tpages . "\">" . $tpages . "</a>\n"; } // next if($page<$tpages) { $out.= "<a href=\"" . $reload . "&page=" . ($page+1) . "\">" . $nextlabel . "</a>\n"; } else { $out.= "<span>" . $nextlabel . "</span>\n"; } $out.= "</div>"; return $out; } ?>