Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
album.php
1
<?php
2
3
namespace
Bitrix\Sale\TradingPlatform\Vk\Feed\Data\Converters
;
4
5
use
Bitrix\Main\ArgumentNullException
;
6
use
Bitrix\Sale\TradingPlatform\Vk
;
7
14
class
Album
extends
DataConverter
15
{
16
const
TITLE_LENGHT_MAX
= 128;
17
private
$result;
18
24
public
function
__construct
(
$exportId
)
25
{
26
if
(!isset(
$exportId
) ||
$exportId
==
''
)
27
throw
new
ArgumentNullException
(
"EXPORT_ID"
);
28
29
$this->exportId =
$exportId
;
30
}
31
32
39
public
function
convert
($data)
40
{
41
$this->result = array();
42
$logger =
new
Vk\Logger
($this->exportId);
43
if
($data[
"ELEMENT_CNT"
] == 0)
44
$logger->addError(
"ALBUM_EMPTY"
, $data[
"ID"
]);
45
46
$this->result[
"SECTION_ID"
] = $data[
"ID"
];
47
$this->result[
"IBLOCK_ID"
] = $data[
"IBLOCK_ID"
];
48
$this->result[
"TITLE"
] = $data[
"TO_ALBUM_ALIAS"
] ? $data[
"TO_ALBUM_ALIAS"
] : $data[
"NAME"
];
49
$this->result[
"TITLE"
] = $this->validateTitle($this->result[
'TITLE'
], $logger);
50
$this->result[
"TITLE"
] =
self::convertToUtf8
($this->result[
"TITLE"
]);
51
// add only checked photos
52
$sortedPhotos = Vk\PhotoResizer::sortPhotoArray(
53
array($data[
"PICTURE"
], $data[
"DETAIL_PICTURE"
]),
54
'ALBUM'
55
);
56
$checkedPhotos = Vk\PhotoResizer::checkPhotos($sortedPhotos,
'ALBUM'
);
57
if
($checkedPhotos)
58
foreach
($checkedPhotos[
"PHOTOS"
] as $photo)
59
{
60
$this->result[
"PHOTO_BX_ID"
] = $photo[
"PHOTO_BX_ID"
];
61
$this->result[
"PHOTO_URL"
] = $photo[
"PHOTO_URL"
];
62
}
63
else
64
$logger->addError(
"ALBUM_EMPTY_PHOTOS"
, $data[
"ID"
]);
65
66
// add item to log, if image was be resized
67
if
($checkedPhotos[
'RESIZE'
])
68
$logger->addError(
'ALBUM_PHOTOS_'
.$checkedPhotos[
'RESIZE_TYPE'
], $data[
"ID"
]);
69
70
return
array($data[
"ID"
] => $this->result);
71
}
72
73
81
private
function
validateTitle($title,
Vk
\
Logger
$logger = NULL)
82
{
83
$newTitle = $title;
84
85
if
(mb_strlen($title) > self::TITLE_LENGHT_MAX)
86
{
87
$newTitle = mb_substr($title, 0, self::TITLE_LENGHT_MAX - 1);
88
if
($logger)
89
$logger->addError(
'ALBUM_LONG_TITLE'
, $this->result[
"ID"
]);
90
}
91
92
return
$newTitle;
93
}
94
}
Bitrix\Main\ArgumentNullException
Definition
exception.php:54
Bitrix\Main\Diag\Logger
Definition
logger.php:19
Bitrix\Sale\Cashbox\Logger
Definition
logger.php:15
Bitrix\Sale\TradingPlatform\Vk\Feed\Data\Converters\Album
Definition
album.php:15
Bitrix\Sale\TradingPlatform\Vk\Feed\Data\Converters\Album\convert
convert($data)
Definition
album.php:39
Bitrix\Sale\TradingPlatform\Vk\Feed\Data\Converters\Album\__construct
__construct($exportId)
Definition
album.php:24
Bitrix\Sale\TradingPlatform\Vk\Feed\Data\Converters\Album\TITLE_LENGHT_MAX
const TITLE_LENGHT_MAX
Definition
album.php:16
Bitrix\Sale\TradingPlatform\Vk\Feed\Data\Converters\DataConverter
Definition
dataconverter.php:11
Bitrix\Sale\TradingPlatform\Vk\Feed\Data\Converters\DataConverter\convertToUtf8
static convertToUtf8($value)
Definition
dataconverter.php:19
Bitrix\Sale\TradingPlatform\Vk\Feed\Data\Converters\DataConverter\$exportId
$exportId
Definition
dataconverter.php:15
Bitrix\Sale\TradingPlatform\Vk\Vk
Definition
vk.php:20
Bitrix\Sale\TradingPlatform\Vk\Feed\Data\Converters
Definition
album.php:3
Bitrix\Sale\TradingPlatform\Vk
Definition
agent.php:3
modules
sale
lib
tradingplatform
vk
feed
data
converters
album.php
Создано системой
1.10.0