From f20959e366402ca4a5b8f2e78b5e791bbfb55fad Mon Sep 17 00:00:00 2001 From: ejikharev Date: Wed, 4 Feb 2009 15:19:02 +0000 Subject: [PATCH] add pager class git-svn-id: svn+ssh://code.netmonsters.ru/svn/majestic/trunk@59 4cb57b5f-5bbd-dd11-951b-001d605cbbc5 --- classes/Pager.class.php | 68 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 classes/Pager.class.php 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