本文整理汇总了PHP中CIBlockProperty::UpdateEnum方法的典型用法代码示例。如果您正苦于以下问题:PHP CIBlockProperty::UpdateEnum方法的具体用法?PHP CIBlockProperty::UpdateEnum怎么用?PHP CIBlockProperty::UpdateEnum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIBlockProperty
的用法示例。
在下文中一共展示了CIBlockProperty::UpdateEnum方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ImportProperties
//.........这里部分代码省略.........
"change_case" => 'U', // 'L' - toLower, 'U' - toUpper, false - do not change
"replace_space" => '_',
"replace_other" => '_',
"delete_repeat_replace" => true,
));
if(preg_match('/^[0-9]/', $arProperty["CODE"]))
$arProperty["CODE"] = '_'.$arProperty["CODE"];
}
$arProperty["ID"] = $obProperty->Add($arProperty);
if(!$arProperty["ID"])
return $obProperty->LAST_ERROR;
}
if($XML_ENUM_PARENT)
{
$arEnumMap = array();
$arProperty["VALUES"] = array();
$rsEnum = CIBlockProperty::GetPropertyEnum($arProperty["ID"]);
while($arEnum = $rsEnum->Fetch())
{
$arProperty["VALUES"][$arEnum["ID"]] = $arEnum;
$arEnumMap[$arEnum["XML_ID"]] = &$arProperty["VALUES"][$arEnum["ID"]];
}
foreach($arEnumXmlNodes as $i => $arE)
{
if(
$arE["NAME"] == GetMessage("IBLOCK_XML2_CHOICE")
|| $arE["NAME"] == GetMessage("IBLOCK_XML2_CHOICE_VALUE")
)
{
$arE = $this->_xml_file->GetAllChildrenArray($arE);
if(isset($arE[GetMessage("IBLOCK_XML2_ID")]))
{
$xml_id = $arE[GetMessage("IBLOCK_XML2_ID")];
if(!array_key_exists($xml_id, $arEnumMap))
{
$arProperty["VALUES"]["n".$i] = array();
$arEnumMap[$xml_id] = &$arProperty["VALUES"]["n".$i];
$i++;
}
$arEnumMap[$xml_id]["CML2_EXPORT_FLAG"] = true;
$arEnumMap[$xml_id]["XML_ID"] = $xml_id;
if(isset($arE[GetMessage("IBLOCK_XML2_VALUE")]))
$arEnumMap[$xml_id]["VALUE"] = $arE[GetMessage("IBLOCK_XML2_VALUE")];
if(isset($arE[GetMessage("IBLOCK_XML2_BY_DEFAULT")]))
$arEnumMap[$xml_id]["DEF"] = ($arE[GetMessage("IBLOCK_XML2_BY_DEFAULT")]=="true") || intval($arE[GetMessage("IBLOCK_XML2_BY_DEFAULT")])? "Y": "N";
if(isset($arE[GetMessage("IBLOCK_XML2_SORT")]))
$arEnumMap[$xml_id]["SORT"] = intval($arE[GetMessage("IBLOCK_XML2_SORT")]);
}
}
elseif(
$arE["NAME"] == GetMessage("IBLOCK_XML2_TYPE_LIST")
)
{
$arE = $this->_xml_file->GetAllChildrenArray($arE);
if(isset($arE[GetMessage("IBLOCK_XML2_VALUE_ID")]))
{
$xml_id = $arE[GetMessage("IBLOCK_XML2_VALUE_ID")];
if(!array_key_exists($xml_id, $arEnumMap))
{
$arProperty["VALUES"]["n".$i] = array();
$arEnumMap[$xml_id] = &$arProperty["VALUES"]["n".$i];
$i++;
}
$arEnumMap[$xml_id]["CML2_EXPORT_FLAG"] = true;
$arEnumMap[$xml_id]["XML_ID"] = $xml_id;
if(isset($arE[GetMessage("IBLOCK_XML2_VALUE")]))
$arEnumMap[$xml_id]["VALUE"] = $arE[GetMessage("IBLOCK_XML2_VALUE")];
}
}
}
$bUpdateOnly = array_key_exists("bUpdateOnly", $this->next_step) && $this->next_step["bUpdateOnly"];
$sort = 100;
foreach($arProperty["VALUES"] as $id=>$arEnum)
{
if(!isset($arEnum["CML2_EXPORT_FLAG"]))
{
//Delete value only when full exchange happened
if(!$bUpdateOnly)
$arProperty["VALUES"][$id]["VALUE"] = "";
}
elseif(isset($arEnum["SORT"]))
{
if($arEnum["SORT"] > $sort)
$sort = $arEnum["SORT"] + 100;
}
else
{
$arProperty["VALUES"][$id]["SORT"] = $sort;
$sort += 100;
}
}
$obProperty->UpdateEnum($arProperty["ID"], $arProperty["VALUES"], false);
}
$sort += 100;
}
return true;
}
示例2: ImportPropertyEnum
function ImportPropertyEnum($arProperty, $arEnumXmlNodes)
{
$arEnumMap = array();
$arProperty["VALUES"] = array();
$rsEnum = CIBlockProperty::GetPropertyEnum($arProperty["ID"]);
while ($arEnum = $rsEnum->Fetch()) {
$arProperty["VALUES"][$arEnum["ID"]] = $arEnum;
$arEnumMap[$arEnum["XML_ID"]] =& $arProperty["VALUES"][$arEnum["ID"]];
}
$i = 0;
foreach ($arEnumXmlNodes as $arE) {
if ($arE["NAME"] == $this->mess["IBLOCK_XML2_CHOICE"] || $arE["NAME"] == $this->mess["IBLOCK_XML2_CHOICE_VALUE"]) {
$arE = $this->_xml_file->GetAllChildrenArray($arE);
if (isset($arE[$this->mess["IBLOCK_XML2_ID"]])) {
$xml_id = $arE[$this->mess["IBLOCK_XML2_ID"]];
if (!array_key_exists($xml_id, $arEnumMap)) {
$arProperty["VALUES"]["n" . $i] = array();
$arEnumMap[$xml_id] =& $arProperty["VALUES"]["n" . $i];
$i++;
}
$arEnumMap[$xml_id]["CML2_EXPORT_FLAG"] = true;
$arEnumMap[$xml_id]["XML_ID"] = $xml_id;
if (isset($arE[$this->mess["IBLOCK_XML2_VALUE"]])) {
$arEnumMap[$xml_id]["VALUE"] = $arE[$this->mess["IBLOCK_XML2_VALUE"]];
}
if (isset($arE[$this->mess["IBLOCK_XML2_BY_DEFAULT"]])) {
$arEnumMap[$xml_id]["DEF"] = $arE[$this->mess["IBLOCK_XML2_BY_DEFAULT"]] == "true" || intval($arE[$this->mess["IBLOCK_XML2_BY_DEFAULT"]]) ? "Y" : "N";
}
if (isset($arE[$this->mess["IBLOCK_XML2_SORT"]])) {
$arEnumMap[$xml_id]["SORT"] = intval($arE[$this->mess["IBLOCK_XML2_SORT"]]);
}
}
} elseif ($arE["NAME"] == $this->mess["IBLOCK_XML2_TYPE_LIST"]) {
$arE = $this->_xml_file->GetAllChildrenArray($arE);
if (isset($arE[$this->mess["IBLOCK_XML2_VALUE_ID"]])) {
$xml_id = $arE[$this->mess["IBLOCK_XML2_VALUE_ID"]];
if (!array_key_exists($xml_id, $arEnumMap)) {
$arProperty["VALUES"]["n" . $i] = array();
$arEnumMap[$xml_id] =& $arProperty["VALUES"]["n" . $i];
$i++;
}
$arEnumMap[$xml_id]["CML2_EXPORT_FLAG"] = true;
$arEnumMap[$xml_id]["XML_ID"] = $xml_id;
if (isset($arE[$this->mess["IBLOCK_XML2_VALUE"]])) {
$arEnumMap[$xml_id]["VALUE"] = $arE[$this->mess["IBLOCK_XML2_VALUE"]];
}
}
}
}
$bUpdateOnly = array_key_exists("bUpdateOnly", $this->next_step) && $this->next_step["bUpdateOnly"];
$sort = 100;
foreach ($arProperty["VALUES"] as $id => $arEnum) {
if (!isset($arEnum["CML2_EXPORT_FLAG"])) {
//Delete value only when full exchange happened
if (!$bUpdateOnly) {
$arProperty["VALUES"][$id]["VALUE"] = "";
}
} elseif (isset($arEnum["SORT"])) {
if ($arEnum["SORT"] > $sort) {
$sort = $arEnum["SORT"] + 100;
}
} else {
$arProperty["VALUES"][$id]["SORT"] = $sort;
$sort += 100;
}
}
$obProperty = new CIBlockProperty();
$obProperty->UpdateEnum($arProperty["ID"], $arProperty["VALUES"], false);
return true;
}
示例3: syncSectionToListProp
public static function syncSectionToListProp($iblock_id, $prop_id)
{
if (intval($iblock_id) && intval($prop_id) > 0) {
\CModule::IncludeModule('iblock');
$arSectionVariants = array();
$dbResult = \CIBlockSection::GetList(array(), array(''), false, array('ID', 'CODE', 'NAME', 'SORT'));
while ($next = $dbResult->GetNext()) {
if (!empty($next['NAME']) && !empty($next['CODE'])) {
$next['VALUE'] = $next['NAME'];
$next['XML_ID'] = 'xml_section_' . $next['CODE'];
unset($next['VALUE']);
unset($next['CODE']);
$arSectionVariants[] = $next;
}
}
$obProperty = new \CIBlockProperty();
return $obProperty->UpdateEnum($prop_id, $arSectionVariants);
}
return false;
}