| Conditions | 5 |
| Paths | 12 |
| Total Lines | 34 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 6.0718 |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | 4 | public function createPaginator($data) |
|
| 19 | { |
||
| 20 | // Read perPage from session, or GET |
||
| 21 | 4 | $perPage = 25; |
|
| 22 | 4 | $session = new Zend_Session_Namespace(); |
|
| 23 | 4 | if (isset($session->perPage)) { |
|
| 24 | $perPage = $session->perPage; |
||
| 25 | } |
||
| 26 | |||
| 27 | 4 | $userPerPage = $this->getRequest()->getParam('perPage'); |
|
| 28 | 4 | if ($userPerPage) { |
|
| 29 | $perPage = $userPerPage; |
||
| 30 | $session->perPage = $perPage; |
||
| 31 | } |
||
| 32 | |||
| 33 | // If we export to csv or rss, override perPage parameter |
||
| 34 | 4 | $currentContext = $this->getActionController()->getHelper('contextSwitch')->getCurrentContext(); |
|
|
|
|||
| 35 | switch ($currentContext) { |
||
| 36 | 4 | case 'csv': |
|
| 37 | $perPage = -1; |
||
| 38 | |||
| 39 | break; |
||
| 40 | 4 | case 'rss': |
|
| 41 | $perPage = 200; |
||
| 42 | |||
| 43 | break; |
||
| 44 | } |
||
| 45 | |||
| 46 | // Defines the paginator |
||
| 47 | 4 | $paginator = Zend_Paginator::factory($data); |
|
| 48 | 4 | $paginator->setCurrentPageNumber($this->getRequest()->getParam('page')); |
|
| 49 | 4 | $paginator->setItemCountPerPage($perPage); |
|
| 50 | |||
| 51 | 4 | return $paginator; |
|
| 52 | } |
||
| 66 |