_rows = $rows; $this->_limit = $limit; $this->_function_callback = $function_callback; $this->_page_number_parameter_index = $page_number_parameter_index; $this->_max_listed_pages = 10; $this->_previous_prompt = '<< back'; $this->_next_prompt = 'next >>'; } // displays the pager links function display($page_number = 1, &$rows, $additional_parameters = '') { $offset = ($page_number - 1) * $this->_limit; $row_count = sizeof($this->_rows); $total_pages = ceil($row_count / $this->_limit); $rows = array_slice($this->_rows, $offset, $this->_limit); // will contain the pager links $links = array(); // display the "<< back" link if ($page_number > 1) { $prev_page = $page_number - 1; $links[] = "$this->_previous_prompt"; } 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[] = "$i"; } else { // no link for the current page $links[] = $i; } } // display "next >>" link if ($page_number < $total_pages) { $next_page = $page_number + 1; $links[] = "$this->_next_prompt"; } else { // no "next >>" link if the visitor is on the last page $links[] = $this->_next_prompt; } // return the pager text return implode(' | ', $links); } } ?>