1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
baseoperator.php
См. документацию.
1<?php
2
4
6
8{
9 protected $toCheck;
10 protected $value;
12
13 public static function getCode(): string
14 {
15 return 'BASE';
16 }
17
18 public static function getTitle(): string
19 {
20 return '';
21 }
22
24 {
25 $this->fieldType = $fieldType;
26 $this->toCheck = $toCheck;
27 $this->value = $value;
28
29 $this->toBaseType();
30 }
31
32 protected function toBaseType(): void
33 {
34 $baseType = $this->fieldType->getBaseType();
35 $documentId = $this->fieldType->getDocumentId();
36 if ($baseType === 'user')
37 {
38 $this->toCheck = \CBPHelper::extractUsers($this->toCheck, $documentId);
39 $this->value = \CBPHelper::extractUsers($this->value, $documentId);
40 }
41 elseif ($baseType === 'select')
42 {
43 if (is_array($this->toCheck) && \CBPHelper::isAssociativeArray($this->toCheck))
44 {
45 $this->toCheck = array_keys($this->toCheck);
46 }
47 }
48 }
49
50 public function check(): bool
51 {
52 $toCheck = $this->valueToArray($this->toCheck);
53 $value = $this->valueToArray($this->value);
54
55 $result = false;
56
57 $fieldCount = count($toCheck);
58 $valueCount = count($value);
59 for ($i = 0; $i < max($fieldCount, $valueCount); $i++)
60 {
61 $fieldI = ($fieldCount > $i) ? $toCheck[$i] : $toCheck[$fieldCount -1];
62 $valueI = ($valueCount > $i) ? $value[$i] : $value[$valueCount - 1];
63
64 [$valueI, $fieldI] = $this->normalizeZeroComparing($valueI, $fieldI);
65
66 $result = $this->compare($fieldI, $valueI);
67
68 if (!$result)
69 {
70 break;
71 }
72 }
73
74 return $result;
75 }
76
77 protected function compare($toCheck, $value): bool
78 {
79 return $toCheck === $value;
80 }
81
82 protected function valueToArray($value): array
83 {
84 $value = is_array($value) ? $value : [$value];
85 $value = \CBPHelper::isAssociativeArray($value) ? array_keys($value) : $value;
86 if (empty($value))
87 {
88 $value = [null];
89 }
90
91 return $value;
92 }
93
94 protected function normalizeZeroComparing($value, $field): array
95 {
96 if ($value === '' && ($field === '0' || $field === 0.0))
97 {
98 return [null, null];
99 }
100
101 if (($value === '0' || $value === 0.0) && $field === '')
102 {
103 return [null, null];
104 }
105
106 return [$value, $field];
107 }
108}
normalizeZeroComparing($value, $field)
Определения baseoperator.php:94
compare($toCheck, $value)
Определения baseoperator.php:77
__construct($toCheck, $value, FieldType $fieldType)
Определения baseoperator.php:23
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
$i
Определения factura.php:643
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936