CBPVirtualDocument::getDocumentFields

  1. Bitrix24 API (v. 23.675.0)
  2. bizproc
  3. CBPVirtualDocument
  4. getDocumentFields
  • Модуль: bizproc
  • Путь к файлу: ~/bitrix/modules/bizproc/classes/general/virtualdocument.php
  • Класс: CBPVirtualDocument
  • Вызов: CBPVirtualDocument::getDocumentFields
static function getDocumentFields($documentType)
{
	$v = mb_substr($documentType, mb_strlen("type_"));
	if (intval($v)."!" != $v."!")
		throw new CBPArgumentOutOfRangeException("documentType", $documentType);
	$iblockId = intval($v);

	$arDocumentFieldTypes = self::GetDocumentFieldTypes($documentType);

	$arResult = array(
		"ID" => array(
			"Name" => GetMessage("BPVDX_FIELD_ID"),
			"Type" => "N",
			"Filterable" => true,
			"Editable" => false,
			"Required" => false,
		),
		"TIMESTAMP_X" => array(
			"Name" => GetMessage("BPVDX_FIELD_TIMESTAMP_X"),
			"Type" => "S:DateTime",
			"Filterable" => true,
			"Editable" => true,
			"Required" => false,
		),
		"MODIFIED_BY" => array(
			"Name" => GetMessage("BPVDX_FIELD_MODYFIED"),
			"Type" => "S:UserID",
			"Filterable" => true,
			"Editable" => true,
			"Required" => false,
		),
		"MODIFIED_BY_PRINTABLE" => array(
			"Name" => GetMessage("BPVDX_FIELD_MODIFIED_BY_USER_PRINTABLE"),
			"Type" => "S",
			"Filterable" => false,
			"Editable" => false,
			"Required" => false,
		),
		"DATE_CREATE" => array(
			"Name" => GetMessage("BPVDX_FIELD_DATE_CREATE"),
			"Type" => "S:DateTime",
			"Filterable" => true,
			"Editable" => true,
			"Required" => false,
		),
		"CREATED_BY" => array(
			"Name" => GetMessage("BPVDX_FIELD_CREATED"),
			"Type" => "S:UserID",
			"Filterable" => true,
			"Editable" => false,
			"Required" => false,
		),
		"CREATED_BY_PRINTABLE" => array(
			"Name" => GetMessage("BPVDX_FIELD_CREATED_BY_USER_PRINTABLE"),
			"Type" => "S",
			"Filterable" => false,
			"Editable" => false,
			"Required" => false,
		),
		"IBLOCK_ID" => array(
			"Name" => GetMessage("BPVDX_FIELD_IBLOCK_ID"),
			"Type" => "N",
			"Filterable" => true,
			"Editable" => true,
			"Required" => false,
		),
		"ACTIVE" => array(
			"Name" => GetMessage("BPVDX_FIELD_ACTIVE"),
			"Type" => "B",
			"Filterable" => true,
			"Editable" => true,
			"Required" => false,
		),
		/*"BP_PUBLISHED" => array(
			"Name" => GetMessage("BPVDX_FIELD_BP_PUBLISHED"),
			"Type" => "B",
			"Filterable" => false,
			"Editable" => true,
			"Required" => false,
		),*/
		"ACTIVE_FROM" => array(
			"Name" => GetMessage("BPVDX_FIELD_DATE_ACTIVE_FROM"),
			"Type" => "S:DateTime",
			"Filterable" => true,
			"Editable" => true,
			"Required" => false,
		),
		"ACTIVE_TO" => array(
			"Name" => GetMessage("BPVDX_FIELD_DATE_ACTIVE_TO"),
			"Type" => "S:DateTime",
			"Filterable" => true,
			"Editable" => true,
			"Required" => false,
		),
		"SORT" => array(
			"Name" => GetMessage("BPVDX_FIELD_SORT"),
			"Type" => "N",
			"Filterable" => true,
			"Editable" => true,
			"Required" => false,
		),
		"NAME" => array(
			"Name" => GetMessage("BPVDX_FIELD_NAME"),
			"Type" => "S",
			"Filterable" => true,
			"Editable" => true,
			"Required" => true,
		),
		"PREVIEW_PICTURE" => array(
			"Name" => GetMessage("BPVDX_FIELD_PREVIEW_PICTURE"),
			"Type" => "F",
			"Filterable" => false,
			"Editable" => true,
			"Required" => false,
		),
		"PREVIEW_TEXT" => array(
			"Name" => GetMessage("BPVDX_FIELD_PREVIEW_TEXT"),
			"Type" => "T",
			"Filterable" => false,
			"Editable" => true,
			"Required" => false,
		),
		"PREVIEW_TEXT_TYPE" => array(
			"Name" => GetMessage("BPVDX_FIELD_PREVIEW_TEXT_TYPE"),
			"Type" => "L",
			"Options" => array(
				"text" => GetMessage("BPVDX_DESC_TYPE_TEXT"),
				"html" => "Html",
			),
			"Filterable" => false,
			"Editable" => true,
			"Required" => false,
		),
		"DETAIL_PICTURE" => array(
			"Name" => GetMessage("BPVDX_FIELD_DETAIL_PICTURE"),
			"Type" => "F",
			"Filterable" => false,
			"Editable" => true,
			"Required" => false,
		),
		"DETAIL_TEXT" => array(
			"Name" => GetMessage("BPVDX_FIELD_DETAIL_TEXT"),
			"Type" => "T",
			"Filterable" => false,
			"Editable" => true,
			"Required" => false,
		),
		"DETAIL_TEXT_TYPE" => array(
			"Name" => GetMessage("BPVDX_FIELD_DETAIL_TEXT_TYPE"),
			"Type" => "L",
			"Options" => array(
				"text" => GetMessage("BPVDX_DESC_TYPE_TEXT"),
				"html" => "Html",
			),
			"Filterable" => false,
			"Editable" => true,
			"Required" => false,
		),
		"CODE" => array(
			"Name" => GetMessage("BPVDX_FIELD_CODE"),
			"Type" => "S",
			"Filterable" => true,
			"Editable" => true,
			"Required" => false,
		),
		"XML_ID" => array(
			"Name" => GetMessage("BPVDX_FIELD_XML_ID"),
			"Type" => "S",
			"Filterable" => true,
			"Editable" => true,
			"Required" => false,
		),
	);

	$arKeys = array_keys($arResult);
	foreach ($arKeys as $key)
		$arResult[$key]["Multiple"] = false;

	$dbProperties = CIBlockProperty::GetList(
		array("sort" => "asc", "name" => "asc"),
		array("IBLOCK_ID" => $iblockId)
	);
	while ($arProperty = $dbProperties->Fetch())
	{
		if (trim($arProperty["CODE"]) <> '')
			$key = "PROPERTY_".$arProperty["CODE"];
		else
			$key = "PROPERTY_".$arProperty["ID"];

		$arResult[$key] = array(
			"Name" => $arProperty["NAME"],
			"Filterable" => ($arProperty["FILTRABLE"] == "Y"),
			"Editable" => true,
			"Required" => ($arProperty["IS_REQUIRED"] == "Y"),
			"Multiple" => ($arProperty["MULTIPLE"] == "Y"),
			"Type" => $arProperty["PROPERTY_TYPE"],
		);

		if ($arProperty["USER_TYPE"] <> '')
		{
			$arResult[$key]["Type"] = "S:".$arProperty["USER_TYPE"];

			if ($arProperty["USER_TYPE"] == "UserID"
				|| $arProperty["USER_TYPE"] == "employee" && (COption::GetOptionString("bizproc", "employee_compatible_mode", "N") != "Y"))
			{
				$arResult[$key."_PRINTABLE"] = array(
					"Name" => $arProperty["NAME"].GetMessage("BPVDX_FIELD_USERNAME_PROPERTY"),
					"Filterable" => false,
					"Editable" => false,
					"Required" => false,
					"Multiple" => ($arProperty["MULTIPLE"] == "Y"),
					"Type" => "S",
				);
			}
			elseif ($arProperty["USER_TYPE"] == "EList")
			{
				$arResult[$key]["Type"] = "E:EList";
				$arResult[$key]["Options"] = $arProperty["LINK_IBLOCK_ID"];
			}
		}
		elseif ($arProperty["PROPERTY_TYPE"] == "L")
		{
			$arResult[$key]["Options"] = array();
			$dbPropertyEnums = CIBlockProperty::GetPropertyEnum($arProperty["ID"]);
			while ($arPropertyEnum = $dbPropertyEnums->GetNext())
				$arResult[$key]["Options"][$arPropertyEnum["XML_ID"]] = $arPropertyEnum["VALUE"];
		}
		elseif ($arProperty["PROPERTY_TYPE"] == "F")
		{
			$arResult[$key."_PRINTABLE"] = array(
				"Name" => $arProperty["NAME"].GetMessage("BPVDX_FIELD_USERNAME_PROPERTY"),
				"Filterable" => false,
				"Editable" => false,
				"Required" => false,
				"Multiple" => ($arProperty["MULTIPLE"] == "Y"),
				"Type" => "S",
			);
		}
		elseif ($arProperty["PROPERTY_TYPE"] == "S" && intval($arProperty["ROW_COUNT"]) > 1)
			$arResult[$key]["Type"] = "T";
	}

	$arKeys = array_keys($arResult);
	foreach ($arKeys as $k)
	{
		$arResult[$k]["BaseType"] = $arDocumentFieldTypes[$arResult[$k]["Type"]]["BaseType"];
		$arResult[$k]["Complex"] = $arDocumentFieldTypes[$arResult[$k]["Type"]]["Complex"];
	}

	return $arResult;
}

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