Вход Регистрация
Файл: gonki.us/system/incfiles/navigator.php
Строк: 66
<?php

class navigator {
    public 
$all = 0;
    public 
$page;
    public 
$start = 0;
    public 
$end = 0;
    public 
$limit = 'LIMIT 0';
    
//Шаблоны
    //Кнопка Назад
public $buttonBack = '<a href="%spage=%s"><center>&laquo; Предыдущая страница</center></a>';
public 
$buttonBackName = '<a><center><font color="grey">&laquo; Предыдущая страница</font></center></a>';
    
//Кнопка Вперед
public $buttonForward = '<a href="%spage=%s"><center>Следующая страница &raquo;<center></a>';
public 
$buttonForwardName = '<a><center><font color="grey">Следующая страница &raquo;</font></center></a>';
public 
$blocAllNavi = '<div class="page">%1$s</div>';

   
/*$all - Всего записей, $pnumber - сколько выводить на стр, $skript - Путь к странице*/
function __construct($all, $pnumber, $skript = '?')
    {
        
$this->all = $all;
        
$this->skript = $skript == '' ? $_SERVER['SCRIPT_NAME'] . '?' : rtrim($skript);
        
$this->page = isset($_REQUEST['page']) && (int)$_REQUEST['page'] ? (int)$_REQUEST['page'] : 1;
        
$this->num_pages = ceil($all / $pnumber);
        if (isset(
$_GET['last'])) $this->page = $this->num_pages;
        if (
$this->page > $this->num_pages || $this->page < 1) $this->page = 1;
        if (
$all) {
            
$this->start = $this->page * $pnumber - $pnumber;
            
$this->end = ($end = $this->start + $pnumber) > $all ? $all : $end;
            
$this->limit = sprintf('LIMIT %s,%s', $this->start, $pnumber);
        }
        
// Для совместимости со старой версией навигатора
        
$this->pnumber = $pnumber;
    }


function 
bac(){
$back = $this->page > 1 ? sprintf($this->buttonBack, $this->skript, $this->page-1) : sprintf($this->buttonBackName);
        return (
$this->num_pages < 2) ? '' : $back . $this->separator;
}
function 
forward()
    {
$forward = $this->page != $this->num_pages ? sprintf($this->buttonForward, $this->skript, $this->page+1) : sprintf($this->buttonForwardName);
return (
$this->num_pages < 2) ? '' : $this->separator . $forward;
    }

function 
back(){
$back = $this->bac();
return 
sprintf($this->blocAllNavi, $back);
}
function 
next(){
$forward = $this->forward();
return 
sprintf($this->blocAllNavi, $forward);
}

}

?>
Онлайн: 1
Реклама