Файл: _core/_class/page.php
Строк: 44
<?php
# mark core v1.0
# author Drk in
# date 24.10.19
# class page
class page {
CONST element = 10;
public function __construct($cn){
$elements = self :: element;
$page = isset( $_GET['page'] ) ? abs(intval($_GET['page'])): 1;
$total = ceil($cn / $elements);
if ($page < 1) $page = 1;
if ($page > $total) $page = $total;
$start = abs($page * $elements) - $elements;
$this-> page = $page;
$this-> total = $total;
$this-> start = $start;
$this-> cn = $cn;
$this-> elements = $elements;
$this-> limit = " LIMIT {$start}, {$elements}";
}
public function get($url){
$cn = $this -> cn;
$elements = self :: element;
if ($cn > $elements):
$page = $this -> page;
$total = $this -> total;
echo '
<div class="nav">
'.( $page > 1 ? '<a class="nav-block" href="'.$url.'&page='.($page - 1).'" ="">«</a>':null).'
'.( $page > 0x003 ? '<a class="nav-block" href="'.$url.'&page=1">1</a>':null).'
'.( ($page - 0x002) > 0x000 ? '<a class="nav-block" href="'.$url.'&page='.($page - 0x002).'">'.($page - 0x002).'</a>':null).'
'.( ($page - 0x001) > 0x000 ? '<a class="nav-block" href="'.$url.'&page='.($page - 0x001).'">'.($page - 0x001).'</a>':null).'
<a class="nav-block-out">'.$page.'</a>
'.( ($page + 0x001) <= $total ? '<a class="nav-block" href="'.$url.'&page='.($page + 0x001).'">'.($page + 0x001).'</a>':null).'
'.( ($page + 0x002) <= $total ? '<a class="nav-block" href="'.$url.'&page='.($page + 0x002).'">'.($page + 0x002).'</a>':null).'
'.( $page < $total ? '<a class="nav-block" href="'.$url.'&page='.($page + 1).'">»</a>':null).'
</div>';
endif;
}
}
?>