Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
page.php
1<?php
3
4use \Bitrix\Landing\Manager;
5
6abstract class Page
7{
12 protected $editMode = false;
13
18 protected $fields = array();
19
24 protected $fieldsPage = array();
25
30 protected $isPage = true;
31
36 protected $customExec = null;
37
42 protected $isNeedPublication = false;
43
49 public function __construct($editMode = false, $isPage = true)
50 {
51 if ($editMode)
52 {
53 $this->editMode = true;
54 }
55 if (!$isPage)
56 {
57 $this->isPage = false;
58 }
59 $this->fields = $this->getMap();
60 }
61
66 public function isPage()
67 {
68 return $this->isPage;
69 }
70
75 public function getTitle()
76 {
77 return '';
78 }
79
84 public function getDescription()
85 {
86 return '';
87 }
88
93 protected function isEditMode()
94 {
95 return $this->editMode === true;
96 }
97
102 public function getSort()
103 {
104 return 100;
105 }
106
111 public function isFree()
112 {
113 return true;
114 }
115
120 public function isLocked()
121 {
122 return false;
123 }
124
129 public function getLockedMessage()
130 {
131 return '';
132 }
133
137 public function isNeedPublication(): bool
138 {
139 return $this->isNeedPublication;
140 }
141
146 public function getCode()
147 {
148 $class = new \ReflectionClass($this);
149 return mb_strtoupper($class->getShortName());
150 }
151
157 public function setData(array $data)
158 {
159 foreach ($data as $key => $value)
160 {
161 if (isset($this->fields[$key]))
162 {
163 $this->fields[$key]->setValue($value);
164 }
165 }
166 }
167
172 public function getPageFields()
173 {
174 if (empty($this->fieldsPage))
175 {
176 foreach ($this->fields as $field)
177 {
178 $code = $field->getCode();
179 $code = $this->getCode() . '_' . $code;
180 $field->setCode($code);
181
182 $this->fieldsPage[$code] = $field;
183 }
184 }
185
186 return $this->fieldsPage;
187 }
188
193 public function getFields()
194 {
195 return $this->fields;
196 }
197
202 public function enabledInEditMode()
203 {
204 return true;
205 }
206
211 public function enabledInIntranetMode()
212 {
213 return true;
214 }
215
220 public function fieldsHash()
221 {
222 $hash = '';
223 $hash .= implode('.', array_keys($this->fields));
224 $hash .= implode('.', array_values($this->fields));
225 $hash = md5($hash);
226
227 return $hash;
228 }
229
234 public function dataExist()
235 {
236 return implode('', array_values($this->fields)) != '';
237 }
238
244 public function setCustomExec(callable $callback)
245 {
246 $this->customExec = $callback;
247 }
248
253 public function issetCustomExec()
254 {
255 return is_callable($this->customExec);
256 }
257
262 protected function execCustom()
263 {
264 if ($this->customExec)
265 {
266 return call_user_func_array($this->customExec, [$this]) === true;
267 }
268 return false;
269 }
270
275 abstract protected function getMap();
276
281 abstract public function enabled();
282
287 abstract public function exec();
288}
__construct($editMode=false, $isPage=true)
Definition page.php:49
setData(array $data)
Definition page.php:157
setCustomExec(callable $callback)
Definition page.php:244