Файл: system/classes/Pages.php
Строк: 25
<?php
class Pages
{
public function __construct($var, $limit)
{
global $am_pages, $page, $start;
$am_pages = $this->am_pages($var, $limit);
$page = $this->page($am_pages);
$start = $limit * $page - $limit;
}
public function page($am_pages = 1)
{
$page = 1;
if (isset($_GET['page']))
{
if ($_GET['page'] == 'end')
$page = intval($am_pages);
else
if (is_numeric($_GET['page']))
$page = intval($_GET['page']);
}
if ($page < 1)
$page = 1;
if ($page > $am_pages)
$page = $am_pages;
return $page;
}
public function am_pages($am_posts = 0, $am_p_pages = 10)
{
if ($am_posts != 0)
{
$v_pages = ceil($am_posts / $am_p_pages);
return $v_pages;
}
else
return 1;
}
public function pages($link = '?', $am_pages = 1, $page = 1)
{
global $smarty;
$smarty->assign([
'link' => $link,
'am_pages' => $am_pages,
'page' => $page
]);
$smarty->display('pages.tpl');
}
public function view($link = '?')
{
global $am_pages, $page;
if ($am_pages > 1)
$this->pages($link, $am_pages, $page);
}
}