...Человеческий поиск в разработке...
- Модуль: bizproc
- Путь к файлу: ~/bitrix/modules/bizproc/classes/general/virtualdocument.php
- Класс: CBPVirtualDocument
- Вызов: CBPVirtualDocument::getDocument
static function getDocument($documentId) { $documentId = intval($documentId); if ($documentId <= 0) throw new CBPArgumentNullException("documentId"); $arResult = null; $dbDocumentList = CIBlockElement::GetList( array(), array("ID" => $documentId, "SHOW_NEW" => "Y") ); if ($objDocument = $dbDocumentList->GetNextElement(false, true)) { $arDocumentFields = $objDocument->GetFields(); $arDocumentProperties = $objDocument->GetProperties(); foreach ($arDocumentFields as $fieldKey => $fieldValue) { if (mb_substr($fieldKey, 0, 1) == "~") continue; $arResult[$fieldKey] = $fieldValue; if (in_array($fieldKey, array("MODIFIED_BY", "CREATED_BY"))) { $arResult[$fieldKey] = "user_".$fieldValue; $arResult[$fieldKey."_PRINTABLE"] = $arDocumentFields[($fieldKey == "MODIFIED_BY") ? "~USER_NAME" : "~CREATED_USER_NAME"]; } elseif (in_array($fieldKey, array("PREVIEW_TEXT", "DETAIL_TEXT"))) { if ($arDocumentFields[$fieldKey."_TYPE"] == "html") $arResult[$fieldKey] = HTMLToTxt($arDocumentFields["~".$fieldKey]); } } foreach ($arDocumentProperties as $propertyKey => $propertyValue) { if ($propertyValue["USER_TYPE"] <> '') { if ($propertyValue["USER_TYPE"] == "UserID" || $propertyValue["USER_TYPE"] == "employee" && (COption::GetOptionString("bizproc", "employee_compatible_mode", "N") != "Y")) { if (!is_array($propertyValue["VALUE"])) { $db = CUser::GetByID($propertyValue["VALUE"]); if ($ar = $db->fetch()) { $arResult["PROPERTY_".$propertyKey] = "user_".intval($propertyValue["VALUE"]); $arResult["PROPERTY_".$propertyKey."_PRINTABLE"] = "(".$ar["LOGIN"].")".(($ar["NAME"] <> '' || $ar["LAST_NAME"] <> '') ? " " : "").CUser::FormatName(COption::GetOptionString("bizproc", "name_template", CSite::GetNameFormat(false), SITE_ID), $ar, false, false); } } else { for ($i = 0, $cnt = count($propertyValue["VALUE"]); $i < $cnt; $i++) { $db = CUser::GetByID($propertyValue["VALUE"][$i]); if ($ar = $db->fetch()) { $arResult["PROPERTY_".$propertyKey][] = "user_".intval($propertyValue["VALUE"][$i]); $arResult["PROPERTY_".$propertyKey."_PRINTABLE"][$propertyValue["VALUE"][$i]] = "(".$ar["LOGIN"].")".(($ar["NAME"] <> '' || $ar["LAST_NAME"] <> '') ? " " : "").CUser::FormatName(COption::GetOptionString("bizproc", "name_template", CSite::GetNameFormat(false), SITE_ID), $ar, false, false); } } } } else { $arResult["PROPERTY_".$propertyKey] = $propertyValue["VALUE"]; } } elseif ($propertyValue["PROPERTY_TYPE"] == "L") { $arPropertyValue = $propertyValue["VALUE"]; $arPropertyKey = $propertyValue["VALUE_XML_ID"]; if (!is_array($arPropertyValue)) { $arPropertyValue = array($arPropertyValue); $arPropertyKey = array($arPropertyKey); } for ($i = 0, $cnt = count($arPropertyValue); $i < $cnt; $i++) $arResult["PROPERTY_".$propertyKey][$arPropertyKey[$i]] = $arPropertyValue[$i]; } elseif ($propertyValue["PROPERTY_TYPE"] == "F") { if (!is_array($propertyValue["VALUE"])) { if ((intval($propertyValue["VALUE"]) > 0) && ($ar = CFile::GetFileArray($propertyValue["VALUE"]))) { $arResult["PROPERTY_".$propertyKey] = $propertyValue["VALUE"]; $arResult["PROPERTY_".$propertyKey."_PRINTABLE"] = $ar["SRC"]; } } else { for ($i = 0, $cnt = count($propertyValue["VALUE"]); $i < $cnt; $i++) { if ((intval($propertyValue["VALUE"][$i]) > 0) && ($ar = CFile::GetFileArray($propertyValue["VALUE"][$i]))) { $arResult["PROPERTY_".$propertyKey][] = $propertyValue["VALUE"][$i]; $arResult["PROPERTY_".$propertyKey."_PRINTABLE"][$propertyValue["VALUE"][$i]] = $ar["SRC"]; } } } } else { $arResult["PROPERTY_".$propertyKey] = $propertyValue["VALUE"]; } } } return $arResult; }