|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Paginator view helper. |
|
5
|
|
|
* |
|
6
|
|
|
* Long description for file (if any)... |
|
7
|
|
|
* |
|
8
|
|
|
* @author Leandro Silva <[email protected]> |
|
9
|
|
|
* |
|
10
|
|
|
* @category LosUi |
|
11
|
|
|
* |
|
12
|
|
|
* @license https://github.com/Lansoweb/LosUi/blob/master/LICENSE MIT License |
|
13
|
|
|
* |
|
14
|
|
|
* @link http://github.com/LansoWeb/LosUi |
|
15
|
|
|
* @link http://getbootstrap.com/components/#pagination |
|
16
|
|
|
*/ |
|
17
|
|
|
namespace LosUi\View\Helper; |
|
18
|
|
|
|
|
19
|
|
|
use Zend\View\Helper\PaginationControl as ZfPaginationControl; |
|
20
|
|
|
use Zend\Paginator; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Paginator view helper. |
|
24
|
|
|
* |
|
25
|
|
|
* Long description for file (if any)... |
|
26
|
|
|
* |
|
27
|
|
|
* @author Leandro Silva <[email protected]> |
|
28
|
|
|
* |
|
29
|
|
|
* @category LosUi |
|
30
|
|
|
* |
|
31
|
|
|
* @license https://github.com/Lansoweb/LosUi/blob/master/LICENSE MIT License |
|
32
|
|
|
* |
|
33
|
|
|
* @link http://github.com/LansoWeb/LosUi |
|
34
|
|
|
* @link http://getbootstrap.com/components/#pagination |
|
35
|
|
|
*/ |
|
36
|
|
|
class PaginationControl extends ZfPaginationControl |
|
37
|
|
|
{ |
|
38
|
|
|
protected static $defaultViewPartial = 'paginator/control.phtml'; |
|
39
|
|
|
protected static $nextLabel = 'Next →'; |
|
40
|
|
|
protected static $previousLabel = '← Previous'; |
|
41
|
|
|
|
|
42
|
|
|
public function __invoke( |
|
43
|
|
|
Paginator\Paginator $paginator = null, |
|
44
|
|
|
$scrollingStyle = null, |
|
45
|
|
|
$partial = null, |
|
46
|
|
|
$params = null |
|
47
|
|
|
) { |
|
48
|
|
|
if (is_string($params)) { |
|
49
|
|
|
$params = (array) $params; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
if (isset($params['size'])) { |
|
53
|
|
|
if ($params['size'] != 'sm' && $params['size'] != 'lg') { |
|
54
|
|
|
throw new \RuntimeException('Size parameter must be either "sm" or "lg"'); |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
if ($partial === null && isset($params['type'])) { |
|
58
|
|
|
if ($params['type'] == 'pager') { |
|
59
|
|
|
$partial = 'paginator/pager.phtml'; |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
if (! isset($params['aligned']) || ! is_bool($params['aligned'])) { |
|
63
|
|
|
$params['aligned'] = true; |
|
64
|
|
|
} |
|
65
|
|
|
if (! isset($params['nextLabel'])) { |
|
66
|
|
|
$params['nextLabel'] = self::$nextLabel; |
|
67
|
|
|
} |
|
68
|
|
|
if (! isset($params['previousLabel'])) { |
|
69
|
|
|
$params['previousLabel'] = self::$previousLabel; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
return parent::__invoke($paginator, $scrollingStyle, $partial, $params); |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
|