当前位置: 首页>>代码示例>>PHP>>正文


PHP CBPDocument::PrepareFileForHistory方法代码示例

本文整理汇总了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;
 }
开发者ID:spas-viktor,项目名称:books,代码行数:41,代码来源:iblockdocument.php

示例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;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:59,代码来源:iblocksocnetbizproc.php

示例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;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:37,代码来源:crm_document.php

示例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;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:29,代码来源:iblockbizprochistory.php


注:本文中的CBPDocument::PrepareFileForHistory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。