21 private static $prop_cache =
array();
23 public function __construct($iblock_id, $field_id, $label, $sort)
27 $this->_iblock_id = intval($iblock_id);
28 $this->_field_id = $field_id;
29 $this->_label = $label;
30 $this->_sort = intval($sort);
32 if($this->_iblock_id > 0 && mb_strlen($this->_field_id))
34 $arField = $this->_read_from_cache($this->_field_id);
39 "IBLOCK_ID" => $this->_iblock_id,
40 "FIELD_ID" => $this->_field_id,
41 "SORT" => $this->_sort,
42 "NAME" => $this->_label,
44 $this->_clear_cache();
47 $arField[
"SORT"] != $this->_sort
48 || $arField[
"NAME"] != $this->_label
53 SET SORT = ".$this->_sort.
"
54 ,NAME = '".
$DB->ForSQL($this->_label).
"'
55 WHERE IBLOCK_ID = ".$this->_iblock_id.
"
56 AND FIELD_ID = '".
$DB->ForSQL($this->_field_id).
"'
58 $this->_clear_cache();
63 private function _read_from_cache($field_id)
67 if($this->_iblock_id > 0 && !isset(self::$prop_cache[$this->_iblock_id]))
69 $rsFields =
$DB->Query(
"
70 SELECT * FROM b_lists_field
71 WHERE IBLOCK_ID = ".$this->_iblock_id.
"
75 while($arField = $rsFields->Fetch())
79 if(isset(self::$prop_cache[$this->_iblock_id][$field_id]))
85 private function _clear_cache()
87 if (CACHED_b_lists_field !==
false)
89 $cache = Bitrix\Main\Data\Cache::createInstance();
90 $cache->clean(CACHED_b_lists_field_prefix . $this->_iblock_id,
'b_lists_field');
93 if(isset(self::$prop_cache[$this->_iblock_id]))
94 unset(self::$prop_cache[$this->_iblock_id]);
109 return $this->_type->GetID();
114 return $this->_type->IsReadonly();
124 switch($this->_field_id)
139 $arField = $this->_read_from_cache($this->_field_id);
142 $res = unserialize($arField[
"SETTINGS"], [
'allowed_classes' =>
false]);
154 switch($this->_field_id)
157 if(preg_match(
'/\s*(\d+)\s*(px|%|)/', $arSettings[
"WIDTH"], $match) && ($match[1] > 0))
158 $width = $match[1].$match[2];
162 if(preg_match(
'/\s*(\d+)\s*(px|%|)/', $arSettings[
"HEIGHT"], $match) && ($match[1] > 0))
163 $height = $match[1].$match[2];
168 "USE_EDITOR" => $arSettings[
"USE_EDITOR"]==
"Y"?
"Y":
"N",
171 "SHOW_ADD_FORM" => $arSettings[
"SHOW_ADD_FORM"],
172 "SHOW_EDIT_FORM" => $arSettings[
"SHOW_EDIT_FORM"],
173 "ADD_READ_ONLY_FIELD" => $arSettings[
"ADD_READ_ONLY_FIELD"],
174 "EDIT_READ_ONLY_FIELD" => $arSettings[
"EDIT_READ_ONLY_FIELD"],
175 "SHOW_FIELD_PREVIEW" => $arSettings[
"SHOW_FIELD_PREVIEW"]
179 $arStore = $arSettings;
183 if(is_array($arStore))
184 $arFields[
"SETTINGS"] = serialize($arStore);
188 $strUpdate =
$DB->PrepareUpdate(
"b_lists_field",
$arFields);
194 WHERE IBLOCK_ID = ".$this->_iblock_id.
"
195 AND FIELD_ID = '".
$DB->ForSQL($this->_field_id).
"'
200 $DB->QueryBind($strSql, $arBinds);
202 $this->_clear_cache();
216 DELETE FROM b_lists_field
217 WHERE IBLOCK_ID = ".$this->_iblock_id.
"
218 AND FIELD_ID = '".
$DB->ForSQL($this->_field_id).
"'
230 private $_iblock_field;
234 parent::__construct($iblock_id, $field_id, $label, $sort);
238 if($this->_iblock_id > 0)
239 $arIBlockFields = CIBlock::GetArrayByID($this->_iblock_id,
"FIELDS");
241 $arIBlockFields = CIBlock::GetFieldsDefaults();
243 $this->_iblock_field = $arIBlockFields[$field_id] ??
null;
248 return isset($this->_iblock_field[
"IS_REQUIRED"]) && $this->_iblock_field[
"IS_REQUIRED"] ==
"Y";
258 return $this->_iblock_field[
"DEFAULT_VALUE"];
263 $this->_sort = intval($sort);
270 "FIELD_ID" => $this->_field_id,
271 "SORT" => $this->_sort,
272 "NAME" => $this->_label,
273 "IS_REQUIRED" => $this->_iblock_field[
"IS_REQUIRED"] ??
'N',
275 "DEFAULT_VALUE" => $this->_iblock_field[
"DEFAULT_VALUE"] ??
null,
277 "PROPERTY_TYPE" =>
false,
278 "PROPERTY_USER_TYPE" =>
false,
286 global $stackCacheManager;
287 if (isset($this->_iblock_field[
'IS_REQUIRED']) && $this->_iblock_field[
'IS_REQUIRED'] ==
'Y')
289 if($this->_iblock_id > 0)
291 $arIBlockFields = CIBlock::GetArrayByID($this->_iblock_id,
"FIELDS");
293 CIBlock::SetFields($this->_iblock_id, $arIBlockFields);
294 $stackCacheManager->Clear(
"b_iblock");
296 $this->_iblock_field[
"IS_REQUIRED"] =
"N";
306 global $stackCacheManager;
314 $arIBlockFields = CIBlock::GetArrayByID($this->_iblock_id,
"FIELDS");
316 CIBlock::SetFields($this->_iblock_id, $arIBlockFields);
317 $stackCacheManager->Clear(
"b_iblock");
331 global $stackCacheManager;
334 $arIBlockFields = CIBlock::GetArrayByID($iblock_id,
"FIELDS");
336 CIBlock::SetFields($iblock_id, $arIBlockFields);
337 $stackCacheManager->Clear(
"b_iblock");
345 private $_property =
false;
346 private static $prop_cache =
array();
350 parent::__construct($iblock_id, $field_id, $label, $sort);
352 if(preg_match(
"/^PROPERTY_(\\d+)$/", $field_id, $match))
354 $this->_property = $this->getPropertyArrayFromCache($match[1]);
357 if ($this->_property)
359 if($this->_property[
"USER_TYPE"])
365 if(!is_object($this->_type))
369 private function getPropertyArrayFromCache($id)
372 if(!array_key_exists($this->_iblock_id, self::$prop_cache))
376 $rsProperties = CIBlockProperty::GetList(
array(),
array(
377 "IBLOCK_ID" => $this->_iblock_id,
378 "CHECK_PERMISSIONS" =>
"N",
381 while($arProperty = $rsProperties->Fetch())
387 private static function resetPropertyArrayCache()
389 self::$prop_cache =
array();
394 return is_array($this->_property) && $this->_property[
"IS_REQUIRED"] ==
"Y";
399 return is_array($this->_property) && $this->_property[
"MULTIPLE"] ==
"Y";
404 return is_array($this->_property) && $this->_property[
"DEFAULT_VALUE"];
409 if(is_array($this->_property))
411 $old_sort = intval($this->_property[
"SORT"]);
412 $new_sort = intval($sort);
414 if($old_sort != $new_sort)
416 $this->_property[
"SORT"] = $new_sort;
418 $obProperty->
Update($this->_property[
"ID"], $this->_property);
419 $this->_sort = $new_sort;
427 if(is_array($this->_property))
430 "FIELD_ID" => $this->_field_id,
431 "SORT" => $this->_sort,
432 "NAME" => $this->_property[
"NAME"],
433 "IS_REQUIRED" => $this->_property[
"IS_REQUIRED"],
434 "MULTIPLE" => $this->_property[
"MULTIPLE"],
435 "DEFAULT_VALUE" => $this->_property[
"DEFAULT_VALUE"],
437 "PROPERTY_TYPE" => $this->_property[
"PROPERTY_TYPE"],
438 "PROPERTY_USER_TYPE" => $this->_property[
"USER_TYPE"]? CIBlockProperty::GetUserType($this->_property[
"USER_TYPE"]):
false,
439 "CODE" => $this->_property[
"CODE"],
440 "ID" => $this->_property[
"ID"],
441 "LINK_IBLOCK_ID" => $this->_property[
"LINK_IBLOCK_ID"],
442 "ROW_COUNT" => $this->_property[
"ROW_COUNT"],
443 "COL_COUNT" => $this->_property[
"COL_COUNT"],
444 "USER_TYPE_SETTINGS" => $this->_property[
"USER_TYPE_SETTINGS"],
456 if(is_array($this->_property))
459 if($obProperty->Delete($this->_property[
"ID"]))
461 $this->resetPropertyArrayCache();
462 $this->_property =
false;
474 $code = CUtil::translit(
$name, LANGUAGE_ID,
array(
"change_case" =>
"U"));
478 while($property = $object->fetch())
480 if($property[
"CODE"] ==
$code && $property[
"ID"] != $propertyId)
499 if (self::existPropertyCode($this->_iblock_id,
$arFields[
"CODE"], $this->_property[
"ID"]))
505 if(array_key_exists($id,
$arFields) && $id !=
"IBLOCK_ID")
508 if(mb_strpos($newType,
":") !==
false)
509 list($this->_property[
"PROPERTY_TYPE"], $this->_property[
"USER_TYPE"]) = explode(
":", $newType);
512 $this->_property[
"PROPERTY_TYPE"] = $newType;
513 $this->_property[
"USER_TYPE"] =
"";
516 $this->_property[
"CHECK_PERMISSIONS"] =
"N";
517 $this->_property[
"ACTIVE"] =
"Y";
520 if($obProperty->Update($this->_property[
"ID"], $this->_property))
522 self::resetPropertyArrayCache();
524 if($this->_property[
"PROPERTY_TYPE"] ==
"L" && is_array(
$arFields[
"LIST"] ??
null))
529 elseif (!empty($obProperty->LAST_ERROR))
542 if (self::existPropertyCode($iblock_id,
$arFields[
"CODE"]))
546 $property_id = intval(
$arFields[
"ID"] ?? 0);
554 if(mb_strpos(
$arFields[
"TYPE"],
":") !==
false)
563 if (!empty($obProperty->LAST_ERROR))
569 self::resetPropertyArrayCache();
584 private static function existPropertyCode(
$iblockId,
$code, $propertyId = 0)
589 throw new ArgumentException(
"Required parameter \"iblockId\" is missing.");
597 $property = $queryObject->fetch();
599 if (!empty($property) && is_array($property))
601 return $property[
"ID"] != $propertyId;
Update($ID, $arFields, $bCheckDescription=false)
static Add($iblock_id, $arFields)
__construct($iblock_id, $field_id, $label, $sort)
static Add($iblock_id, $arFields)
__construct($iblock_id, $field_id, $label, $sort)
static UpdatePropertyList($prop_id, $list)
static Add($iblock_id, $arFields)
__construct($iblock_id, $field_id, $label, $sort)
static generateMnemonicCode($integerCode=0)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
GetMessage($name, $aReplace=null)
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)