Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
reversepagenavigation.php
1<?php
8namespace Bitrix\Main\UI;
9
11{
16 public function __construct($id, $count)
17 {
18 parent::__construct($id);
19 $this->setRecordCount($count);
20 }
21
26 public function getPageCount()
27 {
28 if($this->allRecords)
29 {
30 return 1;
31 }
32 $maxPages = (int)floor($this->recordCount/$this->pageSize);
33 if($this->recordCount > 0 && $maxPages == 0)
34 {
35 $maxPages = 1;
36 }
37 return $maxPages;
38 }
39
44 public function getCurrentPage()
45 {
46 if($this->currentPage !== null)
47 {
48 return $this->currentPage;
49 }
50 return $this->getPageCount();
51 }
52
57 public function getOffset()
58 {
59 if($this->allRecords)
60 {
61 return 0;
62 }
63
64 $offset = 0;
65 $pageCount = $this->getPageCount();
67
68 if($currentPage <> $pageCount)
69 {
70 //counting the last page (wich is the first one on reverse paging)
71 $offset += ($this->recordCount % $this->pageSize);
72 }
73
74 $offset += ($pageCount - $currentPage) * $this->pageSize;
75
76 return $offset;
77 }
78
83 public function getLimit()
84 {
85 if($this->allRecords)
86 {
87 return $this->getRecordCount();
88 }
89 if($this->getCurrentPage() == $this->getPageCount())
90 {
91 //the last page (displayed first)
92 return $this->pageSize + ($this->recordCount % $this->pageSize);
93 }
94 else
95 {
96 return $this->pageSize;
97 }
98 }
99}