Файл: core/class/nav.php
Строк: 38
<?php
/**
* @package Prime Social
* @link http://primesocial.ru
* @copyright Copyright (C) 2016 Prime Social
* @author BoB | http://primesocial.ru/about
*/
class Navigator
{
function __construct($all,$pnumber,$query=''){
$this->all=$all;
$this->pnumber=$pnumber;
$this->query=$query;
$this->p=isset($_GET['p']) ? (int)$_GET['p'] : 1;
if(isset($_POST['p'])){
$this->p=(int)$_POST['p'];}
}
function start()
{
$this->num_ps=ceil($this->all/$this->pnumber);
if (isset($_GET['last']))
$this->p=$this->num_ps;
$this->start=$this->p*$this->pnumber-$this->pnumber;
if ($this->p > $this->num_ps || $this->p < 1)
{
$this->p=1;
$this->start=0;
}
return $this->start;
}
function navi()
{
if ($this->num_ps<2)
return '';
$buff=DIV_BLOCK;
if($this->p>1){
$n=$this->p;
$n--;
$buff.= '«<a href="'.$_SERVER['SCRIPT_NAME'].'?p='.$n.'&'.$this->query.'">Orqaga</a>';}
if(($this->p>1) && ($this->p != $this->num_ps)){$buff.= ' | ';}
if($this->p != $this->num_ps){
$p=$this->p;
$p++;
$buff.= ' <a href="'.$_SERVER['SCRIPT_NAME'].'?p='.$p.'&'.$this->query.'">Oldinga</a>»';}
$buff.='<br/>';
for($pr = '', $i =1; $i <= $this->num_ps; $i++){
$buff.=
$pr=(($i == 1 || $i == $this->num_ps || abs($i-$this->p) < 5) ? ($i == $this->p ? " [$i] " : ' <a href="'.$_SERVER['SCRIPT_NAME'].'?p='.$i.'&'.$this->query.'">'.$i.'</a> ') : (($pr == ' .. ' || $pr == '')? '' : ' .. '));}
if($this->num_ps>9){
$buff.= '</div>'.DIV_BLOCK.'<form action="'.$_SERVER['SCRIPT_NAME'].'?'.$this->query.'" method="POST">
<input type="text" size="3" name="p" value="'.$this->p.'">
<INPUT type="submit" name="" value=">>"><br></FORM>';}
$buff.='</div>';
return $buff.'';
}
}
?>