total = (int) $total; $this->limitstart = (int) max( $limitstart, 0 ); $this->limit = (int) max( $limit, 1 ); if ($this->limit > $this->total) { $this->limitstart = 0; } if (($this->limit-1)*$this->limitstart > $this->total) { $this->limitstart -= $this->limitstart % $this->limit; } } /** * @return string The html for the limit # input box */ function getLimitBox () { $limits = array(); for ($i=5; $i <= 30; $i+=5) { $limits[] = mosHTML::makeOption( "$i" ); } $limits[] = mosHTML::makeOption( "50" ); // build the html select list $html = mosHTML::selectList( $limits, 'limit', 'class="inputbox" size="1" onchange="document.adminForm.submit();"', 'value', 'text', $this->limit ); $html .= "\nlimitstart\" />"; return $html; } /** * Writes the html limit # input box */ function writeLimitBox () { echo mosPageNav::getLimitBox(); } function writePagesCounter() { echo $this->getPagesCounter(); } /** * @return string The html for the pages counter, eg, Results 1-10 of x */ function getPagesCounter() { $html = ''; $from_result = $this->limitstart+1; if ($this->limitstart + $this->limit < $this->total) { $to_result = $this->limitstart + $this->limit; } else { $to_result = $this->total; } if ($this->total > 0) { $html .= "\nResults " . $from_result . " - " . $to_result . " of " . $this->total; } else { $html .= "\nNo records found."; } return $html; } /** * Writes the html for the pages counter, eg, Results 1-10 of x */ function writePagesLinks() { echo $this->getPagesLinks(); } /** * @return string The html links for pages, eg, previous, next, 1 2 3 ... x */ function getPagesLinks() { $html = ''; $displayed_pages = 10; $total_pages = ceil( $this->total / $this->limit ); $this_page = ceil( ($this->limitstart+1) / $this->limit ); $start_loop = (floor(($this_page-1)/$displayed_pages))*$displayed_pages+1; if ($start_loop + $displayed_pages - 1 < $total_pages) { $stop_loop = $start_loop + $displayed_pages - 1; } else { $stop_loop = $total_pages; } if ($this_page > 1) { $page = ($this_page - 2) * $this->limit; $html .= "\n<< Start"; $html .= "\n< Previous"; } else { $html .= "\n<< Start"; $html .= "\n< Previous"; } for ($i=$start_loop; $i <= $stop_loop; $i++) { $page = ($i - 1) * $this->limit; if ($i == $this_page) { $html .= "\n $i "; } else { $html .= "\n$i"; } } if ($this_page < $total_pages) { $page = $this_page * $this->limit; $end_page = ($total_pages-1) * $this->limit; $html .= "\n Next >"; $html .= "\n End >>"; } else { $html .= "\nNext >"; $html .= "\nEnd >>"; } return $html; } function getListFooter() { $html = '
| '; $html .= $this->getPagesLinks(); $html .= ' | ||
|---|---|---|
| Display # | '; $html .= '' .$this->getLimitBox() . ' | '; $html .= '' . $this->getPagesCounter() . ' | '; $html .= '