items = $par1; $this->page = $par2; $this->maxItems = 5; } public function getPagination() { $ret = array(); $n = ceil(count($this->items) / $this->maxItems); for ($i = 1; $i <= $n; $i++) { $class = ($i == $this->page) ? 'active' : ''; $ret[] = array( 'class' => $class, 'page' => $i ); } return $ret; } public function getItems() { $ret = array(); $first = ($this->page - 1) * $this->maxItems; for ($i = 0; $i < $this->maxItems; $i++) { if ($first + $i < count($this->items)) $ret[] = $this->items[$first + $i]; } return $ret; } }