7if (Loader::requireModule(
'bizproc'))
9 class ECrm
extends UserTypeProperty
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();
65 $property = static::getUserType($fieldType);
66 if(
empty($property[
'USER_TYPE_SETTINGS']))
67 $property[
'USER_TYPE_SETTINGS'] = $fieldType->getOptions();
106 if (!
is_array($value) ||
is_array($value) && \CBPHelper::isAssociativeArray($value))
107 $value =
array($value);
109 foreach ($value
as $v)
111 if (\CBPActivity::isExpression(
$v))
120 $property = static::getUserType($fieldType);
122 if(!
empty($property[
'GetPublicEditHTMLMulty']))
124 $fieldName = static::generateControlName($field);
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
137 'FORM_NAME' => $field[
'Form'],
138 'VALUE' => $fieldName,
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]);
170 public static function toSingleValue(FieldType $fieldType, $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();
201 private static function normalizeValue(FieldType $fieldType, $value)