Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
pagenavigation.php
1<?php
9namespace Bitrix\Sender\UI;
10
13
19{
20 protected $sessionKeyName = 'sender_page_navigation';
21
27 public function resetSessionVar()
28 {
29 if(isset($_SESSION[$this->sessionKeyName]))
30 {
31 unset($_SESSION[$this->sessionKeyName]);
32 }
33 }
34
35 protected function setSessionVar($page = 1, $allRecords=false)
36 {
37 if(!isset($_SESSION[$this->sessionKeyName]))
38 {
39 $_SESSION[$this->sessionKeyName] = array();
40 }
41
42 $_SESSION[$this->sessionKeyName][$this->id] = [
43 'page' => $page,
44 'allRecords' => $allRecords
45 ];
46 }
47
48 protected function getSessionVar()
49 {
50 if(!isset($_SESSION[$this->sessionKeyName]))
51 {
52 return 1;
53 }
54
55 if (!isset($_SESSION[$this->sessionKeyName][$this->id]))
56 {
57 return 1;
58 }
59
60 return $_SESSION[$this->sessionKeyName][$this->id];
61 }
62
66 public function initFromUri()
67 {
68 parent::initFromUri();
69
70 $page = $this->currentPage;
71 $request = Application::getInstance()->getContext()->getRequest();
72 if ($request->get('apply_filter') === 'Y')
73 {
74 $page = 1;
75 }
76 if (!$page && $request->get('grid_action') === 'pagination')
77 {
78 $page = 1;
79 }
80
81 if ($page > 0)
82 {
83 $this->setSessionVar($page, $this->allRecords);
84 }
85 else
86 {
87 $page = is_array($this->getSessionVar()) ? ($this->getSessionVar()['page'] ?? 0) : 0;
88 }
89
90 $page = $page > 0 ? $page : 1;
91 $this->setCurrentPage($page);
92 $this->allRecords = is_array($this->getSessionVar()) ? ($this->getSessionVar()['allRecords'] ?? false) : false;
93 }
94}
setSessionVar($page=1, $allRecords=false)