Вход Регистрация
Файл: impwar.tk/nav_class.php
Строк: 21
<?php
class Navigator{
public 
$pages; //Количество страниц
public $p; //Текущая страница
public $c; //Всего объектов
public $start;//параметр для LIMIT
public function __construct($c, $e){
$this->pages = ceil($c/$e);
$this->c= $c;
$p = 1;
if(isset(
$_REQUEST['p'])){
if(
$_REQUEST['p'] == 'last')
$p=$this->pages;
elseif(
$_REQUEST['p'] <= $this->pages){
$p=(int)$_REQUEST['p'];
if(
$p < 1)
$p = 1;
}
}
$this->start = ($p - 1) * $e;
$this->p = $p;
}
public function 
print_nav($q){
if(
$this->pages > 1){
echo
'<p class="post">';
if(
$this->p > 1)echo'<a href="'.$_SERVER['PHP_SELF'].'?p='.($this->p-1).$q.'"accesskey="7">&laquo;-Назад</a>';
if(
$this->p < $this->pages && $this->p>1)
echo
' | ';
if(
$this->p < $this->pages)echo'<a href="'.$_SERVER['PHP_SELF'].'?p='.($this->p + 1).$q.'"accesskey="9">Дальше-&raquo;</a>';
}
echo
'<br/>
Стр: '
;
$prev=$this->p - 2;
$next=$this->p + 3;
if(
$prev < $this->c && $prev > 1)
echo
'<a href="'.$_SERVER['PHP_SELF'].'?p=1'.$q.'">1</a> ... ';
for(
$i = $prev; $i < $next; $i++)
{
if(
$i <= $this->pages && $i >= 1){
if(
$this->p == $i)
echo
'<strong>['.$i.']</strong>';
else
echo
' <a href="'.$_SERVER['PHP_SELF'].'?p='.$i.$q.'">'.$i.'</a> ';
}
}
if(
$next <= $this->pages)echo '... <a href="'.$_SERVER['PHP_SELF'].'?p='.$this->pages.$q.'">'.$this->pages.'</a>';
echo
'<form nctype="multipart/form-data" action="'.$_SERVER['PHP_SELF'].'?'.$q.'"   method="post"><p> <input  type="text" style="width:15%; height:25px;" class="input" name="p" size="4" maxlength="4" value="" /><input type="submit" style="width:10%; height:25px;" value="&raquo;"/></form>';
}
}
?>
Онлайн: 0
Реклама