]>
src.bluestatic.org Git - bugdar.git/blob - includes/class_pagination.php
2 /*=====================================================================*\
3 || ################################################################### ||
4 || # BugStrike [#]version[#]
5 || # --------------------------------------------------------------- # ||
6 || # Copyright ©2002-[#]year[#] by Iris Studios, Inc. All Rights Reserved. # ||
7 || # This file may not be reproduced in any way without permission. # ||
8 || # --------------------------------------------------------------- # ||
9 || # User License Agreement at http://www.iris-studios.com/license/ # ||
10 || ################################################################### ||
11 \*=====================================================================*/
14 * Class that is responsible for paginating data. Takes passed
15 * parameters and creates pagination links.
32 * Number of page links
38 * Total number of results
44 * Total number of pages
50 * Constructor: sanitize incoming variables
52 * @param string Name of page number variable
53 * @param string Name of per-page variable
55 function Pagination($page, $perpage)
59 $this->page
= intval($bugsys->in
["$page"]);
60 $this->perpage = intval($bugsys->in["$perpage"]);
61 $this->pagelinks
= intval($bugsys->options
['pagelinks']);
68 if ($this->perpage
<= 0)
70 $this->perpage
= $bugsys->options
['defaultpp'];
72 if ($this->perpage
> $bugsys->options
['maxpp'])
74 $this->perpage
= $bugsys->options
['maxpp'];
79 * Takes the variables and splits up the pages
83 function split_pages()
85 $this->pagecount
= ceil($this->total
/ $this->perpage
);
89 * Returns the lower limit of the pages
93 * @param integer Page number
95 * @return integer Lower result limit
97 function fetch_limit($page = null)
108 else if ($page > $this->pagecount
)
110 $page = $this->pagecount
- 1;
113 $limit = $page * $this->perpage
;
119 else if ($limit > $this->total
)
130 * Constructs the page navigator
134 * @return string Generated HTML page navigator
136 function construct_page_nav()
138 // first page number in page nav
139 $startpage = $this->page
- $this->pagelinks
;
145 // last page number in page nav
146 $endpage = $this->page +
$this->pagelinks
;
147 if ($endpage > $this->pagecount
)
149 $endpage = $this->pagecount
;
152 // prev page in page nav
153 $prevpage = $this->page
- 1;
159 // next page in page nav
160 $nextpage = $this->page +
1;
161 if ($nextpage > $this->pagecount
)
163 $nextpage = $this->pagecount
;
166 // show the prev page
168 if ($this->page
== $startpage)
173 // show the next page
175 if ($this->page
== $endpage)
180 // show the first page
187 // show the last page
189 if ($endpage < $this->pagecount
)
194 // add the special links
204 // construct the page bits
205 for ($i = $startpage; $i <= $endpage; $i++
)
207 $pages[] = ($i == $this->page
? "<strong>$i</strong>" : $i);
210 // last special links
224 /*=====================================================================*\
225 || ###################################################################
228 || ###################################################################
229 \*=====================================================================*/