CBPVirtualDocument::getFieldInputValuePrintable

  1. Bitrix24 API (v. 23.675.0)
  2. bizproc
  3. CBPVirtualDocument
  4. getFieldInputValuePrintable
  • Модуль: bizproc
  • Путь к файлу: ~/bitrix/modules/bizproc/classes/general/virtualdocument.php
  • Класс: CBPVirtualDocument
  • Вызов: CBPVirtualDocument::getFieldInputValuePrintable
static function getFieldInputValuePrintable($documentType, $arFieldType, $fieldValue)
{
	$result = $fieldValue;

	switch ($arFieldType['Type'])
	{
		case "S:UserID":
			if (!is_array($fieldValue))
				$fieldValue = array($fieldValue);

			$result = CBPHelper::UsersArrayToString($fieldValue, null, array("bizproc", "CBPVirtualDocument", $documentType));
			break;

		case "B":
			if (is_array($fieldValue))
			{
				$result = array();
				foreach ($fieldValue as $r)
					$result[] = ((mb_strtoupper($r) != "N" && !empty($r)) ? GetMessage("BPVDX_YES") : GetMessage("BPVDX_NO"));
			}
			else
			{
				$result = ((mb_strtoupper($fieldValue) != "N" && !empty($fieldValue)) ? GetMessage("BPVDX_YES") : GetMessage("BPVDX_NO"));
			}
			break;

		case "F":
			if (is_array($fieldValue))
			{
				$result = array();
				foreach ($fieldValue as $r)
				{
					$r = intval($r);
					$dbImg = CFile::GetByID($r);
					if ($arImg = $dbImg->Fetch())
						$result[] = "[url=/bitrix/tools/bizproc_show_file.php?f=".urlencode($arImg["FILE_NAME"])."&i=".$r."]".htmlspecialcharsbx($arImg["ORIGINAL_NAME"])."[/url]";
				}
			}
			else
			{
				$fieldValue = intval($fieldValue);
				$dbImg = CFile::GetByID($fieldValue);
				if ($arImg = $dbImg->Fetch())
					$result = "[url=/bitrix/tools/bizproc_show_file.php?f=".urlencode($arImg["FILE_NAME"])."&i=".$fieldValue."]".htmlspecialcharsbx($arImg["ORIGINAL_NAME"])."[/url]";
			}
			break;
		case "L":
			if (is_array($arFieldType["Options"]))
			{
				if (is_array($fieldValue))
				{
					$result = array();
					foreach ($fieldValue as $r)
					{
						if (array_key_exists($r, $arFieldType["Options"]))
							$result[] = $arFieldType["Options"][$r];
					}
				}
				else
				{
					if (array_key_exists($fieldValue, $arFieldType["Options"]))
						$result = $arFieldType["Options"][$fieldValue];
				}
			}
			break;
	}

	if (mb_strpos($arFieldType['Type'], ":") !== false)
	{
		if ($arFieldType["Type"] == "S:employee")
			$fieldValue = CBPHelper::StripUserPrefix($fieldValue);

		$arCustomType = CIBlockProperty::GetUserType(mb_substr($arFieldType['Type'], 2));
		if (array_key_exists("GetPublicViewHTML", $arCustomType))
		{
			if (is_array($fieldValue) && !CBPHelper::IsAssociativeArray($fieldValue))
			{
				$checkValue = $arCustomType["GetPublicViewHTML"][0] == "CIBlockPropertyElementList";
				$result = array();
				foreach ($fieldValue as $value)
				{
					$v = $checkValue && isset($value['VALUE']) ? $value : array('VALUE' => $value);
					$r = call_user_func_array(
						$arCustomType["GetPublicViewHTML"],
						array(
							array("LINK_IBLOCK_ID" => $arFieldType["Options"]),
							$v,
							""
						)
					);

					$result[] = HTMLToTxt($r);
				}
			}
			else
			{
				$result = call_user_func_array(
					$arCustomType["GetPublicViewHTML"],
					array(
						array("LINK_IBLOCK_ID" => $arFieldType["Options"]),
						array("VALUE" => $fieldValue),
						""
					)
				);

				$result = HTMLToTxt($result);
			}
		}
	}

	return $result;
}

Добавить комментарий