- Модуль: lists
- Путь к файлу: ~/bitrix/modules/lists/lib/entity/element.php
- Класс: BitrixListsEntityElement
- Вызов: Element::getFileUrl
public function getFileUrl()
{
$this->param->checkRequiredInputParams(["IBLOCK_CODE", "IBLOCK_ID", "ELEMENT_CODE", "ELEMENT_ID", "FIELD_ID"]);
if ($this->param->hasErrors())
{
$this->errorCollection->add($this->param->getErrors());
return [];
}
$urls = [];
$sefFolder = $this->getSefFolder();
$queryProperty = CIBlockElement::getProperty($this->iblockId, $this->elementId,
"SORT", "ASC", array("ACTIVE"=>"Y", "EMPTY"=>"N", "ID" => $this->params["FIELD_ID"])
);
while ($property = $queryProperty->fetch())
{
if ($property["PROPERTY_TYPE"] == "F")
{
$file = new CListFile($this->iblockId, 0, $this->elementId,
"PROPERTY_".$this->params["FIELD_ID"], $property["VALUE"]);
$file->SetSocnetGroup($this->params["SOCNET_GROUP_ID"]);
$urls[] = $file->GetImgSrc(["url_template" => $sefFolder.
"#list_id#/file/#section_id#/#element_id#/#field_id#/#file_id#/"]);
}
elseif ($property["USER_TYPE"] == "DiskFile")
{
if (is_array($property["VALUE"]))
{
foreach ($property["VALUE"] as $attacheId)
{
$driver = BitrixDiskDriver::getInstance();
$urls[] = $driver->getUrlManager()->getUrlUfController(
"download", array("attachedId" => $attacheId));
}
}
}
}
return $urls;
}