9 class ECrm
extends UserTypeProperty
11 protected static $formatSeparator =
', ';
19 public static function formatValueMultiple(
FieldType $fieldType, $value, $format =
'printable')
21 if (!is_array($value) || is_array($value) && \CBPHelper::isAssociativeArray($value))
22 $value =
array($value);
24 self::$formatSeparator = static::getFormatSeparator($format);
26 return static::formatValuePrintable($fieldType, $value);
35 public static function formatValueSingle(FieldType $fieldType, $value, $format =
'printable')
37 return static::formatValueMultiple($fieldType, $value, $format);
40 protected static function formatValuePrintable(FieldType $fieldType, $value)
42 $property = static::getUserType($fieldType);
43 $property[
'IBLOCK_ID'] = self::getIblockId($fieldType);
44 if(empty($property[
'USER_TYPE_SETTINGS']))
45 $property[
'USER_TYPE_SETTINGS'] = $fieldType->getOptions();
47 if (array_key_exists(
'GetValuePrintable', $property))
49 return call_user_func_array($property[
'GetValuePrintable'],
array($property, $value, self::$formatSeparator));
63 public static function renderControlOptions(FieldType $fieldType, $callbackFunctionName, $value)
65 $property = static::getUserType($fieldType);
66 if(empty($property[
'USER_TYPE_SETTINGS']))
67 $property[
'USER_TYPE_SETTINGS'] = $fieldType->getOptions();
69 if(array_key_exists(
'GetSettingsHTML', $property))
72 return call_user_func_array($property[
'GetSettingsHTML'],
array($property,
73 array(
'USE_BP' =>
true,
'CALLBACK_FUNCTION' => $callbackFunctionName,
'NAME' =>
'ENTITY'), &$fieldData));
89 public static function renderControlSingle(FieldType $fieldType,
array $field, $value, $allowSelection, $renderMode)
91 return static::renderControlMultiple($fieldType, $field, $value, $allowSelection, $renderMode);
102 public static function renderControlMultiple(FieldType $fieldType,
array $field, $value, $allowSelection, $renderMode)
104 $selectorValue =
null;
105 $typeValue =
array();
106 if (!is_array($value) || is_array($value) && \CBPHelper::isAssociativeArray($value))
109 foreach ($value as $v)
117 if (empty($typeValue))
120 $property = static::getUserType($fieldType);
122 if(!empty($property[
'GetPublicEditHTMLMulty']))
124 $fieldName = static::generateControlName($field);
125 $renderResult = call_user_func_array(
126 $property[
'GetPublicEditHTMLMulty'],
129 'IBLOCK_ID' => self::getIblockId($fieldType),
130 'USER_TYPE_SETTINGS' => $fieldType->getOptions(),
131 'MULTIPLE' => $fieldType->isMultiple() ?
'Y' :
'N',
132 'IS_REQUIRED' => $fieldType->isRequired() ?
'Y' :
'N',
133 'PROPERTY_USER_TYPE' => $property
135 array(
'VALUE' => $typeValue),
137 'FORM_NAME' => $field[
'Form'],
138 'VALUE' => $fieldName,
147 $renderResult = static::renderControl($fieldType, $field,
'', $allowSelection, $renderMode);
152 $renderResult .= static::renderControlSelector($field, $selectorValue,
true,
'', $fieldType);
155 return $renderResult;
158 public static function extractValueSingle(FieldType $fieldType,
array $field,
array $request)
160 return static::extractValueMultiple($fieldType, $field,
$request);
163 private static function getIblockId(FieldType $fieldType)
165 $documentType = $fieldType->getDocumentType();
166 $type = explode(
'_', $documentType[2]);
167 return intval(
$type[1]);
170 public static function toSingleValue(FieldType $fieldType, $value)
172 if (is_array($value))
174 $values = array_values($value);
175 return isset($values[0]) ? $values[0] :
null;
177 return parent::toSingleValue($fieldType, $value);
180 public static function externalizeValue(FieldType $fieldType,
$context, $value)
182 return self::normalizeValue(
183 $fieldType, \CBPHelper::stringify(parent::externalizeValue($fieldType,
$context, $value))
187 private static function isUsePrefix(FieldType $fieldType): ?bool
189 $options = $fieldType->getOptions();
195 return count(array_filter(
$options,
static fn($mark) => $mark ===
'Y')) !== 1;
201 private static function normalizeValue(FieldType $fieldType, $value)
203 $hasPrefix = strpos($value,
'_') !==
false;
204 $isUsePrefix = self::isUsePrefix($fieldType);
206 if ($hasPrefix && $isUsePrefix ===
false)
208 return current(array_reverse(explode(
'_', $value)));
if(!Loader::includeModule('catalog')) if(!AccessController::getCurrent() ->check(ActionDictionary::ACTION_PRICE_EDIT)) if(!check_bitrix_sessid()) $request
static requireModule($moduleName)
static isExpression($text)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"