- Модуль: iblock
- Путь к файлу: ~/bitrix/modules/iblock/classes/general/cml2.php
- Класс: CIBlockCMLImport
- Вызов: CIBlockCMLImport::CheckFileByName
function CheckFileByName($file, $fields = null)
{
$external_id = $file;
$fileName = bx_basename($file);
if (!empty($fields) && $fileName != "")
{
if (empty($this->arElementFiles))
{
$this->arElementFiles = array();
$ID = array();
foreach ($this->arElementFilesId as $fileId)
{
foreach($fileId as $value)
$ID[$value] = $value;
}
$rsFile = CFile::GetList(array(), array(
"@ID" => implode(",", $ID),
));
while ($arFile = $rsFile->Fetch())
{
$arFile["~ORIGINAL_NAME"] = preg_replace("/(\.resize[0-9]+\.)/", ".", $arFile["ORIGINAL_NAME"]);
$this->arElementFiles[$arFile["ID"]] = $arFile;
}
}
foreach ($fields as $fieldId)
{
if (isset($this->arElementFilesId[$fieldId]))
{
foreach ($this->arElementFilesId[$fieldId] as $fileId)
{
if (isset($this->arElementFiles[$fileId]))
{
if ($this->arElementFiles[$fileId]["EXTERNAL_ID"] === $external_id)
return $fileId;
if ($this->arElementFiles[$fileId]["~ORIGINAL_NAME"] === $fileName)
return $fileId;
}
}
}
}
}
return false;
}