diff --git a/classes/Pager.class.php b/classes/Pager.class.php new file mode 100644 index 0000000..0ea6bdb --- /dev/null +++ b/classes/Pager.class.php @@ -0,0 +1,68 @@ +count = $count; + $this->limit = $records_limit; + + $this->max_page_num = ceil($this->count/$this->limit); + $this->current_page = ((int)$current_page <= $this->max_page_num && (int)$current_page > 0) ? (int)$current_page : 1; + + $this->start_offset = $this->limit * ($this->current_page - 1); + $this->num_rows = ($this->limit + $this->start_offset) <= $this->count ? ($this->limit + $this->start_offset) : $this->count; + } + + public function startOffset() + { + return $this->start_offset; + } + + public function limit() + { + return $this->limit; + } + + public function setNumRows($num_rows) + { + $this->num_rows = $num_rows; + } + + function init() + { + $this->template = "Pager"; + } + + function prepare() + { + $this->templater->assign('page', $this->current_page); + $this->templater->assign('page_max', $this->max_page_num); + $this->templater->assign('limit', $this->limit); + $this->templater->assign('count', $this->count); + } +} +?> \ No newline at end of file