7if (Loader::requireModule(
"bizproc"))
9 class Sequence
extends UserTypeProperty
11 public static function getType()
13 return FieldType::INT;
24 public static function renderControlSingle(FieldType $fieldType, array $field, $value, $allowSelection, $renderMode)
26 return self::renderControl($fieldType, $field, $value, $allowSelection, $renderMode);
37 public static function renderControlMultiple(FieldType $fieldType, array $field, $value, $allowSelection, $renderMode)
40 if (!is_array($value) || is_array($value) && \CBPHelper::isAssociativeArray($value))
45 foreach ($value as $v)
47 if (!\CBPActivity::isExpression($v))
54 foreach ($typeValue as $k => $v)
56 $singleField = $field;
57 $singleField[
"Index"] = $k;
58 $controls[] = self::renderControlSingle($fieldType, $singleField, $v, $allowSelection, $renderMode);
61 return static::wrapCloneableControls($controls, static::generateControlName($field));
73 protected static function renderControl(FieldType $fieldType, array $field, $value, $allowSelection, $renderMode)
75 $name = static::generateControlName($field);
76 $controlId = static::generateControlId($field);
77 $className = static::generateControlClassName($fieldType, $field);
79 $options = $fieldType->getOptions();
81 $iblockId = self::getIblockId($fieldType);
83 $queryObject = \CIBlockProperty::getByID(mb_substr($field[
"Field"], mb_strlen(
"PROPERTY_")), $iblockId);
84 if ($property = $queryObject->fetch())
86 $propertyId = $property[
"ID"];
91 $value = (int) $value;
95 $sequence = new \CIBlockSequence($iblockId, $propertyId);
96 $value = $sequence->getCurrent();
99 $readonly = ((isset($options[
"write"]) && $options[
"write"] ==
"Y") ?
"" :
"readonly");
101 return '<input '.htmlspecialcharsbx($readonly).
' type="text" class="'.
102 htmlspecialcharsbx($className).
'" size="40" id="'.htmlspecialcharsbx($controlId).
'" name="'
103 .htmlspecialcharsbx($name).
'" value="'.htmlspecialcharsbx((
string) $value).
'"/>';
106 private static function getIblockId(FieldType $fieldType)
108 $documentType = $fieldType->getDocumentType();
109 $type = explode(
'_', $documentType[2]);
110 return intval($type[1]);