Размер файла: 2.01Kb
<?
/*
* Animated Collapsible DIV- © Dynamic Drive DHTML code library (www.pokazuha.tv)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.pokazuha.tv/ for this script and 100s more
* Last Update : Tuesday, November 13 2005
*/
class Pager
{
var $m_curr_page;
var $m_total_pages;
var $m_per_page;
var $m_ad_curr_page;
var $search_type;
var $keywords;
function Pager($total,$per_page,$search_type,$keywords)
{
$this->m_total_pages = $total;
$this->m_per_page = $per_page;
$this->m_curr_page = isset($_GET['pos']) ? $_GET['pos'] : 1;
$this->m_ad_curr_page = isset($_GET['adsp']) ? $_GET['adsp'] : 1;
$this->search_type = $search_type;
$this->keywords = htmlspecialchars($keywords);
}
function get_curr_search_page()
{
return $this->m_curr_page;
}
function get_curr_ads_page()
{
return $this->m_ad_curr_page;
}
function get_pager()
{
$num_pages = ceil($this->m_total_pages / $this->m_per_page);
$start_count = (ceil($this->m_curr_page / 10)) * 10 - 10 + 1;
$offset = (($num_pages - $start_count) > 10) ? 10 : ($num_pages - $start_count);
$add_string = "";
if (isset($_GET['sort']))
{
$add_string .= "&sort={$_GET['sort']}";
}
$html = "";
if ($start_count > 1)
$html .= " <a href=\"?type={$this->search_type}&search={$this->keywords}&pos=".($start_count - 1)."$add_string\">« Предыдущая</a> ";
for($i = $start_count; $i < $start_count + $offset; $i++)
{
if ($i == $this->m_curr_page)
$html .= " <font color=\"#FF8040\">$i</font> ";
else
{
$html .= " <a href=\"?type={$this->search_type}&search={$this->keywords}&pos=$i{$add_string}\"><b>$i</b></a> ";
}
}
if ($offset >= 10)
$html .= " <a href=\"?type={$this->search_type}&search={$this->keywords}&pos=$i{$add_string}\">Следующая »</a> ";
return $html;
}
}
?>