38 $logger->addError(
'TOO_MANY_SECTIONS_TO_EXPORT');
43 $startPosition = current($data);
44 $startPosition = $startPosition[
"SECTION_ID"];
48 if (self::$firstRunning)
51 self::$isAgressive = self::$vk->isAgressiveExport($this->exportId);
52 self::$firstRunning =
false;
57 $albumsFromVk = $vkExportedData->getData();
59 $data = Vk\Map::checkMappingMatches($data, $albumsFromVk, $this->exportId,
'ALBUMS', self::$isAgressive);
66 $logger->addLog(
"Upload album photo");
68 $photoUploader =
new PhotoUploader($this->exportId, PhotoUploader::TYPE_ALBUM_PHOTO, $timer);
69 $albumPhotoSaveResults = $photoUploader->upload($data);
72 if(!array_key_exists(
'errors', $albumPhotoSaveResults))
74 $data = Vk\Api\ApiHelper::addResultToData($data, $albumPhotoSaveResults,
"SECTION_ID");
78 $logger->addLog(
"Add or edit albums", $data);
79 $albumsData = Vk\Api\ApiHelper::extractItemsFromArray($data,
80 array(
"SECTION_ID",
"TITLE",
"FLAG_EDIT",
"PHOTO_VK_ID",
"ALBUM_VK_ID"));
81 $albumsAddEditResults = $this->executer->executeMarketAlbumAddEdit(array(
82 "owner_id" => $this->vkGroupId,
83 "data" => $albumsData,
84 "count" => count($data),
86 $data = Vk\Api\ApiHelper::addResultToData($data, $albumsAddEditResults,
"SECTION_ID");
90 $dataToMapping = array();
91 foreach ($albumsAddEditResults as $item)
93 if (isset($item[
"flag_album_add_result"]) && $item[
"flag_album_add_result"])
94 $dataToMapping[] = array(
95 "value_external" => $item[
"ALBUM_VK_ID"],
96 "value_internal" => $item[
"SECTION_ID"],
100 if (!empty($dataToMapping))
102 Vk\Map::addAlbumMapping($dataToMapping, $this->exportId);
109 $dataToCache = Vk\Api\ApiHelper::extractItemsFromArray($data, array(
'ALBUM_VK_ID'));
110 $dataToCache = Vk\Api\ApiHelper::changeArrayMainKey($dataToCache,
'ALBUM_VK_ID');
111 $vkExportedData->addData($dataToCache);
115 if ($timer !==
null && !$timer->check())