10if (Loader::requireModule(
'bizproc'))
12 class UserTypePropertyDiskFile
extends UserTypeProperty
19 public static function getType()
21 return FieldType::INT;
24 public static function formatValueMultiple(FieldType $fieldType, $value, $format =
'printable')
26 if (!
is_array($value) ||
is_array($value) && \CBPHelper::isAssociativeArray($value))
27 $value =
array($value);
29 foreach ($value
as $k =>
$v)
31 $value[
$k] = static::formatValuePrintable($fieldType,
$v);
34 return implode(static::getFormatSeparator($format), $value);
37 public static function formatValueSingle(FieldType $fieldType, $value, $format =
'printable')
39 return static::formatValueMultiple($fieldType, $value, $format);
47 protected static function formatValuePrintable(FieldType $fieldType, $value)
49 $iblockId = self::getIblockId($fieldType);
51 $property = static::getUserType($fieldType);
68 public static function convertTo(FieldType $fieldType, $value,
$toTypeClass)
71 $value = $value[
'VALUE'];
73 $value = (
int) $value;
76 $type = $toTypeClass::getType();
80 $diskFile = File::getById($value);
81 $value = $diskFile? $diskFile->getFileId() :
null;
90 public static function convertValueMultiple(FieldType $fieldType, $value,
$toTypeClass)
99 public static function getConversionMap()
108 public static function canRenderControl(
$renderMode)
112 return (static::getMobileControlRenderer() !==
null);
146 $value = current($value);
148 if (\CBPActivity::isExpression($value))
153 return static::renderControlSelector($field,
$selectorValue,
true,
'', $fieldType);
164 $userType = static::getUserType($fieldType);
165 $iblockId = self::getIblockId($fieldType);
167 if (!
empty($userType[
'GetPublicEditHTML']))
170 $value = $value[
'VALUE'];
172 $fieldName = static::generateControlName($field);
174 $userType[
'GetPublicEditHTML'],
177 'IBLOCK_ID' => $iblockId,
178 'IS_REQUIRED' => $fieldType->isRequired()?
'Y' :
'N',
179 'PROPERTY_USER_TYPE' => $userType
181 array(
'VALUE' => $value),
183 'FORM_NAME' => $field[
'Form'],
184 'VALUE' => $fieldName,
197 public static function extractValueSingle(FieldType $fieldType,
array $field,
array $request)
199 return static::extractValueMultiple($fieldType, $field, $request);
202 public static function extractValueMultiple(FieldType $fieldType,
array $field,
array $request)
204 if (defined(
'BX_MOBILE'))
209 return parent::extractValueMultiple($fieldType, $field, $request);
212 private static function getIblockId(FieldType $fieldType)
214 $documentType = $fieldType->getDocumentType();
215 $type =
explode(
'_', $documentType[2]);
221 $value = parent::extractValue($fieldType, $field, $request);
224 $value = $value[
'VALUE'];
232 $property = static::getUserType($fieldType);
233 $iblockId = self::getIblockId($fieldType);
252 [$renderer,
'extractValues'],
253 static::generateControlName($field),
257 $property = static::getUserType($fieldType);
258 $iblockId = self::getIblockId($fieldType);
265 $property[
'AttachFilesWorkflow'], [$iblockId, $diskFileId]
270 if (!$fieldType->isMultiple())
278 public static function clearValueSingle(FieldType $fieldType, $value)
280 static::clearValueMultiple($fieldType, $value);
283 public static function clearValueMultiple(FieldType $fieldType, $values)
287 $values =
array($values);
290 $property = static::getUserType($fieldType);
291 $iblockId = self::getIblockId($fieldType);
299 public static function toSingleValue(FieldType $fieldType, $value)
303 $value = $value[
'VALUE'];
316 $className = \CBitrixComponent::includeComponentClass(self::MOBILE_COMPONENT_NAME);
319 return $className ?:
null;
328 self::MOBILE_COMPONENT_NAME,
331 'INPUT_NAME' => static::generateControlName($field),
332 'INPUT_VALUE' => $value,
333 'MULTIPLE' => $fieldType->isMultiple() ?
'Y' :
'N'
extractValue(array $fieldProperties, $value)