本文整理汇总了PHP中CIBlockPropertyEnum类的典型用法代码示例。如果您正苦于以下问题:PHP CIBlockPropertyEnum类的具体用法?PHP CIBlockPropertyEnum怎么用?PHP CIBlockPropertyEnum使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CIBlockPropertyEnum类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateAddCode
/**
* Генерация создания Информационного блока
*
* generateAddCode
* @param array $IblockCode
* @return bool|string
*/
public function generateAddCode($IblockCode)
{
$return = array();
$iblockObject = $this->iblock->GetList(array(), array('CODE' => $IblockCode, 'CHECK_PERMISSIONS' => 'N'));
if ($item = $iblockObject->Fetch()) {
# Установка групп пользователей
$this->setUserGroupId($item['ID'], $item);
$item['FIELDS'] = \CIBlock::GetFields($item['ID']);
Helper::unsetFields(array('ID'), $item);
if ($return[] = $this->getMethodContent('Bim\\Db\\Iblock\\IblockIntegrate', 'Add', array($item))) {
$IblockProperty = new \CIBlockProperty();
$iblockPropertyQuery = $IblockProperty->GetList(array(), array('IBLOCK_CODE' => $item['CODE']));
while ($iblockProperty = $iblockPropertyQuery->Fetch()) {
Helper::unsetFields(array('ID'), $iblockProperty);
$iblockProperty['IBLOCK_CODE'] = $item['CODE'];
$propertyQuery = \CIBlockPropertyEnum::GetList(array(), array("IBLOCK_ID" => $iblockProperty['IBLOCK_ID'], "CODE" => $iblockProperty['CODE']));
while ($propertyValues = $propertyQuery->Fetch()) {
Helper::unsetFields(array('ID', 'PROPERTY_ID'), $propertyValues);
$iblockProperty['VALUES'][] = $propertyValues;
}
if (!is_null($iblockProperty['LINK_IBLOCK_ID'])) {
$linkedIBlock = $this->iblock->GetList(array(), array('ID' => $iblockProperty['LINK_IBLOCK_ID'], 'CHECK_PERMISSIONS' => 'N'))->Fetch();
$iblockProperty['LINK_IBLOCK_CODE'] = $linkedIBlock['CODE'];
}
$return[] = $this->getMethodContent('Bim\\Db\\Iblock\\IblockPropertyIntegrate', 'Add', array($iblockProperty));
}
return implode(PHP_EOL, $return);
} else {
return false;
}
} else {
return false;
}
}
示例2: _getPropertiesEx
function _getPropertiesEx($arParams)
{
$arFilter = array();
$arProperties = array();
$arPropListIds = array();
if (notEmpty($arParams["type"])) {
$arFilter["PROPERTY_TYPE"] = $arParams["type"];
}
if (notEmpty($arParams["iblock_id"])) {
$arFilter["IBLOCK_ID"] = iblock($arParams["iblock_id"]);
}
$resProperties = \CIBlockProperty::GetList(array(), $arFilter);
while ($arProperty = $resProperties->Fetch()) {
$arProperties[$arProperty["CODE"]] = $arProperty;
if ($arProperty["PROPERTY_TYPE"] == "L") {
$arPropListIds[] = $arProperty["ID"];
}
}
// В фильтр CIBlockPropertyEnum::GetList() нельзя передать
// PROPERTY_ID в виде массива ID, поэтому перебираем
// каждое свойство в цикле
foreach ($arPropListIds as $propListId) {
$resPropValues = \CIBlockPropertyEnum::GetList(array('SORT' => 'ASC', 'VALUE' => 'ASC'), array('PROPERTY_ID' => $propListId));
while ($arPropValue = $resPropValues->Fetch()) {
$arProperties[$arPropValue["PROPERTY_CODE"]]["VALUES"][$arPropValue["XML_ID"]] = $arPropValue["ID"];
}
}
return $arProperties;
}
示例3: onBeforeElementAddHandler
static function onBeforeElementAddHandler($arFields)
{
$IBLOCK_ID = Config\Option::get("citfact.replaceurl", "IBLOCK_ID", "");
$SECTION_ID = Config\Option::get("citfact.replaceurl", "SECTION_BREND_ID", "BRENDI");
$CODE_PROP = Config\Option::get("citfact.replaceurl", "PROPERTY_CODE_BRENDI", "BRENDI");
if ($IBLOCK_ID == $arFields["IBLOCK_ID"]) {
$propertyBrand = \CIBlockProperty::GetByID($CODE_PROP, $arFields["IBLOCK_ID"]);
if ($arResultProperty = $propertyBrand->GetNext()) {
$propertyBrandValue = \CIBlockPropertyEnum::GetByID($arFields["PROPERTY_VALUES"][$arResultProperty["ID"]][0]["VALUE"]);
}
$rqParentSection = \CIBlockSection::GetByID($SECTION_ID);
if ($arParentSection = $rqParentSection->GetNext()) {
$arFilter = array('IBLOCK_ID' => $arParentSection['IBLOCK_ID'], '>LEFT_MARGIN' => $arParentSection['LEFT_MARGIN'], '<RIGHT_MARGIN' => $arParentSection['RIGHT_MARGIN'], '>DEPTH_LEVEL' => $arParentSection['DEPTH_LEVEL']);
// выберет потомков без учета активности
$rqSectChild = \CIBlockSection::GetList(array('left_margin' => 'asc'), $arFilter);
while ($arSectChild = $rqSectChild->GetNext()) {
$arSections[$arSectChild["NAME"]] = $arSectChild["ID"];
}
}
if (array_key_exists($propertyBrandValue["VALUE"], $arSections)) {
$arFields["IBLOCK_SECTION"][] = $arSections[$propertyBrandValue["VALUE"]];
} else {
$arParams = array("replace_space" => "-", "replace_other" => "-");
$trans = \Cutil::translit($propertyBrandValue["VALUE"], "ru", $arParams);
$bs = new \CIBlockSection();
$arFieldsNewSection = array("ACTIVE" => "Y", "IBLOCK_SECTION_ID" => $SECTION_ID, "IBLOCK_ID" => $IBLOCK_ID, "NAME" => $propertyBrandValue["VALUE"], "CODE" => $trans);
$resultAdd = $bs->Add($arFieldsNewSection);
$arFields["IBLOCK_SECTION"][] = $resultAdd;
}
}
return true;
}
示例4: storeResult
function storeResult($arResult, $arParams) {
$iblock = CIBlock::GetList(
array(),
array(
'TYPE' => $arParams['IBLOCK_TYPE'],
'CODE' => $arParams['IBLOCK_CODE'],
)
);
$iblock = $iblock->Fetch();
$el = new CIBlockElement;
$props = array();
foreach ($arResult['FIELDS_LIST'] as $arField) {
if ($arField['FIELD_TYPE'] == 'TEXT' || $arField['FIELD_TYPE'] == 'NUMBER') {
$props[$arField['CODE']] = array(
'VALUE' => $arResult['POST_DATA']['~'.$arField['CODE']],
);
} elseif ($arField['FIELD_TYPE'] == 'TEXTAREA') {
$props[$arField['CODE']] = array(
'VALUE' => array(
'TYPE' => 'text',
'TEXT' => $arResult['POST_DATA']['~'.$arField['CODE']],
),
);
} elseif ($arField['FIELD_TYPE'] == 'LIST') {
$propEnum = CIBlockPropertyEnum::GetList(
array(),
array(
'XML_ID' => $arResult['POST_DATA']['~'.$arField['CODE']],
'CODE' => $arField['CODE'],
'IBLOCK_ID' => $iblock['ID'],
)
);
$propEnum = $propEnum->Fetch();
if ( ! $propEnum) return false;
$props[$arField['CODE']] = array(
'VALUE' => $propEnum['ID'],
);
}
}
$res = $el->Add(array(
'IBLOCK_TYPE' => $arParams['IBLOCK_TYPE'],
'IBLOCK_ID' => $iblock['ID'],
'ACTIVE' => 'Y',
'PROPERTY_VALUES' => $props,
'ACTIVE_FROM' => ConvertTimeStamp(time()+CTimeZone::GetOffset(), 'FULL'),
'NAME' => 'Form result', # !!! NEED TO REPLACE TO DEFAULT VALUE
));
if (!$res) {
return array(
'MESSAGE' => $el->LAST_ERROR,
);
}
return true;
}
示例5: _applyPropertyListTypeValues
private function _applyPropertyListTypeValues($id, $values)
{
$addValues = array();
$updateValues = array();
$useValuesIds = array();
foreach ($values as $value) {
$value['PROPERTY_ID'] = $id;
try {
$value['ID'] = $this->getReferenceController()->getItemCurrentVersionByReference($value['~reference'])->id;
$useValuesIds[] = $value['ID'];
$updateValues[] = $value;
} catch (\Exception $e) {
$addValues[] = $value;
}
}
$currentValues = PropertyEnumerationTable::getList(array('filter' => array('=PROPERTY_ID' => $id)))->fetchAll();
foreach ($currentValues as $value) {
!in_array($value['ID'], $useValuesIds) && PropertyEnumerationTable::delete(array('ID' => $value['ID'], 'PROPERTY_ID' => $value['PROPERTY_ID']));
}
foreach ($addValues as $value) {
unset($value['ID']);
unset($value['~reference']);
$enum = new \CIBlockPropertyEnum();
$enumElementId = $enum->Add($value);
if (!$enumElementId) {
throw new \Exception('Add property list value. Property not save. ' . var_export($value, true));
}
$result = PropertyEnumerationTable::update(array('ID' => $enumElementId, 'PROPERTY_ID' => $value['PROPERTY_ID']), $value);
if (!$result->isSuccess()) {
throw new \Exception('Add property list value in table. Property not save. ' . var_export($result->getErrorMessages(), true));
}
$referenceItem = new ReferenceItem();
$referenceItem->id = $enumElementId;
$referenceItem->group = ReferenceController::GROUP_IBLOCK_PROPERTY_LIST_VALUES;
$referenceItem->reference = $value['~reference'];
$this->getReferenceController()->registerItem($referenceItem);
}
foreach ($updateValues as $value) {
$vId = $value['ID'];
unset($value['ID']);
unset($value['~reference']);
$result = PropertyEnumerationTable::update(array('ID' => $vId, 'PROPERTY_ID' => $value['PROPERTY_ID']), $value);
if (!$result->isSuccess()) {
throw new \Exception('Update property list value. Property not save. ' . var_export($result->getErrorMessages(), true));
}
}
}
示例6: getPropertyEnumValueId
/**
* Тип свойства - список
* По коду и значению свойства получить id этого значения
* В случае отсутствия, значение будет создано и будет возвращен его id
*
* <code>
* $propertyCountryValue = getPropertyEnumValueId($IBLOCK_ID, 'COUNTRIES', 'Япония');
* $be = new CIBlockElement;
* $be->Add(array(
* "ACTIVE" => 'Y',
* "IBLOCK_ID" => $IBLOCK_ID,
* "NAME" => $name,
* "PROPERTY_VALUES" => array(
* 'COUNTRIES' => $propertyCountryValue,
* )
* );
* </code>
* @param $IBLOCK_ID int id инфоблока, в котором находится данное свойство
* @param $prop string код свойства
* @param $value string значение свойства
* @return bool|int ID значения свойства или false, если не удалось найти свойство с таким кодом или не удалось создать запись с данным значением
*/
function getPropertyEnumValueId($IBLOCK_ID, $prop, $value)
{
$property = CIBlockProperty::GetByID($prop, $IBLOCK_ID)->Fetch();
if (!$property) {
return false;
}
$ar_enum_list = CIBlockProperty::GetPropertyEnum($prop, array("SORT" => "asc"), array("IBLOCK_ID" => $IBLOCK_ID, 'VALUE' => $value))->Fetch();
if (!$ar_enum_list) {
$ibpenum = new CIBlockPropertyEnum();
if ($PropID = $ibpenum->Add(array('PROPERTY_ID' => $property['ID'], 'VALUE' => $value))) {
$ar_enum_list['ID'] = $PropID;
} else {
return false;
}
}
return $ar_enum_list['ID'];
}
示例7: generateAddCode
/**
* Генерация создания
*
* generateAddCode
* @param array $IblockTypeId
* @return bool|string
*/
public function generateAddCode($IblockTypeId)
{
$iBlock = new \CIBlock();
$CIblockType = new \CIBlockType();
$lang = new \CLanguage();
$return = array();
$dbIblockType = $CIblockType->GetByID($IblockTypeId);
if ($arIblockType = $dbIblockType->GetNext()) {
$Iblock = new \CIBlock();
$dbIblock = $Iblock->GetList(array(), array('TYPE' => $IblockTypeId, 'CHECK_PERMISSIONS' => 'N'));
while ($arIblock = $dbIblock->GetNext()) {
$IblockProperty = new \CIBlockProperty();
$dbIblockProperty = $IblockProperty->GetList(array(), array('IBLOCK_CODE' => $arIblock['CODE'], 'CHECK_PERMISSIONS' => 'N'));
while ($arIblockProperty = $dbIblockProperty->GetNext()) {
$dbPropertyValues = \CIBlockPropertyEnum::GetList(array(), array("IBLOCK_ID" => $arIblockProperty['IBLOCK_ID'], "CODE" => $arIblockProperty['CODE']));
while ($arPropertyValues = $dbPropertyValues->Fetch()) {
$arIblockProperty['VALUES'][$arPropertyValues['ID']] = $arPropertyValues;
}
Helper::unsetFields(array('ID', '~ID', 'IBLOCK_ID', '~IBLOCK_ID'), $arIblockProperty);
$arIblockProperty['IBLOCK_CODE'] = $arIblock['CODE'];
foreach ($arIblockProperty as $k => $v) {
if (strstr($k, "~") || is_null($v)) {
unset($arIblockProperty[$k]);
}
}
if (isset($arIblockProperty['LINK_IBLOCK_ID'])) {
$res = $iBlock->GetList(array(), array("ID" => $arIblockProperty['LINK_IBLOCK_ID'], 'CHECK_PERMISSIONS' => 'N'));
if ($ar_res = $res->GetNext()) {
unset($arIblockProperty['LINK_IBLOCK_ID']);
$arIblockProperty['LINK_IBLOCK_CODE'] = $ar_res['CODE'];
}
}
$return[] = $this->getMethodContent('Bim\\Db\\Iblock\\IblockPropertyIntegrate', 'Add', array($arIblockProperty));
}
foreach ($arIblock as $k => $v) {
if (strstr($k, "~") || $k == 'ID') {
unset($arIblock[$k]);
}
}
$return[] = $this->getMethodContent('Bim\\Db\\Iblock\\IblockIntegrate', 'Add', array($arIblock));
}
foreach ($arIblockType as $k => $v) {
if (strstr($k, "~") || is_null($v)) {
unset($arIblockType[$k]);
}
}
$rsLang = $lang->GetList($by = "lid", $order = "desc");
while ($arLang = $rsLang->Fetch()) {
$arTypeLang = $CIblockType->GetByIDLang($IblockTypeId, $arLang['LID']);
$arIblockType["LANG"][$arLang['LID']] = array('NAME' => $arTypeLang['NAME'], 'SECTION_NAME' => $arTypeLang['SECTION_NAME'], 'ELEMENT_NAME' => $arTypeLang['ELEMENT_NAME']);
}
$return[] = $this->getMethodContent('Bim\\Db\\Iblock\\IblockTypeIntegrate', 'Add', array($arIblockType));
$return = array_reverse($return);
return implode(PHP_EOL, $return);
} else {
return false;
}
}
示例8: getItemsFlagsIds
static function getItemsFlagsIds($code, $iblockId = IBLOCK_CATALOG)
{
$flagsIds = array();
$flagsDb = \CIBlockPropertyEnum::GetList(array('id' => 'asc'), array('IBLOCK_ID' => $iblockId, 'CODE' => $code));
while ($flags = $flagsDb->GetNext()) {
$flagsIds[$flags['XML_ID']] = $flags['ID'];
}
return $flagsIds;
}
示例9: getEnumItemList
/**
* getEnumItemList
* @param $iblockId
* @param $iblockPropId
* @return array
*/
private function getEnumItemList($iblockId, $iblockPropId)
{
$result = array();
$propEnumDbRes = \CIBlockPropertyEnum::GetList(array('SORT' => 'ASC'), array('IBLOCK_ID' => $iblockId, 'PROPERTY_ID' => $iblockPropId));
if ($propEnumDbRes !== false && $propEnumDbRes->SelectedRowsCount()) {
$index = 0;
while ($propEnum = $propEnumDbRes->Fetch()) {
$result[$index] = array('ID' => $index, 'VALUE' => $propEnum['VALUE'], 'XML_ID' => $propEnum['XML_ID'], 'SORT' => $propEnum['SORT'], 'DEF' => $propEnum['DEF']);
$index++;
}
}
return $result;
}
示例10: getById
/**
* Возвращает список всех вариантов для указанного свойства
* @param int $propertyId
* @return array
*/
public static function getById($id)
{
if (!isset(self::$_items[$id])) {
if (!\CModule::IncludeModule('iblock')) {
throw new \bxar\Exception('Iblock module is not installed');
}
self::$_items[$id] = array();
$res = \CIBlockPropertyEnum::GetList(array('SORT' => 'ASC', 'VALUE' => 'ASC'), array('PROPERTY_ID' => $id));
while ($ob = $res->GetNext()) {
self::$_items[$id][] = $ob;
}
}
return self::$_items[$id];
}
示例11: addElementReview
function addElementReview($arResult, $ID_SECTION, $IBLOCK_ID)
{
CModule::IncludeModule('iblock');
$property_enums = CIBlockPropertyEnum::GetList(array("DEF" => "DESC", "SORT" => "ASC"), array("IBLOCK_ID" => $IBLOCK_ID, "CODE" => "RATING", "VALUE" => $arResult['RATING']));
while ($rating = $property_enums->GetNext()) {
$arRating = $rating["ID"];
}
$current_date = dateActiveFrom(date('d.m.Y'));
$NAME = $current_date . ' ' . $arResult['NAME'];
$arFields = array("ACTIVE" => "N", "IBLOCK_ID" => $IBLOCK_ID, "IBLOCK_SECTION_ID" => $ID_SECTION, "NAME" => $NAME, "DETAIL_TEXT" => "Описание элемента", "PROPERTY_VALUES" => array("NAME" => $arResult['NAME'], "EMAIL" => $arResult['EMAIL'], "RATING" => array('VALUE' => $arRating), "BENEFITS" => $arResult['BENEFITS'], "DISADVANTAGES" => $arResult['DISADVANTAGES'], "COMMENT" => $arResult['COMMENT']));
$oElement = new CIBlockElement();
$idElement = $oElement->Add($arFields, false, false, true);
return $idElement;
}
示例12: GetFilterData
private function GetFilterData($IBLOCK_ID, $arFields = array())
{
$filter_name = $this->sk_filter_name;
global ${$filter_name};
$arPROPERTIES = array();
foreach ($arFields as $i => $PROP_ID) {
$arSort = array();
$arFilter = array("ACTIVE" => "Y", "IBLOCK_ID" => $IBLOCK_ID);
if (intval($PROP_ID) > 0) {
$arFilter["ID"] = $PROP_ID;
} else {
$arFilter["CODE"] = $PROP_ID;
}
$properties = CIBlockProperty::GetList($arSort, $arFilter);
while ($prop_fields = $properties->GetNext()) {
switch ($prop_fields["PROPERTY_TYPE"]) {
case "L":
$PROP_ENUM_VALUES = array();
$arPropSort = array("value" => "asc");
$arPropFilter = array("PROPERTY_ID" => $prop_fields["ID"], "IBLOCK_ID" => $IBLOCK_ID);
$prop_enums = CIBlockPropertyEnum::GetList($arPropSort, $arPropFilter);
while ($enum_fields = $prop_enums->GetNext()) {
$PROP_ENUM_VALUES[] = $enum_fields;
}
$prop_fields["VALUES"] = $PROP_ENUM_VALUES;
break;
case "E":
$PROP_ENUM_VALUES = array();
$arPropSort = array("NAME" => "asc");
$arPropFilter = array("ACTIVE" => "Y", "IBLOCK_ID" => $prop_fields["LINK_IBLOCK_ID"]);
$arSelFields = array("IBLOCK_ID", "ID", "NAME", "PROPERTY_*");
$db_vals = CIBlockElement::GetList($arPropSort, $arPropFilter, false, false, $arSelFields);
while ($obElement = $db_vals->GetNextElement()) {
$tmp = array();
$tmp = $obElement->GetFields();
$tmp["PROPERTIES"] = $obElement->GetProperties();
$PROP_ENUM_VALUES[$tmp["ID"]] = $tmp;
}
$prop_fields["VALUES"] = $PROP_ENUM_VALUES;
break;
}
$arPROPERTIES[$prop_fields["ID"]] = $prop_fields;
}
}
// // print_r( $arPROPERTIES );
return $arPROPERTIES;
}
示例13: getPropertyIblock
/**
* [getPropertyIblock description]
* @return array all products on iblock
*/
protected function getPropertyIblock(){
if (!CModule::IncludeModule("iblock")):
return false;
endif;
$properties = CIBlockProperty::GetList(Array("sort"=>"asc", "name"=>"asc"), Array("ACTIVE"=>"Y", "IBLOCK_ID"=>$this->getIblockId()));
while ($prop_fields = $properties->GetNext())
{
if ($prop_fields["PROPERTY_TYPE"] == "L"):
$property_enums = CIBlockPropertyEnum::GetList(Array("DEF"=>"DESC", "SORT"=>"ASC"), Array("IBLOCK_ID"=>$this->getIblockId(), "CODE"=>$prop_fields["CODE"]));
while($enum_fields = $property_enums->GetNext())
{
$prop_fields["ENUM_LIST"][] = $enum_fields;
}
endif;
$arProperties[] = $prop_fields;
}
return $arProperties;
}
示例14: findCode
function findCode($id, $val)
{
if (CModule::IncludeModule("iblock")) {
$properties = CIBlockProperty::GetList(array("sort" => "asc", "name" => "asc"), array("ACTIVE" => "Y", 'ID' => $id));
while ($prop_fields = $properties->GetNext()) {
$temp['CODE'] = $prop_fields['CODE'];
if ($prop_fields['PROPERTY_TYPE'] == 'L') {
$property_enums = CIBlockPropertyEnum::GetList(array("DEF" => "DESC", "SORT" => "ASC"), array("CODE" => $prop_fields['CODE'], 'ID' => $val));
while ($enum_fields = $property_enums->GetNext()) {
$temp['VALUE'] = $enum_fields["VALUE"];
}
}
}
return $temp;
} else {
return false;
}
}
示例15: GetEditFormHTML
function GetEditFormHTML($arUserField, $arHtmlControl)
{
$return = '';
if (CModule::IncludeModule("iblock")) {
$resdb = CIBlockPropertyEnum::GetList(array("SORT" => "ASC", "VALUE" => "ASC"), array("ACTIVE" => "Y", "IBLOCK_ID" => IBLOCK_ID_CATALOG, 'PROPERTY_ID' => PROPERTY_ID_TORGOVAYA_MARKA));
$arPropertyListValue = array();
while ($res = $resdb->fetch()) {
$arPropertyListValue[$res['ID']] = $res['VALUE'];
}
if (count($arPropertyListValue) > 0) {
ob_start();
?>
<select name="<?php
echo $arUserField["FIELD_NAME"];
?>
">
<option value=""></option>
<?php
foreach ($arPropertyListValue as $ID => $NAME) {
?>
<option value="<?php
echo $ID;
?>
" <?php
if ($ID == $arUserField["VALUE"]) {
echo 'selected';
}
?>
><?php
echo $NAME;
?>
</option>
<?php
}
?>
</select>
<?php
$return = ob_get_contents();
ob_end_clean();
}
}
return $return;
}