1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
sale_cond.php
См. документацию.
1<?php
2
4
6{
7 public static function GetControlDescr()
8 {
9 $description = parent::GetControlDescr();
10 $description['SORT'] = 400;
11 return $description;
12 }
13
14 public static function GetControlShow($arParams)
15 {
16 $result = parent::GetControlShow($arParams);
17 $result['label'] = Loc::getMessage('BT_MOD_SALE_COND_IBLOCK_CONTROLGROUP_LABEL');
18 return $result;
19 }
20
21 public static function Generate($arOneCondition, $arParams, $arControl, $arSubs = false)
22 {
23 $strParentResult = '';
24 $strResult = '';
25 $parentResultValues = array();
26 $resultValues = array();
27
28 if (is_string($arControl))
29 {
30 $arControl = static::GetControls($arControl);
31 }
32 $boolError = !is_array($arControl);
33
34 $arValues = array();
35 if (!$boolError)
36 {
37 $arValues = static::Check($arOneCondition, $arOneCondition, $arControl, false);
38 $boolError = ($arValues === false);
39 }
40
41 if (!$boolError)
42 {
43 $arLogic = static::SearchLogic($arValues['logic'], $arControl['LOGIC']);
44 if (!isset($arLogic['OP'][$arControl['MULTIPLE']]) || empty($arLogic['OP'][$arControl['MULTIPLE']]))
45 {
46 $boolError = true;
47 }
48 else
49 {
50 $useParent = ($arControl['PARENT'] && isset($arLogic['PARENT']));
51 $strParent = $arParams['BASKET_ROW'].'[\'CATALOG\'][\'PARENT_'.$arControl['FIELD'].'\']';
52 $strField = $arParams['BASKET_ROW'].'[\'CATALOG\'][\''.$arControl['FIELD'].'\']';
53 switch ($arControl['FIELD_TYPE'])
54 {
55 case 'int':
56 case 'double':
57 if (is_array($arValues['value']))
58 {
59 if (!isset($arLogic['MULTI_SEP']))
60 {
61 $boolError = true;
62 }
63 else
64 {
65 foreach ($arValues['value'] as &$value)
66 {
67 if ($useParent)
68 $parentResultValues[] = str_replace(
69 array('#FIELD#', '#VALUE#'),
70 array($strParent, $value),
71 $arLogic['OP'][$arControl['MULTIPLE']]
72 );
73 $resultValues[] = str_replace(
74 array('#FIELD#', '#VALUE#'),
75 array($strField, $value),
76 $arLogic['OP'][$arControl['MULTIPLE']]
77 );
78 }
79 unset($value);
80 if ($useParent)
81 $strParentResult = '('.implode($arLogic['MULTI_SEP'], $parentResultValues).')';
82 $strResult = '('.implode($arLogic['MULTI_SEP'], $resultValues).')';
83 unset($resultValues, $parentResultValues);
84 }
85 }
86 else
87 {
88 if ($useParent)
89 $strParentResult = str_replace(
90 array('#FIELD#', '#VALUE#'),
91 array($strParent, $arValues['value']),
92 $arLogic['OP'][$arControl['MULTIPLE']]
93 );
94 $strResult = str_replace(
95 array('#FIELD#', '#VALUE#'),
96 array($strField, $arValues['value']),
97 $arLogic['OP'][$arControl['MULTIPLE']]
98 );
99 }
100 break;
101 case 'char':
102 case 'string':
103 case 'text':
104 if (is_array($arValues['value']))
105 {
106 $boolError = true;
107 }
108 else
109 {
110 if ($useParent)
111 $strParentResult = str_replace(
112 array('#FIELD#', '#VALUE#'),
113 array($strParent, '"'.EscapePHPString($arValues['value']).'"'),
114 $arLogic['OP'][$arControl['MULTIPLE']]
115 );
116 $strResult = str_replace(
117 array('#FIELD#', '#VALUE#'),
118 array($strField, '"'.EscapePHPString($arValues['value']).'"'),
119 $arLogic['OP'][$arControl['MULTIPLE']]
120 );
121 }
122 break;
123 case 'date':
124 case 'datetime':
125 if (is_array($arValues['value']))
126 {
127 $boolError = true;
128 }
129 else
130 {
131 if ($useParent)
132 $strParentResult = str_replace(
133 array('#FIELD#', '#VALUE#'),
134 array($strParent, $arValues['value']),
135 $arLogic['OP'][$arControl['MULTIPLE']]
136 );
137 $strResult = str_replace(
138 array('#FIELD#', '#VALUE#'),
139 array($strField, $arValues['value']),
140 $arLogic['OP'][$arControl['MULTIPLE']]
141 );
142 }
143 break;
144 }
145
146 $strResult = 'isset('.$strField.') && '.$strResult;
147 if ($useParent)
148 $strResult = 'isset('.$strParent.') ? (('.$strResult.')'.$arLogic['PARENT'].$strParentResult.') : ('.$strResult.')';
149 $strResult = '('.$strResult.')';
150 }
151 }
152
153 return (!$boolError ? $strResult : false);
154 }
155
156 public static function GetShowIn($arControls)
157 {
158 if (!empty($arControls))
159 {
160 $strDisableKey = CSaleCondCtrlGroup::GetControlID();
161 $arControlsMap = array_fill_keys($arControls, true);
162 if (array_key_exists($strDisableKey, $arControlsMap))
163 unset($arControlsMap[$strDisableKey]);
164 $arControls = array_keys($arControlsMap);
165 }
166 return $arControls;
167 }
168}
169
170class CCatalogCondCtrlBasketProductProps extends CCatalogCondCtrlIBlockProps
171{
172 public static function GetControlDescr()
173 {
174 $description = parent::GetControlDescr();
175 $description['SORT'] = 500;
176 return $description;
177 }
178
179 public static function Generate($arOneCondition, $arParams, $arControl, $arSubs = false)
180 {
181 $strResult = '';
182 $resultValues = array();
183 $arValues = false;
184
185 if (is_string($arControl))
186 {
187 $arControl = static::GetControls($arControl);
188 }
189 $boolError = !is_array($arControl);
190
191 if (!$boolError)
192 {
193 $arValues = static::Check($arOneCondition, $arOneCondition, $arControl, false);
194 $boolError = ($arValues === false);
195 }
196
197 if (!$boolError)
198 {
199 $arLogic = static::SearchLogic($arValues['logic'], $arControl['LOGIC']);
200 if (!isset($arLogic['OP'][$arControl['MULTIPLE']]) || empty($arLogic['OP'][$arControl['MULTIPLE']]))
201 {
202 $boolError = true;
203 }
204 else
205 {
206 $strField = $arParams['BASKET_ROW'].'[\'CATALOG\'][\''.$arControl['FIELD'].'\']';
207 switch ($arControl['FIELD_TYPE'])
208 {
209 case 'int':
210 case 'double':
211 if (is_array($arValues['value']))
212 {
213 if (!isset($arLogic['MULTI_SEP']))
214 {
215 $boolError = true;
216 }
217 else
218 {
219 foreach ($arValues['value'] as &$value)
220 {
221 $resultValues[] = str_replace(
222 array('#FIELD#', '#VALUE#'),
223 array($strField, $value),
224 $arLogic['OP'][$arControl['MULTIPLE']]
225 );
226 }
227 unset($value);
228 $strResult = '('.implode($arLogic['MULTI_SEP'], $resultValues).')';
229 unset($resultValues);
230 }
231 }
232 else
233 {
234 $strResult = str_replace(
235 array('#FIELD#', '#VALUE#'),
236 array($strField, $arValues['value']),
237 $arLogic['OP'][$arControl['MULTIPLE']]
238 );
239 }
240 break;
241 case 'char':
242 case 'string':
243 case 'text':
244 if (is_array($arValues['value']))
245 {
246 $boolError = true;
247 }
248 else
249 {
250 $strResult = str_replace(
251 array('#FIELD#', '#VALUE#'),
252 array($strField, '"'.EscapePHPString($arValues['value']).'"'),
253 $arLogic['OP'][$arControl['MULTIPLE']]
254 );
255 }
256 break;
257 case 'date':
258 case 'datetime':
259 if (is_array($arValues['value']))
260 {
261 $boolError = true;
262 }
263 else
264 {
265 $strResult = str_replace(
266 array('#FIELD#', '#VALUE#'),
267 array($strField, $arValues['value']),
268 $arLogic['OP'][$arControl['MULTIPLE']]
269 );
270 }
271 break;
272 }
273 $strResult = '(isset('.$strField.') && '.$strResult.')';
274 }
275 }
276
277 return (!$boolError ? $strResult : false);
278 }
279
280 public static function GetShowIn($arControls)
281 {
282 if (!empty($arControls))
283 {
284 $strDisableKey = CSaleCondCtrlGroup::GetControlID();
285 $arControlsMap = array_fill_keys($arControls, true);
286 if (array_key_exists($strDisableKey, $arControlsMap))
287 unset($arControlsMap[$strDisableKey]);
288 $arControls = array_keys($arControlsMap);
289 }
290 return $arControls;
291 }
292}
293
294class CCatalogCondCtrlCatalogSettings extends CGlobalCondCtrlComplex
295{
296 public static function GetControlDescr()
297 {
298 $description = parent::GetControlDescr();
299 $description['SORT'] = 900;
300 return $description;
301 }
302
303 public static function GetControlShow($arParams)
304 {
305 $controlList = static::GetControls();
306 $result = array(
307 'controlgroup' => true,
308 'group' => false,
309 'label' => Loc::getMessage('BX_COND_CATALOG_SETTINGS_CONTROLGROUP_LABEL'),
310 'showIn' => static::GetShowIn($arParams['SHOW_IN_GROUPS']),
311 'children' => array()
312 );
313 foreach ($controlList as &$control)
314 {
315 $jsControl = array(
316 'controlId' => $control['ID'],
317 'group' => ($control['GROUP'] == 'Y'),
318 'label' => $control['LABEL'],
319 'showIn' => static::GetShowIn($arParams['SHOW_IN_GROUPS']),
320 'control' => array()
321 );
322 if ($control['ID'] == 'CondCatalogRenewal')
323 {
324 $jsControl['control'] = array(
325 array(
326 'id' => 'prefix',
327 'type' => 'prefix',
328 'text' => $control['PREFIX'],
329 ),
330 static::GetValueAtom($control['JS_VALUE'])
331 );
332 }
333 else
334 {
335 $jsControl['control'] = array(
336 array(
337 'id' => 'prefix',
338 'type' => 'prefix',
339 'text' => $control['PREFIX'],
340 ),
341 static::GetLogicAtom($control['LOGIC']),
342 static::GetValueAtom($control['JS_VALUE'])
343 );
344 }
345 $result['children'][] = $jsControl;
346 }
347 unset($jsControl, $control, $controlList);
348 return $result;
349 }
350
351 public static function GetConditionShow($arParams)
352 {
353 if (!isset($arParams['ID']))
354 return false;
355
356 if ($arParams['ID'] == 'CondCatalogRenewal')
357 {
358 $control = static::GetControls($arParams['ID']);
359 if ($control === false)
360 return false;
361
362 return array(
363 'id' => $arParams['COND_NUM'],
364 'controlId' => $control['ID'],
365 'values' => array('value' => 'Y')
366 );
367 }
368 else
369 {
370 return parent::GetConditionShow($arParams);
371 }
372 }
373
374 public static function Parse($arOneCondition)
375 {
376 if (!isset($arOneCondition['controlId']))
377 return false;
378 if ($arOneCondition['controlId'] == 'CondCatalogRenewal')
379 {
380 $control = static::GetControls($arOneCondition['controlId']);
381 if ($control === false)
382 return false;
383 return array('value' => 'Y');
384 }
385 else
386 {
387 return parent::Parse($arOneCondition);
388 }
389 }
390
391 public static function Generate($arOneCondition, $arParams, $arControl, $arSubs = false)
392 {
393 $strResult = '';
394
395 if (is_string($arControl))
396 {
397 $arControl = static::GetControls($arControl);
398 }
399 $boolError = !is_array($arControl);
400
401 if (!$boolError && $arOneCondition['value'] === 'Y')
402 {
403 $strField = $arParams['ORDER']."['RECURRING_ID']";
404 $strResult = 'isset('.$strField.') && '.$strField;
405 }
406
407 return (!$boolError ? $strResult : false);
408 }
409
410 public static function GetShowIn($arControls)
411 {
412 return array(CSaleCondCtrlGroup::GetControlID());
413 }
414
415 public static function GetControlID()
416 {
417 return array(
418 'CondCatalogRenewal'
419 );
420 }
421
425 public static function GetControls($strControlID = false)
426 {
427 $controlList = array(
428 'CondCatalogRenewal' => array(
429 'ID' => 'CondCatalogRenewal',
430 'PARENT' => false,
431 'EXECUTE_MODULE' => 'catalog',
432 'EXIST_HANDLER' => 'Y',
433 'MODULE_ID' => 'catalog',
434 'MODULE_ENTITY' => 'catalog',
435 'ENTITY' => 'DISCOUNT',
436 'FIELD' => 'RENEWAL',
437 'FIELD_TABLE' => 'RENEWAL',
438 'FIELD_TYPE' => 'char',
439 'MULTIPLE' => 'N',
440 'GROUP' => 'N',
441 'LABEL' => Loc::getMessage('BX_COND_CATALOG_RENEWAL_LABEL'),
442 'PREFIX' => Loc::getMessage('BX_COND_CATALOG_RENEWAL_PREFIX'),
443 'JS_VALUE' => array(
444 'type' => 'hidden',
445 'value' => 'Y',
446 ),
447 )
448 );
449 if ($strControlID === false)
450 {
451 return $controlList;
452 }
453 elseif (isset($controlList[$strControlID]))
454 {
455 return $controlList[$strControlID];
456 }
457 else
458 {
459 return false;
460 }
461 }
462}
$arParams
Определения access_dialog.php:21
static GetControlDescr()
Определения sale_cond.php:7
static Generate($arOneCondition, $arParams, $arControl, $arSubs=false)
Определения sale_cond.php:21
static GetControlShow($arParams)
Определения sale_cond.php:14
$arValues
Определения component_props.php:25
</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(Loader::includeModule( 'bitrix24')) elseif(Loader::includeModule('intranet') &&CIntranetUtils::getPortalZone() !=='ru') $description
Определения .description.php:24