<?php function decide_list_page_size($pagesize_requested=false) { global $Config; $pagesize=bound_value( $pagesize_requested, $Config->LIST_PAGE_LENGTH_MIN, $Config->LIST_PAGE_LENGTH_MAX, $Config->LIST_PAGE_LENGTH_DEFAULT ); return $pagesize; } function decide_page_range($pageno_requested=false,$pagesize_requested=false) { $pageno=max(1,0+$pageno_requested); $pagesize=decide_list_page_size($pagesize_requested); return array(($pageno-1)*$pagesize,$pagesize,$pageno); } function prepare_paging_dataset($pageno,$pagesize,&$datarows,$removeoverpeek=true,$nonparamkeys=array('cmd','p')) { $dataset=array(); $dataset['pageno']=$pageno; $dataset['pagesize']=$pagesize; $dataset['pageno.next']=$pageno+1; $dataset['pageno.prev']=$pageno-1; $dataset['PREV-PAGE']=$pageno>1?array(0):array(); $dataset['NEXT-PAGE']=sizeof($datarows)>$pagesize?array(0):array(); $dataset['PAGING']=$dataset['PREV-PAGE'] || $dataset['NEXT-PAGE']?array(0):array(); if ($removeoverpeek) while (sizeof($datarows)>$pagesize) array_pop($datarows); $parameters_page_prev=$parameters; $parameters=trim_parameter_variable($_GET); foreach ($nonparamkeys as $v) unset($parameters[$v]); foreach (array_keys($parameters) as $v) if (!$parameters[$v]) unset($parameters[$v]); $parameters_page_prev=$parameters; $parameters_page_next=$parameters; $parameters_page_prev['p']=$dataset['pageno.prev']; $parameters_page_next['p']=$dataset['pageno.next']; $dataset['param_page_prev']=http_build_query($parameters_page_prev); $dataset['param_page_next']=http_build_query($parameters_page_next); return $dataset; } ?>