本文整理汇总了PHP中CBPDocument::PrepareFileForHistory方法的典型用法代码示例。如果您正苦于以下问题:PHP CBPDocument::PrepareFileForHistory方法的具体用法?PHP CBPDocument::PrepareFileForHistory怎么用?PHP CBPDocument::PrepareFileForHistory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBPDocument
的用法示例。
在下文中一共展示了CBPDocument::PrepareFileForHistory方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetDocumentForHistory
/**
* ћетод возвращает массив произвольной структуры, содержащий всю информацию о документе. ѕо этому массиву документ восстановливаетс¤ методом RecoverDocumentFromHistory.
*
* @param string $documentId - код документа.
* @return array - массив документа.
*/
public 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"][substr($fieldKey, 1)] = CBPDocument::PrepareFileForHistory(array("iblock", "CIBlockDocument", $documentId), $fieldValue, $historyIndex);
} elseif (substr($fieldKey, 0, 1) == "~") {
$arResult["FIELDS"][substr($fieldKey, 1)] = $fieldValue;
}
}
$arResult["PROPERTIES"] = array();
foreach ($arDocumentProperties as $propertyKey => $propertyValue) {
if (strlen($propertyValue["USER_TYPE"]) > 0) {
$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;
}
示例2: GetDocumentForHistory
/**
* Метод возвращает массив произвольной структуры, содержащий всю информацию о документе. По этому массиву документ восстановливается методом RecoverDocumentFromHistory.
*
* @param string $documentId - код документа.
* @return array - массив документа.
*/
public function GetDocumentForHistory($documentId, $historyIndex, $update = false)
{
$documentId = intval($documentId);
if ($documentId <= 0) {
throw new CBPArgumentNullException("documentId");
}
$diskId = self::processGetDiskIdByDocId($documentId);
if ($diskId !== null) {
return self::proxyToDisk(__FUNCTION__, array($diskId, $historyIndex, $update));
}
$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"][substr($fieldKey, 1)] = CBPDocument::PrepareFileForHistory(array("webdav", "CIBlockDocumentWebdavSocnet", $documentId), $fieldValue, $historyIndex);
} elseif (substr($fieldKey, 0, 1) == "~") {
$arResult["FIELDS"][substr($fieldKey, 1)] = $fieldValue;
}
}
$arResult["PROPERTIES"] = array();
foreach ($arDocumentProperties as $propertyKey => $propertyValue) {
if (strlen($propertyValue["USER_TYPE"]) > 0) {
$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" && $propertyKey == 'FILE') {
$arDocID = $documentId;
if (!is_array($documentId)) {
$arDocID = array("webdav", "CIBlockDocumentWebdavSocnet", $documentId);
}
$arResult['PROPERTIES'][$propertyKey] = CWebdavDocumentHistory::GetFileForHistory($arDocID, $propertyValue, $historyIndex);
$arResult['OLD_FILE_ID'] = $propertyValue['VALUE'];
//for historical comment.
if ($update) {
$historyGlueState = CWebdavDocumentHistory::GetHistoryState($arDocID, null, null, array('CHECK_TIME' => 'Y'));
} else {
$historyGlueState = CWebdavDocumentHistory::GetHistoryState($arDocID, null, null, array('NEW' => 'Y', 'CHECK_TIME' => 'Y'));
}
$arResult['PROPERTIES'][$propertyKey]['HISTORYGLUE'] = $historyGlueState;
} elseif ($propertyValue["PROPERTY_TYPE"] == "F") {
$arResult["PROPERTIES"][$propertyKey] = array("VALUE" => CBPDocument::PrepareFileForHistory(array("webdav", "CIBlockDocumentWebdavSocnet", $documentId), $propertyValue["VALUE"], $historyIndex), "DESCRIPTION" => $propertyValue["DESCRIPTION"]);
} else {
$arResult["PROPERTIES"][$propertyKey] = array("VALUE" => $propertyValue["VALUE"], "DESCRIPTION" => $propertyValue["DESCRIPTION"]);
}
}
}
return $arResult;
}
示例3: GetDocumentForHistory
public static function GetDocumentForHistory($documentId, $historyIndex)
{
global $USER_FIELD_MANAGER;
$arDocumentID = self::GetDocumentInfo($documentId);
if (empty($arDocumentID)) {
throw new CBPArgumentNullException('documentId');
}
$arResult = self::GetDocument($documentId);
switch ($arDocumentID['TYPE']) {
case 'CONTACT':
if (!empty($arResult['PHOTO'])) {
$arResult['PHOTO'] = CBPDocument::PrepareFileForHistory(array('crm', 'CCrmDocument' . ucfirst(strtolower($arDocumentID['TYPE'])), $documentId), $arResult['PHOTO'], $historyIndex);
}
break;
case 'COMPANY':
if (!empty($arResult['LOGO'])) {
$arResult['LOGO'] = CBPDocument::PrepareFileForHistory(array('crm', 'CCrmDocument' . ucfirst(strtolower($arDocumentID['TYPE'])), $documentId), $arResult['LOGO'], $historyIndex);
}
break;
}
$arUserFields = $USER_FIELD_MANAGER->GetUserFields('CRM_' . $arDocumentID['TYPE'], $arDocumentID['ID'], LANGUAGE_ID);
foreach ($arUserFields as $FIELD_NAME => $arUserField) {
if ($arUserField['USER_TYPE']['BASE_TYPE'] == 'file') {
$arFiles = !is_array($arUserField[$FIELD_NAME]) ? array($arUserField[$FIELD_NAME]) : $arUserField[$FIELD_NAME];
foreach ($arFiles as $sFilePath) {
$sFilePath = CBPDocument::PrepareFileForHistory(array('crm', 'CCrmDocument' . ucfirst(strtolower($arDocumentID['TYPE'])), $documentId), $sFilePath, $historyIndex);
if (!is_array($arUserField[$FIELD_NAME])) {
$arResult[$FIELD_NAME] = $sFilePath;
break;
} else {
$arResult[$FIELD_NAME][] = $sFilePath;
}
}
}
}
return $arResult;
}
示例4: GetFileForHistory
public static function GetFileForHistory($documentId, $propertyValue, $historyIndex)
{
$newFileID = $propertyValue['VALUE'];
$bNewFile = true;
$history = self::GetHistoryService();
$dbDoc = $history->GetHistoryList(array("ID" => "DESC"), array("DOCUMENT_ID" => $documentId), false, false, array("ID", "DOCUMENT_ID", "NAME", "MODIFIED", "USER_ID", "USER_NAME", "USER_LAST_NAME", "USER_LOGIN", "DOCUMENT"));
$newFileHash = CWebDavBase::_get_file_hash($newFileID);
$oldFileHash = null;
if ($newFileHash !== null) {
if ($dbDoc && ($arTmpDoc = $dbDoc->Fetch())) {
while ($arDoc = $dbDoc->Fetch()) {
$oldFileHash = $arDoc['DOCUMENT']['PROPERTIES']['FILE']['HASH'];
if ($oldFileHash == $newFileHash) {
$bNewFile = false;
$result = $arDoc['DOCUMENT']['PROPERTIES']['FILE'];
break;
}
}
}
}
if ($oldFileHash == null || $newFileHash == null) {
$bNewFile = true;
}
// add new copy to history
if ($bNewFile) {
$result = array("VALUE" => CBPDocument::PrepareFileForHistory($documentId, $propertyValue["VALUE"], $historyIndex), "DESCRIPTION" => $propertyValue["DESCRIPTION"], "HASH" => $newFileHash);
}
return $result;
}