- Модуль: iblock
- Путь к файлу: ~/bitrix/modules/iblock/classes/general/iblockdocument.php
- Класс: CIBlockDocument
- Вызов: CIBlockDocument::GetDocumentForHistory
static function GetDocumentForHistory($documentId, $historyIndex)
{
$documentId = intval($documentId);
if ($documentId <= 0)
throw new CBPArgumentNullException("documentId");
$arResult = null;
$dbDocumentList = CIBlockElement::GetList(
array(),
array("ID" => $documentId, "SHOW_NEW"=>"Y", "SHOW_HISTORY" => "Y")
);
if ($objDocument = $dbDocumentList->GetNextElement())
{
$arDocumentFields = $objDocument->GetFields();
$arDocumentProperties = $objDocument->GetProperties();
$arResult["NAME"] = $arDocumentFields["~NAME"];
$arResult["FIELDS"] = array();
foreach ($arDocumentFields as $fieldKey => $fieldValue)
{
if ($fieldKey == "~PREVIEW_PICTURE" || $fieldKey == "~DETAIL_PICTURE")
{
$arResult["FIELDS"][mb_substr($fieldKey, 1)] = CBPDocument::PrepareFileForHistory(
array("iblock", "CIBlockDocument", $documentId),
$fieldValue,
$historyIndex
);
}
elseif (mb_substr($fieldKey, 0, 1) == "~")
{
$arResult["FIELDS"][mb_substr($fieldKey, 1)] = $fieldValue;
}
}
$arResult["PROPERTIES"] = array();
foreach ($arDocumentProperties as $propertyKey => $propertyValue)
{
if ($propertyValue["USER_TYPE"] <> '')
{
$arResult["PROPERTIES"][$propertyKey] = array(
"VALUE" => $propertyValue["VALUE"],
"DESCRIPTION" => $propertyValue["DESCRIPTION"]
);
}
elseif ($propertyValue["PROPERTY_TYPE"] == "L")
{
$arResult["PROPERTIES"][$propertyKey] = array(
"VALUE" => $propertyValue["VALUE_ENUM_ID"],
"DESCRIPTION" => $propertyValue["DESCRIPTION"]
);
}
elseif ($propertyValue["PROPERTY_TYPE"] == "F")
{
$arResult["PROPERTIES"][$propertyKey] = array(
"VALUE" => CBPDocument::PrepareFileForHistory(
array("iblock", "CIBlockDocument", $documentId),
$propertyValue["VALUE"],
$historyIndex
),
"DESCRIPTION" => $propertyValue["DESCRIPTION"]
);
}
else
{
$arResult["PROPERTIES"][$propertyKey] = array(
"VALUE" => $propertyValue["VALUE"],
"DESCRIPTION" => $propertyValue["DESCRIPTION"]
);
}
}
}
return $arResult;
}