13 final class CallbackHandler
implements Transformer\InterfaceCallback
36 Transformer\FileTransformer::clearInfoCache(
$params[
'fileId']);
38 if (
$status == Transformer\Command::STATUS_ERROR && isset(
$params[
'id']))
45 return 'wrong parameters';
48 if (
$status != Transformer\Command::STATUS_UPLOAD)
50 return 'wrong command status';
53 $previewLogId = $previewId = $previewImageId = 0;
54 $previewLog = FilePreviewTable::getList([
56 'filter' => [
'FILE_ID' =>
$params[
'fileId']],
60 if (isset($previewLog[
'ID']))
62 $previewLogId = $previewLog[
'ID'];
65 foreach (
$result[
'files'] as $ext => $filePath)
69 $previewImageId = self::saveFile($filePath,
'image/jpeg');
74 FilePreviewTable::update($previewLogId, [
75 'PREVIEW_IMAGE_ID' => $previewImageId,
80 $resultAdd = FilePreviewTable::add([
82 'PREVIEW_IMAGE_ID' => $previewImageId,
85 if ($resultAdd->getId())
87 $previewLogId = $resultAdd->getId();
94 $previewId = self::saveFile($filePath, MimeType::getByFileExtension($ext));
97 FilePreviewTable::update($previewLogId, [
98 'PREVIEW_ID' => $previewId,
103 FilePreviewTable::add([
104 'FILE_ID' =>
$params[
'fileId'],
105 'PREVIEW_ID' => $previewId,
109 self::sendNotifyAboutTransformation(
$params[
'fileId']);
113 (
new Event(
'main',
'onFileTransformationComplete', [
120 protected static function sendNotifyAboutTransformation($fileId)
122 if (Loader::includeModule(
'pull'))
124 \CPullWatch::addToStack(
125 TransformerManager::getPullTag($fileId),
127 'module_id' =>
'main',
128 'command' =>
'transformationComplete',
137 protected static function saveFile($file,
$type)
139 $fileArray = \CFile::makeFileArray($file,
$type);
140 $fileArray[
'MODULE_ID'] =
'main';
141 $fileId = \CFile::saveFile($fileArray,
'main_preview');
150 public static function existSavedFile($fileId)
152 $previewRow = FilePreviewTable::getList([
153 'select' => [
'ID',
'PID' =>
'PREVIEW.ID'],
155 '=FILE_ID' => $fileId,
160 return !empty($previewRow[
'PID']);
static includeModule($moduleName)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
send(AbstractCommand $command, Workgroup $entity)
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']