1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
PropertyFilterProvider.php
См. документацию.
1<?php
2
3namespace Bitrix\Iblock\Integration\UI\Grid\Filter\Property;
4
5use Bitrix\Iblock\Helpers\Admin\Property;
6use Bitrix\Iblock\Integration\UI\Grid\Property\PropertyGridProvider;
7use Bitrix\Main\Filter\EntityDataProvider;
8use Bitrix\Main\Filter\Settings;
9use Bitrix\Main\Localization\Loc;
10use Bitrix\Main\Type\Collection;
11use CIBlockProperty;
12
14{
15 private Settings $settings;
16 private PropertyGridProvider $gridProvider;
17 private int $iblockId;
18
23 public function __construct(int $iblockId, PropertyGridProvider $gridProvider)
24 {
25 $this->iblockId = $iblockId;
26 $this->gridProvider = $gridProvider;
27 }
28
32 public function getSettings()
33 {
34 $this->settings ??= new Settings([
35 'ID' => "iblock_property_{$this->iblockId}",
36 ]);
37
38 return $this->settings;
39 }
40
44 protected function getFieldName($fieldID)
45 {
46 return $fieldID;
47 }
48
52 public function prepareFields()
53 {
54 return [
55 'NAME' => $this->createField('NAME', [
56 'name' => $this->gridProvider->getFieldName('NAME'),
57 'default' => true,
58 ]),
59 'CODE' => $this->createField('CODE', [
60 'name' => $this->gridProvider->getFieldName('CODE'),
61 ]),
62 'ACTIVE' => $this->createField('ACTIVE', [
63 'name' => $this->gridProvider->getFieldName('ACTIVE'),
64 'type' => 'list',
65 'default' => true,
66 'data' => [
67 'items' => [
68 'Y' => Loc::getMessage('IBLOCK_YES'),
69 'N' => Loc::getMessage('IBLOCK_NO')
70 ],
71 ],
72 ]),
73 'SEARCHABLE' => $this->createField('SEARCHABLE', [
74 'name' => $this->gridProvider->getFieldName('SEARCHABLE'),
75 'type' => 'list',
76 'data' => [
77 'items' => [
78 'Y' => Loc::getMessage('IBLOCK_YES'),
79 'N' => Loc::getMessage('IBLOCK_NO')
80 ],
81 ],
82 ]),
83 'FILTRABLE' => $this->createField('FILTRABLE', [
84 'name' => $this->gridProvider->getFieldName('FILTRABLE'),
85 'type' => 'list',
86 'data' => [
87 'items' => [
88 'Y' => Loc::getMessage('IBLOCK_YES'),
89 'N' => Loc::getMessage('IBLOCK_NO')
90 ],
91 ],
92 ]),
93 'IS_REQUIRED' => $this->createField('IS_REQUIRED', [
94 'name' => $this->gridProvider->getFieldName('IS_REQUIRED'),
95 'type' => 'list',
96 'data' => [
97 'items' => [
98 'Y' => Loc::getMessage('IBLOCK_YES'),
99 'N' => Loc::getMessage('IBLOCK_NO')
100 ],
101 ],
102 ]),
103 'MULTIPLE' => $this->createField('MULTIPLE', [
104 'name' => $this->gridProvider->getFieldName('MULTIPLE'),
105 'type' => 'list',
106 'data' => [
107 'items' => [
108 'Y' => Loc::getMessage('IBLOCK_YES'),
109 'N' => Loc::getMessage('IBLOCK_NO')
110 ],
111 ],
112 ]),
113 'XML_ID' => $this->createField('XML_ID', [
114 'name' => $this->gridProvider->getFieldName('XML_ID'),
115 ]),
116 'PROPERTY_TYPE' => $this->createField('PROPERTY_TYPE', [
117 'name' => $this->gridProvider->getFieldName('PROPERTY_TYPE'),
118 'type' => 'list',
119 'default' => true,
120 'data' => [
121 'items' => $this->getPropertyTypes(),
122 ],
123 ]),
124 ];
125 }
126
132 private function getPropertyTypes(): array
133 {
134 $result = [];
135
136 $baseTypes = Property::getBaseTypeList(true);
137 foreach ($baseTypes as $type => $name)
138 {
140 }
141
142 $userTypes = CIBlockProperty::GetUserType();
143 Collection::sortByColumn($userTypes, [
144 'DESCRIPTION' => SORT_STRING,
145 ]);
146
147 foreach ($userTypes as $type => $item)
148 {
149 $key = "{$item['PROPERTY_TYPE']}:{$type}";
150 $result[$key] = $item['DESCRIPTION'];
151 }
152
153 return $result;
154 }
155
159 public function prepareFieldData($fieldID)
160 {
161 return null;
162 }
163
167 public function prepareFilterValue(array $rawFilterValue): array
168 {
169 $isEmpty = empty($rawFilterValue);
170 $rawFilterValue['=IBLOCK_ID'] = $this->iblockId;
171
172 if ($isEmpty)
173 {
174 return $rawFilterValue;
175 }
176
177 // parse property type
178 if (isset($rawFilterValue['PROPERTY_TYPE']))
179 {
180 $parts = explode(':', $rawFilterValue['PROPERTY_TYPE']);
181 if (count($parts) === 2)
182 {
183 $rawFilterValue['PROPERTY_TYPE'] = $parts[0];
184 $rawFilterValue['USER_TYPE'] = $parts[1];
185 }
186 }
187
188 // process fields operations
189 $filterOperations = [
190 'NAME' => '?',
191 'CODE' => '?',
192 'ACTIVE' => '=',
193 'SEARCHABLE' => '=',
194 'FILTRABLE' => '=',
195 'IS_REQUIRED' => '=',
196 'MULTIPLE' => '=',
197 'XML_ID' => '=',
198 'PROPERTY_TYPE' => '=',
199 'USER_TYPE' => '=',
200 ];
201 foreach ($rawFilterValue as $field => $value)
202 {
203 $operator = $filterOperations[$field] ?? null;
204 if (isset($operator))
205 {
206 $rawFilterValue[$operator . $field] = $value;
207 unset($rawFilterValue[$field]);
208 }
209 }
210
211 // searchable
212 if (isset($rawFilterValue['FIND']))
213 {
214 $rawFilterValue[] = [
215 '?NAME' => $rawFilterValue['FIND'],
216 ];
217 }
218
219 return $rawFilterValue;
220 }
221}
$type
Определения options.php:106
__construct(int $iblockId, PropertyGridProvider $gridProvider)
Определения PropertyFilterProvider.php:23
createField($fieldID, array $params=null)
Определения entitydataprovider.php:26
</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
$iblockId
Определения iblock_catalog_edit.php:30
$name
Определения menu_edit.php:35
$settings
Определения product_settings.php:43
if(empty($signedUserToken)) $key
Определения quickway.php:257
</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