1 | <?php |
||
18 | class Configuration |
||
19 | { |
||
20 | /** |
||
21 | * Length of the list of pagination defaults |
||
22 | * |
||
23 | * @var int |
||
24 | */ |
||
25 | const DEFAULT_LIST_LENGTH = 5; |
||
26 | |||
27 | /** |
||
28 | * @var int |
||
29 | */ |
||
30 | const DEFAULT_PAGE_LINK = '%s'; |
||
31 | |||
32 | /** |
||
33 | * @var int |
||
34 | */ |
||
35 | protected $total_pages = 0; |
||
36 | |||
37 | /** |
||
38 | * @var int |
||
39 | */ |
||
40 | protected $current_page = 1; |
||
41 | |||
42 | /** |
||
43 | * @var View |
||
44 | */ |
||
45 | protected $view; |
||
46 | |||
47 | /** |
||
48 | * The number of pages displayed in the navigation |
||
49 | * |
||
50 | * @var int |
||
51 | */ |
||
52 | protected $max_navigate = self::DEFAULT_LIST_LENGTH; |
||
53 | |||
54 | /** |
||
55 | * @var string|callback |
||
56 | */ |
||
57 | protected $page_link = self::DEFAULT_PAGE_LINK; |
||
58 | |||
59 | /** |
||
60 | * @var string |
||
61 | */ |
||
62 | protected $first_page_link = ''; |
||
63 | |||
64 | /** |
||
65 | * @param int $total_pages |
||
66 | * @param int $current_page |
||
67 | */ |
||
68 | 39 | public function __construct($total_pages = 0, $current_page = 1) |
|
73 | |||
74 | /** |
||
75 | * @param int $total_pages |
||
76 | * @param int $current_page |
||
77 | * |
||
78 | * @return Configuration |
||
79 | */ |
||
80 | 2 | public static function create($total_pages = 0, $current_page = 1) |
|
84 | |||
85 | /** |
||
86 | * @return int |
||
87 | */ |
||
88 | 7 | public function getTotalPages() |
|
92 | |||
93 | /** |
||
94 | * @param int $total_pages |
||
95 | * |
||
96 | * @return Configuration |
||
97 | */ |
||
98 | 1 | public function setTotalPages($total_pages) |
|
103 | |||
104 | /** |
||
105 | * @return int |
||
106 | */ |
||
107 | 7 | public function getCurrentPage() |
|
111 | |||
112 | /** |
||
113 | * @param int $current_page |
||
114 | * |
||
115 | * @return Configuration |
||
116 | */ |
||
117 | 1 | public function setCurrentPage($current_page) |
|
122 | |||
123 | /** |
||
124 | * @return int |
||
125 | */ |
||
126 | 3 | public function getMaxNavigate() |
|
130 | |||
131 | /** |
||
132 | * @param int $max_navigate |
||
133 | * |
||
134 | * @return Configuration |
||
135 | */ |
||
136 | 3 | public function setMaxNavigate($max_navigate) |
|
141 | |||
142 | /** |
||
143 | * @return string|callback |
||
144 | */ |
||
145 | 2 | public function getPageLink() |
|
149 | |||
150 | /** |
||
151 | * Set page link |
||
152 | * |
||
153 | * Basic reference, for example `page_%s.html` where %s page number, or |
||
154 | * callback function which takes one parameter - the number of the page. |
||
155 | * |
||
156 | * <code> |
||
157 | * function ($number) { |
||
158 | * return 'page_'.$number.'.html'; |
||
159 | * } |
||
160 | * </code> |
||
161 | * |
||
162 | * @param string|callback $page_link |
||
163 | * |
||
164 | * @return Configuration |
||
165 | */ |
||
166 | 3 | public function setPageLink($page_link) |
|
171 | |||
172 | /** |
||
173 | * @return string |
||
174 | */ |
||
175 | public function getFirstPageLink() |
||
176 | { |
||
177 | return $this->first_page_link; |
||
178 | } |
||
179 | |||
180 | /** |
||
181 | * @param string $first_page_link |
||
182 | * |
||
183 | * @return Configuration |
||
184 | */ |
||
185 | public function setFirstPageLink($first_page_link) |
||
186 | { |
||
187 | $this->first_page_link = $first_page_link; |
||
188 | return $this; |
||
189 | } |
||
190 | |||
191 | /** |
||
192 | * @return View |
||
193 | */ |
||
194 | 1 | public function getView() |
|
201 | } |
||
202 |