1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
image.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Sale\TradingPlatform\Ebay\Feed\Data\Converters;
4
5
use Bitrix\Main\ArgumentNullException;
6
7
class
Image
extends
DataConverter
8
{
9
protected
$siteId
;
10
protected
$morePhotoProp
;
11
protected
$domainName
;
12
13
public
function
__construct
(
$params
)
14
{
15
if
(!isset(
$params
[
"SITE_ID"
]) ||
$params
[
"SITE_ID"
] ==
''
)
16
throw
new
ArgumentNullException
(
"SITE_ID"
);
17
18
$this->siteId =
$params
[
"SITE_ID"
];
19
}
20
21
public
function
convert
(
$data
)
22
{
23
$result
=
""
;
24
$ebay =
\Bitrix\Sale\TradingPlatform\Ebay\Ebay::getInstance
();
25
$ebaySettings = $ebay->getSettings();
26
$this->morePhotoProp = isset($ebaySettings[$this->siteId][
"MORE_PHOTO_PROP"
][
$data
[
"IBLOCK_ID"
]]) ? $ebaySettings[
$this->siteId
][
"MORE_PHOTO_PROP"
][
$data
[
"IBLOCK_ID"
]] :
null
;
27
28
if
(!$this->morePhotoProp)
29
return
""
;
30
31
$this->domainName = isset($ebaySettings[$this->siteId][
"DOMAIN_NAME"
]) ? $ebaySettings[
$this->siteId
][
"DOMAIN_NAME"
] :
null
;
32
33
if
(!empty(
$data
[
"OFFERS"
]) && is_array(
$data
[
"OFFERS"
]))
34
{
35
foreach
(
$data
[
"OFFERS"
] as $offer)
36
$result
.= $this->
getItemData
($offer,
$data
[
"IBLOCK_ID"
].
"_"
.
$data
[
"ID"
].
"_"
.$offer[
"ID"
]);
37
}
38
else
39
{
40
$result
= $this->
getItemData
($data,
$data
[
"IBLOCK_ID"
].
"_"
.
$data
[
"ID"
]);
41
}
42
43
return
$result
;
44
}
45
46
protected
function
getItemData
(
$data
, $sku)
47
{
48
$morePhotoValue =
array
();
49
50
if
(empty(
$data
[
"PROPERTIES"
]) || !is_array(
$data
[
"PROPERTIES"
]))
51
return
""
;
52
53
foreach
(
$data
[
"PROPERTIES"
] as $propCode => $propParams)
54
{
55
if
($propParams[
"ID"
] == $this->morePhotoProp)
56
{
57
if
(!empty($propParams[
"VALUE"
]) && is_array($propParams[
"VALUE"
]))
58
{
59
$morePhotoValue = $propParams[
"VALUE"
];
60
break
;
61
}
62
else
63
{
64
return
""
;
65
}
66
}
67
}
68
69
$pictureUrls =
""
;
70
71
foreach
($morePhotoValue as $value)
72
{
73
$pictureUrl = $this->
getPictureUrl
($value);
74
75
if
($pictureUrl <>
''
)
76
$pictureUrls .=
"\t\t<URL>"
.$pictureUrl.
"</URL>\n"
;
77
}
78
79
if
($pictureUrls ==
''
)
80
return
""
;
81
82
$result
=
"\t<Image>\n"
.
83
"\t\t<SKU>"
.$sku.
"</SKU>\n"
.
84
$pictureUrls.
85
"\t</Image>\n"
;
86
87
return
$result
;
88
}
89
90
protected
function
getPictureUrl
($pictNo)
91
{
92
$strFile
=
""
;
93
94
if
($file = \CFile::GetFileArray($pictNo))
95
{
96
if
(mb_substr($file[
"SRC"
], 0, 1) ==
"/"
)
97
$strFile
=
"http://"
.$this->domainName.implode(
"/"
, array_map(
"rawurlencode"
, explode(
"/"
, $file[
"SRC"
])));
98
elseif
(preg_match(
"/^(http|https):\\/\\/(.*?)\\/(.*)\$/"
, $file[
"SRC"
], $match))
99
$strFile
=
"http://"
.$match[2].
'/'
.implode(
"/"
, array_map(
"rawurlencode"
, explode(
"/"
, $match[3])));
100
else
101
$strFile
= $file[
"SRC"
];
102
}
103
104
return
$strFile
;
105
}
106
107
}
Bitrix\Main\ArgumentNullException
Определения
ArgumentNullException.php:9
Bitrix\Sale\TradingPlatform\Ebay\Ebay\getInstance
static getInstance()
Определения
ebay.php:23
Bitrix\Sale\TradingPlatform\Ebay\Feed\Data\Converters\DataConverter
Определения
dataconverter.php:6
Bitrix\Sale\TradingPlatform\Ebay\Feed\Data\Converters\Image
Определения
image.php:8
Bitrix\Sale\TradingPlatform\Ebay\Feed\Data\Converters\Image\getPictureUrl
getPictureUrl($pictNo)
Определения
image.php:90
Bitrix\Sale\TradingPlatform\Ebay\Feed\Data\Converters\Image\convert
convert($data)
Определения
image.php:21
Bitrix\Sale\TradingPlatform\Ebay\Feed\Data\Converters\Image\getItemData
getItemData($data, $sku)
Определения
image.php:46
Bitrix\Sale\TradingPlatform\Ebay\Feed\Data\Converters\Image\$morePhotoProp
$morePhotoProp
Определения
image.php:10
Bitrix\Sale\TradingPlatform\Ebay\Feed\Data\Converters\Image\__construct
__construct($params)
Определения
image.php:13
Bitrix\Sale\TradingPlatform\Ebay\Feed\Data\Converters\Image\$domainName
$domainName
Определения
image.php:11
Bitrix\Sale\TradingPlatform\Ebay\Feed\Data\Converters\Image\$siteId
$siteId
Определения
image.php:9
$data
$data['IS_AVAILABLE']
Определения
.description.php:13
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$result
$result
Определения
get_property_values.php:14
$strFile
if(! $ar_profile) $strFile
Определения
cron_frame.php:59
elseif
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения
prolog_main_admin.php:393
$params
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения
template.php:799
bitrix
modules
sale
lib
tradingplatform
ebay
feed
data
converters
image.php
Создано системой
1.14.0