11if (Loader::requireModule(
'bizproc'))
13 class UserTypePropertyHtml
extends UserTypeProperty
22 public static function convertTo(FieldType $fieldType, $value,
$toTypeClass)
25 $value = $value[
'VALUE'];
27 $value = $value[
'TEXT'];
29 return parent::convertTo($fieldType, $value,
$toTypeClass);
38 public static function convertFrom(FieldType $fieldType, $value,
$fromTypeClass)
44 $type = $fromTypeClass::getType();
49 case FieldType::DATETIME:
50 case FieldType::DOUBLE:
52 case FieldType::INTERNALSELECT:
53 case FieldType::SELECT:
54 case FieldType::STRING:
57 $value =
array(
'TYPE' =>
'text',
'TEXT' => (
string) $value);
70 public static function getConversionMap()
81 FieldType::INTERNALSELECT,
95 protected static function formatValuePrintable(FieldType $fieldType, $value)
98 $value = $value[
'VALUE'];
100 $value = $value[
'TEXT'];
116 $name = static::generateControlName($field);
117 $controlId = static::generateControlId($field);
120 $value = $value[
'VALUE'];
122 $value = $value[
'TEXT'];
124 return \CBPViewHelper::getHtmlEditor($controlId, $name, $value);
138 if (\CBPActivity::isExpression($value))
166 if (!
is_array($value) ||
is_array($value) && \CBPHelper::isAssociativeArray($value))
167 $value =
array($value);
169 foreach ($value
as $v)
171 if (\CBPActivity::isExpression(
$v))
186 $controls[] = static::renderControl(
195 $renderResult = static::wrapCloneableControls($controls, static::generateControlName($field));
210 protected static function wrapCloneableControls(
array $controls,
$wrapperId)
213 $renderResult =
'<table width="100%" border="0" cellpadding="2" cellspacing="2" id="BizprocCloneable_'
221 $renderResult .=
'<input type="button" value="'.Loc::getMessage(
'BPDT_BASE_ADD')
222 .
'" onclick="BX.Bizproc.cloneTypeControlHtml(\'BizprocCloneable_'
223 .$wrapperId.
'\', \
''.$wrapperId.
'\')
"/><br />';
225 return $renderResult;
228 public static function externalizeValue(FieldType $fieldType, $context, $value)
230 if (is_array($value) && isset($value['TEXT']) && !is_scalar($value['TEXT']))
232 return is_object($value['TEXT']) && method_exists($value['TEXT'], '__toString')
233 ? (string)$value['TEXT']
238 return parent::externalizeValue($fieldType, $context, $value);
241 protected static function generateControlName(array $field)
243 $name = $field['Field'];
244 $index = isset($field['Index']) ? (int)$field['Index'] : null;
247 $name .= "[
n{$field[
'Index']}]
";