Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
base.php
1<?php
9
11
12abstract class Base
13{
14 protected $fieldPrefix;
16 protected $fieldValues;
17 protected $fieldFormName;
18 protected $moduleId;
19
21 protected $resultView;
22
24 protected $dataTypeId = Recipient\Type::EMAIL;
25
26 protected bool $checkAccessRights = true;
31 public function setModuleId($moduleId)
32 {
33 $this->moduleId = $moduleId;
34 }
35
39 public function getModuleId()
40 {
41 return $this->moduleId;
42 }
43
49 public function getDataTypeId()
50 {
51 return $this->dataTypeId;
52 }
53
60 public function setDataTypeId($dataTypeId)
61 {
62 $this->dataTypeId = $dataTypeId;
63 }
64
70 {
71 $this->fieldFormName = $fieldFormName;
72 }
73
75 public function getFieldFormName()
76 {
78 }
79
85 {
86 $this->fieldPrefix = $fieldPrefix;
87 }
89 public function getFieldPrefix()
90 {
91 return $this->fieldPrefix;
92 }
93
99 {
100 $this->fieldPrefixExtended = $fieldPrefixExtended;
101 }
103 public function getFieldPrefixExtended()
104 {
106 }
107
114 public function setFieldValues(array $fieldValues = null)
115 {
116 $this->fieldValues = $fieldValues;
117 }
118
124 public function getFieldValues()
125 {
126 return is_array($this->fieldValues) ? $this->fieldValues : array();
127 }
128
134 public function hasFieldValues()
135 {
136 return count($this->getFieldValues()) > 0;
137 }
138
143 public function getFieldId($id)
144 {
145 $fieldPrefix = $this->getFieldPrefix();
147 if($fieldPrefix)
148 {
149 $moduleId = str_replace('.', '_', $this->getModuleId());
150 return $fieldPrefix . '_' . $moduleId . '_' . $this->getCode() . '_%CONNECTOR_NUM%_' . $id;
151 }
153 {
154 return str_replace(array('][', '[', ']'), array('_', '', ''), $fieldPrefixExtended) .'_'. $id;
155 }
156 else
157 return $id;
158 }
159
164 public function getFieldName($name)
165 {
166 $fieldPrefix = $this->getFieldPrefix();
169 {
170 $arReturnName = array();
171 if($fieldPrefix)
172 $arReturnName[] = $fieldPrefix.'['.$this->getModuleId().']['.$this->getCode().'][%CONNECTOR_NUM%]';
173 else
174 $arReturnName[] = $fieldPrefixExtended;
175
176 $arName = explode('[', $name);
177 $arReturnName[] = '['.$arName[0].']';
178 if(count($arName)>1)
179 {
180 unset($arName[0]);
181 $arReturnName[] = '['.implode('[', $arName);
182 }
183
184 return implode('', $arReturnName);
185 }
186 else
187 return $name;
188 }
189
195 public function getFieldValue($name, $defaultValue = null)
196 {
197 if($this->fieldValues && array_key_exists($name, $this->fieldValues))
198 return $this->fieldValues[$name];
199 else
200 return $defaultValue;
201 }
202
206 public function getId()
207 {
208 return $this->getModuleId().'_'.$this->getCode();
209 }
210
216 public function getDataCount()
217 {
218 return $this->getResult()->getSelectedRowsCount();
219 }
220
226 protected function getDataCountByType()
227 {
228 return null;
229 }
230
236 final function getDataCounter()
237 {
238 $dataCounts = $this->getDataCountByType();
239 if (is_object($dataCounts) && $dataCounts instanceof DataCounter)
240 {
241 return $dataCounts;
242 }
243 else if (!is_array($dataCounts))
244 {
245 $dataCounts = array($this->getDataTypeId() => $this->getDataCount());
246 }
247
248 return new DataCounter($dataCounts);
249 }
250
256 final function getResult()
257 {
258 $personalizeList = array();
259 $personalizeListTmp = $this->getPersonalizeList();
260 foreach($personalizeListTmp as $tag)
261 {
262 if(!empty($tag['ITEMS']))
263 {
264 foreach ($tag['ITEMS'] as $item)
265 {
266 $personalizeList[$item['CODE']] = $item['CODE'];
267 }
268 continue;
269 }
270 if(strlen($tag['CODE']) > 0)
271 {
272 $personalizeList[] = $tag['CODE'];
273 }
274 }
275
276 $result = new Result($this->getData());
277 $result->setFilterFields($personalizeList);
278 $result->setDataTypeId($this->getDataTypeId());
279
280 return $result;
281 }
282
288 public function isResultViewable()
289 {
290 return false;
291 }
292
299 public function getResultView()
300 {
301 if (!$this->resultView)
302 {
303 $this->resultView = new ResultView($this);
304 $this->onInitResultView();
305 }
306
307 return $this->resultView;
308 }
309
316 public function setResultView($resultView)
317 {
318 $this->resultView = $resultView;
319 }
320
321 protected function onInitResultView()
322 {
323
324 }
325
329 public function requireConfigure()
330 {
331 return false;
332 }
333
337 public static function getPersonalizeList()
338 {
339 return array();
340 }
341
345 public abstract function getName();
346
350 public abstract function getCode();
351
357 public abstract function getData();
358
359
360
361 public function buildData()
362 {
363 return null;
364 }
365
369 public abstract function getForm();
370
375 public function getStatFields()
376 {
377 return [];
378 }
379
383 public function isCheckAccessRights(): bool
384 {
386 }
387
393 public function setCheckAccessRights(bool $checkAccessRights): static
394 {
395 $this->checkAccessRights = $checkAccessRights;
396
397 return $this;
398 }
399}
setCheckAccessRights(bool $checkAccessRights)
Definition base.php:393
setResultView($resultView)
Definition base.php:316
setFieldValues(array $fieldValues=null)
Definition base.php:114
setFieldPrefix($fieldPrefix)
Definition base.php:84
setFieldFormName($fieldFormName)
Definition base.php:69
setFieldPrefixExtended($fieldPrefixExtended)
Definition base.php:98
setDataTypeId($dataTypeId)
Definition base.php:60
getFieldValue($name, $defaultValue=null)
Definition base.php:195