1 | <?php |
||
15 | class UIPagination extends \Asymptix\ui\UIControl { |
||
16 | /** |
||
17 | * Default dialog panel HTML template. |
||
18 | */ |
||
19 | const DEFAULT_TEMPLATE = "core/ui/templates/controls/ui_pagination.tpl.php"; |
||
20 | |||
21 | public $url = ""; |
||
22 | |||
23 | public $pagesNumber; |
||
24 | public $firstPage; |
||
25 | public $previousPage; |
||
26 | public $currentPage; |
||
27 | public $nextPage; |
||
28 | public $lastPage; |
||
29 | public $pagesOffset; |
||
30 | |||
31 | /** |
||
32 | * Display Pagination control. |
||
33 | * |
||
34 | * @param string $url Basic URL of the pagination links (common part). |
||
35 | * @param int $pagesNumber Total pages number. |
||
36 | * @param int $currentPage Current page number. |
||
37 | * @param int $pagesOffset Number of visible pagination links before and |
||
38 | * after current page link. |
||
39 | * @param string $template Path to the pagination HTML template. |
||
40 | */ |
||
41 | public function __construct($url = "", $pagesNumber = 1, $currentPage = 1, $pagesOffset = 3, $template = "") { |
||
57 | |||
58 | private function correctPages() { |
||
64 | |||
65 | public function setCurrentPage($currentPage) { |
||
76 | |||
77 | public static function getCurrentPageNumber($page, $totalPages) { |
||
78 | $page = (int)$page; |
||
79 | |||
80 | if ($page < 1) { |
||
81 | return 1; |
||
82 | } |
||
83 | |||
84 | if ($page > $totalPages) { |
||
85 | return $totalPages; |
||
86 | } |
||
92 |