View file ICQ_distribution/Navigator.class.php

File size: 1.29Kb
<?php
/*
=>Автор: Демидов Анатолий aka lugaro
=>ICQ: 2000882
=>E-mail: [email protected]
=>Сайт: http://wphp.ru
=>Категория скрипта: ПЛАТНЫЙ
---------------------------------
Внимание! Распространять скрип ЗАПРЕЩЕННО! А тем более продавать!
Уважайте авторское право!
*/
class Navigator
{
function __construct($all,$pnumber,$query=''){
$this->all=$all;
$this->pnumber=$pnumber;
$this->query=$query;
$this->page=isset($_GET['page']) ? (int)$_GET['page'] : 1;
}
function start()
{
$this->num_pages=ceil($this->all/$this->pnumber);
if (isset($_GET['last']))
$this->page=$this->num_pages;
$this->start=$this->page*$this->pnumber-$this->pnumber;
if ($this->page > $this->num_pages || $this->page < 1)
{
$this->page=1;
$this->start=0;
}
return $this->start;
}
function navi()
{		
if ($this->num_pages<2)
return '';
$buff='<br>';
for($pr = '', $i =1; $i <= $this->num_pages; $i++)
{
$buff.= 
$pr=(($i == 1 || $i == $this->num_pages || abs($i-$this->page) < 5) ? ($i == $this->page ? " [$i] " : ' <a href="'.$_SERVER['SCRIPT_NAME'].'?page='.$i.'&amp;'.$this->query.'">'.$i.'</a> ') : (($pr == ' ... ' || $pr == '')? '' : ' ... '));
}
return $buff.'';
}
}
?>