35 return get_called_class();
40 $strClassName = get_called_class();
42 'ID' => static::GetControlID(),
43 'GetControlShow' =>
array($strClassName,
'GetControlShow'),
44 'GetConditionShow' =>
array($strClassName,
'GetConditionShow'),
45 'IsGroup' =>
array($strClassName,
'IsGroup'),
46 'Parse' =>
array($strClassName,
'Parse'),
47 'Generate' =>
array($strClassName,
'Generate'),
48 'ApplyValues' =>
array($strClassName,
'ApplyValues'),
49 'InitParams' =>
array($strClassName,
'InitParams')
63 public static function IsGroup($strControlID =
false)
68 public static function Parse($arOneCondition)
78 public static function ApplyValues($arOneCondition, $arControl)
88 static::$boolInit =
true;
102 if (!is_array($arControls))
103 $arControls =
array($arControls);
104 return array_values(array_unique($arControls));
121 public static function GetAtomsEx($strControlID =
false, $boolEx =
false)
140 public static function GetLogic($arOperators =
false)
142 $arOperatorsList =
array(
146 'Y' =>
'in_array(#VALUE#, #FIELD#)',
147 'N' =>
'#FIELD# == #VALUE#'
150 'MULTI_SEP' =>
' || ',
157 'Y' =>
'!in_array(#VALUE#, #FIELD#)',
158 'N' =>
'#FIELD# != #VALUE#'
161 'MULTI_SEP' =>
' && ',
168 'N' =>
'#FIELD# > #VALUE#',
169 'Y' =>
'CGlobalCondCtrl::LogicGreat(#FIELD#, #VALUE#)'
177 'N' =>
'#FIELD# < #VALUE#',
178 'Y' =>
'CGlobalCondCtrl::LogicLess(#FIELD#, #VALUE#)'
186 'N' =>
'#FIELD# >= #VALUE#',
187 'Y' =>
'CGlobalCondCtrl::LogicEqualGreat(#FIELD#, #VALUE#)'
195 'N' =>
'#FIELD# <= #VALUE#',
196 'Y' =>
'CGlobalCondCtrl::LogicEqualLess(#FIELD#, #VALUE#)'
204 'N' =>
'false !== mb_strpos(#FIELD#, #VALUE#)',
205 'Y' =>
'CGlobalCondCtrl::LogicContain(#FIELD#, #VALUE#)'
208 'MULTI_SEP' =>
' || ',
209 'VALUE' =>
'Contain',
215 'N' =>
'false === mb_strpos(#FIELD#, #VALUE#)',
216 'Y' =>
'CGlobalCondCtrl::LogicNotContain(#FIELD#, #VALUE#)'
219 'MULTI_SEP' =>
' && ',
220 'VALUE' =>
'NotCont',
227 if (!empty($arOperators) && is_array($arOperators))
229 foreach ($arOperators as &$intOneOp)
231 if (isset($arOperatorsList[$intOneOp]))
234 $arSearch[$intOneOp] = $arOperatorsList[$intOneOp];
239 return ($boolSearch ? $arSearch : $arOperatorsList);
247 public static function GetLogicEx($arOperators =
false, $arLabels =
false)
249 $arOperatorsList = static::GetLogic($arOperators);
250 if (!empty($arLabels) && is_array($arLabels))
252 foreach ($arOperatorsList as &$arOneOperator)
254 if (isset($arLabels[$arOneOperator[
'ID']]))
255 $arOneOperator[
'LABEL'] = $arLabels[$arOneOperator[
'ID']];
257 if (isset($arOneOperator))
258 unset($arOneOperator);
260 return $arOperatorsList;
265 if (!empty($arLogic) && is_array($arLogic))
268 foreach ($arLogic as &$arOneLogic)
270 $arValues[$arOneLogic[
'VALUE']] = $arOneLogic[
'LABEL'];
272 if (isset($arOneLogic))
289 if (empty($arValue) || !isset($arValue[
'type']))
305 public static function CheckLogic($strValue, $arLogic, $boolShow =
false)
307 $boolShow = (
true === $boolShow);
308 if (empty($arLogic) || !is_array($arLogic))
311 foreach ($arLogic as &$arOneLogic)
313 if ($strValue == $arOneLogic[
'VALUE'])
315 $strResult = $arOneLogic[
'VALUE'];
319 if (isset($arOneLogic))
321 if ($strResult ==
'')
325 $arOneLogic = current($arLogic);
326 $strResult = $arOneLogic[
'VALUE'];
329 return ($strResult ==
'' ?
false : $strResult);
335 if (empty($arLogic) || !is_array($arLogic))
337 foreach ($arLogic as &$arOneLogic)
339 if ($strValue == $arOneLogic[
'VALUE'])
341 $mxResult = $arOneLogic;
345 if (isset($arOneLogic))
352 $boolShow = ($boolShow ===
true);
354 $boolFatalError =
false;
363 static $intTimeOffset =
false;
364 if ($intTimeOffset ===
false)
365 $intTimeOffset = CTimeZone::GetOffset();
369 if (!isset($arOneCondition[
'logic']))
371 $arOneCondition[
'logic'] =
'';
374 if (!isset($arOneCondition[
'value']))
376 $arOneCondition[
'value'] =
'';
379 $strLogic = static::CheckLogic($arOneCondition[
'logic'], $arControl[
'LOGIC'], $boolShow);
380 if ($strLogic ===
false)
383 $boolFatalError =
true;
391 $boolValueError = static::ClearValue($arOneCondition[
'value']);
392 if (!$boolValueError)
394 $boolMulti = is_array($arOneCondition[
'value']);
395 switch ($arControl[
'FIELD_TYPE'])
400 foreach ($arOneCondition[
'value'] as &$intOneValue)
402 $intOneValue = (int)$intOneValue;
408 $arOneCondition[
'value'] = (int)$arOneCondition[
'value'];
414 foreach ($arOneCondition[
'value'] as &$dblOneValue)
416 $dblOneValue = (float)$dblOneValue;
422 $arOneCondition[
'value'] = (float)$arOneCondition[
'value'];
428 foreach ($arOneCondition[
'value'] as &$strOneValue)
430 $strOneValue = mb_substr($strOneValue, 0, 1);
436 $arOneCondition[
'value'] = mb_substr($arOneCondition[
'value'], 0, 1);
440 $intMaxLen = (int)(isset($arControl[
'FIELD_LENGTH']) ? $arControl[
'FIELD_LENGTH'] : 255);
445 foreach ($arOneCondition[
'value'] as &$strOneValue)
447 $strOneValue = mb_substr($strOneValue, 0, $intMaxLen);
453 $arOneCondition[
'value'] = mb_substr($arOneCondition[
'value'], 0, $intMaxLen);
460 if ($arControl[
'FIELD_TYPE'] ==
'date')
462 $strFormat =
'SHORT';
468 $intOffset = $intTimeOffset;
470 $boolValueError = static::ConvertInt2DateTime($arOneCondition[
'value'], $strFormat, $intOffset);
473 $boolValueError =
true;
476 if (!$boolValueError)
479 $arOneCondition[
'value'] = array_values(array_unique($arOneCondition[
'value']));
483 if (!$boolValueError)
485 if (isset($arControl[
'PHP_VALUE']) && !empty($arControl[
'PHP_VALUE'][
'VALIDATE']))
487 $arValidate = static::Validate($arOneCondition,
$arParams, $arControl, $boolShow);
488 if ($arValidate ===
false)
490 $boolValueError =
true;
494 if (isset($arValidate[
'err_cond']) && $arValidate[
'err_cond'] ==
'Y')
496 $boolValueError =
true;
497 if (isset($arValidate[
'err_cond_mess']) && !empty($arValidate[
'err_cond_mess']))
498 $arMsg = array_merge($arMsg, $arValidate[
'err_cond_mess']);
502 $arValues[
'value'] = $arValidate[
'values'];
503 if (isset($arValidate[
'labels']))
504 $arLabels[
'value'] = $arValidate[
'labels'];
510 $arValues[
'value'] = $arOneCondition[
'value'];
515 $boolError = $boolValueError;
519 if (!isset($arOneCondition[
'logic']) || !isset($arOneCondition[
'value']))
525 $strLogic = static::CheckLogic($arOneCondition[
'logic'], $arControl[
'LOGIC'], $boolShow);
532 $arValues[
'logic'] = $arOneCondition[
'logic'];
538 $boolError = static::ClearValue($arOneCondition[
'value']);
543 $boolMulti = is_array($arOneCondition[
'value']);
544 switch ($arControl[
'FIELD_TYPE'])
549 foreach ($arOneCondition[
'value'] as &$intOneValue)
551 $intOneValue = (int)$intOneValue;
557 $arOneCondition[
'value'] = (int)$arOneCondition[
'value'];
563 foreach ($arOneCondition[
'value'] as &$dblOneValue)
565 $dblOneValue = (float)$dblOneValue;
571 $arOneCondition[
'value'] = (float)$arOneCondition[
'value'];
577 foreach ($arOneCondition[
'value'] as &$strOneValue)
579 $strOneValue = mb_substr($strOneValue, 0, 1);
585 $arOneCondition[
'value'] = mb_substr($arOneCondition[
'value'], 0, 1);
589 $intMaxLen = (int)(isset($arControl[
'FIELD_LENGTH']) ? $arControl[
'FIELD_LENGTH'] : 255);
594 foreach ($arOneCondition[
'value'] as &$strOneValue)
596 $strOneValue = mb_substr($strOneValue, 0, $intMaxLen);
602 $arOneCondition[
'value'] = mb_substr($arOneCondition[
'value'], 0, $intMaxLen);
609 if ($arControl[
'FIELD_TYPE'] ==
'date')
611 $strFormat =
'SHORT';
617 $intOffset = $intTimeOffset;
619 $boolError = static::ConvertDateTime2Int($arOneCondition[
'value'], $strFormat, $intOffset);
628 $arOneCondition[
'value'] = array_values(array_unique($arOneCondition[
'value']));
634 if (isset($arControl[
'PHP_VALUE']) && !empty($arControl[
'PHP_VALUE'][
'VALIDATE']))
636 $arValidate = static::Validate($arOneCondition,
$arParams, $arControl, $boolShow);
637 if ($arValidate ===
false)
643 $arValues[
'value'] = $arValidate[
'values'];
644 if (isset($arValidate[
'labels']))
645 $arLabels[
'value'] = $arValidate[
'labels'];
650 $arValues[
'value'] = $arOneCondition[
'value'];
659 'controlId' => $arControl[
'ID'],
662 if (!empty($arLabels))
670 $arResult[
'err_cond_mess'] = implode(
'. ', $arMsg);
678 return (!$boolError ?
$arResult :
false);
684 static $userNameFormat =
null;
686 $boolShow = ($boolShow ===
true);
694 if (!(isset($arControl[
'PHP_VALUE']) && isset($arControl[
'PHP_VALUE'][
'VALIDATE']) && !empty($arControl[
'PHP_VALUE'][
'VALIDATE'])))
704 $boolMulti = is_array($arOneCondition[
'value']);
705 switch($arControl[
'PHP_VALUE'][
'VALIDATE'])
708 $rsItems = CIBlockElement::GetList(
710 array(
'ID' => $arOneCondition[
'value']),
717 $arCheckResult =
array();
718 while ($arItem = $rsItems->Fetch())
720 $arCheckResult[(int)$arItem[
'ID']] = $arItem[
'NAME'];
722 if (!empty($arCheckResult))
724 $arResult[
'values'] = array_keys($arCheckResult);
725 $arResult[
'labels'] = array_values($arCheckResult);
730 $arMsg[] =
Loc::getMessage(
'BT_MOD_COND_ERR_CHECK_DATA_ELEMENT_ABSENT_MULTI');
735 if ($arItem = $rsItems->Fetch())
737 $arResult[
'values'] = (int)$arItem[
'ID'];
743 $arMsg[] =
Loc::getMessage(
'BT_MOD_COND_ERR_CHECK_DATA_ELEMENT_ABSENT');
748 $rsSections = CIBlockSection::GetList(
750 array(
'ID' => $arOneCondition[
'value']),
756 $arCheckResult =
array();
757 while ($arSection = $rsSections->Fetch())
759 $arCheckResult[(int)$arSection[
'ID']] = $arSection[
'NAME'];
761 if (!empty($arCheckResult))
763 $arResult[
'values'] = array_keys($arCheckResult);
764 $arResult[
'labels'] = array_values($arCheckResult);
769 $arMsg[] =
Loc::getMessage(
'BT_MOD_COND_ERR_CHECK_DATA_SECTION_ABSENT_MULTI');
774 if ($arSection = $rsSections->Fetch())
776 $arResult[
'values'] = (int)$arSection[
'ID'];
777 $arResult[
'labels'] = $arSection[
'NAME'];
782 $arMsg[] =
Loc::getMessage(
'BT_MOD_COND_ERR_CHECK_DATA_SECTION_ABSENT');
789 $arCheckResult =
array();
793 if ($strName !==
false && $strName !==
null)
800 if (!empty($arCheckResult))
802 $arResult[
'values'] = array_keys($arCheckResult);
803 $arResult[
'labels'] = array_values($arCheckResult);
808 $arMsg[] =
Loc::getMessage(
'BT_MOD_COND_ERR_CHECK_DATA_IBLOCK_ABSENT_MULTI');
813 $strName = CIBlock::GetArrayByID($arOneCondition[
'value'],
'NAME');
814 if ($strName !==
false && $strName !==
null)
816 $arResult[
'values'] = $arOneCondition[
'value'];
822 $arMsg[] =
Loc::getMessage(
'BT_MOD_COND_ERR_CHECK_DATA_IBLOCK_ABSENT');
828 'select' =>
array(
'ID',
'VALUE'),
829 'filter' =>
array(
'@ID' => $arOneCondition[
'value'])
833 $checkResult =
array();
835 $checkResult[$row[
'ID']] = $row[
'VALUE'];
837 if (!empty($checkResult))
839 $arResult[
'values'] = array_keys($checkResult);
840 $arResult[
'labels'] = array_values($checkResult);
845 $arMsg[] =
Loc::getMessage(
'BT_MOD_COND_ERR_CHECK_DATA_ENUM_VALUE_ABSENT_MULTI');
860 $arMsg[] =
Loc::getMessage(
'BT_MOD_COND_ERR_CHECK_DATA_ENUM_VALUE_ABSENT');
866 if ($userNameFormat ===
null)
867 $userNameFormat = CSite::GetNameFormat(
true);
870 $arCheckResult =
array();
872 'select' =>
array(
'ID',
'LOGIN',
'NAME',
'LAST_NAME',
'SECOND_NAME',
'EMAIL'),
873 'filter' =>
array(
'ID' => $arOneCondition[
'value'])
875 while (
$user = $userIterator->fetch())
878 $arCheckResult[
$user[
'ID']] = CUser::FormatName($userNameFormat,
$user);
880 if (!empty($arCheckResult))
882 $arResult[
'values'] = array_keys($arCheckResult);
883 $arResult[
'labels'] = array_values($arCheckResult);
888 $arMsg[] =
Loc::getMessage(
'BT_MOD_COND_ERR_CHECK_DATA_USER_ABSENT_MULTI');
894 'select' =>
array(
'ID',
'LOGIN',
'NAME',
'LAST_NAME',
'SECOND_NAME',
'EMAIL'),
895 'filter' =>
array(
'ID' => $arOneCondition[
'value'])
897 if (
$user = $userIterator->fetch())
910 if (isset($arControl[
'JS_VALUE']) && isset($arControl[
'JS_VALUE'][
'values']) && !empty($arControl[
'JS_VALUE'][
'values']))
914 $arCheckResult =
array();
915 foreach ($arOneCondition[
'value'] as &$strValue)
917 if (isset($arControl[
'JS_VALUE'][
'values'][$strValue]))
918 $arCheckResult[] = $strValue;
920 if (isset($strValue))
922 if (!empty($arCheckResult))
929 $arMsg[] =
Loc::getMessage(
'BT_MOD_COND_ERR_CHECK_DATA_LIST_ABSENT_MULTI');
934 if (isset($arControl[
'JS_VALUE'][
'values'][$arOneCondition[
'value']]))
936 $arResult[
'values'] = $arOneCondition[
'value'];
955 $boolMulti = is_array($arOneCondition[
'value']);
956 switch($arControl[
'PHP_VALUE'][
'VALIDATE'])
959 $rsItems = CIBlockElement::GetList(
array(),
array(
'ID' => $arOneCondition[
'value']),
false,
false,
array(
'ID'));
962 $arCheckResult =
array();
963 while ($arItem = $rsItems->Fetch())
965 $arCheckResult[] = (int)$arItem[
'ID'];
967 if (!empty($arCheckResult))
978 if ($arItem = $rsItems->Fetch())
980 $arResult[
'values'] = (int)$arItem[
'ID'];
989 $rsSections = CIBlockSection::GetList(
array(),
array(
'ID' => $arOneCondition[
'value']),
false,
array(
'ID'));
992 $arCheckResult =
array();
993 while ($arSection = $rsSections->Fetch())
995 $arCheckResult[] = (int)$arSection[
'ID'];
997 if (!empty($arCheckResult))
1008 if ($arSection = $rsSections->Fetch())
1010 $arResult[
'values'] = (int)$arSection[
'ID'];
1021 $arCheckResult =
array();
1024 $strName = CIBlock::GetArrayByID(
$intIBlockID,
'NAME');
1025 if ($strName !==
false && $strName !==
null)
1032 if (!empty($arCheckResult))
1043 $strName = CIBlock::GetArrayByID($arOneCondition[
'value'],
'NAME');
1044 if ($strName !==
false && $strName !==
null)
1046 $arResult[
'values'] = $arOneCondition[
'value'];
1056 'select' =>
array(
'ID'),
1057 'filter' =>
array(
'@ID' => $arOneCondition[
'value'])
1061 $checkResult =
array();
1063 $checkResult[] = (int)$row[
'ID'];
1065 if (!empty($checkResult))
1069 unset($checkResult);
1085 $arCheckResult =
array();
1087 'select' =>
array(
'ID'),
1088 'filter' =>
array(
'ID' => $arOneCondition[
'value'])
1090 while (
$user = $userIterator->fetch())
1092 $arCheckResult[] = (int)
$user[
'ID'];
1094 if (!empty($arCheckResult))
1106 'select' =>
array(
'ID'),
1107 'filter' =>
array(
'ID' => $arOneCondition[
'value'])
1109 if (
$user = $userIterator->fetch())
1120 if (isset($arControl[
'JS_VALUE']) && isset($arControl[
'JS_VALUE'][
'values']) && !empty($arControl[
'JS_VALUE'][
'values']))
1124 $arCheckResult =
array();
1125 foreach ($arOneCondition[
'value'] as &$strValue)
1127 if (isset($arControl[
'JS_VALUE'][
'values'][$strValue]))
1128 $arCheckResult[] = $strValue;
1130 if (isset($strValue))
1132 if (!empty($arCheckResult))
1143 if (isset($arControl[
'JS_VALUE'][
'values'][$arOneCondition[
'value']]))
1145 $arResult[
'values'] = $arOneCondition[
'value'];
1173 return (!$boolError ?
$arResult :
false);
1179 $boolShow = (
true === $boolShow);
1181 $boolFatalError =
false;
1185 $arLabels =
array();
1187 static $intTimeOffset =
false;
1188 if ($intTimeOffset ===
false)
1189 $intTimeOffset = CTimeZone::GetOffset();
1191 if (!isset($arControl[
'ATOMS']) || empty($arControl[
'ATOMS']) || !is_array($arControl[
'ATOMS']))
1193 $boolFatalError =
true;
1199 $boolValidate =
false;
1202 foreach ($arControl[
'ATOMS'] as &$arOneAtom)
1204 $boolAtomError =
false;
1205 $strID = $arOneAtom[
'ATOM'][
'ID'];
1207 if (!isset($arOneCondition[$strID]))
1209 $boolAtomError =
true;
1213 $boolMulti = is_array($arOneCondition[$strID]);
1214 switch ($arOneAtom[
'ATOM'][
'FIELD_TYPE'])
1219 foreach ($arOneCondition[$strID] as &$intOneValue)
1221 $intOneValue = (int)$intOneValue;
1223 if (isset($intOneValue))
1224 unset($intOneValue);
1228 $arOneCondition[$strID] = (int)$arOneCondition[$strID];
1234 foreach ($arOneCondition[$strID] as &$dblOneValue)
1236 $dblOneValue = (float)$dblOneValue;
1238 if (isset($dblOneValue))
1239 unset($dblOneValue);
1243 $arOneCondition[$strID] = doubleval($arOneCondition[$strID]);
1249 foreach ($arOneCondition[$strID] as &$dblOneValue)
1251 if ($dblOneValue !==
'')
1252 $dblOneValue = (float)$dblOneValue;
1254 if (isset($dblOneValue))
1255 unset($dblOneValue);
1259 if ($arOneCondition[$strID] !==
'')
1260 $arOneCondition[$strID] = (float)$arOneCondition[$strID];
1266 foreach ($arOneCondition[$strID] as &$strOneValue)
1268 $strOneValue = mb_substr($strOneValue, 0, 1);
1270 if (isset($strOneValue))
1271 unset($strOneValue);
1275 $arOneCondition[$strID] = mb_substr($arOneCondition[$strID], 0, 1);
1279 $intMaxLen = (int)(isset($arOneAtom[
'ATOM'][
'FIELD_LENGTH']) ? $arOneAtom[
'ATOM'][
'FIELD_LENGTH'] : 255);
1280 if ($intMaxLen <= 0)
1284 foreach ($arOneCondition[$strID] as &$strOneValue)
1286 $strOneValue = mb_substr($strOneValue, 0, $intMaxLen);
1288 if (isset($strOneValue))
1289 unset($strOneValue);
1293 $arOneCondition[$strID] = mb_substr($arOneCondition[$strID], 0, $intMaxLen);
1300 if ($arOneAtom[
'ATOM'][
'FIELD_TYPE'] ==
'date')
1302 $strFormat =
'SHORT';
1307 $strFormat =
'FULL';
1308 $intOffset = $intTimeOffset;
1310 $boolAtomError = static::ConvertInt2DateTime($arOneCondition[$strID], $strFormat, $intOffset);
1313 $boolAtomError =
true;
1316 if (!$boolAtomError)
1319 $arOneCondition[$strID] = array_values(array_unique($arOneCondition[$strID]));
1320 $arValues[$strID] = $arOneCondition[$strID];
1321 if (isset($arOneAtom[
'ATOM'][
'VALIDATE']) && !empty($arOneAtom[
'ATOM'][
'VALIDATE']))
1322 $boolValidate =
true;
1331 if (isset($arOneAtom))
1339 if ($arValidate ===
false)
1345 if (isset($arValidate[
'err_cond']) && $arValidate[
'err_cond'] ==
'Y')
1348 if (isset($arValidate[
'err_cond_mess']) && !empty($arValidate[
'err_cond_mess']))
1349 $arMsg = array_merge($arMsg, $arValidate[
'err_cond_mess']);
1354 if (isset($arValidate[
'labels']))
1355 $arLabels = $arValidate[
'labels'];
1363 foreach ($arControl[
'ATOMS'] as &$arOneAtom)
1365 $boolAtomError =
false;
1366 $strID = $arOneAtom[
'ATOM'][
'ID'];
1367 $strName = $arOneAtom[
'JS'][
'name'];
1369 if (!isset($arOneCondition[$strName]))
1371 $boolAtomError =
true;
1375 $boolMulti = is_array($arOneCondition[$strName]);
1377 if (!$boolAtomError)
1379 switch ($arOneAtom[
'ATOM'][
'FIELD_TYPE'])
1384 foreach ($arOneCondition[$strName] as &$intOneValue)
1386 $intOneValue = (int)$intOneValue;
1388 if (isset($intOneValue))
1389 unset($intOneValue);
1393 $arOneCondition[$strName] = (int)$arOneCondition[$strName];
1399 foreach ($arOneCondition[$strName] as &$dblOneValue)
1401 $dblOneValue = (float)$dblOneValue;
1403 if (isset($dblOneValue))
1404 unset($dblOneValue);
1408 $arOneCondition[$strName] = (float)$arOneCondition[$strName];
1414 foreach ($arOneCondition[$strName] as &$dblOneValue)
1416 if ($dblOneValue !==
'')
1417 $dblOneValue = (float)$dblOneValue;
1419 if (isset($dblOneValue))
1420 unset($dblOneValue);
1424 if ($arOneCondition[$strName] !==
'')
1426 $arOneCondition[$strName] = (float)$arOneCondition[$strName];
1433 foreach ($arOneCondition[$strName] as &$strOneValue)
1435 $strOneValue = mb_substr($strOneValue, 0, 1);
1437 if (isset($strOneValue))
1438 unset($strOneValue);
1442 $arOneCondition[$strName] = mb_substr($arOneCondition[$strName], 0, 1);
1446 $intMaxLen = (int)(isset($arOneAtom[
'ATOM'][
'FIELD_LENGTH']) ? $arOneAtom[
'ATOM'][
'FIELD_LENGTH'] : 255);
1447 if ($intMaxLen <= 0)
1451 foreach ($arOneCondition[$strName] as &$strOneValue)
1453 $strOneValue = mb_substr($strOneValue, 0, $intMaxLen);
1455 if (isset($strOneValue))
1456 unset($strOneValue);
1460 $arOneCondition[$strName] = mb_substr($arOneCondition[$strName], 0, $intMaxLen);
1467 if ($arOneAtom[
'ATOM'][
'FIELD_TYPE'] ==
'date')
1469 $strFormat =
'SHORT';
1474 $strFormat =
'FULL';
1475 $intOffset = $intTimeOffset;
1477 $boolAtomError = static::ConvertDateTime2Int($arOneCondition[$strName], $strFormat, $intOffset);
1480 $boolAtomError =
true;
1482 if (!$boolAtomError)
1485 $arOneCondition[$strName] = array_values(array_unique($arOneCondition[$strName]));
1486 $arValues[$strID] = $arOneCondition[$strName];
1487 if (isset($arOneAtom[
'ATOM'][
'VALIDATE']) && !empty($arOneAtom[
'ATOM'][
'VALIDATE']))
1488 $boolValidate =
true;
1498 if (isset($arOneAtom))
1506 if ($arValidate ===
false)
1513 if (isset($arValidate[
'labels']))
1514 $arLabels = $arValidate[
'labels'];
1525 'controlId' => $arControl[
'ID'],
1528 if (!empty($arLabels))
1533 if ($boolFatalError)
1536 $arResult[
'err_cond_mess'] = implode(
'. ', $arMsg);
1542 return (!$boolError ?
$arValues :
false);
1548 static $userNameFormat =
null;
1550 $boolShow = ($boolShow ===
true);
1555 'values' =>
array(),
1556 'labels' =>
array(),
1560 if (!isset($arControl[
'ATOMS']) || empty($arControl[
'ATOMS']) || !is_array($arControl[
'ATOMS']))
1569 foreach ($arControl[
'ATOMS'] as &$arOneAtom)
1571 $strID = $arOneAtom[
'ATOM'][
'ID'];
1572 if (!isset($arOneAtom[
'ATOM'][
'VALIDATE']) || empty($arOneAtom[
'ATOM'][
'VALIDATE']))
1577 switch ($arOneAtom[
'ATOM'][
'VALIDATE'])
1580 if (isset($arOneAtom[
'JS']) && isset($arOneAtom[
'JS'][
'values']) && !empty($arOneAtom[
'JS'][
'values']))
1584 $arCheckResult =
array();
1585 foreach (
$arValues[$strID] as &$strValue)
1587 if (isset($arOneAtom[
'JS'][
'values'][$strValue]))
1588 $arCheckResult[] = $strValue;
1590 if (isset($strValue))
1592 if (!empty($arCheckResult))
1594 $arResult[
'values'][$strID] = $arCheckResult;
1599 $arMsg[] =
Loc::getMessage(
'BT_MOD_COND_ERR_CHECK_DATA_LIST_ABSENT_MULTI');
1604 if (isset($arOneAtom[
'JS'][
'values'][
$arValues[$strID]]))
1624 $arCheckResult =
array();
1625 while ($arItem = $rsItems->Fetch())
1627 $arCheckResult[(int)$arItem[
'ID']] = $arItem[
'NAME'];
1629 if (!empty($arCheckResult))
1631 $arResult[
'values'][$strID] = array_keys($arCheckResult);
1632 $arResult[
'labels'][$strID] = array_values($arCheckResult);
1637 $arMsg[] =
Loc::getMessage(
'BT_MOD_COND_ERR_CHECK_DATA_ELEMENT_ABSENT_MULTI');
1642 if ($arItem = $rsItems->Fetch())
1644 $arResult[
'values'][$strID] = (int)$arItem[
'ID'];
1645 $arResult[
'labels'][$strID] = $arItem[
'NAME'];
1650 $arMsg[] =
Loc::getMessage(
'BT_MOD_COND_ERR_CHECK_DATA_ELEMENT_ABSENT');
1658 $arCheckResult =
array();
1659 while ($arSection = $rsSections->Fetch())
1661 $arCheckResult[(int)$arSection[
'ID']] = $arSection[
'NAME'];
1663 if (!empty($arCheckResult))
1665 $arResult[
'values'][$strID] = array_keys($arCheckResult);
1666 $arResult[
'labels'][$strID] = array_values($arCheckResult);
1671 $arMsg[] =
Loc::getMessage(
'BT_MOD_COND_ERR_CHECK_DATA_SECTION_ABSENT_MULTI');
1676 if ($arSection = $rsSections->Fetch())
1678 $arResult[
'values'][$strID] = (int)$arSection[
'ID'];
1679 $arResult[
'labels'][$strID] = $arSection[
'NAME'];
1684 $arMsg[] =
Loc::getMessage(
'BT_MOD_COND_ERR_CHECK_DATA_SECTION_ABSENT');
1691 $arCheckResult =
array();
1694 $strName = CIBlock::GetArrayByID(
$intIBlockID,
'NAME');
1695 if ($strName !==
false && $strName !==
null)
1702 if (!empty($arCheckResult))
1704 $arResult[
'values'][$strID] = array_keys($arCheckResult);
1705 $arResult[
'labels'][$strID] = array_values($arCheckResult);
1710 $arMsg[] =
Loc::getMessage(
'BT_MOD_COND_ERR_CHECK_DATA_IBLOCK_ABSENT_MULTI');
1715 $strName = CIBlock::GetArrayByID(
$arValues[$strID],
'NAME');
1716 if ($strName !==
false && $strName !==
null)
1724 $arMsg[] =
Loc::getMessage(
'BT_MOD_COND_ERR_CHECK_DATA_IBLOCK_ABSENT');
1729 if ($userNameFormat ===
null)
1730 $userNameFormat = CSite::GetNameFormat(
true);
1733 $arCheckResult =
array();
1735 'select' =>
array(
'ID',
'LOGIN',
'NAME',
'LAST_NAME',
'SECOND_NAME',
'EMAIL'),
1738 while (
$user = $userIterator->fetch())
1741 $arCheckResult[
$user[
'ID']] = CUser::FormatName($userNameFormat,
$user);
1743 if (!empty($arCheckResult))
1745 $arResult[
'values'][$strID] = array_keys($arCheckResult);
1746 $arResult[
'labels'][$strID] = array_values($arCheckResult);
1751 $arMsg[] =
Loc::getMessage(
'BT_MOD_COND_ERR_CHECK_DATA_USER_ABSENT_MULTI');
1757 'select' =>
array(
'ID',
'LOGIN',
'NAME',
'LAST_NAME',
'SECOND_NAME',
'EMAIL'),
1760 if (
$user = $userIterator->fetch())
1774 if (isset($arOneAtom))
1779 foreach ($arControl[
'ATOMS'] as &$arOneAtom)
1781 $strID = $arOneAtom[
'ATOM'][
'ID'];
1782 if (!isset($arOneAtom[
'ATOM'][
'VALIDATE']) || empty($arOneAtom[
'ATOM'][
'VALIDATE']))
1787 switch ($arOneAtom[
'ATOM'][
'VALIDATE'])
1790 if (isset($arOneAtom[
'JS']) && isset($arOneAtom[
'JS'][
'values']) && !empty($arOneAtom[
'JS'][
'values']))
1794 $arCheckResult =
array();
1795 foreach (
$arValues[$strID] as &$strValue)
1797 if (isset($arOneAtom[
'JS'][
'values'][$strValue]))
1798 $arCheckResult[] = $strValue;
1800 if (isset($strValue))
1802 if (!empty($arCheckResult))
1804 $arResult[
'values'][$strID] = $arCheckResult;
1813 if (isset($arOneAtom[
'JS'][
'values'][
$arValues[$strID]]))
1832 $arCheckResult =
array();
1833 while ($arItem = $rsItems->Fetch())
1835 $arCheckResult[] = (int)$arItem[
'ID'];
1837 if (!empty($arCheckResult))
1839 $arResult[
'values'][$strID] = $arCheckResult;
1848 if ($arItem = $rsItems->Fetch())
1850 $arResult[
'values'][$strID] = (int)$arItem[
'ID'];
1862 $arCheckResult =
array();
1863 while ($arSection = $rsSections->Fetch())
1865 $arCheckResult[] = (int)$arSection[
'ID'];
1867 if (!empty($arCheckResult))
1869 $arResult[
'values'][$strID] = $arCheckResult;
1878 if ($arSection = $rsSections->Fetch())
1880 $arResult[
'values'][$strID] = (int)$arSection[
'ID'];
1891 $arCheckResult =
array();
1894 $strName = CIBlock::GetArrayByID(
$intIBlockID,
'NAME');
1895 if ($strName !==
false && $strName !==
null)
1902 if (!empty($arCheckResult))
1904 $arResult[
'values'][$strID] = $arCheckResult;
1913 $strName = CIBlock::GetArrayByID(
$arValues[$strID],
'NAME');
1914 if ($strName !==
false && $strName !==
null)
1927 $arCheckResult =
array();
1929 'select' =>
array(
'ID'),
1932 while (
$user = $userIterator->fetch())
1934 $arCheckResult[] = (int)
$user[
'ID'];
1936 if (!empty($arCheckResult))
1938 $arResult[
'values'][$strID] = $arCheckResult;
1948 'select' =>
array(
'ID'),
1951 if (
$user = $userIterator->fetch())
1953 $arCheckResult[] = (int)
$user[
'ID'];
1963 if (isset($arOneAtom))
1979 return (!$boolError ?
$arResult :
false);
1985 $boolResult =
false;
1986 if (!is_array($arField))
1987 $arField =
array($arField);
1988 if (!empty($arField))
1990 foreach ($arField as &$mxOneValue)
1992 if ($mxOneValue ===
null || $mxOneValue ===
false || $mxOneValue ===
'')
1994 if ($mxOneValue > $mxValue)
2000 if (isset($mxOneValue))
2008 $boolResult =
false;
2009 if (!is_array($arField))
2010 $arField =
array($arField);
2011 if (!empty($arField))
2013 foreach ($arField as &$mxOneValue)
2015 if ($mxOneValue ===
null || $mxOneValue ===
false || $mxOneValue ===
'')
2017 if ($mxOneValue < $mxValue)
2023 if (isset($mxOneValue))
2031 $boolResult =
false;
2032 if (!is_array($arField))
2033 $arField =
array($arField);
2034 if (!empty($arField))
2036 foreach ($arField as &$mxOneValue)
2038 if ($mxOneValue ===
null || $mxOneValue ===
false || $mxOneValue ===
'')
2040 if ($mxOneValue >= $mxValue)
2046 if (isset($mxOneValue))
2054 $boolResult =
false;
2055 if (!is_array($arField))
2056 $arField =
array($arField);
2057 if (!empty($arField))
2059 foreach ($arField as &$mxOneValue)
2061 if ($mxOneValue ===
null || $mxOneValue ===
false || $mxOneValue ===
'')
2063 if ($mxOneValue <= $mxValue)
2069 if (isset($mxOneValue))
2077 $boolResult =
false;
2078 if (!is_array($arField))
2079 $arField =
array($arField);
2080 if (!empty($arField))
2082 foreach ($arField as &$mxOneValue)
2084 if (mb_strpos($mxOneValue, $mxValue) !==
false)
2090 if (isset($mxOneValue))
2099 if (!is_array($arField))
2100 $arField =
array($arField);
2101 if (!empty($arField))
2103 foreach ($arField as &$mxOneValue)
2105 if (mb_strpos($mxOneValue, $mxValue) !==
false)
2107 $boolResult =
false;
2111 if (isset($mxOneValue))
2119 $boolLocalError =
false;
2120 if (is_array($mxValues))
2122 if (!empty($mxValues))
2125 foreach ($mxValues as &$strOneValue)
2127 $strOneValue = trim((
string)$strOneValue);
2128 if ($strOneValue !==
'')
2131 if (isset($strOneValue))
2132 unset($strOneValue);
2134 if (empty($mxValues))
2135 $boolLocalError =
true;
2139 $boolLocalError =
true;
2144 $mxValues = trim((
string)$mxValues);
2145 if ($mxValues ===
'')
2147 $boolLocalError =
true;
2150 return $boolLocalError;
2157 $boolValueError =
false;
2158 if (is_array($mxValues))
2160 foreach ($mxValues as &$strValue)
2162 if ($strValue.
'!' == (
int)$strValue.
'!')
2164 $strValue = ConvertTimeStamp($strValue + $intOffset, $strFormat);
2166 if (!
$DB->IsDate($strValue,
false,
false, $strFormat))
2168 $boolValueError =
true;
2171 if (isset($strValue))
2176 if ($mxValues.
'!' == (
int)$mxValues.
'!')
2178 $mxValues = ConvertTimeStamp($mxValues + $intOffset, $strFormat);
2180 $boolValueError = !
$DB->IsDate($mxValues,
false,
false, $strFormat);
2182 return $boolValueError;
2190 if (is_array($mxValues))
2192 $boolLocalErr =
false;
2194 foreach ($mxValues as &$strValue)
2196 if ($strValue.
'!' != (
int)$strValue.
'!')
2198 if (!
$DB->IsDate($strValue,
false,
false, $strFormat))
2201 $boolLocalErr =
true;
2208 $arLocal[] = $strValue;
2211 if (isset($strValue))
2214 $mxValues = $arLocal;
2218 if ($mxValues.
'!' != (
int)$mxValues.
'!')
2220 if (!
$DB->IsDate($mxValues,
false,
false, $strFormat))
2244 $extendedMode = ($extendedMode ===
true);
2247 foreach (array_keys($atoms) as $index)
2249 foreach (array_keys($atoms[$index]) as $atomId)
2251 $atoms[$index][$atomId] = $atoms[$index][$atomId][
'JS'];
2254 unset($atomId, $index);
2257 if ($controlId ===
false)
2260 $controlId = (string)$controlId;
2261 return (isset($atoms[$controlId]) ? $atoms[$controlId] :
false);
2266 if (empty($controls))
2269 if ($controlId ===
false)
2272 $controlId = (string)$controlId;
2273 return (isset($controls[$controlId]) ? $controls[$controlId] :
false);
2281 $strClassName = get_called_class();
2284 'GetControlShow' =>
array($strClassName,
'GetControlShow'),
2285 'GetConditionShow' =>
array($strClassName,
'GetConditionShow'),
2286 'IsGroup' =>
array($strClassName,
'IsGroup'),
2287 'Parse' =>
array($strClassName,
'Parse'),
2288 'Generate' =>
array($strClassName,
'Generate'),
2289 'ApplyValues' =>
array($strClassName,
'ApplyValues'),
2290 'InitParams' =>
array($strClassName,
'InitParams'),
2291 'CONTROLS' => static::GetControls()
2299 $arControl = static::GetControls(
$arParams[
'ID']);
2300 if ($arControl ===
false)
2307 public static function Parse($arOneCondition)
2309 if (!isset($arOneCondition[
'controlId']))
2311 $arControl = static::GetControls($arOneCondition[
'controlId']);
2312 if ($arControl ===
false)
2314 return static::Check($arOneCondition, $arOneCondition, $arControl,
false);
2320 $resultValues =
array();
2323 if (is_string($arControl))
2325 $arControl = static::GetControls($arControl);
2327 $boolError = !is_array($arControl);
2331 $arValues = static::Check($arOneCondition, $arOneCondition, $arControl,
false);
2336 $boolError = !isset($arControl[
'MULTIPLE']);
2341 $arLogic = static::SearchLogic(
$arValues[
'logic'], $arControl[
'LOGIC']);
2342 if (!isset($arLogic[
'OP'][$arControl[
'MULTIPLE']]) || empty($arLogic[
'OP'][$arControl[
'MULTIPLE']]))
2348 $strField =
$arParams[
'FIELD'].
'[\''.$arControl[
'FIELD'].
'\']
';
2349 switch ($arControl['FIELD_TYPE
'])
2353 if (is_array($arValues['value
']))
2355 if (!isset($arLogic['MULTI_SEP
']))
2361 foreach ($arValues['value
'] as &$value)
2363 $resultValues[] = str_replace(
2364 array('#FIELD#
', '#VALUE#
'),
2365 array($strField, $value),
2366 $arLogic['OP
'][$arControl['MULTIPLE
']]
2370 $strResult = '(
'.implode($arLogic['MULTI_SEP
'], $resultValues).')
';
2371 unset($resultValues);
2376 $strResult = str_replace(
2377 array('#FIELD#
', '#VALUE#
'),
2378 array($strField, $arValues['value
']),
2379 $arLogic['OP
'][$arControl['MULTIPLE
']]
2386 if (is_array($arValues['value
']))
2392 $strResult = str_replace(
2393 array('#FIELD#
', '#VALUE#
'),
2394 array($strField, '"'.EscapePHPString($arValues['value']).'"'),
2395 $arLogic['OP
'][$arControl['MULTIPLE
']]
2401 if (is_array($arValues['value
']))
2407 $strResult = str_replace(
2408 array('#FIELD#
', '#VALUE#
'),
2409 array($strField, $arValues['value
']),
2410 $arLogic['OP
'][$arControl['MULTIPLE
']]
2418 return (!$boolError ? $strResult : false);
2425 public static function GetControls($strControlID = false)
2431class CGlobalCondCtrlAtoms extends CGlobalCondCtrl
2436 public static function GetControlDescr()
2438 $className = get_called_class();
2439 $controls = static::GetControls();
2440 if (empty($controls) || !is_array($controls))
2443 foreach ($controls as &$oneControl)
2445 unset($oneControl['ATOMS
']);
2458 unset($oneControl, $controls, $className);
2462 public static function GetConditionShow($params)
2464 if (!isset($params['ID
']))
2466 $atoms = static::GetAtomsEx($params['ID
'], true);
2470 'ID
' => $params['ID
'],
2474 return static::CheckAtoms($params['DATA
'], $params, $control, true);
2477 public static function Parse($condition)
2479 if (!isset($condition['controlId
']))
2481 $atoms = static::GetAtomsEx($condition['controlId
'], true);
2485 'ID
' => $condition['controlId
'],
2489 return static::CheckAtoms($condition, $condition, $control, false);
2492 public static function Generate($condition, $params, $control, $childrens = false)
2497 public static function GetAtomsEx($controlId = false, $extendedMode = false)
2502 public static function GetAtoms()
2504 return static::GetAtomsEx(false, false);
2510 public static function GetControlID()
2512 $atoms = static::GetAtomsEx(false, true);
2513 return (empty($atoms) ? array() : array_keys($atoms));
2520 public static function GetControls($strControlID = false)
2525 public static function GetControlShow($params)
2527 $controls = static::GetControls();
2528 if (empty($controls) || !is_array($controls))
2531 foreach ($controls as $controlId => $data)
2534 'controlId
' => $data['ID
'],
2536 'label
' => $data['LABEL
'],
2537 'showIn
' => static::GetShowIn($params['SHOW_IN_GROUPS
']),
2538 'control
' => array()
2540 if (isset($data['PREFIX
']))
2541 $row['control
'][] = $data['PREFIX
'];
2542 if (empty($row['control
']))
2544 $row['control
'] = array_values($data['ATOMS
']);
2548 foreach ($data['ATOMS
'] as &$atom)
2549 $row['control
'][] = $atom;
2555 unset($controlId, $data, $controls);
2560class CGlobalCondCtrlGroup extends CGlobalCondCtrl
2562 public static function GetControlDescr()
2564 $className = get_called_class();
2566 'ID
' => static::GetControlID(),
2577 public static function GetControlShow($arParams)
2580 'controlId
' => static::GetControlID(),
2582 'label
' => Loc::getMessage('BT_CLOBAL_COND_GROUP_LABEL
'),
2583 'defaultText
' => Loc::getMessage('BT_CLOBAL_COND_GROUP_DEF_TEXT
'),
2584 'showIn
' => static::GetShowIn($arParams['SHOW_IN_GROUPS
']),
2585 'visual
' => static::GetVisual(),
2586 'control
' => array_values(static::GetAtoms())
2590 public static function GetConditionShow($arParams)
2594 foreach (static::GetAtoms() as $atom)
2597 !isset($arParams['DATA
'][$atom['id']])
2598 || !is_string($arParams['DATA
'][$atom['id']])
2599 || !isset($atom['values
'][$arParams['DATA
'][$atom['id']]])
2603 $values[$atom['id']] = ($error ? '' : $arParams['DATA
'][$atom['id']]);
2608 'id' => $arParams['COND_NUM
'],
2609 'controlId
' => static::GetControlID(),
2613 $result['err_cond
'] = 'Y
';
2622 public static function GetControlID()
2627 public static function GetAtoms()
2632 'name
' => 'aggregator
',
2635 'AND
' => Loc::getMessage('BT_CLOBAL_COND_GROUP_SELECT_ALL
'),
2636 'OR
' => Loc::getMessage('BT_CLOBAL_COND_GROUP_SELECT_ANY
')
2638 'defaultText
' => Loc::getMessage('BT_CLOBAL_COND_GROUP_SELECT_DEF
'),
2639 'defaultValue
' => 'AND
',
2640 'first_option
' => '...
'
2647 'True
' => Loc::getMessage('BT_CLOBAL_COND_GROUP_SELECT_TRUE
'),
2648 'False
' => Loc::getMessage('BT_CLOBAL_COND_GROUP_SELECT_FALSE
')
2650 'defaultText
' => Loc::getMessage('BT_CLOBAL_COND_GROUP_SELECT_DEF
'),
2651 'defaultValue
' => 'True
',
2652 'first_option
' => '...
'
2657 public static function GetVisual()
2660 'controls
' => array(
2684 'style' => 'condition-logic-and
',
2685 'message
' => Loc::getMessage('BT_CLOBAL_COND_GROUP_LOGIC_AND
')
2688 'style' => 'condition-logic-and
',
2689 'message
' => Loc::getMessage('BT_CLOBAL_COND_GROUP_LOGIC_NOT_AND
')
2692 'style' => 'condition-logic-or
',
2693 'message
' => Loc::getMessage('BT_CLOBAL_COND_GROUP_LOGIC_OR
')
2696 'style' => 'condition-logic-or
',
2697 'message
' => Loc::getMessage('BT_CLOBAL_COND_GROUP_LOGIC_NOT_OR
')
2703 public static function IsGroup($strControlID = false)
2708 public static function Parse($arOneCondition)
2712 foreach (static::GetAtoms() as $atom)
2715 !isset($arOneCondition[$atom['name
']])
2716 || !is_string($arOneCondition[$atom['name
']])
2717 || !isset($atom['values
'][$arOneCondition[$atom['name
']]])
2723 $result[$atom['id']] = $arOneCondition[$atom['name
']];
2727 return (!$error ? $result : false);
2730 public static function Generate($arOneCondition, $arParams, $arControl, $arSubs = false)
2735 foreach (static::GetAtoms() as $atom)
2738 !isset($arOneCondition[$atom['id']])
2739 || !is_string($arOneCondition[$atom['id']])
2740 || !isset($atom['values
'][$arOneCondition[$atom['id']]])
2746 if (!isset($arSubs) || !is_array($arSubs))
2750 elseif (empty($arSubs))
2757 if ('AND
' == $arOneCondition['All
'])
2761 $itemPrefix = ($arOneCondition['True
'] == 'True
' ? '' : '!
');
2766 if ($arOneCondition['True
'] == 'True
')
2778 $commandLine = $itemPrefix.implode($logic.$itemPrefix, $arSubs);
2780 $commandLine = $prefix.'(
'.$commandLine.')
';
2781 if ($commandLine != '')
2782 $commandLine = '(
'.$commandLine.')
';
2783 $result = $commandLine;
2784 unset($commandLine);
2790 public static function ApplyValues($arOneCondition, $arControl)
2792 return (isset($arOneCondition['True
']) && $arOneCondition['True
'] == 'True
');
2796class CCatalogCondCtrl extends CGlobalCondCtrl
2800class CCatalogCondCtrlComplex extends CGlobalCondCtrlComplex
2804class CCatalogCondCtrlGroup extends CGlobalCondCtrlGroup
2806 public static function GetControlDescr()
2808 $description = parent::GetControlDescr();
2809 $description['SORT
'] = 100;
2810 return $description;
2814class CCatalogCondCtrlIBlockFields extends CCatalogCondCtrlComplex
2816 public static function GetControlDescr()
2818 $description = parent::GetControlDescr();
2819 $description['SORT
'] = 200;
2820 return $description;
2826 public static function GetControlID()
2835 'CondIBDateActiveFrom
',
2836 'CondIBDateActiveTo
',
2838 'CondIBPreviewText
',
2848 'CondCatVatIncluded
',
2852 public static function GetControlShow($arParams)
2854 $arControls = static::GetControls();
2856 'controlgroup
' => true,
2858 'label
' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_CONTROLGROUP_LABEL
'),
2859 'showIn
' => static::GetShowIn($arParams['SHOW_IN_GROUPS
']),
2860 'children
' => array()
2862 foreach ($arControls as $arOneControl)
2864 $arResult['children
'][] = array(
2865 'controlId
' => $arOneControl['ID
'],
2867 'label
' => $arOneControl['LABEL
'],
2868 'showIn
' => static::GetShowIn($arParams['SHOW_IN_GROUPS
']),
2873 'text
' => $arOneControl['PREFIX
']
2875 static::GetLogicAtom($arOneControl['LOGIC
']),
2876 static::GetValueAtom($arOneControl['JS_VALUE
'])
2880 unset($arOneControl);
2889 public static function GetControls($strControlID = false)
2892 $vatIterator = Catalog\VatTable::getList(array(
2893 '
select' => array('ID
', 'NAME
', 'SORT
'),
2894 'order
' => array('SORT
' => 'ASC
')
2896 while ($vat = $vatIterator->fetch())
2898 $vat['ID
'] = (int)$vat['ID
'];
2899 $vatList[$vat['ID
']] = $vat['NAME
'];
2901 unset($vat, $vatIterator);
2903 $arControlList = array(
2904 'CondIBElement
' => array(
2905 'ID
' => 'CondIBElement
',
2907 'FIELD_TYPE
' => 'int',
2908 'LABEL
' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_ELEMENT_ID_LABEL
'),
2909 'PREFIX
' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_ELEMENT_ID_PREFIX
'),
2910 'LOGIC
' => static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ)),
2911 'JS_VALUE
' => array(
2912 'type
' => 'multiDialog
',
2913 'popup_url
' => self::getAdminSection().'cat_product_search_dialog.php
',
2914 'popup_params
' => array(
2915 'lang' => LANGUAGE_ID,
2916 'caller
' => 'discount_rules
',
2917 'allow_select_parent
' => 'Y
'
2922 'PHP_VALUE
' => array(
2923 'VALIDATE
' => 'element
'
2926 'CondIBIBlock
' => array(
2927 'ID
' => 'CondIBIBlock
',
2928 'FIELD
' => 'IBLOCK_ID
',
2929 'FIELD_TYPE
' => 'int',
2930 'LABEL
' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_IBLOCK_ID_LABEL
'),
2931 'PREFIX
' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_IBLOCK_ID_PREFIX
'),
2932 'LOGIC
' => static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ)),
2933 'JS_VALUE
' => array(
2935 'popup_url
' => self::getAdminSection().'cat_iblock_search.php
',
2936 'popup_params
' => array(
2937 'lang' => LANGUAGE_ID,
2943 'PHP_VALUE
' => array(
2944 'VALIDATE
' => 'iblock
'
2947 'CondIBSection
' => array(
2948 'ID
' => 'CondIBSection
',
2950 'FIELD
' => 'SECTION_ID
',
2951 'FIELD_TYPE
' => 'int',
2952 'LABEL
' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_SECTION_ID_LABEL
'),
2953 'PREFIX
' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_SECTION_ID_PREFIX
'),
2954 'LOGIC
' => static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ)),
2955 'JS_VALUE
' => array(
2957 'popup_url
' => self::getAdminSection().'iblock_section_search.php
',
2958 'popup_params
' => array(
2959 'lang' => LANGUAGE_ID,
2966 'PHP_VALUE
' => array(
2967 'VALIDATE
' => 'section
'
2970 'CondIBCode
' => array(
2971 'ID
' => 'CondIBCode
',
2973 'FIELD_TYPE
' => 'string',
2974 'FIELD_LENGTH
' => 255,
2975 'LABEL
' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_CODE_LABEL
'),
2976 'PREFIX
' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_CODE_PREFIX
'),
2977 'LOGIC
' => static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ, BT_COND_LOGIC_CONT, BT_COND_LOGIC_NOT_CONT)),
2978 'JS_VALUE
' => array(
2983 'CondIBXmlID
' => array(
2984 'ID
' => 'CondIBXmlID
',
2985 'FIELD
' => 'XML_ID
',
2986 'FIELD_TYPE
' => 'string',
2987 'FIELD_LENGTH
' => 255,
2988 'LABEL
' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_XML_ID_LABEL
'),
2989 'PREFIX
' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_XML_ID_PREFIX
'),
2990 'LOGIC
' => static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ, BT_COND_LOGIC_CONT, BT_COND_LOGIC_NOT_CONT)),
2991 'JS_VALUE
' => array(
2996 'CondIBName
' => array(
2997 'ID
' => 'CondIBName
',
2999 'FIELD_TYPE
' => 'string',
3000 'FIELD_LENGTH
' => 255,
3001 'LABEL
' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_NAME_LABEL
'),
3002 'PREFIX
' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_NAME_PREFIX
'),
3003 'LOGIC
' => static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ, BT_COND_LOGIC_CONT, BT_COND_LOGIC_NOT_CONT)),
3004 'JS_VALUE
' => array(
3009 'CondIBDateActiveFrom
' => array(
3010 'ID
' => 'CondIBDateActiveFrom
',
3011 'FIELD
' => 'DATE_ACTIVE_FROM
',
3012 'FIELD_TYPE
' => 'datetime
',
3013 'LABEL
' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_DATE_ACTIVE_FROM_LABEL
'),
3014 'PREFIX
' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_DATE_ACTIVE_FROM_PREFIX
'),
3015 'LOGIC
' => static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ, BT_COND_LOGIC_GR, BT_COND_LOGIC_LS, BT_COND_LOGIC_EGR, BT_COND_LOGIC_ELS)),
3016 'JS_VALUE
' => array(
3017 'type
' => 'datetime
',
3018 'format
' => 'datetime
'
3022 'CondIBDateActiveTo
' => array(
3023 'ID
' => 'CondIBDateActiveTo
',
3024 'FIELD
' => 'DATE_ACTIVE_TO
',
3025 'FIELD_TYPE
' => 'datetime
',
3026 'LABEL
' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_DATE_ACTIVE_TO_LABEL
'),
3027 'PREFIX
' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_DATE_ACTIVE_TO_PREFIX
'),
3028 'LOGIC
' => static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ, BT_COND_LOGIC_GR, BT_COND_LOGIC_LS, BT_COND_LOGIC_EGR, BT_COND_LOGIC_ELS)),
3029 'JS_VALUE
' => array(
3030 'type
' => 'datetime
',
3031 'format
' => 'datetime
'
3035 'CondIBSort
' => array(
3036 'ID
' => 'CondIBSort
',
3038 'FIELD_TYPE
' => 'int',
3039 'LABEL
' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_SORT_LABEL
'),
3040 'PREFIX
' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_SORT_PREFIX
'),
3041 'LOGIC
' => static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ, BT_COND_LOGIC_GR, BT_COND_LOGIC_LS, BT_COND_LOGIC_EGR, BT_COND_LOGIC_ELS)),
3042 'JS_VALUE
' => array(
3047 'CondIBPreviewText
' => array(
3048 'ID
' => 'CondIBPreviewText
',
3049 'FIELD
' => 'PREVIEW_TEXT
',
3050 'FIELD_TYPE
' => 'text
',
3051 'LABEL
' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_PREVIEW_TEXT_LABEL
'),
3052 'PREFIX
' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_PREVIEW_TEXT_PREFIX
'),
3053 'LOGIC
' => static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ, BT_COND_LOGIC_CONT, BT_COND_LOGIC_NOT_CONT)),
3054 'JS_VALUE
' => array(
3059 'CondIBDetailText
' => array(
3060 'ID
' => 'CondIBDetailText
',
3061 'FIELD
' => 'DETAIL_TEXT
',
3062 'FIELD_TYPE
' => 'text
',
3063 'LABEL
' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_DETAIL_TEXT_LABEL
'),
3064 'PREFIX
' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_DETAIL_TEXT_PREFIX
'),
3065 'LOGIC
' => static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ, BT_COND_LOGIC_CONT, BT_COND_LOGIC_NOT_CONT)),
3066 'JS_VALUE
' => array(
3071 'CondIBDateCreate
' => array(
3072 'ID
' => 'CondIBDateCreate
',
3073 'FIELD
' => 'DATE_CREATE
',
3074 'FIELD_TYPE
' => 'datetime
',
3075 'LABEL
' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_DATE_CREATE_LABEL
'),
3076 'PREFIX
' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_DATE_CREATE_PREFIX
'),
3077 'LOGIC
' => static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ, BT_COND_LOGIC_GR, BT_COND_LOGIC_LS, BT_COND_LOGIC_EGR, BT_COND_LOGIC_ELS)),
3078 'JS_VALUE
' => array(
3079 'type
' => 'datetime
',
3080 'format
' => 'datetime
'
3084 'CondIBCreatedBy
' => array(
3085 'ID
' => 'CondIBCreatedBy
',
3086 'FIELD
' => 'CREATED_BY
',
3087 'FIELD_TYPE
' => 'int',
3088 'LABEL
' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_CREATED_BY_LABEL
'),
3089 'PREFIX
' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_CREATED_BY_PREFIX
'),
3090 'LOGIC
' => static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ)),
3091 'JS_VALUE
' => array(
3094 'PHP_VALUE
' => array(
3095 'VALIDATE
' => 'user
'
3098 'CondIBTimestampX
' => array(
3099 'ID
' => 'CondIBTimestampX
',
3100 'FIELD
' => 'TIMESTAMP_X
',
3101 'FIELD_TYPE
' => 'datetime
',
3102 'LABEL
' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_TIMESTAMP_X_LABEL
'),
3103 'PREFIX
' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_TIMESTAMP_X_PREFIX
'),
3104 'LOGIC
' => static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ, BT_COND_LOGIC_GR, BT_COND_LOGIC_LS, BT_COND_LOGIC_EGR, BT_COND_LOGIC_ELS)),
3105 'JS_VALUE
' => array(
3106 'type
' => 'datetime
',
3107 'format
' => 'datetime
'
3111 'CondIBModifiedBy
' => array(
3112 'ID
' => 'CondIBModifiedBy
',
3113 'FIELD
' => 'MODIFIED_BY
',
3114 'FIELD_TYPE
' => 'int',
3115 'LABEL
' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_MODIFIED_BY_LABEL
'),
3116 'PREFIX
' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_MODIFIED_BY_PREFIX
'),
3117 'LOGIC
' => static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ)),
3118 'JS_VALUE
' => array(
3121 'PHP_VALUE
' => array(
3122 'VALIDATE
' => 'user
'
3125 'CondIBTags
' => array(
3126 'ID
' => 'CondIBTags
',
3128 'FIELD_TYPE
' => 'string',
3129 'FIELD_LENGTH
' => 255,
3130 'LABEL
' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_TAGS_LABEL
'),
3131 'PREFIX
' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_TAGS_PREFIX
'),
3132 'LOGIC
' => static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ, BT_COND_LOGIC_CONT, BT_COND_LOGIC_NOT_CONT)),
3133 'JS_VALUE
' => array(
3138 'CondCatQuantity
' => array(
3139 'ID
' => 'CondCatQuantity
',
3141 'MODULE_ENTITY
' => 'catalog
',
3142 'ENTITY
' => 'PRODUCT
',
3143 'FIELD
' => 'CATALOG_QUANTITY
',
3144 'FIELD_TABLE
' => 'QUANTITY
',
3145 'FIELD_TYPE
' => 'double',
3146 'LABEL
' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_CATALOG_QUANTITY_LABEL
'),
3147 'PREFIX
' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_CATALOG_QUANTITY_PREFIX
'),
3148 'LOGIC
' => static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ, BT_COND_LOGIC_GR, BT_COND_LOGIC_LS, BT_COND_LOGIC_EGR, BT_COND_LOGIC_ELS)),
3149 'JS_VALUE
' => array(
3153 'CondCatWeight
' => array(
3154 'ID
' => 'CondCatWeight
',
3156 'MODULE_ENTITY
' => 'catalog
',
3157 'ENTITY
' => 'PRODUCT
',
3158 'FIELD
' => 'CATALOG_WEIGHT
',
3159 'FIELD_TABLE
' => 'WEIGHT
',
3160 'FIELD_TYPE
' => 'double',
3161 'LABEL
' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_CATALOG_WEIGHT_LABEL
'),
3162 'PREFIX
' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_CATALOG_WEIGHT_PREFIX
'),
3163 'LOGIC
' => static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ, BT_COND_LOGIC_GR, BT_COND_LOGIC_LS, BT_COND_LOGIC_EGR, BT_COND_LOGIC_ELS)),
3164 'JS_VALUE
' => array(
3169 'CondCatVatID
' => array(
3170 'ID
' => 'CondCatVatID
',
3172 'MODULE_ENTITY
' => 'catalog
',
3173 'ENTITY
' => 'PRODUCT
',
3174 'FIELD
' => 'CATALOG_VAT_ID
',
3175 'FIELD_TABLE
' => 'VAT_ID
',
3176 'FIELD_TYPE
' => 'int',
3177 'LABEL
' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_CATALOG_VAT_ID_LABEL
'),
3178 'PREFIX
' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_CATALOG_VAT_ID_PREFIX
'),
3179 'LOGIC
' => static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ)),
3180 'JS_VALUE
' => array(
3182 'values
' => $vatList
3184 'PHP_VALUE
' => array(
3185 'VALIDATE
' => 'list
'
3188 'CondCatVatIncluded
' => array(
3189 'ID
' => 'CondCatVatIncluded
',
3191 'MODULE_ENTITY
' => 'catalog
',
3192 'ENTITY
' => 'PRODUCT
',
3193 'FIELD
' => 'CATALOG_VAT_INCLUDED
',
3194 'FIELD_TABLE
' => 'VAT_INCLUDED
',
3195 'FIELD_TYPE
' => 'char',
3196 'LABEL
' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_CATALOG_VAT_INCLUDED_LABEL
'),
3197 'PREFIX
' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_CATALOG_VAT_INCLUDED_PREFIX
'),
3198 'LOGIC
' => static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ)),
3199 'JS_VALUE
' => array(
3202 'Y
' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_CATALOG_VAT_INCLUDED_VALUE_YES
'),
3203 'N
' => Loc::getMessage('BT_MOD_CATALOG_COND_CMP_CATALOG_VAT_INCLUDED_VALUE_NO
')
3206 'PHP_VALUE
' => array(
3207 'VALIDATE
' => 'list
'
3211 if (empty($vatList))
3213 unset($arControlList['CondCatVatID
']);
3214 unset($arControlList['CondCatVatIncluded
']);
3216 foreach ($arControlList as &$control)
3218 if (!isset($control['PARENT
']))
3219 $control['PARENT
'] = true;
3220 $control['EXIST_HANDLER
'] = 'Y
';
3221 $control['MODULE_ID
'] = 'catalog
';
3222 if (!isset($control['MODULE_ENTITY
']))
3223 $control['MODULE_ENTITY
'] = 'iblock
';
3224 if (!isset($control['ENTITY
']))
3225 $control['ENTITY
'] = 'ELEMENT
';
3226 if (!isset($control['FIELD_TABLE
']))
3227 $control['FIELD_TABLE
'] = false;
3228 $control['MULTIPLE
'] = 'N
';
3229 $control['GROUP
'] = 'N
';
3230 $control['ENTITY_ID
'] = -1;
3233 $arControlList['CondIBSection
']['MULTIPLE
'] = 'Y
';
3235 return static::searchControl($arControlList, $strControlID);
3238 public static function Generate($arOneCondition, $arParams, $arControl, $arSubs = false)
3240 $strParentResult = '';
3242 $parentResultValues = array();
3243 $resultValues = array();
3245 if (is_string($arControl))
3247 $arControl = static::GetControls($arControl);
3249 $boolError = !is_array($arControl);
3253 $arValues = static::Check($arOneCondition, $arOneCondition, $arControl, false);
3254 $boolError = ($arValues === false);
3259 $boolError = !isset($arControl['MULTIPLE
']);
3264 $arLogic = static::SearchLogic($arValues['logic
'], $arControl['LOGIC
']);
3265 if (!isset($arLogic['OP
'][$arControl['MULTIPLE
']]) || empty($arLogic['OP
'][$arControl['MULTIPLE
']]))
3271 $useParent = ($arControl['PARENT
'] && isset($arLogic['PARENT
']));
3272 $strParent = $arParams['FIELD
'].'[\
'PARENT_'.$arControl[
'FIELD'].
'\']
';
3273 $strField = $arParams['FIELD
'].'[\
''.$arControl[
'FIELD'].
'\']
';
3274 switch ($arControl['FIELD_TYPE
'])
3278 if (is_array($arValues['value
']))
3280 if (!isset($arLogic['MULTI_SEP
']))
3286 foreach ($arValues['value
'] as $value)
3289 $parentResultValues[] = str_replace(
3290 array('#FIELD#
', '#VALUE#
'),
3291 array($strParent, $value),
3292 $arLogic['OP
'][$arControl['MULTIPLE
']]
3294 $resultValues[] = str_replace(
3295 array('#FIELD#
', '#VALUE#
'),
3296 array($strField, $value),
3297 $arLogic['OP
'][$arControl['MULTIPLE
']]
3302 $strParentResult = '(
'.implode($arLogic['MULTI_SEP
'], $parentResultValues).')
';
3303 $strResult = '(
'.implode($arLogic['MULTI_SEP
'], $resultValues).')
';
3304 unset($resultValues, $parentResultValues);
3310 $strParentResult = str_replace(
3311 array('#FIELD#
', '#VALUE#
'),
3312 array($strParent, $arValues['value
']),
3313 $arLogic['OP
'][$arControl['MULTIPLE
']]
3315 $strResult = str_replace(
3316 array('#FIELD#
', '#VALUE#
'),
3317 array($strField, $arValues['value
']),
3318 $arLogic['OP
'][$arControl['MULTIPLE
']]
3325 if (is_array($arValues['value
']))
3332 $strParentResult = str_replace(
3333 array('#FIELD#
', '#VALUE#
'),
3334 array($strParent, '"'.EscapePHPString($arValues['value']).'"'),
3335 $arLogic['OP
'][$arControl['MULTIPLE
']]
3337 $strResult = str_replace(
3338 array('#FIELD#
', '#VALUE#
'),
3339 array($strField, '"'.EscapePHPString($arValues['value']).'"'),
3340 $arLogic['OP
'][$arControl['MULTIPLE
']]
3346 if (is_array($arValues['value
']))
3353 $strParentResult = str_replace(array('#FIELD#
', '#VALUE#
'), array($strParent, $arValues['value
']), $arLogic['OP
'][$arControl['MULTIPLE
']]);
3354 $strResult = str_replace(array('#FIELD#
', '#VALUE#
'), array($strField, $arValues['value
']), $arLogic['OP
'][$arControl['MULTIPLE
']]);
3355 if (!(BT_COND_LOGIC_EQ == $arLogic['ID
'] || BT_COND_LOGIC_NOT_EQ == $arLogic['ID
']))
3358 $strParentResult = 'null !==
'.$strParent.' && \
'\' !==
'.$strParent.' &&
'.$strResult;
3359 $strResult = 'null !==
'.$strField.' && \
'\' !==
'.$strField.' &&
'.$strResult;
3364 $strResult = 'isset(
'.$strField.') && (
'.$strResult.')
';
3367 $strResult = '(isset(
'.$strParent.') ? ((
'.$strResult.')
'.$arLogic['PARENT
'].$strParentResult.') : (
'.$strResult.'))
';
3372 return (!$boolError ? $strResult : false);
3375 public static function ApplyValues($arOneCondition, $arControl)
3377 $arResult = array();
3385 if (is_string($arControl))
3387 $arControl = static::GetControls($arControl);
3389 $boolError = !is_array($arControl);
3393 $arValues = static::Check($arOneCondition, $arOneCondition, $arControl, false);
3394 if (false === $arValues)
3402 $arLogic = static::SearchLogic($arValues['logic
'], $arControl['LOGIC
']);
3403 if (in_array($arLogic['ID
'], $arLogicID))
3406 'ID
' => $arControl['ID
'],
3407 'FIELD
' => $arControl['FIELD
'],
3408 'FIELD_TYPE
' => $arControl['FIELD_TYPE
'],
3409 'VALUES
' => (is_array($arValues['value
']) ? $arValues['value
'] : array($arValues['value
']))
3414 return (!$boolError ? $arResult : false);
3420 private static function getAdminSection()
3422 //TODO: need use \CAdminPage::getSelfFolderUrl, but in general it is impossible now
3423 return (defined('SELF_FOLDER_URL
') ? SELF_FOLDER_URL : '/bitrix/admin/
');
3427class CCatalogCondCtrlIBlockProps extends CCatalogCondCtrlComplex
3429 public static function GetControlDescr()
3431 $description = parent::GetControlDescr();
3432 $description['SORT
'] = 300;
3433 return $description;
3440 public static function GetControls($strControlID = false)
3442 $arControlList = array();
3443 $arIBlockList = array();
3444 $iterator = Catalog\CatalogIblockTable::getList(array(
3445 '
select' => array('IBLOCK_ID
', 'PRODUCT_IBLOCK_ID
')
3447 while ($arIBlock = $iterator->fetch())
3449 $arIBlock['IBLOCK_ID
'] = (int)$arIBlock['IBLOCK_ID
'];
3450 $arIBlock['PRODUCT_IBLOCK_ID
'] = (int)$arIBlock['PRODUCT_IBLOCK_ID
'];
3451 if ($arIBlock['IBLOCK_ID
'] > 0)
3452 $arIBlockList[$arIBlock['IBLOCK_ID
']] = true;
3453 if ($arIBlock['PRODUCT_IBLOCK_ID
'] > 0)
3454 $arIBlockList[$arIBlock['PRODUCT_IBLOCK_ID
']] = true;
3456 unset($arIBlock, $iterator);
3457 if (!empty($arIBlockList))
3459 $arIBlockList = array_keys($arIBlockList);
3460 sort($arIBlockList);
3461 foreach ($arIBlockList as $intIBlockID)
3463 $strName = CIBlock::GetArrayByID($intIBlockID, 'NAME
');
3464 if (false !== $strName)
3467 $rsProps = CIBlockProperty::GetList(array('SORT
' => 'ASC
', 'NAME
' => 'ASC
'), array('IBLOCK_ID
' => $intIBlockID));
3468 while ($arProp = $rsProps->Fetch())
3470 if ('CML2_LINK
' == $arProp['XML_ID
'] || 'F
' == $arProp['PROPERTY_TYPE
'])
3472 if ('L
' == $arProp['PROPERTY_TYPE
'])
3473 $arProp['VALUES
'] = array();
3480 $boolUserType = false;
3481 if (isset($arProp['USER_TYPE
']) && !empty($arProp['USER_TYPE
']))
3483 switch ($arProp['USER_TYPE
'])
3486 $strFieldType = 'datetime
';
3487 $arLogic = static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ, BT_COND_LOGIC_GR, BT_COND_LOGIC_LS, BT_COND_LOGIC_EGR, BT_COND_LOGIC_ELS));
3489 'type
' => 'datetime
',
3490 'format
' => 'datetime
'
3492 $boolUserType = true;
3495 $strFieldType = 'date
';
3496 $arLogic = static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ, BT_COND_LOGIC_GR, BT_COND_LOGIC_LS, BT_COND_LOGIC_EGR, BT_COND_LOGIC_ELS));
3498 'type
' => 'datetime
',
3501 $boolUserType = true;
3504 $strFieldType = 'text
';
3505 $arLogic = static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ));
3507 'type
' => 'lazySelect
',
3508 'load_url
' => '/bitrix/tools/catalog/get_property_values.php
',
3509 'load_params
' => array(
3510 'lang' => LANGUAGE_ID,
3511 'propertyId
' => $arProp['ID
']
3514 $boolUserType = true;
3517 $boolUserType = false;
3524 switch ($arProp['PROPERTY_TYPE
'])
3527 $strFieldType = 'double';
3528 $arLogic = static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ, BT_COND_LOGIC_GR, BT_COND_LOGIC_LS, BT_COND_LOGIC_EGR, BT_COND_LOGIC_ELS));
3529 $arValue = array('type
' => 'input
');
3532 $strFieldType = 'text
';
3533 $arLogic = static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ, BT_COND_LOGIC_CONT, BT_COND_LOGIC_NOT_CONT));
3534 $arValue = array('type
' => 'input
');
3537 $strFieldType = 'int';
3538 $arLogic = static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ));
3540 'type
' => 'lazySelect
',
3541 'load_url
' => '/bitrix/tools/catalog/get_property_values.php
',
3542 'load_params
' => array(
3543 'lang' => LANGUAGE_ID,
3544 'propertyId
' => $arProp['ID
']
3547 $arPhpValue = array('VALIDATE
' => 'enumValue
');
3550 $strFieldType = 'int';
3551 $arLogic = static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ));
3554 'popup_url
' => self::getAdminSection().'iblock_element_search.php
',
3555 'popup_params
' => array(
3556 'lang' => LANGUAGE_ID,
3557 'IBLOCK_ID
' => $arProp['LINK_IBLOCK_ID
'],
3562 $arPhpValue = array('VALIDATE
' => 'element
');
3565 $popupParams = array(
3566 'lang' => LANGUAGE_ID,
3567 'IBLOCK_ID
' => $arProp['LINK_IBLOCK_ID
'],
3569 'simplename
' => 'Y
',
3571 if ($arProp['LINK_IBLOCK_ID
'] > 0)
3572 $popupParams['iblockfix
'] = 'y
';
3573 $strFieldType = 'int';
3574 $arLogic = static::GetLogic(array(BT_COND_LOGIC_EQ, BT_COND_LOGIC_NOT_EQ));
3577 'popup_url
' => self::getAdminSection().'iblock_section_search.php
',
3578 'popup_params
' => $popupParams,
3581 unset($popupParams);
3582 $arPhpValue = array('VALIDATE
' => 'section
');
3586 $arControlList['CondIBProp:
'.$intIBlockID.':
'.$arProp['ID
']] = array(
3587 'ID
' => 'CondIBProp:
'.$intIBlockID.':
'.$arProp['ID
'],
3589 'EXIST_HANDLER
' => 'Y
',
3590 'MODULE_ID
' => 'catalog
',
3591 'MODULE_ENTITY
' => 'iblock
',
3592 'ENTITY
' => 'ELEMENT_PROPERTY
',
3593 'ENTITY_ID
' => $intIBlockID,
3594 'IBLOCK_ID
' => $intIBlockID, // deprecated
3595 'PROPERTY_ID
' => $arProp['ID
'],
3596 'FIELD
' => 'PROPERTY_
'.$arProp['ID
'].'_VALUE
',
3597 'FIELD_TABLE
' => $intIBlockID.':
'.$arProp['ID
'],
3598 'FIELD_TYPE
' => $strFieldType,
3601 'SEP
' => ($boolSep ? 'Y
' : 'N
'),
3602 'SEP_LABEL
' => ($boolSep
3604 array('#ID#
', '#NAME#
'),
3605 array($intIBlockID, $strName),
3606 Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_PROP_LABEL
')
3610 'LABEL
' => $arProp['NAME
'],
3611 'PREFIX
' => str_replace(
3612 array('#NAME#
', '#IBLOCK_ID#
', '#IBLOCK_NAME#
'),
3613 array($arProp['NAME
'], $intIBlockID, $strName),
3614 Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_ONE_PROP_PREFIX
')
3616 'LOGIC
' => $arLogic,
3617 'JS_VALUE
' => $arValue,
3618 'PHP_VALUE
' => $arPhpValue
3625 unset($intIBlockID);
3627 unset($arIBlockList);
3629 return static::searchControl($arControlList, $strControlID);
3632 public static function GetControlShow($arParams)
3634 $arControls = static::GetControls();
3635 $arResult = array();
3637 foreach ($arControls as &$arOneControl)
3639 if (isset($arOneControl['SEP
']) && 'Y
' == $arOneControl['SEP
'])
3642 $arResult[$intCount] = array(
3643 'controlgroup
' => true,
3645 'label
' => $arOneControl['SEP_LABEL
'],
3646 'showIn
' => static::GetShowIn($arParams['SHOW_IN_GROUPS
']),
3647 'children
' => array()
3650 $arLogic = static::GetLogicAtom($arOneControl['LOGIC
']);
3651 $arValue = static::GetValueAtom($arOneControl['JS_VALUE
']);
3653 $arResult[$intCount]['children
'][] = array(
3654 'controlId
' => $arOneControl['ID
'],
3656 'label
' => $arOneControl['LABEL
'],
3657 'showIn
' => static::GetShowIn($arParams['SHOW_IN_GROUPS
']),
3662 'text
' => $arOneControl['PREFIX
']
3669 if (isset($arOneControl))
3670 unset($arOneControl);
3675 public static function Generate($arOneCondition, $arParams, $arControl, $arSubs = false)
3679 if (is_string($arControl))
3681 $arControl = static::GetControls($arControl);
3683 $boolError = !is_array($arControl);
3687 $strResult = parent::Generate($arOneCondition, $arParams, $arControl, $arSubs);
3688 if (false === $strResult || '' == $strResult)
3694 $strField = 'isset(
'.$arParams['FIELD
'].'[\
''.$arControl[
'FIELD'].
'\'])
';
3695 $strResult = $strField.' &&
'.$strResult;
3699 return (!$boolError ? $strResult : false);
3702 public static function ApplyValues($arOneCondition, $arControl)
3704 $arResult = array();
3713 if (is_string($arControl))
3715 $arControl = static::GetControls($arControl);
3717 $boolError = !is_array($arControl);
3721 $arValues = static::Check($arOneCondition, $arOneCondition, $arControl, false);
3722 if ($arValues === false)
3730 $arLogic = static::SearchLogic($arValues['logic
'], $arControl['LOGIC
']);
3731 if (in_array($arLogic['ID
'], $arLogicID))
3734 'ID
' => $arControl['ID
'],
3735 'FIELD
' => $arControl['FIELD
'],
3736 'FIELD_TYPE
' => $arControl['FIELD_TYPE
'],
3737 'VALUES
' => (is_array($arValues['value
']) ? $arValues['value
'] : array($arValues['value
']))
3741 return (!$boolError ? $arResult : false);
3744 public static function Check($arOneCondition, $arParams, $arControl, $boolShow)
3746 $result = parent::Check($arOneCondition, $arParams, $arControl, $boolShow);
3747 if (self::checkActiveProperty($arControl))
3749 $boolShow = ($boolShow === true);
3752 $result['err_cond
'] = 'Y
';
3753 if (isset($result['err_cond_mess
']))
3754 $result['err_cond_mess
'] .= '.
'.Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_PROPERTY_NOT_ACTIVE
');
3756 $result['err_cond_mess
'] = Loc::getMessage('BT_MOD_CATALOG_COND_CMP_IBLOCK_PROPERTY_NOT_ACTIVE
');
3768 private static function getAdminSection()
3770 //TODO: need use \CAdminPage::getSelfFolderUrl, but in general it is impossible now
3771 return (defined('SELF_FOLDER_URL
') ? SELF_FOLDER_URL : '/bitrix/admin/
');
3778 private static function checkActiveProperty(array $control)
3780 $iterator = Iblock\PropertyTable::getList([
3781 '
select' => ['ID
', 'IBLOCK_ID
'],
3783 '=IBLOCK_ID
' => $control['IBLOCK_ID
'],
3784 '=ID
' => $control['PROPERTY_ID
'],
3788 $row = $iterator->fetch();
3789 $result = !empty($row);
3790 unset($row, $iterator);
3795class CGlobalCondTree
3797 protected const PARAM_TITLE_MASK = '/^[A-Za-z_][A-Za-z01-9_]*$/
';
3799 protected $intMode = BT_COND_MODE_DEFAULT; // work mode
3800 protected $arEvents = array(); // events ID
3801 protected $arInitParams = array(); // start params
3802 protected $boolError = false; // error flag
3803 protected $arMsg = array(); // messages (errors)
3805 protected $strFormName = ''; // form name
3806 protected $strFormID = ''; // form id
3807 protected $strContID = ''; // container id
3808 protected $strJSName = ''; // js object var name
3809 protected $boolCreateForm = false; // need create form
3810 protected $boolCreateCont = false; // need create container
3811 protected $strPrefix = 'rule
'; // prefix for input
3812 protected $strSepID = '__
'; // separator for id
3814 protected $arSystemMess = array(); // system messages
3816 protected $arAtomList = null; // atom list cache
3817 protected $arAtomJSPath = null; // atom js files
3818 protected $arControlList = null; // control list cache
3819 protected $arShowControlList = null; // control show method list
3820 protected $arShowInGroups = null; // showin group list
3821 protected $forcedShowInGroup = null; // forced showin list
3822 protected $arInitControlList = null; // control init list
3824 protected $arDefaultControl = array(
3829 ); // required control fields
3831 protected $usedModules = array(); // modules for real conditions
3832 protected $usedExtFiles = array(); // files from AddEventHandler
3833 protected $usedEntity = array(); // entity list in conditions
3835 protected $arConditions = null; // conditions array
3837 public function __construct()
3839 CJSCore::Init(array("core_condtree"));
3842 public function __destruct()
3847 public function OnConditionAtomBuildList()
3849 if ($this->boolError || isset($this->arAtomList))
3852 $this->arAtomList = array();
3853 $this->arAtomJSPath = array();
3856 if (isset($this->arEvents['INTERFACE_ATOMS
']))
3858 $event = new Main\Event(
3859 $this->arEvents['INTERFACE_ATOMS
']['MODULE_ID
'],
3860 $this->arEvents['INTERFACE_ATOMS
']['EVENT_ID
']
3863 $resultList = $event->getResults();
3864 if (!empty($resultList))
3866 foreach ($resultList as $eventResult)
3868 if ($eventResult->getType() != Main\EventResult::SUCCESS)
3870 $module = $eventResult->getModuleId();
3873 $result[] = $eventResult->getParameters();
3875 unset($eventResult);
3877 unset($resultList, $event);
3879 if (isset($this->arEvents['ATOMS
']))
3881 foreach (GetModuleEvents($this->arEvents['ATOMS
']['MODULE_ID
'], $this->arEvents['ATOMS
']['EVENT_ID
'], true) as $arEvent)
3883 $result[] = ExecuteModuleEventEx($arEvent);
3887 if (!empty($result))
3889 foreach ($result as $row)
3891 if (empty($row) || !is_array($row))
3893 if (empty($row['ID
']) || isset($this->arAtomList[$row['ID
']]))
3895 $this->arAtomList[$row['ID
']] = $row;
3897 !empty($row['JS_SRC
'])
3898 && is_string($row['JS_SRC
'])
3899 && !in_array($row['JS_SRC
'], $this->arAtomJSPath)
3902 $this->arAtomJSPath[] = $row['JS_SRC
'];
3910 public function OnConditionControlBuildList()
3912 if ($this->boolError || isset($this->arControlList))
3915 $this->arControlList = array();
3916 $this->arShowInGroups = array();
3917 $this->forcedShowInGroup = array();
3918 $this->arShowControlList = array();
3919 $this->arInitControlList = array();
3923 if (isset($this->arEvents['CONTROLS
']))
3925 foreach (GetModuleEvents($this->arEvents['CONTROLS
']['MODULE_ID
'], $this->arEvents['CONTROLS
']['EVENT_ID
'], true) as $arEvent)
3927 $result[] = ExecuteModuleEventEx($arEvent);
3930 if (isset($this->arEvents['INTERFACE_CONTROLS
']))
3932 $event = new Main\Event(
3933 $this->arEvents['INTERFACE_CONTROLS
']['MODULE_ID
'],
3934 $this->arEvents['INTERFACE_CONTROLS
']['EVENT_ID
']
3937 $resultList = $event->getResults();
3938 if (!empty($resultList))
3940 foreach ($resultList as $eventResult)
3942 if ($eventResult->getType() != Main\EventResult::SUCCESS)
3944 $module = $eventResult->getModuleId();
3947 $result[] = $eventResult->getParameters();
3949 unset($eventResult);
3951 unset($resultList, $event);
3954 if (!empty($result))
3956 $rawControls = array();
3958 foreach ($result as $arRes)
3960 if (empty($arRes) || !is_array($arRes))
3962 if (isset($arRes['ID
']))
3964 if (isset($arRes['EXIST_HANDLER
']) && $arRes['EXIST_HANDLER
'] === 'Y
')
3966 if (!isset($arRes['MODULE_ID
']) && !isset($arRes['EXT_FILE
']))
3971 $arRes['MODULE_ID
'] = '';
3972 $arRes['EXT_FILE
'] = '';
3974 if (array_key_exists('EXIST_HANDLER
', $arRes))
3975 unset($arRes['EXIST_HANDLER
']);
3976 $arRes['GROUP
'] = (isset($arRes['GROUP
']) && $arRes['GROUP
'] == 'Y
' ? 'Y
' : 'N
');
3977 if (isset($this->arControlList[$arRes['ID
']]))
3979 $this->arMsg[] = array('id' => 'CONTROLS
', 'text
' => str_replace('#CONTROL#
', $arRes['ID
'], Loc::getMessage('BT_MOD_COND_ERR_CONTROL_DOUBLE
')));
3980 $this->boolError = true;
3984 if (!$this->CheckControl($arRes))
3986 $this->arControlList[$arRes["ID"]] = $arRes;
3987 if ($arRes['GROUP
'] == 'Y
')
3989 if (empty($arRes['FORCED_SHOW_LIST
']))
3991 $this->arShowInGroups[] = $arRes['ID
'];
3995 $forcedList = $arRes['FORCED_SHOW_LIST
'];
3996 if (!is_array($forcedList))
3997 $forcedList = array($forcedList);
3998 foreach ($forcedList as $forcedId)
4000 if (is_array($forcedId))
4002 $forcedId = trim($forcedId);
4003 if ($forcedId == '')
4005 if (!isset($this->forcedShowInGroup[$forcedId]))
4006 $this->forcedShowInGroup[$forcedId] = array();
4007 $this->forcedShowInGroup[$forcedId][] = $arRes['ID
'];
4009 unset($forcedId, $forcedList);
4014 if (!in_array($arRes['GetControlShow'], $this->arShowControlList))
4017 $showDescription = array(
4020 if (isset($arRes['SORT
']) && (int)$arRes['SORT
'] > 0)
4022 $showDescription['SORT
'] = (int)$arRes['SORT
'];
4023 $showDescription['INDEX
'] = 1;
4027 $showDescription['SORT
'] = INF;
4028 $showDescription['INDEX
'] = $controlIndex;
4031 $rawControls[] = $showDescription;
4032 unset($showDescription);
4037 if (!in_array($arRes['InitParams'], $this->arInitControlList))
4038 $this->arInitControlList[] = $arRes['InitParams'];
4042 elseif (isset($arRes['COMPLEX
']) && 'Y
' == $arRes['COMPLEX
'])
4044 $complexModuleID = '';
4045 $complexExtFiles = '';
4046 if (isset($arRes['EXIST_HANDLER
']) && $arRes['EXIST_HANDLER
'] === 'Y
')
4048 if (isset($arRes['MODULE_ID
']))
4049 $complexModuleID = $arRes['MODULE_ID
'];
4050 if (isset($arRes['EXT_FILE
']))
4051 $complexExtFiles = $arRes['EXT_FILE
'];
4053 if (isset($arRes['CONTROLS
']) && !empty($arRes['CONTROLS
']) && is_array($arRes['CONTROLS
']))
4055 if (array_key_exists('EXIST_HANDLER
', $arRes))
4056 unset($arRes['EXIST_HANDLER
']);
4058 unset($arInfo['COMPLEX
'], $arInfo['CONTROLS
']);
4059 foreach ($arRes['CONTROLS
'] as &$arOneControl)
4061 if (isset($arOneControl['ID
']))
4063 if (isset($arOneControl['EXIST_HANDLER
']) && $arOneControl['EXIST_HANDLER
'] === 'Y
')
4065 if (!isset($arOneControl['MODULE_ID
']) && !isset($arOneControl['EXT_FILE
']))
4068 $arInfo['GROUP
'] = 'N
';
4069 $arInfo['MODULE_ID
'] = isset($arOneControl['MODULE_ID
']) ? $arOneControl['MODULE_ID
'] : $complexModuleID;
4070 $arInfo['EXT_FILE
'] = isset($arOneControl['EXT_FILE
']) ? $arOneControl['EXT_FILE
'] : $complexExtFiles;
4071 $control = array_merge($arOneControl, $arInfo);
4072 if (isset($this->arControlList[$control['ID
']]))
4074 $this->arMsg[] = array('id' => 'CONTROLS
', 'text
' => str_replace('#CONTROL#
', $control['ID
'], Loc::getMessage('BT_MOD_COND_ERR_CONTROL_DOUBLE
')));
4075 $this->boolError = true;
4079 if (!$this->CheckControl($control))
4081 $this->arControlList[$control['ID
']] = $control;
4086 if (isset($arOneControl))
4087 unset($arOneControl);
4090 if (!in_array($arRes['GetControlShow'], $this->arShowControlList))
4093 $showDescription = array(
4096 if (isset($arRes['SORT
']) && (int)$arRes['SORT
'] > 0)
4098 $showDescription['SORT
'] = (int)$arRes['SORT
'];
4099 $showDescription['INDEX
'] = 1;
4103 $showDescription['SORT
'] = INF;
4104 $showDescription['INDEX
'] = $controlIndex;
4107 $rawControls[] = $showDescription;
4108 unset($showDescription);
4113 if (!in_array($arRes['InitParams'], $this->arInitControlList))
4114 $this->arInitControlList[] = $arRes['InitParams'];
4120 foreach ($arRes as &$arOneRes)
4122 if (is_array($arOneRes) && isset($arOneRes['ID
']))
4124 if (isset($arOneRes['EXIST_HANDLER
']) && $arOneRes['EXIST_HANDLER
'] === 'Y
')
4126 if (!isset($arOneRes['MODULE_ID
']) && !isset($arOneRes['EXT_FILE
']))
4131 $arOneRes['MODULE_ID
'] = '';
4132 $arOneRes['EXT_FILE
'] = '';
4134 if (array_key_exists('EXIST_HANDLER
', $arOneRes))
4135 unset($arOneRes['EXIST_HANDLER
']);
4136 $arOneRes['GROUP
'] = (isset($arOneRes['GROUP
']) && $arOneRes['GROUP
'] == 'Y
' ? 'Y
' : 'N
');
4137 if (isset($this->arControlList[$arOneRes['ID
']]))
4139 $this->arMsg[] = array('id' => 'CONTROLS
', 'text
' => str_replace('#CONTROL#
', $arOneRes['ID
'], Loc::getMessage('BT_MOD_COND_ERR_CONTROL_DOUBLE
')));
4140 $this->boolError = true;
4144 if (!$this->CheckControl($arOneRes))
4146 $this->arControlList[$arOneRes['ID
']] = $arOneRes;
4147 if ($arOneRes['GROUP
'] == 'Y
')
4149 if (empty($arOneRes['FORCED_SHOW_LIST
']))
4151 $this->arShowInGroups[] = $arOneRes['ID
'];
4155 $forcedList = (!is_array($arOneRes['FORCED_SHOW_LIST
']) ? array($arOneRes['FORCED_SHOW_LIST
']) : $arOneRes['FORCED_SHOW_LIST
']);
4156 foreach ($forcedList as &$forcedId)
4158 if (is_array($forcedId))
4160 $forcedId = trim($forcedId);
4161 if ($forcedId == '')
4163 if (!isset($this->forcedShowInGroup[$forcedId]))
4164 $this->forcedShowInGroup[$forcedId] = array();
4165 $this->forcedShowInGroup[$forcedId][] = $arOneRes['ID
'];
4172 if (!in_array($arOneRes['GetControlShow'], $this->arShowControlList))
4175 $showDescription = array(
4178 if (isset($arOneRes['SORT
']) && (int)$arOneRes['SORT
'] > 0)
4180 $showDescription['SORT
'] = (int)$arOneRes['SORT
'];
4181 $showDescription['INDEX
'] = 1;
4185 $showDescription['SORT
'] = INF;
4186 $showDescription['INDEX
'] = $controlIndex;
4189 $rawControls[] = $showDescription;
4190 unset($showDescription);
4195 if (!in_array($arOneRes['InitParams'], $this->arInitControlList))
4196 $this->arInitControlList[] = $arOneRes['InitParams'];
4206 if (!empty($rawControls))
4208 $this->arShowControlList = array();
4209 Main\Type\Collection::sortByColumn($rawControls, array('SORT
' => SORT_ASC, 'INDEX
' => SORT_ASC));
4210 foreach ($rawControls as $row)
4211 $this->arShowControlList[] = $row['CONTROL
'];
4214 unset($controlIndex, $rawControls);
4216 if (empty($this->arControlList))
4218 $this->arMsg[] = array('id' => 'CONTROLS
', 'text
' => Loc::getMessage('BT_MOD_COND_ERR_CONTROLS_EMPTY
'));
4219 $this->boolError = true;
4223 protected function CheckControl($arControl)
4226 foreach ($this->arDefaultControl as &$strKey)
4228 if (!isset($arControl[$strKey]) || empty($arControl[$strKey]))
4230 $boolResult = false;
4238 protected function GetModeList()
4241 BT_COND_MODE_DEFAULT,
4243 BT_COND_MODE_GENERATE,
4249 protected function GetEventList($intEventID)
4251 $arEventList = array(
4252 BT_COND_BUILD_CATALOG => array(
4253 'INTERFACE_ATOMS
' => array(
4254 'MODULE_ID
' => 'catalog
',
4255 'EVENT_ID
' => 'onBuildDiscountInterfaceAtoms
'
4257 'INTERFACE_CONTROLS
' => array(
4258 'MODULE_ID
' => 'catalog
',
4259 'EVENT_ID
' => 'onBuildDiscountInterfaceControls
'
4262 'MODULE_ID
' => 'catalog
',
4263 'EVENT_ID
' => 'OnCondCatAtomBuildList
'
4265 'CONTROLS
' => array(
4266 'MODULE_ID
' => 'catalog
',
4267 'EVENT_ID
' => 'OnCondCatControlBuildList
'
4270 BT_COND_BUILD_SALE => array(
4271 'INTERFACE_ATOMS
' => array(
4272 'MODULE_ID
' => 'sale
',
4273 'EVENT_ID
' => 'onBuildDiscountConditionInterfaceAtoms
'
4275 'INTERFACE_CONTROLS
' => array(
4276 'MODULE_ID
' => 'sale
',
4277 'EVENT_ID
' => 'onBuildDiscountConditionInterfaceControls
'
4280 'MODULE_ID
' => 'sale
',
4281 'EVENT_ID
' => 'OnCondSaleAtomBuildList
'
4283 'CONTROLS
' => array(
4284 'MODULE_ID
' => 'sale
',
4285 'EVENT_ID
' => 'OnCondSaleControlBuildList
'
4288 BT_COND_BUILD_SALE_ACTIONS => array(
4289 'INTERFACE_ATOMS
' => array(
4290 'MODULE_ID
' => 'sale
',
4291 'EVENT_ID
' => 'onBuildDiscountActionInterfaceAtoms
'
4293 'INTERFACE_CONTROLS
' => array(
4294 'MODULE_ID
' => 'sale
',
4295 'EVENT_ID
' => 'onBuildDiscountActionInterfaceControls
'
4298 'MODULE_ID
' => 'sale
',
4299 'EVENT_ID
' => 'OnCondSaleActionsAtomBuildList
'
4301 'CONTROLS
' => array(
4302 'MODULE_ID
' => 'sale
',
4303 'EVENT_ID
' => 'OnCondSaleActionsControlBuildList
'
4307 return (isset($arEventList[$intEventID]) ? $arEventList[$intEventID] : false);
4310 protected function CheckEvent($arEvent)
4312 if (!is_array($arEvent))
4314 if (!isset($arEvent['MODULE_ID
']) || empty($arEvent['MODULE_ID
']) || !is_string($arEvent['MODULE_ID
']))
4316 if (!isset($arEvent['EVENT_ID
']) || empty($arEvent['EVENT_ID
']) || !is_string($arEvent['EVENT_ID
']))
4321 public function Init($intMode, $mxEvent, $arParams = array())
4323 global $APPLICATION;
4324 $this->arMsg = array();
4326 $intMode = (int)$intMode;
4327 if (!in_array($intMode, $this->GetModeList()))
4328 $intMode = BT_COND_MODE_DEFAULT;
4329 $this->intMode = $intMode;
4332 if (is_array($mxEvent))
4335 'INTERFACE_ATOMS
', 'INTERFACE_CONTROLS
',
4338 foreach ($fields as $fieldName)
4340 if (!isset($mxEvent[$fieldName]) || !$this->CheckEvent($mxEvent[$fieldName]))
4342 $arEvent[$fieldName] = $mxEvent[$fieldName];
4345 if (!isset($arEvent['INTERFACE_CONTROLS
']) && !isset($arEvent['CONTROLS
']))
4350 $mxEvent = (int)$mxEvent;
4352 $arEvent = $this->GetEventList($mxEvent);
4355 if ($arEvent === false)
4357 $this->boolError = true;
4358 $this->arMsg[] = array('id' => 'EVENT
','text
' => Loc::getMessage('BT_MOD_COND_ERR_EVENT_BAD
'));
4362 $this->arEvents = $arEvent;
4365 $this->arInitParams = $arParams;
4367 if (!is_array($arParams))
4368 $arParams = array();
4371 if (BT_COND_MODE_DEFAULT == $this->intMode)
4373 if (!empty($arParams) && is_array($arParams))
4376 isset($arParams['FORM_NAME
'])
4377 && is_string($arParams['FORM_NAME
'])
4378 && preg_match(self::PARAM_TITLE_MASK, $arParams['FORM_NAME
'], $parsedValues)
4381 $this->strFormName = $arParams['FORM_NAME
'];
4384 isset($arParams['FORM_ID
'])
4385 && is_string($arParams['FORM_ID
'])
4386 && preg_match(self::PARAM_TITLE_MASK, $arParams['FORM_ID
'], $parsedValues)
4389 $this->strFormID = $arParams['FORM_ID
'];
4392 isset($arParams['CONT_ID
'])
4393 && is_string($arParams['CONT_ID
'])
4394 && preg_match(self::PARAM_TITLE_MASK, $arParams['CONT_ID
'], $parsedValues)
4397 $this->strContID = $arParams['CONT_ID
'];
4400 isset($arParams['JS_NAME
'])
4401 && is_string($arParams['JS_NAME
'])
4402 && preg_match(self::PARAM_TITLE_MASK, $arParams['JS_NAME
'], $parsedValues)
4405 $this->strJSName = $arParams['JS_NAME
'];
4408 $this->boolCreateForm = (isset($arParams['CREATE_FORM
']) && 'Y
' == $arParams['CREATE_FORM
']);
4409 $this->boolCreateCont = (isset($arParams['CREATE_CONT
']) && 'Y
' == $arParams['CREATE_CONT
']);
4412 if (empty($this->strJSName))
4414 if (empty($this->strContID))
4416 $this->boolError = true;
4417 $this->arMsg[] = array('id' => 'JS_NAME
','text
' => Loc::getMessage('BT_MOD_COND_ERR_JS_NAME_BAD
'));
4421 $this->strJSName = md5($this->strContID);
4425 if (BT_COND_MODE_DEFAULT == $this->intMode || BT_COND_MODE_PARSE == $this->intMode)
4427 if (!empty($arParams) && is_array($arParams))
4430 isset($arParams['PREFIX
'])
4431 && is_string($arParams['PREFIX
'])
4432 && preg_match(self::PARAM_TITLE_MASK, $arParams['PREFIX
'], $parsedValues)
4435 $this->strPrefix = $arParams['PREFIX
'];
4438 isset($arParams['SEP_ID
'])
4439 && is_string($arParams['SEP_ID
'])
4440 && preg_match(self::PARAM_TITLE_MASK, $arParams['SEP_ID
'], $parsedValues)
4443 $this->strSepID = $arParams['SEP_ID
'];
4448 $this->OnConditionAtomBuildList();
4449 $this->OnConditionControlBuildList();
4451 if (!$this->boolError)
4453 if (!empty($this->arInitControlList) && is_array($this->arInitControlList))
4455 if (!empty($arParams) && is_array($arParams))
4457 if (isset($arParams['INIT_CONTROLS
']) && !empty($arParams['INIT_CONTROLS
']) && is_array($arParams['INIT_CONTROLS
']))
4459 foreach ($this->arInitControlList as &$arOneControl)
4461 call_user_func_array($arOneControl,
4463 $arParams['INIT_CONTROLS
']
4467 if (isset($arOneControl))
4468 unset($arOneControl);
4474 if (isset($arParams['SYSTEM_MESSAGES
']) && !empty($arParams['SYSTEM_MESSAGES
']) && is_array($arParams['SYSTEM_MESSAGES
']))
4476 $this->arSystemMess = $arParams['SYSTEM_MESSAGES
'];
4479 if ($this->boolError)
4481 $obError = new CAdminException($this->arMsg);
4482 $APPLICATION->ThrowException($obError);
4484 return !$this->boolError;
4487 public function Show($arConditions)
4489 $this->arMsg = array();
4491 if (!$this->boolError)
4493 if (!empty($arConditions))
4495 if (!is_array($arConditions))
4497 if (!CheckSerializedData($arConditions))
4499 $this->boolError = true;
4500 $this->arMsg[] = array('id' => 'CONDITIONS
', 'text
' => Loc::getMessage('BT_MOD_COND_ERR_SHOW_DATA_UNSERIALIZE
'));
4504 $arConditions = unserialize($arConditions, ['allowed_classes
' => false]);
4505 if (!is_array($arConditions))
4507 $this->boolError = true;
4508 $this->arMsg[] = array('id' => 'CONDITIONS
', 'text
' => Loc::getMessage('BT_MOD_COND_ERR_SHOW_DATA_UNSERIALIZE
'));
4515 if (!$this->boolError)
4517 $this->arConditions = (!empty($arConditions) ? $arConditions : $this->GetDefaultConditions());
4521 $this->ShowScripts();
4523 if ($this->boolCreateForm)
4527 if ($this->boolCreateCont)
4532 $strResult .= '<script>
'."\n";
4533 $strResult .= 'var
'.$this->strJSName.' =
new BX.TreeConditions(
'."\n";
4534 $strResult .= $this->ShowParams().",\n";
4535 $strResult .= $this->ShowConditions().",\n";
4536 $strResult .= $this->ShowControls()."\n";
4538 $strResult .= ');
'."\n";
4539 $strResult .= '</script>
'."\n";
4541 if ($this->boolCreateCont)
4545 if ($this->boolCreateForm)
4554 public function GetDefaultConditions()
4557 'CLASS_ID
' => 'CondGroup
',
4558 'DATA
' => array('All
' => 'AND
', 'True
' => 'True
'),
4559 'CHILDREN
' => array()
4563 public function Parse($arData = '', $arParams = false)
4565 global $APPLICATION;
4566 $this->arMsg = array();
4568 $this->usedModules = array();
4569 $this->usedExtFiles = array();
4571 $arResult = array();
4572 if (!$this->boolError)
4574 if (empty($arData) || !is_array($arData))
4576 if (isset($_POST[$this->strPrefix]) && !empty($_POST[$this->strPrefix]) && is_array($_POST[$this->strPrefix]))
4578 $arData = $_POST[$this->strPrefix];
4582 $this->boolError = true;
4583 $this->arMsg[] = array('id' => 'CONDITIONS
', 'text
' => Loc::getMessage('BT_MOD_COND_ERR_PARSE_DATA_EMPTY
'));
4588 if (!$this->boolError)
4590 foreach ($arData as $strKey => $value)
4592 $arKeys = $this->__ConvertKey($strKey);
4595 $this->boolError = true;
4596 $this->arMsg[] = array('id' => 'CONDITIONS
', 'text
' => Loc::getMessage('BT_MOD_COND_ERR_PARSE_DATA_BAD_KEY
'));
4600 if (!isset($value['controlId
']) || empty($value['controlId
']))
4602 $this->boolError = true;
4603 $this->arMsg[] = array('id' => 'CONDITIONS
', 'text
' => Loc::getMessage('BT_MOD_COND_ERR_PARSE_DATA_EMPTY_CONTROLID
'));
4607 if (!isset($this->arControlList[$value['controlId
']]))
4609 $this->boolError = true;
4610 $this->arMsg[] = array('id' => 'CONDITIONS
', 'text
' => Loc::getMessage('BT_MOD_COND_ERR_PARSE_DATA_BAD_CONTROLID
'));
4614 $arOneCondition = call_user_func_array($this->arControlList[$value['controlId
']]['Parse'],
4619 if (false === $arOneCondition)
4621 $this->boolError = true;
4622 $this->arMsg[] = array('id' => 'CONDITIONS
', 'text
' => Loc::getMessage('BT_MOD_COND_ERR_PARSE_DATA_CONTROL_BAD_VALUE
'));
4627 'CLASS_ID
' => $value['controlId
'],
4628 'DATA
' => $arOneCondition
4630 if ('Y
' == $this->arControlList[$value['controlId
']]['GROUP
'])
4632 $arItem['CHILDREN
'] = array();
4634 if (!$this->__SetCondition($arResult, $arKeys, 0, $arItem))
4636 $this->boolError = true;
4637 $this->arMsg[] = array('id' => 'CONDITIONS
', 'text
' => Loc::getMessage('BT_MOD_COND_ERR_PARSE_DATA_DOUBLE_KEY
'));
4643 if ($this->boolError)
4645 $obError = new CAdminException($this->arMsg);
4646 $APPLICATION->ThrowException($obError);
4648 return (!$this->boolError ? $arResult : '');
4651 public function ShowScripts()
4653 if (!$this->boolError)
4659 public function ShowAtoms()
4661 if (!$this->boolError)
4663 if (!isset($this->arAtomList))
4665 $this->OnConditionAtomBuildList();
4667 if (!empty($this->arAtomJSPath) && is_array($this->arAtomJSPath))
4669 $asset = Main\Page\Asset::getInstance();
4670 foreach ($this->arAtomJSPath as $jsPath)
4671 $asset->addJs($jsPath);
4678 public function ShowParams()
4680 if (!$this->boolError)
4683 'parentContainer
' => $this->strContID,
4684 'form
' => $this->strFormID,
4685 'formName
' => $this->strFormName,
4686 'sepID
' => $this->strSepID,
4687 'prefix
' => $this->strPrefix,
4690 if (!empty($this->arSystemMess))
4691 $arParams['messTree
'] = $this->arSystemMess;
4693 return CUtil::PhpToJSObject($arParams);
4701 public function ShowControls()
4703 if ($this->boolError)
4707 if (!empty($this->arShowControlList))
4709 foreach ($this->arShowControlList as &$arOneControl)
4711 $arShowControl = call_user_func_array($arOneControl, array(
4712 array('SHOW_IN_GROUPS
' => $this->arShowInGroups)
4714 if (!empty($arShowControl) && is_array($arShowControl))
4716 $this->fillForcedShow($arShowControl);
4717 if (isset($arShowControl['controlId
']) || isset($arShowControl['controlgroup
']))
4719 $result[] = $arShowControl;
4723 foreach ($arShowControl as &$oneControl)
4724 $result[] = $oneControl;
4729 unset($arOneControl);
4732 return CUtil::PhpToJSObject($result);
4735 public function ShowLevel(&$arLevel, $boolFirst = false)
4737 $boolFirst = ($boolFirst === true);
4738 $arResult = array();
4739 if (empty($arLevel) || !is_array($arLevel))
4744 if (isset($arLevel['CLASS_ID
']) && !empty($arLevel['CLASS_ID
']))
4746 if (isset($this->arControlList[$arLevel['CLASS_ID
']]))
4748 $arOneControl = $this->arControlList[$arLevel['CLASS_ID
']];
4750 'COND_NUM
' => $intCount,
4751 'DATA
' => $arLevel['DATA
'],
4752 'ID
' => $arOneControl['ID
'],
4754 $arOneResult = call_user_func_array($arOneControl["GetConditionShow"],
4759 if ('Y
' == $arOneControl['GROUP
'])
4761 $arOneResult['children
'] = array();
4762 if (isset($arLevel['CHILDREN
']))
4763 $arOneResult['children
'] = $this->ShowLevel($arLevel['CHILDREN
'], false);
4765 $arResult[] = $arOneResult;
4771 foreach ($arLevel as &$arOneCondition)
4773 if (isset($arOneCondition['CLASS_ID
']) && !empty($arOneCondition['CLASS_ID
']))
4775 if (isset($this->arControlList[$arOneCondition['CLASS_ID
']]))
4777 $arOneControl = $this->arControlList[$arOneCondition['CLASS_ID
']];
4779 'COND_NUM
' => $intCount,
4780 'DATA
' => $arOneCondition['DATA
'],
4781 'ID
' => $arOneControl['ID
'],
4783 $arOneResult = call_user_func_array($arOneControl["GetConditionShow"],
4789 if ('Y
' == $arOneControl['GROUP
'] && isset($arOneCondition['CHILDREN
']))
4791 $arOneResult['children
'] = $this->ShowLevel($arOneCondition['CHILDREN
'], false);
4793 $arResult[] = $arOneResult;
4798 if (isset($arOneCondition))
4799 unset($arOneCondition);
4804 public function ShowConditions()
4806 if (!$this->boolError)
4808 if (empty($this->arConditions))
4809 $this->arConditions = $this->GetDefaultConditions();
4811 $arResult = $this->ShowLevel($this->arConditions, true);
4813 return CUtil::PhpToJSObject(current($arResult));
4821 public function Generate($arConditions, $arParams)
4823 $this->usedModules = array();
4824 $this->usedExtFiles = array();
4825 $this->usedEntity = array();
4828 if (!$this->boolError)
4830 if (!empty($arConditions) && is_array($arConditions))
4832 $arResult = $this->GenerateLevel($arConditions, $arParams, true);
4833 if (empty($arResult))
4836 $this->boolError = true;
4840 $strResult = current($arResult);
4845 $this->boolError = true;
4851 public function GenerateLevel(&$arLevel, $arParams, $boolFirst = false)
4853 $arResult = array();
4854 $boolFirst = ($boolFirst === true);
4855 if (empty($arLevel) || !is_array($arLevel))
4861 if (isset($arLevel['CLASS_ID
']) && !empty($arLevel['CLASS_ID
']))
4863 if (isset($this->arControlList[$arLevel['CLASS_ID
']]))
4865 $arOneControl = $this->arControlList[$arLevel['CLASS_ID
']];
4866 if ('Y
' == $arOneControl['GROUP
'])
4868 $arSubEval = $this->GenerateLevel($arLevel['CHILDREN
'], $arParams);
4869 if (false === $arSubEval || !is_array($arSubEval))
4871 $strEval = call_user_func_array($arOneControl['Generate'],
4872 array($arLevel['DATA
'], $arParams, $arLevel['CLASS_ID
'], $arSubEval)
4877 $strEval = call_user_func_array($arOneControl['Generate'],
4878 array($arLevel['DATA
'], $arParams, $arLevel['CLASS_ID
'])
4881 if (false === $strEval || !is_string($strEval) || 'false' === $strEval)
4885 $arResult[] = '(
'.$strEval.')
';
4886 $this->fillUsedData($arOneControl);
4892 foreach ($arLevel as &$arOneCondition)
4894 if (isset($arOneCondition['CLASS_ID
']) && !empty($arOneCondition['CLASS_ID
']))
4896 if (isset($this->arControlList[$arOneCondition['CLASS_ID
']]))
4898 $arOneControl = $this->arControlList[$arOneCondition['CLASS_ID
']];
4899 if ('Y
' == $arOneControl['GROUP
'])
4901 $arSubEval = $this->GenerateLevel($arOneCondition['CHILDREN
'], $arParams);
4902 if (false === $arSubEval || !is_array($arSubEval))
4904 $strEval = call_user_func_array($arOneControl['Generate'],
4905 array($arOneCondition['DATA
'], $arParams, $arOneCondition['CLASS_ID
'], $arSubEval)
4910 $strEval = call_user_func_array($arOneControl['Generate'],
4911 array($arOneCondition['DATA
'], $arParams, $arOneCondition['CLASS_ID
'])
4915 if (false === $strEval || !is_string($strEval) || 'false' === $strEval)
4919 $arResult[] = '(
'.$strEval.')
';
4920 $this->fillUsedData($arOneControl);
4924 if (isset($arOneCondition))
4925 unset($arOneCondition);
4928 if (!empty($arResult))
4930 foreach ($arResult as $key => $value)
4932 if ('' == $value || '()
' == $value)
4933 unset($arResult[$key]);
4936 if (!empty($arResult))
4937 $arResult = array_values($arResult);
4942 public function GetConditionValues($arConditions)
4945 if (!$this->boolError)
4947 if (!empty($arConditions) && is_array($arConditions))
4949 $arValues = array();
4950 $this->GetConditionValuesLevel($arConditions, $arValues, true);
4951 $arResult = $arValues;
4957 public function GetConditionValuesLevel(&$arLevel, &$arResult, $boolFirst = false)
4959 $boolFirst = ($boolFirst === true);
4960 if (is_array($arLevel) && !empty($arLevel))
4964 if (isset($arLevel['CLASS_ID
']) && !empty($arLevel['CLASS_ID
']))
4966 if (isset($this->arControlList[$arLevel['CLASS_ID
']]))
4968 $arOneControl = $this->arControlList[$arLevel['CLASS_ID
']];
4969 if ('Y
' == $arOneControl['GROUP
'])
4971 if (call_user_func_array($arOneControl['ApplyValues'],
4972 array($arLevel['DATA
'], $arLevel['CLASS_ID
'])))
4974 $this->GetConditionValuesLevel($arLevel['CHILDREN
'], $arResult, false);
4979 $arCondInfo = call_user_func_array($arOneControl['ApplyValues'],
4980 array($arLevel['DATA
'], $arLevel['CLASS_ID
'])
4982 if (!empty($arCondInfo) && is_array($arCondInfo))
4984 if (!isset($arResult[$arLevel['CLASS_ID
']]) || empty($arResult[$arLevel['CLASS_ID
']]) || !is_array($arResult[$arLevel['CLASS_ID
']]))
4986 $arResult[$arLevel['CLASS_ID
']] = $arCondInfo;
4990 $arResult[$arLevel['CLASS_ID
']]['VALUES
'] = array_merge($arResult[$arLevel['CLASS_ID
']]['VALUES
'], $arCondInfo['VALUES
']);
4999 foreach ($arLevel as &$arOneCondition)
5001 if (isset($arOneCondition['CLASS_ID
']) && !empty($arOneCondition['CLASS_ID
']))
5003 if (isset($this->arControlList[$arOneCondition['CLASS_ID
']]))
5005 $arOneControl = $this->arControlList[$arOneCondition['CLASS_ID
']];
5006 if ('Y
' == $arOneControl['GROUP
'])
5008 if (call_user_func_array($arOneControl['ApplyValues'],
5009 array($arOneCondition['DATA
'], $arOneCondition['CLASS_ID
'])))
5011 $this->GetConditionValuesLevel($arOneCondition['CHILDREN
'], $arResult, false);
5016 $arCondInfo = call_user_func_array($arOneControl['ApplyValues'],
5017 array($arOneCondition['DATA
'], $arOneCondition['CLASS_ID
'])
5019 if (!empty($arCondInfo) && is_array($arCondInfo))
5021 if (!isset($arResult[$arOneCondition['CLASS_ID
']]) || empty($arResult[$arOneCondition['CLASS_ID
']]) || !is_array($arResult[$arOneCondition['CLASS_ID
']]))
5023 $arResult[$arOneCondition['CLASS_ID
']] = $arCondInfo;
5027 $arResult[$arOneCondition['CLASS_ID
']]['VALUES
'] = array_merge($arResult[$arOneCondition['CLASS_ID
']]['VALUES
'], $arCondInfo['VALUES
']);
5034 if (isset($arOneCondition))
5035 unset($arOneCondition);
5040 public function GetConditionHandlers()
5043 'MODULES
' => (!empty($this->usedModules) ? array_keys($this->usedModules) : array()),
5044 'EXT_FILES
' => (!empty($this->usedExtFiles) ? array_keys($this->usedExtFiles) : array())
5048 public function GetUsedEntityList()
5050 return $this->usedEntity;
5053 protected function __ConvertKey($strKey)
5057 $arKeys = explode($this->strSepID, $strKey);
5058 if (is_array($arKeys))
5060 foreach ($arKeys as &$intOneKey)
5062 $intOneKey = (int)$intOneKey;
5073 protected function __SetCondition(&$arResult, $arKeys, $intIndex, $arOneCondition)
5077 if (1 == sizeof($arKeys))
5079 $arResult = $arOneCondition;
5084 return $this->__SetCondition($arResult, $arKeys, $intIndex + 1, $arOneCondition);
5089 if (!isset($arResult['CHILDREN
']))
5091 $arResult['CHILDREN
'] = array();
5093 if (!isset($arResult['CHILDREN
'][$arKeys[$intIndex]]))
5095 $arResult['CHILDREN
'][$arKeys[$intIndex]] = array();
5097 if (($intIndex + 1) < sizeof($arKeys))
5099 return $this->__SetCondition($arResult['CHILDREN
'][$arKeys[$intIndex]], $arKeys, $intIndex + 1, $arOneCondition);
5103 if (!empty($arResult['CHILDREN
'][$arKeys[$intIndex]]))
5109 $arResult['CHILDREN
'][$arKeys[$intIndex]] = $arOneCondition;
5116 protected function fillUsedData(&$control)
5118 if (!empty($control['MODULE_ID
']))
5120 if (is_array($control['MODULE_ID
']))
5122 foreach ($control['MODULE_ID
'] as &$oneModuleID)
5124 if ($oneModuleID != $this->arEvents['CONTROLS
']['MODULE_ID
'])
5125 $this->usedModules[$oneModuleID] = true;
5127 unset($oneModuleID);
5131 if ($control['MODULE_ID
'] != $this->arEvents['CONTROLS
']['MODULE_ID
'])
5132 $this->usedModules[$control['MODULE_ID
']] = true;
5135 if (!empty($control['EXT_FILE
']))
5137 if (is_array($control['EXT_FILE
']))
5139 foreach ($control['EXT_FILE
'] as &$oneExtFile)
5140 $this->usedExtFiles[$oneExtFile] = true;
5145 $this->usedExtFiles[$control['EXT_FILE
']] = true;
5149 if (!empty($control['ENTITY
']))
5151 $entityID = $control['ENTITY
'].'|
';
5152 $entityID .= (is_array($control['FIELD
']) ? implode('-
', $control['FIELD
']) : $control['FIELD
']);
5153 if (!isset($this->usedEntity[$entityID]))
5156 'MODULE
' => (!empty($control['MODULE_ID
']) ? $control['MODULE_ID
'] : $control['MODULE_ENTITY
']),
5157 'ENTITY
' => $control['ENTITY
'],
5158 'FIELD_ENTITY
' => $control['FIELD
'],
5159 'FIELD_TABLE
' => (!empty($control['FIELD_TABLE
']) ? $control['FIELD_TABLE
'] : $control['FIELD
'])
5161 if (isset($control['ENTITY_ID
']))
5163 $row['ENTITY_ID
'] = $control['ENTITY_ID
'];
5165 if (isset($control['ENTITY_VALUE
']) || isset($control['ENTITY_ID
']))
5167 $row['ENTITY_VALUE
'] = (isset($control['ENTITY_VALUE
'])
5168 ? $control['ENTITY_VALUE
']
5169 : $control['ENTITY_ID
']
5172 $this->usedEntity[$entityID] = $row;
5179 protected function fillForcedShow(&$showControl)
5181 if (empty($this->forcedShowInGroup))
5183 if (isset($showControl['controlId
']) || isset($showControl['controlgroup
']))
5185 if (!isset($showControl['controlgroup
']))
5187 if (isset($this->forcedShowInGroup[$showControl['controlId
']]))
5188 $showControl['showIn
'] = array_values(array_unique(array_merge(
5189 $showControl['showIn
'], $this->forcedShowInGroup[$showControl['controlId
']]
5194 $forcedGroup = array();
5195 foreach ($showControl['children
'] as &$oneControl)
5197 if (isset($oneControl['controlId
']))
5199 if (isset($this->forcedShowInGroup[$oneControl['controlId
']]))
5201 $oneControl['showIn
'] = array_values(array_unique(array_merge(
5202 $oneControl['showIn
'], $this->forcedShowInGroup[$oneControl['controlId
']]
5204 $forcedGroup = array_merge($forcedGroup, $this->forcedShowInGroup[$oneControl['controlId
']]);
5209 if (!empty($forcedGroup))
5211 $forcedGroup = array_values(array_unique($forcedGroup));
5212 $showControl['showIn
'] = array_values(array_unique(array_merge($showControl['showIn
'], $forcedGroup)));
5214 unset($forcedGroup);
5220 foreach ($showControl as &$oneControl)
5222 if (isset($oneControl['controlId
']))
5224 if (isset($this->forcedShowInGroup[$oneControl['controlId
']]))
5225 $oneControl['showIn
'] = array_values(array_unique(array_merge(
5226 $oneControl['showIn
'], $this->forcedShowInGroup[$oneControl['controlId
']]
5235class CCatalogCondTree extends CGlobalCondTree
5237 public function __construct()
5239 parent::__construct();
5242 public function __destruct()
5244 parent::__destruct();
const BT_COND_MODE_DEFAULT
const BT_COND_BUILD_SALE_ACTIONS
const BT_COND_MODE_GENERATE
const BT_COND_LOGIC_NOT_CONT
const BT_COND_LOGIC_NOT_EQ
const BT_COND_MODE_SEARCH
const BT_COND_BUILD_CATALOG
static getMessage($code, $replace=null, $language=null)
static getList(array $parameters=array())
static GetConditionShow($params)
static Generate($condition, $params, $control, $childrens=false)
static GetControlShow($params)
static GetConditionShow($arParams)
static Generate($arOneCondition, $arParams, $arControl, $arSubs=false)
static Parse($arOneCondition)
static ApplyValues($arOneCondition, $arControl)
static GetConditionShow($arParams)
static Generate($arOneCondition, $arParams, $arControl, $arSubs=false)
static IsGroup($strControlID=false)
static Parse($arOneCondition)
static GetControlShow($arParams)
static ApplyValues($arOneCondition, $arControl)
static LogicEqualGreat($arField, $mxValue)
static CheckLogic($strValue, $arLogic, $boolShow=false)
static LogicGreat($arField, $mxValue)
static ClearValue(&$mxValues)
static ConvertDateTime2Int(&$mxValues, $strFormat, $intOffset)
static Validate($arOneCondition, $arParams, $arControl, $boolShow)
static InitParams($arParams)
static searchControlAtoms(array $atoms, $controlId, $extendedMode)
static LogicContain($arField, $mxValue)
static GetLogicAtom($arLogic)
static GetConditionShow($arParams)
static Generate($arOneCondition, $arParams, $arControl, $arSubs=false)
static CheckAtoms($arOneCondition, $arParams, $arControl, $boolShow)
static LogicNotContain($arField, $mxValue)
static GetLogicEx($arOperators=false, $arLabels=false)
static GetLogic($arOperators=false)
static GetShowIn($arControls)
static GetValueAtom($arValue)
static IsGroup($strControlID=false)
static Parse($arOneCondition)
static LogicLess($arField, $mxValue)
static GetJSControl($arControl, $arParams=array())
static searchControl(array $controls, $controlId)
static Check($arOneCondition, $arParams, $arControl, $boolShow)
static ValidateAtoms($arValues, $arParams, $arControl, $boolShow)
static GetControls($strControlID=false)
static LogicEqualLess($arField, $mxValue)
static OnBuildConditionAtomList()
static GetAtomsEx($strControlID=false, $boolEx=false)
static SearchLogic($strValue, $arLogic)
static GetControlShow($arParams)
static ConvertInt2DateTime(&$mxValues, $strFormat, $intOffset)
Generate($arConditions, $arParams)
Parse($arData='', $arParams=false)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
MakeTimeStamp($datetime, $format=false)
if(!AccessController::getCurrent() ->check(ActionDictionary::ACTION_CATALOG_EXPORT_EDIT)) if((!isset($_REQUEST['IBLOCK_ID']))||($_REQUEST['IBLOCK_ID']=='')) $intIBlockID