2namespace Bitrix\Landing\Controller;
4use Bitrix\Landing\Block;
5use Bitrix\Landing\Connector;
6use Bitrix\Landing\Site\Type;
7use Bitrix\Main\Engine\Controller;
8use Bitrix\Main\Engine\Response\BFile;
10use Bitrix\Main\UI\Viewer;
14 private const FILE_DOWNLOAD_URL =
'/bitrix/services/main/ajax.php?' .
15 'action=landing.api.diskFile.download&' .
16 'fileId=#fileId#&blockId=#blockId#&scope=#scope#';
31 public static function getDownloadLink(
string $scope,
int $blockId, ?
int $fileId =
null): string
34 [
'#scope#',
'#blockId#',
'#fileId#'],
35 [$scope, $blockId, $fileId ?:
'#fileId#'],
36 self::FILE_DOWNLOAD_URL .
'&ver=' . time()
48 private function blockContainsFile(
string $scope,
int $blockId,
int $fileId): bool
50 if (Type::isPublicScope($scope))
58 return Block::isContains($blockId, $needed);
69 private function landingContainsFile(
string $scope,
int $landingId,
int $fileId): bool
71 if (Type::isPublicScope($scope))
77 $needed = Connector\Disk::FILE_PREFIX_HREF . $fileId;
79 return Block::isContains($landingId, $needed,
true);
92 if ($this->blockContainsFile($scope, $blockId, $fileId))
97 return new BFile(\CFile::getFileArray($fileInfo[
'ID']), $fileInfo[
'NAME']);
115 if ($this->blockContainsFile($scope, $blockId, $fileId))
122 $attributes->setTitle($fileInfo[
'NAME']);
123 return $attributes->getAttributes();
139 if ($this->landingContainsFile($scope, $landingId, $fileId))
141 return \Bitrix\Landing\Connector\Disk::getFileInfo($fileId,
false);
static getFileInfo(int $objectId, bool $checkRights=true, bool $copyInLocalStorage=false)
viewAction(string $scope, int $blockId, int $fileId)
infoAction(int $fileId, string $scope, int $landingId)
downloadAction(string $scope, int $blockId, int $fileId)
static getDownloadLink(string $scope, int $blockId, ?int $fileId=null)
static tryBuildByFileId($fileId, $sourceUri)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)