當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CIBlockProperty::UpdateEnum方法代碼示例

本文整理匯總了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;
	}
開發者ID:nProfessor,項目名稱:Mytb,代碼行數:101,代碼來源:cml2.php

示例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;
 }
開發者ID:nycmic,項目名稱:bittest,代碼行數:70,代碼來源:cml2.php

示例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;
 }
開發者ID:firestorm23,項目名稱:bxhelper,代碼行數:20,代碼來源:BXHelper.php


注:本文中的CIBlockProperty::UpdateEnum方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。