本文整理汇总了PHP中CIBlockProperty::getPropertyEnum方法的典型用法代码示例。如果您正苦于以下问题:PHP CIBlockProperty::getPropertyEnum方法的具体用法?PHP CIBlockProperty::getPropertyEnum怎么用?PHP CIBlockProperty::getPropertyEnum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIBlockProperty
的用法示例。
在下文中一共展示了CIBlockProperty::getPropertyEnum方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetDocumentFields
public function GetDocumentFields($documentType)
{
$iblockId = intval(substr($documentType, strlen("iblock_")));
if ($iblockId <= 0) {
throw new CBPArgumentOutOfRangeException("documentType", $documentType);
}
$documentFieldTypes = self::getDocumentFieldTypes($documentType);
$result = array("ID" => array("Name" => GetMessage("IBD_FIELD_ID"), "Type" => "int", "Filterable" => true, "Editable" => false, "Required" => false), "TIMESTAMP_X" => array("Name" => GetMessage("IBD_FIELD_TIMESTAMP_X"), "Type" => "datetime", "Filterable" => true, "Editable" => true, "Required" => false), "MODIFIED_BY" => array("Name" => GetMessage("IBD_FIELD_MODYFIED"), "Type" => "user", "Filterable" => true, "Editable" => true, "Required" => false), "MODIFIED_BY_PRINTABLE" => array("Name" => GetMessage("IBD_FIELD_MODIFIED_BY_USER_PRINTABLE"), "Type" => "string", "Filterable" => false, "Editable" => false, "Required" => false), "DATE_CREATE" => array("Name" => GetMessage("IBD_FIELD_DATE_CREATE"), "Type" => "datetime", "Filterable" => true, "Editable" => true, "Required" => false), "CREATED_BY" => array("Name" => GetMessage("IBD_FIELD_CREATED"), "Type" => "user", "Filterable" => true, "Editable" => false, "Required" => false), "CREATED_BY_PRINTABLE" => array("Name" => GetMessage("IBD_FIELD_CREATED_BY_USER_PRINTABLE"), "Type" => "string", "Filterable" => false, "Editable" => false, "Required" => false), "IBLOCK_ID" => array("Name" => GetMessage("IBD_FIELD_IBLOCK_ID"), "Type" => "int", "Filterable" => true, "Editable" => true, "Required" => false), "ACTIVE" => array("Name" => GetMessage("IBD_FIELD_ACTIVE"), "Type" => "bool", "Filterable" => true, "Editable" => true, "Required" => false), "BP_PUBLISHED" => array("Name" => GetMessage("IBD_FIELD_BP_PUBLISHED"), "Type" => "bool", "Filterable" => false, "Editable" => true, "Required" => false), "CODE" => array("Name" => GetMessage("IBD_FIELD_CODE"), "Type" => "string", "Filterable" => true, "Editable" => true, "Required" => false), "XML_ID" => array("Name" => GetMessage("IBD_FIELD_XML_ID"), "Type" => "string", "Filterable" => true, "Editable" => true, "Required" => false));
$keys = array_keys($result);
foreach ($keys as $key) {
$result[$key]["Multiple"] = false;
}
$dbProperties = CIBlockProperty::getList(array("sort" => "asc", "name" => "asc"), array("IBLOCK_ID" => $iblockId, 'ACTIVE' => 'Y'));
$ignoreProperty = array();
while ($property = $dbProperties->fetch()) {
if (strlen(trim($property["CODE"])) > 0) {
$key = "PROPERTY_" . $property["CODE"];
$ignoreProperty["PROPERTY_" . $property["ID"]] = "PROPERTY_" . $property["CODE"];
} else {
$key = "PROPERTY_" . $property["ID"];
$ignoreProperty["PROPERTY_" . $property["ID"]] = 0;
}
$result[$key] = array("Name" => $property["NAME"], "Filterable" => $property["FILTRABLE"] == "Y", "Editable" => true, "Required" => $property["IS_REQUIRED"] == "Y", "Multiple" => $property["MULTIPLE"] == "Y", "TypeReal" => $property["PROPERTY_TYPE"]);
if (strlen($property["USER_TYPE"]) > 0) {
$result[$key]["TypeReal"] = $property["PROPERTY_TYPE"] . ":" . $property["USER_TYPE"];
if ($property["USER_TYPE"] == "UserID" || $property["USER_TYPE"] == "employee" && COption::getOptionString("bizproc", "employee_compatible_mode", "N") != "Y") {
$result[$key]["Type"] = "user";
$result[$key . "_PRINTABLE"] = array("Name" => $property["NAME"] . GetMessage("IBD_FIELD_USERNAME_PROPERTY"), "Filterable" => false, "Editable" => false, "Required" => false, "Multiple" => $property["MULTIPLE"] == "Y", "Type" => "string");
$result[$key]["DefaultValue"] = $property["DEFAULT_VALUE"];
} elseif ($property["USER_TYPE"] == "DateTime") {
$result[$key]["Type"] = "datetime";
$result[$key]["DefaultValue"] = $property["DEFAULT_VALUE"];
} elseif ($property["USER_TYPE"] == "Date") {
$result[$key]["Type"] = "date";
$result[$key]["DefaultValue"] = $property["DEFAULT_VALUE"];
} elseif ($property["USER_TYPE"] == "EList") {
$result[$key]["Type"] = "E:EList";
$result[$key]["Options"] = $property["LINK_IBLOCK_ID"];
} elseif ($property["USER_TYPE"] == "HTML") {
$result[$key]["Type"] = "S:HTML";
$result[$key]["DefaultValue"] = $property["DEFAULT_VALUE"];
} else {
$result[$key]["Type"] = "string";
$result[$key]["DefaultValue"] = $property["DEFAULT_VALUE"];
}
} elseif ($property["PROPERTY_TYPE"] == "L") {
$result[$key]["Type"] = "select";
$result[$key]["Options"] = array();
$dbPropertyEnums = CIBlockProperty::getPropertyEnum($property["ID"]);
while ($propertyEnum = $dbPropertyEnums->getNext()) {
$result[$key]["Options"][$propertyEnum["XML_ID"]] = $propertyEnum["VALUE"];
if ($propertyEnum["DEF"] == "Y") {
$result[$key]["DefaultValue"] = $propertyEnum["VALUE"];
}
}
} elseif ($property["PROPERTY_TYPE"] == "N") {
$result[$key]["Type"] = "int";
$result[$key]["DefaultValue"] = $property["DEFAULT_VALUE"];
} elseif ($property["PROPERTY_TYPE"] == "F") {
$result[$key]["Type"] = "file";
$result[$key . "_printable"] = array("Name" => $property["NAME"] . GetMessage("IBD_FIELD_USERNAME_PROPERTY"), "Filterable" => false, "Editable" => false, "Required" => false, "Multiple" => $property["MULTIPLE"] == "Y", "Type" => "string");
} elseif ($property["PROPERTY_TYPE"] == "S") {
$result[$key]["Type"] = "string";
$result[$key]["DefaultValue"] = $property["DEFAULT_VALUE"];
} else {
$result[$key]["Type"] = "string";
$result[$key]["DefaultValue"] = $property["DEFAULT_VALUE"];
}
}
$keys = array_keys($result);
foreach ($keys as $k) {
$result[$k]["BaseType"] = $documentFieldTypes[$result[$k]["Type"]]["BaseType"];
$result[$k]["Complex"] = $documentFieldTypes[$result[$k]["Type"]]["Complex"];
}
$list = new CList($iblockId);
$fields = $list->getFields();
foreach ($fields as $fieldId => $field) {
if (empty($field["SETTINGS"])) {
$field["SETTINGS"] = array("SHOW_ADD_FORM" => 'Y', "SHOW_EDIT_FORM" => 'Y');
}
if (array_key_exists($fieldId, $ignoreProperty)) {
$ignoreProperty[$fieldId] ? $key = $ignoreProperty[$fieldId] : ($key = $fieldId);
$result[$key]["sort"] = $field["SORT"];
$result[$key]["settings"] = $field["SETTINGS"];
if ($field["ROW_COUNT"] && $field["COL_COUNT"]) {
$result[$key]["row_count"] = $field["ROW_COUNT"];
$result[$key]["col_count"] = $field["COL_COUNT"];
}
} else {
if (!isset($result[$fieldId])) {
$result[$fieldId] = array('Name' => $field['NAME'], 'Filterable' => false, 'Editable' => true, 'Required' => $field['IS_REQUIRED'], 'Multiple' => $field['MULTIPLE'], 'Type' => $field['TYPE']);
}
$result[$fieldId]["sort"] = $field["SORT"];
$result[$fieldId]["settings"] = $field["SETTINGS"];
if ($field["ROW_COUNT"] && $field["COL_COUNT"]) {
$result[$fieldId]["row_count"] = $field["ROW_COUNT"];
$result[$fieldId]["col_count"] = $field["COL_COUNT"];
}
}
}
//.........这里部分代码省略.........
示例2: createPreparedFields
//.........这里部分代码省略.........
$html = '<input type="text" name="' . $fieldId . '[' . $key . '][VALUE]" value="' . $value["VALUE"] . '">';
}
}
$this->lists['PREPARED_FIELDS'][$fieldId] = array("id" => $fieldId, "name" => $field["NAME"], "required" => $field["IS_REQUIRED"] == "Y" ? true : false, "type" => "custom", "value" => $html);
} elseif ($field["PROPERTY_TYPE"] == "S") {
$html = '';
if ($field["MULTIPLE"] == "Y") {
$html = '<table id="tbl' . $fieldId . '">';
if ($field["ROW_COUNT"] > 1) {
foreach ($this->lists['FORM_DATA'][$fieldId] as $key => $value) {
$html .= '<tr><td><textarea name="' . $fieldId . '[' . $key . '][VALUE]" rows="' . intval($field["ROW_COUNT"]) . '" cols="' . intval($field["COL_COUNT"]) . '">' . $value["VALUE"] . '</textarea></td></tr>';
}
} else {
foreach ($this->lists['FORM_DATA'][$fieldId] as $key => $value) {
$html .= '<tr><td><input type="text" name="' . $fieldId . '[' . $key . '][VALUE]" value="' . $value["VALUE"] . '"></td></tr>';
}
}
$html .= '</table>';
$html .= '<span class="bx-lists-input-add-button"><input type="button" onclick="javascript:BX[\'LiveFeedClass_' . $this->randomString . '\'].addNewTableRow(\'tbl' . $fieldId . '\', 1, /' . $fieldId . '\\[(n)([0-9]*)\\]/g, 2)" value="' . Loc::getMessage("LISTS_SEAC_ADD_BUTTON") . '"></span>';
} else {
if ($field["ROW_COUNT"] > 1) {
foreach ($this->lists['FORM_DATA'][$fieldId] as $key => $value) {
$html = '<textarea name="' . $fieldId . '[' . $key . '][VALUE]" rows="' . intval($field["ROW_COUNT"]) . '" cols="' . intval($field["COL_COUNT"]) . '">' . $value["VALUE"] . '</textarea>';
}
} else {
foreach ($this->lists['FORM_DATA'][$fieldId] as $key => $value) {
$html = '<input type="text" name="' . $fieldId . '[' . $key . '][VALUE]" value="' . $value["VALUE"] . '" size="' . intval($field["COL_COUNT"]) . '">';
}
}
}
$this->lists['PREPARED_FIELDS'][$fieldId] = array("id" => $fieldId, "name" => $field["NAME"], "required" => $field["IS_REQUIRED"] == "Y" ? true : false, "type" => "custom", "value" => $html);
} elseif ($field["PROPERTY_TYPE"] == "L") {
$items = array("" => Loc::getMessage("LISTS_SEAC_NO_VALUE"));
$propEnums = CIBlockProperty::getPropertyEnum($field["ID"]);
while ($enum = $propEnums->fetch()) {
$items[$enum["ID"]] = $enum["VALUE"];
}
if ($field["MULTIPLE"] == "Y") {
$this->lists['PREPARED_FIELDS'][$fieldId] = array("id" => $fieldId . '[]', "name" => $field["NAME"], "required" => $field["IS_REQUIRED"] == "Y" ? true : false, "type" => 'list', "items" => $items, "value" => $this->lists['FORM_DATA'][$fieldId], "params" => array("size" => 5, "multiple" => "multiple"));
} else {
$this->lists['PREPARED_FIELDS'][$fieldId] = array("id" => $fieldId, "name" => $field["NAME"], "required" => $field["IS_REQUIRED"] == "Y" ? true : false, "type" => 'list', "items" => $items, "value" => $this->lists['FORM_DATA'][$fieldId]);
}
} elseif ($field['PROPERTY_TYPE'] == 'F') {
$html = '
<script>
var wrappers = document.getElementsByClassName("bx-lists-input-file");
for (var i = 0; i < wrappers.length; i++)
{
var inputs = wrappers[i].getElementsByTagName("input");
for (var j = 0; j < inputs.length; j++)
{
inputs[j].onchange = getName;
}
}
function getName ()
{
var str = this.value, i;
if (str.lastIndexOf("\\\\"))
{
i = str.lastIndexOf("\\\\")+1;
}
else
{
i = str.lastIndexOf("\\\\")+1;
}
str = str.slice(i);
示例3: getPropsParams
protected static function getPropsParams($iblockId)
{
$arRes = array();
$bUseHLIblock = \Bitrix\Main\Loader::includeModule('highloadblock');
$rsProps = \CIBlockProperty::getList(array('SORT' => 'ASC', 'ID' => 'ASC'), array('IBLOCK_ID' => $iblockId, 'ACTIVE' => 'Y'));
while ($arProp = $rsProps->fetch()) {
if ($arProp['PROPERTY_TYPE'] == 'L' || $arProp['PROPERTY_TYPE'] == 'E' || $arProp['PROPERTY_TYPE'] == 'S' && $arProp['USER_TYPE'] == 'directory') {
if ($arProp['XML_ID'] == 'CML2_LINK') {
continue;
}
$arValues = array();
if ($arProp['PROPERTY_TYPE'] == 'L') {
$arValues = array();
$rsPropEnums = \CIBlockProperty::getPropertyEnum($arProp['ID']);
while ($arEnum = $rsPropEnums->fetch()) {
$arValues[$arEnum['VALUE']] = array('ID' => $arEnum['ID'], 'NAME' => $arEnum['VALUE'], 'PICT' => false);
}
} elseif ($arProp['PROPERTY_TYPE'] == 'E') {
$rsPropEnums = \CIBlockElement::getList(array('SORT' => 'ASC'), array('IBLOCK_ID' => $arProp['LINK_IBLOCK_ID'], 'ACTIVE' => 'Y'), false, false, array('ID', 'NAME', 'PREVIEW_PICTURE'));
while ($arEnum = $rsPropEnums->Fetch()) {
$arEnum['PREVIEW_PICTURE'] = \CFile::getFileArray($arEnum['PREVIEW_PICTURE']);
if (!is_array($arEnum['PREVIEW_PICTURE'])) {
$arEnum['PREVIEW_PICTURE'] = false;
}
if ($arEnum['PREVIEW_PICTURE'] !== false) {
$productImg = \CFile::resizeImageGet($arEnum['PREVIEW_PICTURE'], array('width' => 80, 'height' => 80), BX_RESIZE_IMAGE_PROPORTIONAL, false, false);
$arEnum['PREVIEW_PICTURE']['SRC'] = $productImg['src'];
}
$arValues[$arEnum['NAME']] = array('ID' => $arEnum['ID'], 'NAME' => $arEnum['NAME'], 'SORT' => $arEnum['SORT'], 'PICT' => $arEnum['PREVIEW_PICTURE']);
}
} elseif ($arProp['PROPERTY_TYPE'] == 'S' && $arProp['USER_TYPE'] == 'directory') {
if ($bUseHLIblock) {
$hlblock = HL\HighloadBlockTable::getList(array("filter" => array("TABLE_NAME" => $arProp["USER_TYPE_SETTINGS"]["TABLE_NAME"])))->fetch();
if ($hlblock) {
$entity = HL\HighloadBlockTable::compileEntity($hlblock);
$entity_data_class = $entity->getDataClass();
$rsData = $entity_data_class::getList();
while ($arData = $rsData->fetch()) {
$arValues[$arData['UF_XML_ID']] = array('ID' => $arData['ID'], 'NAME' => $arData['UF_NAME'], 'SORT' => $arData['UF_SORT'], 'FILE' => $arData['UF_FILE'], 'PICT' => '', 'XML_ID' => $arData['UF_XML_ID']);
}
}
}
}
if (!empty($arValues) && is_array($arValues)) {
$arRes[$arProp['ID']] = array('ID' => $arProp['ID'], 'CODE' => $arProp['CODE'], 'NAME' => $arProp['NAME'], 'TYPE' => $arProp['PROPERTY_TYPE'], 'ORDER' => array_keys($arValues), 'VALUES' => $arValues, 'SORT' => $arProp['SORT']);
}
}
if ($arProp['PROPERTY_TYPE'] == "S" && is_array($arRes[$arProp['ID']]['VALUES'])) {
foreach ($arRes[$arProp['ID']]['VALUES'] as $id => $value) {
$arTmpFile = \CFile::getFileArray($value["FILE"]);
$tmpImg = \CFile::resizeImageGet($arTmpFile, array('width' => 20, 'height' => 20), BX_RESIZE_IMAGE_PROPORTIONAL, false, false);
$arRes[$arProp['ID']]['VALUES'][$id]['PICT'] = $tmpImg['src'];
}
}
}
return $arRes;
}