21 $fields = $this->getFieldsToCopy($iblockId, $copiedIblockId);
22 $this->addListsFields($iblockId, $copiedIblockId, $fields);
27 private function getFieldsToCopy($iblockId, $copiedIblockId)
31 $object = new \CList($iblockId);
33 foreach($object->getFields() as $fieldId => $field)
37 "NAME" => $field[
"NAME"],
38 "SORT" => $field[
"SORT"],
39 "MULTIPLE" => $field[
"MULTIPLE"],
40 "IS_REQUIRED" => $field[
"IS_REQUIRED"],
41 "IBLOCK_ID" => $copiedIblockId,
42 "SETTINGS" => $field[
"SETTINGS"],
43 "DEFAULT_VALUE" => $field[
"DEFAULT_VALUE"],
44 "TYPE" => $field[
"TYPE"],
45 "PROPERTY_TYPE" => $field[
"PROPERTY_TYPE"],
48 if (!$object->is_field($fieldId))
50 if ($field[
"TYPE"] ==
"L")
55 $copiedField[
"CODE"] = $field[
"CODE"];
56 $copiedField[
"LINK_IBLOCK_ID"] = $field[
"LINK_IBLOCK_ID"];
57 if (!empty($field[
"PROPERTY_USER_TYPE"][
"USER_TYPE"]))
58 $copiedField[
"USER_TYPE"] = $field[
"PROPERTY_USER_TYPE"][
"USER_TYPE"];
59 if (!empty($field[
"ROW_COUNT"]))
60 $copiedField[
"ROW_COUNT"] = $field[
"ROW_COUNT"];
61 if (!empty($field[
"COL_COUNT"]))
62 $copiedField[
"COL_COUNT"] = $field[
"COL_COUNT"];
63 if (!empty($field[
"USER_TYPE_SETTINGS"]))
64 $copiedField[
"USER_TYPE_SETTINGS"] = $field[
"USER_TYPE_SETTINGS"];
66 $fields[] = $copiedField;
72 private function addListsFields($iblockId, $copiedIblockId, array $fields)
74 $object = new \CList($copiedIblockId);
76 foreach ($fields as $field)
78 if ($field[
"ID"] ==
"NAME")
80 $result = $object->updateField(
"NAME", $field);
84 $result = $object->addField($field);
95 $this->result->addError(
98 self::FIELD_COPY_ERROR
static loadMessages($file)
static getMessage($code, $replace=null, $language=null)