1 | <?php |
||
16 | class Configuration |
||
17 | { |
||
18 | /** |
||
19 | * Length of the list of pagination defaults |
||
20 | * |
||
21 | * @var int |
||
22 | */ |
||
23 | const DEFAULT_LIST_LENGTH = 5; |
||
24 | |||
25 | /** |
||
26 | * @var int |
||
27 | */ |
||
28 | const DEFAULT_PAGE_LINK = '%s'; |
||
29 | |||
30 | /** |
||
31 | * @var int |
||
32 | */ |
||
33 | protected $total_pages = 0; |
||
34 | |||
35 | /** |
||
36 | * @var int |
||
37 | */ |
||
38 | protected $current_page = 1; |
||
39 | |||
40 | /** |
||
41 | * @var View |
||
42 | */ |
||
43 | protected $view; |
||
44 | |||
45 | /** |
||
46 | * The number of pages displayed in the navigation |
||
47 | * |
||
48 | * @var int |
||
49 | */ |
||
50 | protected $max_navigate = self::DEFAULT_LIST_LENGTH; |
||
51 | |||
52 | /** |
||
53 | * @var string|callback |
||
54 | */ |
||
55 | protected $page_link = self::DEFAULT_PAGE_LINK; |
||
56 | |||
57 | /** |
||
58 | * @var string |
||
59 | */ |
||
60 | protected $first_page_link = ''; |
||
61 | |||
62 | /** |
||
63 | * @param int $total_pages |
||
64 | * @param int $current_page |
||
65 | */ |
||
66 | 41 | public function __construct($total_pages = 0, $current_page = 1) |
|
67 | { |
||
68 | 41 | $this->setCurrentPage($current_page); |
|
69 | 41 | $this->setTotalPages($total_pages); |
|
70 | 41 | } |
|
71 | |||
72 | /** |
||
73 | * @param int $total_pages |
||
74 | * @param int $current_page |
||
75 | * |
||
76 | * @return Configuration |
||
77 | */ |
||
78 | 2 | public static function create($total_pages = 0, $current_page = 1) |
|
82 | |||
83 | /** |
||
84 | * @return int |
||
85 | */ |
||
86 | 9 | public function getTotalPages() |
|
90 | |||
91 | /** |
||
92 | * @param int $total_pages |
||
93 | * |
||
94 | * @return Configuration |
||
95 | */ |
||
96 | 15 | public function setTotalPages($total_pages) |
|
101 | |||
102 | /** |
||
103 | * @return int |
||
104 | */ |
||
105 | 9 | public function getCurrentPage() |
|
109 | |||
110 | /** |
||
111 | * @param int $current_page |
||
112 | * |
||
113 | * @return Configuration |
||
114 | */ |
||
115 | 15 | public function setCurrentPage($current_page) |
|
120 | |||
121 | /** |
||
122 | * @return int |
||
123 | */ |
||
124 | 5 | public function getMaxNavigate() |
|
128 | |||
129 | /** |
||
130 | * @param int $max_navigate |
||
131 | * |
||
132 | * @return Configuration |
||
133 | */ |
||
134 | 5 | public function setMaxNavigate($max_navigate) |
|
139 | |||
140 | /** |
||
141 | * @return string|callback |
||
142 | */ |
||
143 | 2 | public function getPageLink() |
|
147 | |||
148 | /** |
||
149 | * Set page link |
||
150 | * |
||
151 | * Basic reference, for example `page_%s.html` where %s page number, or |
||
152 | * callback function which takes one parameter - the number of the page. |
||
153 | * |
||
154 | * <code> |
||
155 | * function ($number) { |
||
156 | * return 'page_'.$number.'.html'; |
||
157 | * } |
||
158 | * </code> |
||
159 | * |
||
160 | * @param string|callback $page_link |
||
161 | * |
||
162 | * @return Configuration |
||
163 | */ |
||
164 | 3 | public function setPageLink($page_link) |
|
169 | |||
170 | /** |
||
171 | * @return string |
||
172 | */ |
||
173 | 1 | public function getFirstPageLink() |
|
177 | |||
178 | /** |
||
179 | * @param string $first_page_link |
||
180 | * |
||
181 | * @return Configuration |
||
182 | */ |
||
183 | 1 | public function setFirstPageLink($first_page_link) |
|
188 | |||
189 | /** |
||
190 | * @return View |
||
191 | */ |
||
192 | 1 | public function getView() |
|
199 | } |
||
200 |