page = intval($bugsys->in["$page"]); $this->perpage = intval($bugsys->in["$perpage"]); $this->pagelinks = intval($bugsys->options['pagelinks']); if ($this->page <= 0) { $this->page = 1; } if ($this->perpage <= 0) { $this->perpage = $bugsys->options['defaultpp']; } if ($this->perpage > $bugsys->options['maxpp']) { $this->perpage = $bugsys->options['maxpp']; } } /** * Takes the variables and splits up the pages * * @access protected */ function split_pages() { $this->pagecount = ceil($this->total / $this->perpage); } /** * Returns the lower limit of the pages * * @access public * * @param integer Page number * * @return integer Lower result limit */ function fetch_limit($page = null) { if ($page === null) { $page = $this->page; } if ($page < 1) { $page = 1; } else if ($page > $this->pagecount) { $page = $this->pagecount - 1; } $limit = $page * $this->perpage; if ($limit < 0) { return 0; } else if ($limit > $this->total) { return $this->total; } else { return $limit; } } /** * Constructs the page navigator * * @access public * * @return string Generated HTML page navigator */ function construct_page_nav() { // first page number in page nav $startpage = $this->page - $this->pagelinks; if ($startpage < 1) { $startpage = 1; } // last page number in page nav $endpage = $this->page + $this->pagelinks; if ($endpage > $this->pagecount) { $endpage = $this->pagecount; } // prev page in page nav $prevpage = $this->page - 1; if ($prevpage < 1) { $prevpage = 1; } // next page in page nav $nextpage = $this->page + 1; if ($nextpage > $this->pagecount) { $nextpage = $this->pagecount; } // show the prev page $doprev = true; if ($this->page == $startpage) { $doprev = false; } // show the next page $donext = true; if ($this->page == $endpage) { $donext = false; } // show the first page $dofirst = false; if ($startpage > 1) { $dofirst = true; } // show the last page $dolast = false; if ($endpage < $this->pagecount) { $dolast = true; } // add the special links if ($dofirst) { $pages[] = 'first'; } if ($doprev) { $pages[] = 'prev'; } // construct the page bits for ($i = $startpage; $i <= $endpage; $i++) { $pages[] = ($i == $this->page ? "$i" : $i); } // last special links if ($donext) { $pages[] = 'next'; } if ($dolast) { $pages[] = 'last'; } return $pages; } } /*=====================================================================*\ || ################################################################### || # $HeadURL$ || # $Id$ || ################################################################### \*=====================================================================*/ ?>