30 private static $instances =
null;
41 $typeId = (int)$typeId;
44 if(!DocumentType::IsDefined($typeId))
49 if(self::$instances ===
null || !isset(self::$instances[$typeId]))
51 if(self::$instances ===
null)
53 self::$instances = array();
56 if(!isset(self::$instances[$typeId]))
58 self::$instances[$typeId] = ConverterFactory::create($typeId);
61 return self::$instances[$typeId];
74 return $this->settings;
79 return $this->entityTypeId;
84 return $this->documentTypeId;
87 public function init(
ISettings $settings, $entityTypeId = EntityType::UNDEFINED, $documentTypeId = DocumentType::UNDEFINED)
89 $this->settings = $settings;
102 switch($fieldInfo[
'TYPE'])
105 $value = self::toText($value);
109 $value = \CDatabase::FormatDate($value->toString(), \CSite::GetDateFormat(
"FULL", LANG),
"HH:MI:SS");
113 $value = \CDatabase::FormatDate($value->toString(), \CSite::GetDateFormat(
"FULL", LANG),
"YYYY-MM-DD");
117 $value = \CDatabase::FormatDate($value->toString(), \CSite::GetDateFormat(
"FULL", LANG),
"YYYY-MM-DD HH:MI:SS");
120 $value = $value ==
'Y'?
'true':
'false';
123 $value = intval($value);
135 $value = preg_replace(
'/<style[^>]*>.*?<\/style>/is',
'', $value);
136 $value = preg_replace(
'/<blockquote[^>]*>.*?<\/blockquote>/is',
'', $value);
137 $value = preg_replace(
'/<script[^>]*>.*?<\/script>/is',
'', $value);
139 return html_entity_decode(
141 preg_replace(
'/(<br[^>]*>)+/is'.BX_UTF_PCRE_MODIFIER,
"\n", $value)
153 list($productXmlId, $offerXmlId) = explode(
"#", $xml_id, 2);
154 if ($productXmlId === $offerXmlId)
155 $xml_id = $productXmlId;
169 foreach($rekv as $kRekv=>$vRekv)
171 foreach($info[
'FIELDS'] as $name=>$fieldInfo)
182 $fieldInfo[
'TYPE'] =
'datetime';
186 $result[$rowId][$name] = $value;
201 foreach($info[
'FIELDS'] as $name=>$fieldInfo)
207 $value = DocumentBase::getLangByCodeField($kRekv);
214 $result[$name] = $value;
227 foreach ($fields as $key=>$value)
233 if($key ===
'REK_VALUES' || $key ===
'ADDRESS_FIELD' || $key ===
'CONTACT' || $key ===
'REPRESENTATIVE')
235 $groupFieldValues = array();
236 foreach ($value as $k=>$v)
240 unset($fields[$key][$k]);
242 $groupFieldValues = $fields[$key];
244 if(count($groupFieldValues)>0)
245 $result[$key] = $groupFieldValues;
247 unset($fields[$key]);
253 $result[$key]=$value;
260 $result[$key]=$value;
277 $res = \CSite::getList(
"sort",
"desc");
278 while ($site = $res->fetch())
280 $sites[$site[
'LID']]=$site[
'NAME'];
283 if(!is_array($sites))
288 return isset($sites[$lid]) ? $sites[$lid]:
'';
295 if(is_array($fields))
297 foreach($fields as $k=>$items)
299 foreach($items as $productXML_ID => $item)
301 if($item[
'NAME'] == DocumentBase::getLangByCodeField(ImportOneCBase::DELIVERY_SERVICE_XMLID))
303 unset($result[$k][$productXML_ID]);
305 $item[
'ID'] = ImportOneCBase::DELIVERY_SERVICE_XMLID;
306 $result[$k][ImportOneCBase::DELIVERY_SERVICE_XMLID] = $item;
externalizeField(&$value, $fieldInfo=null)
const CURRENCY_RATE_DEFAULT
modifyItemIdByItemName($fields)
externalizeRekv(array $rekv, array $info)
externalizeRekvValue($kRekv, $vRekv, array $info)
static getSiteNameByLid($lid)
const MEASURE_CODE_DEFAULT
static getInstance($typeId)
init(ISettings $settings, $entityTypeId=EntityType::UNDEFINED, $documentTypeId=DocumentType::UNDEFINED)
modifyTrim(array $fields)
static normalizeExternalCode($code)