Location: PHPKode > scripts > SelectaPix Image Gallery > classes/pager.php
<?php
/* +----------------------------------------------------------------------+
   |SelectaPix Open Source Gallery	                                      |
   +----------------------------------------------------------------------+
   | Copyright (c) 2004 OutOfTheTrees			                          |
   |                                                                      |
   | http://www.outofthetrees.co.uk/index.php                             |
   | 												                      |
   +----------------------------------------------------------------------+
   | This source file is subject to version 2.0 of the GPL license,       |
   | that is bundled with this package in the file LICENSE, and is        |
   | available through the world-wide-web at the following url:           |
   | http://www.outofthetrees.co.uk/license/2_0.txt.                      |
   | If you did not receive a copy of the SelectaPix license and are 	  |
   | unable to obtain it through the world-wide-web, please send a note   |
   | to hide@address.com so we can mail you a copy immediately.|
   +----------------------------------------------------------------------+ */
if (!defined("ACCESS")) {
    die ("Direct request denied");
}

class Pager {
  	function findStart($limit) {
   		if ((!isset($_GET['page'])) || ($_GET['page'] == "1")) {
	       	$start = 0;
	       	$_GET['page'] = 1;
      	}
     	else {
       		$start = ($_GET['page']-1) * $limit;
      	}
     	return $start;
    }

   	function findPages($count, $limit) {
     $pages = (($count % $limit) == 0) ? $count / $limit : floor($count / $limit) + 1;
     return $pages;
	}

   	function pageList($curpage, $pages, $albumID) {
     	$page_list  = "\n<div class=\"prevnext\">\n".'Album pages:'."&nbsp;&nbsp;";
     	/* Print the first and previous page links if necessary */
     	if (($curpage != 1) && ($curpage)) {
       		$page_list .= "  <a href=\"".$_SERVER['PHP_SELF']."?page=1";
       		$page_list .= "&amp;albumID=".$albumID;
         	$page_list .= "\" title=\"First Page\">&lt;&lt;&nbsp;</a> \n";
      	}
     	if (($curpage-1) > 0) {
       		$page_list .= "<a href=\"".$_SERVER['PHP_SELF']."?page=".($curpage-1);
       		$page_list .= "&amp;albumID=".$albumID;
         	$page_list .= "\" title=\"Previous Page\">&nbsp;&lt;&nbsp;</a> \n";
      	}
     	/* Print the numeric page list; make the current page unlinked and bold */
     	for ($i=1; $i<=$pages; $i++) {
       		if ($i == $curpage) {
         		$page_list .= "<strong>".$i."</strong>\n";
        	}
       		else {
          		$page_list .= "<a href=\"".$_SERVER['PHP_SELF']."?page=".$i;
         		$page_list .= "&amp;albumID=".$albumID;
         		$page_list .= "\" title=\"Page ".$i."\">&nbsp;".$i."&nbsp;</a>\n";
        	}
       		$page_list .= " ";
      	}
     	/* Print the Next and Last page links if necessary */
     	if (($curpage+1) <= $pages) {
       		$page_list .= "<a href=\"".$_SERVER['PHP_SELF']."?page=".($curpage+1);
       		$page_list .= "&amp;albumID=".$albumID;
         	$page_list .= "\" title=\"Next Page\">&nbsp;&gt;&nbsp;</a>\n ";
      	}
     	if (($curpage != $pages) && ($pages != 0)) {
       		$page_list .= "<a href=\"".$_SERVER['PHP_SELF']."?page=".$pages;
       		$page_list .= "&amp;albumID=".$albumID;
         	$page_list .= "\" title=\"Last Page\">&nbsp;&gt;&gt;</a>\n ";
      	}
     	$page_list .= "\n</div>\n";
      	return $page_list;
   	}

  	function nextPrev($curpage, $pages, $albumID) {
     	$next_prev  = "<div class=\"prevnext\">";
     	if (($curpage-1) <= 0) {
       		$next_prev .= "Previous";
      	}
     	else {
       		$next_prev .= "<a href=\"".$_SERVER['PHP_SELF']."?page=".($curpage-1);
       		$page_list .= "&amp;albumID=".$albumID;
         	$page_list .= "\">Previous</a>";
      	}
     	$next_prev .= " | ";
     	if (($curpage+1) > $pages) {
       		$next_prev .= "Next";
      	}
     	else {
       		$next_prev .= "<a href=\"".$_SERVER['PHP_SELF']."?page=".($curpage+1);
       		$page_list .= "&amp;albumID=".$albumID;
         	$page_list .= "\">Next</a>";
      	}
     	$next_prev  .= "</div>";
     	return $next_prev;
    }
}
?>
Return current item: SelectaPix Image Gallery