Location: PHPKode > projects > PHPmyCDMouse > phpmycdmouse_031/pagenav.php
<?
/*
   Copyright (C) 2003  by Uwe Thiel, Germany

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful, but
    WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
    USA.
*/
# Pagenav: displays page navigation

		$pgnumber = $FileOffset/$LinesPerPage;                             # actual pagenumber
                $pgnumbermax = intval($RecordCount->f("FileCount")/$LinesPerPage); # highest pagenumber
				if (($RecordCount->f("FileCount")%$LinesPerPage) == 0) $pgnumbermax--;
?>
<tr class="ListHeader"><?if (!ereg("^CD",$SearchField)) { ?>
                           <td colspan=8>
			   <? } else { ?>
				<td colspan=10>
				<? } ?>
			   <b>Listing files <?=$FileOffset+1?> to <? ##here: Listing files ... to ...
                if (($FileOffset+$LinesPerPage)>$RecordCount->f("FileCount")) {
			echo $RecordCount->f("FileCount");
		} else {
			echo $FileOffset+$LinesPerPage;
		}
?> of <?=$RecordCount->f("FileCount")?> </b><br>
<b>Page [ <a href="<?=$_SERVER["PHP_SELF"]?>?FileOffset=0&<?=$Param?>" class="ListHeaderred">|<</a>



<a href="<?=$_SERVER["PHP_SELF"]?>?FileOffset=<?
		if (($FileOffset - 10*$LinesPerPage)>0) {

			echo intval($FileOffset-10*$LinesPerPage);


		} else {
			echo "0";
		}
?>&<?=$Param?>" class="ListHeaderred" >-10</a>



<a href="<?=$_SERVER["PHP_SELF"]?>?FileOffset=<?
		if (($FileOffset - 5*$LinesPerPage)>0) {

			echo intval($FileOffset-5*$LinesPerPage);


		} else {
			echo "0";
		}
?>&<?=$Param?>" class="ListHeaderred" >-5</a>





<a href="<?=$_SERVER["PHP_SELF"]?>?FileOffset=<?
		if (($FileOffset-$LinesPerPage)>0) {

			echo intval($FileOffset-$LinesPerPage);


		} else {
			echo "0";
		}
?>&<?=$Param?>" class="ListHeaderred">-1</a>
<?             if (($RecordCount->f("FileCount")%$LinesPerPage) == 0) $pagestotal = $RecordCount->f("FileCount")/$LinesPerPage;  else $pagestotal = (intval($RecordCount->f("FileCount")/$LinesPerPage)) +1;
		if ($pgnumbermax < 10) $formax=$pgnumbermax;                       # only print the first 10 Pagelinks
		   else
		     {
		      if (($pgnumbermax-$pgnumber) >= 5) {
		      $formax=$pgnumber+5;
		      if ( $pgnumbermax >= 10 && $pgnumber < 5) $formax=10;
                                                         } else $formax=$pgnumber+($pgnumbermax-$pgnumber);
		     }
                if (($pgnumber-5) > 0) $formin=$pgnumber-5; else $formin=0;
		if (($pgnumbermax - $pgnumber) <= 5 && ($pgnumbermax-10) > 0) $formin=$pgnumbermax-10; #even show 10 Pagelinks on the last 5 Pages (if possible)
		for ($i=$formin; $i<=$formax; $i++) {

			if (($i+1)==($FileOffset/$LinesPerPage+1)) {
			?><FONT color="yellow"><?
				echo " ".($i+1)." ";                                #this is the actual page. Therefore there must be no link.
			?></FONT><?
			} else {
?> <a href="<?=$_SERVER["PHP_SELF"]?>?FileOffset=<?=intval($LinesPerPage*$i)?>&<?=$Param?>" class="ListHeader"><?=$i+1?></a>
<?			}
		}
?>
<a href="<?=$_SERVER["PHP_SELF"]?>?FileOffset=<?
		if (($FileOffset+$LinesPerPage)<(intval($RecordCount->f("FileCount")/$LinesPerPage)*$LinesPerPage)) {
			echo intval($FileOffset+$LinesPerPage);
		} else {
			echo ($i-1)*$LinesPerPage;
		}
?>&<?=$Param?>" class="ListHeaderred">+1</a>

<a href="<?=$_SERVER["PHP_SELF"]?>?FileOffset=<?
		if (($FileOffset+5*$LinesPerPage)<(intval($pagestotal*$LinesPerPage))) {
			echo intval($FileOffset+5*$LinesPerPage);
		} else {
			echo ($i-1)*$LinesPerPage;
		}
?>&<?=$Param?>" class="ListHeaderred">+5</a>

<a href="<?=$_SERVER["PHP_SELF"]?>?FileOffset=<?
		if (($FileOffset+10*$LinesPerPage)<(intval($pagestotal*$LinesPerPage))) {
			echo intval($FileOffset+10*$LinesPerPage);
		} else {
			echo ($i-1)*$LinesPerPage;
		}
?>&<?=$Param?>" class="ListHeaderred">+10</a>

<? $tempnav=intval($RecordCount->f("FileCount")/$LinesPerPage)*$LinesPerPage;
  if (($RecordCount->f("FileCount")%$LinesPerPage)==0) $tempnav=$tempnav-$LinesPerPage;
?>

<a href="<?=$_SERVER["PHP_SELF"]?>?FileOffset=<?=$tempnav?>&<?=$Param?>" class="ListHeaderred">>|</a> ]  <? echo(" of ". $pagestotal . ".");?></td></tr>



Return current item: PHPmyCDMouse