JavaScript Editor Ajax software     Free javascripts 



Main Page

// will contain the pager links
$links = array();
// display the “<< back” link
if ($page_number > 1)
{
$prev_page = $page_number - 1;
$links[] =
“<a href=’“ .
call_user_func_array($this->_function_callback,
array_merge($additional_parameters,
array($this->_page_number_parameter_index => $prev_page))) .
“‘>$this->_previous_prompt</a>”;
}
else
{
// no “<< back” link if the visitor is on the first page
$links[] = $this->_previous_prompt;
}
// calculate the first and last listed pages
$start = floor($page_number / ($this->_max_listed_pages))
* $this->_max_listed_pages;
if (!$start) $start = 1;
$end = ($total_pages < $start + $this->_max_listed_pages - 1) ?
$total_pages : $start + $this->_max_listed_pages - 1;
// display pager links
for ($i = $start; $i <= $end; $i++)
{
// display links for all pages except the current one
if ($i != $page_number)
{
$links[] =
“<a href=’“ .
call_user_func_array($this->_function_callback,
array_merge($additional_parameters,
array($this->_page_number_parameter_index => $i))) .
“‘>$i</a>”;
}
else
{
// no link for the current page
$links[] = $i;
}
}
// display “next >>” link
if ($page_number < $total_pages)
{
$next_page = $page_number + 1;
$links[] =
“<a href=’“ .
call_user_func_array($this->_function_callback,
array_merge($additional_parameters,
273
Chapter 14: Case Study: Building an E-Commerce Store
c14.qxd:c14 10:46 273


JavaScript Editor Ajax software     Free javascripts