1: <?php
 2: 
 3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 
22: 
23: namespace picon;
24: 
25: 26: 27: 28: 29: 30: 
31: class PaginatingGridView extends GridView implements Pageable
32: {
33:     private $rowsPerPage;
34:     private $currentPage = 1;
35:     
36:     public function __construct($id, $columnId, $columns, $rowsPerPage, $callback = null, $model = null)
37:     {
38:         parent::__construct($id, $columnId, $columns, $callback, $model);
39:         Args::isNumeric($rowsPerPage, 'rowsPerPage');
40:         $this->rowsPerPage = $rowsPerPage;
41:     }
42:     
43:     public function setRowsPerPage($rowsPerPage)
44:     {
45:         Args::isNumeric($rows, 'rowsPerPage');
46:         $this->rowsPerPage = $rowsPerPage;
47:     }
48:     
49:     public function getRowsPerPage()
50:     {
51:         return $this->rowsPerPage;
52:     }
53:     
54:     public function getPageCount()
55:     {
56:         return ceil(count($this->getModelObject())/$this->rowsPerPage);
57:     }
58:     
59:     public function getCurrentPage()
60:     {
61:         return $this->currentPage;
62:     }
63:     
64:     public function setCurrentPage($page)
65:     {
66:         Args::isNumeric($page, 'page');
67:         $this->currentPage = $page;
68:     }
69:     
70:     protected function getRecords()
71:     {
72:         return array_slice($this->getModelObject(), ($this->currentPage-1)*$this->rowsPerPage, $this->rowsPerPage);
73:     }
74:     
75:     public function isStateless()
76:     {
77:         return false;
78:     }
79: }
80: 
81: ?>
82: