$int_all_recs_num) { return; } // total number of pages $_num_page_total = ceil($int_all_recs_num/$int_recs_each_page); if ($_num_page_total < 2) { return; } // total number of pager set $_pager_set_num = ceil($_num_page_total/$int_pages_each_set); // check the current page number if (isset($_GET['page']) AND $_GET['page'] > 1) { $_page = (integer)$_GET['page']; } else {$_page = 1;} // check the query string if (isset($_SERVER['QUERY_STRING']) AND !empty($_SERVER['QUERY_STRING'])) { parse_str($_SERVER['QUERY_STRING'], $arr_query_var); // rebuild query str without "page" var $_query_str_page = ''; foreach ($arr_query_var as $varname => $varvalue) { if (is_string($varvalue)) { $varvalue = urlencode($varvalue); if ($varname != 'page') { $_query_str_page .= $varname.'='.$varvalue.'&'; } } else if (is_array($varvalue)) { foreach ($varvalue as $e_val) { if ($varname != 'page') { $_query_str_page .= $varname.'[]='.$e_val.'&'; } } } } // append "page" var at the end $_query_str_page .= 'page='; // create full URL $_current_page = $_SERVER['PHP_SELF'].'?'.$_query_str_page; } else { $_current_page = $_SERVER['PHP_SELF'].'?page='; } // target frame $str_target_frame = 'target="'.$str_target_frame.'"'; // init the return string $_buffer = ''; $_stopper = 1; // count the offset of paging if (($_page > 5) AND ($_page%5 == 1)) { $_lowest = $_page-5; if ($_page == $_lowest) { $_pager_offset = $_lowest; } else { $_pager_offset = $_page; } } else if (($_page > 5) AND (($_page*2)%5 == 0)) { $_lowest = $_page-5; $_pager_offset = $_lowest+1; } else if (($_page > 5) AND ($_page%5 > 1)) { $_rest = $_page%5; $_pager_offset = $_page-($_rest-1); } else { $_pager_offset = 1; } // Previous page link $_first = __('First Page'); $_prev = __('Previous'); if ($_page > 1) { $_buffer .= '  '; $_buffer .= ''.$_first.'  '."\n"; $_buffer .= '  '; $_buffer .= ''.$_prev.'  '."\n"; } for ($p = $_pager_offset; ($p <= $_num_page_total) AND ($_stopper < $int_pages_each_set+1); $p++) { if ($p == $_page) { $_buffer .= '  '.$p.'  '."\n"; } else { $_buffer .= '  '; $_buffer .= ''.$p.'  '."\n"; } $_stopper++; } // Next page link $_next = __('Next'); if (($_pager_offset != $_num_page_total-4) AND ($_page != $_num_page_total)) { $_buffer .= '  '; $_buffer .= ''.$_next.'  '."\n"; } // Last page link $_last = __('Last Page'); if ($_page < $_num_page_total) { $_buffer .= '  '; $_buffer .= ''.$_last.'  '."\n"; } $_buffer .= ''; return $_buffer; } }