topical media & game development
professional-search-14-seophp-include-simple-pager.inc.php / php
<?php
// generates pager links
class SimplePager
{
var _limit;
var _page_number_parameter_index;
var _previous_prompt;
var _show_disabled_links;
// constructor
function SimplePager(limit, page_number_parameter_index = 1)
{
rows;
limit;
function_callback;
page_number_parameter_index;
this->_previous_prompt = '<< back';
page_number = 1, &additional_parameters = '')
{
page_number - 1) * row_count = sizeof(total_pages = ceil(this->_limit);
this->_rows, this->_limit);
// will contain the pager links
page_number > 1)
{
page_number - 1;
this->_function_callback,
array_merge(this->_page_number_parameter_index => this->_previous_prompt</a>";
}
else
{
// no "<< back" link if the visitor is on the first page
this->_previous_prompt;
}
// calculate the first and last listed pages
page_number / (this->_max_listed_pages;
if (!start = 1;
total_pages < this->_max_listed_pages - 1) ?
start + i = i <= i++)
{
// display links for all pages except the current one
if (page_number)
{
this->_function_callback,
array_merge(this->_page_number_parameter_index => i</a>";
}
else
{
// no link for the current page
i;
}
}
// display "next >>" link
if (total_pages)
{
page_number + 1;
this->_function_callback,
array_merge(this->_page_number_parameter_index => this->_next_prompt</a>";
}
else
{
// no "next >>" link if the visitor is on the last page
this->_next_prompt;
}
// return the pager text
return implode(' | ',
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.