1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
iblock_element.php
См. документацию.
1<?php
2
4
6{
7 var $fields;
8 var $props=false;
9
10 function GetFields()
11 {
12 return $this->fields;
13 }
14
20 function GetProperties($arOrder = false, $arFilter = array())
21 {
22 if($arOrder === false)
23 $arOrder = array("sort"=>"asc","id"=>"asc","enum_sort"=>"asc","value_id"=>"asc");
24 if (empty($arFilter) && is_array($this->props))
25 {
26 $arAllProps = array();
27 foreach($this->props as $arProp)
28 {
29 if(trim($arProp["CODE"]) <> '')
30 $PIND = $arProp["CODE"];
31 else
32 $PIND = $arProp["ID"];
33
34 $arProp['VALUE'] = $this->fields['PROPERTY_'.$arProp['ID']];
35 $arProp['DESCRIPTION'] = $this->fields['DESCRIPTION_' . $arProp['ID']] ?? '';
36 if ($arProp['MULTIPLE'] === 'N')
37 {
38 if ($arProp['PROPERTY_TYPE'] === PropertyTable::TYPE_LIST)
39 {
40 $arProp['VALUE_ENUM_ID'] = $arProp['VALUE'];
41 $arEnum =
42 $arProp['VALUE']
43 ? CIBlockPropertyEnum::GetByID($arProp['VALUE'])
44 : false
45 ;
46 if ($arEnum !== false)
47 {
48 $arProp["~VALUE"] = $arEnum["VALUE"];
49 if(
50 is_array($arProp["VALUE"])
51 || (is_string($arProp["VALUE"]) &&preg_match("/[;&<>\"]/", $arProp["VALUE"]))
52 )
53 {
54 $arProp["VALUE"] = htmlspecialcharsEx($arEnum["VALUE"]);
55 }
56 else
57 {
58 $arProp["VALUE"] = $arEnum["VALUE"];
59 }
60 $arProp["VALUE_ENUM"] = $arProp["VALUE"];
61 $arProp["VALUE_XML_ID"] = htmlspecialcharsEx((string)$arEnum["XML_ID"]);
62 $arProp["VALUE_SORT"] = $arEnum["SORT"];
63 }
64 else
65 {
66 $arProp["~VALUE"] = "";
67 $arProp["VALUE"] = "";
68 }
69 }
70 elseif(is_array($arProp["VALUE"]) || mb_strlen($arProp["VALUE"]))
71 {
72 if ($arProp['PROPERTY_TYPE'] === PropertyTable::TYPE_NUMBER)
73 {
74 $arProp['VALUE'] = htmlspecialcharsEx(CIBlock::NumberFormat($arProp['VALUE']));
75 }
76 $arProp['~VALUE'] = $this->fields['~PROPERTY_'.$arProp['ID']];
77 $arProp['~DESCRIPTION'] = $this->fields['~DESCRIPTION_'.$arProp['ID']] ?? '';
78 }
79 else
80 {
81 $arProp['~VALUE'] = '';
82 $arProp['VALUE'] = '';
83 $arProp['~DESCRIPTION'] = '';
84 $arProp['DESCRIPTION'] = '';
85 }
86 }
87 else
88 {
89 $arList = $arProp["VALUE"];
90 $arListTilda = $this->fields["~PROPERTY_".$arProp["ID"]];
91 if ($arProp['PROPERTY_TYPE'] === PropertyTable::TYPE_LIST)
92 {
93 $arProp['VALUE_ENUM_ID'] = false;
94 $arProp['VALUE'] = false;
95 $arProp['~VALUE'] =false;
96 $arProp['VALUE_XML_ID'] = false;
97 foreach($arList as $key => $val)
98 {
99 if ($val)
100 {
102 if ($arEnum !== false)
103 {
104 $xml_id = htmlspecialcharsEx($arEnum["XML_ID"]);
105 $sort = $arEnum["SORT"];
106 }
107 else
108 {
109 $xml_id = false;
110 $sort = false;
111 }
112
113 if (is_array($arProp['VALUE']))
114 {
115
116 $arProp["VALUE_ENUM_ID"][] = $key;
117 $arProp["~VALUE"][] = $val;
118 if(is_array($val) || preg_match("/[;&<>\"]/", $val))
119 $arProp["VALUE"][] = htmlspecialcharsEx($val);
120 else
121 $arProp["VALUE"][] = $val;
122 $arProp["VALUE_XML_ID"][] = $xml_id;
123 $arProp["VALUE_SORT"][] = $sort;
124 }
125 else
126 {
127 $arProp["VALUE_ENUM_ID"] = array($key);
128 $arProp["~VALUE"] = array($val);
129 if(is_array($val) || preg_match("/[;&<>\"]/", $val))
130 $arProp["VALUE"] = array(htmlspecialcharsEx($val));
131 else
132 $arProp["VALUE"] = array($val);
133 $arProp["VALUE_XML_ID"] = array($xml_id);
134 $arProp["VALUE_SORT"] = array($sort);
135 }
136 }
137 }
138 $arProp["VALUE_ENUM"] = $arProp["VALUE"];
139 }
140 else
141 {
142 $arDesc = $arProp['DESCRIPTION'];
143 $arDescTilda = $this->fields['~DESCRIPTION_' . $arProp['ID']] ?? '';
144
145 $arProp['~VALUE'] = false;
146 $arProp['VALUE'] = false;
147 $arProp['~DESCRIPTION'] = false;
148 $arProp['DESCRIPTION'] = false;
149 foreach($arList as $key=>$val)
150 {
151 if(is_array($val) || $val <> '')
152 {
153 if(is_array($arProp["VALUE"]))
154 {
155 $arProp["~VALUE"][] = $arListTilda[$key];
156 if($arProp["PROPERTY_TYPE"]=="N")
157 $val = htmlspecialcharsEx(CIBlock::NumberFormat($val));
158 $arProp["VALUE"][] = $val;
159 $arProp["~DESCRIPTION"][] = $arDescTilda[$key];
160 $arProp["DESCRIPTION"][] = $arDesc[$key];
161 }
162 else
163 {
164 $arProp["~VALUE"] = array($arListTilda[$key]);
165 if($arProp["PROPERTY_TYPE"]=="N")
166 $val = htmlspecialcharsEx(CIBlock::NumberFormat($val));
167 $arProp["VALUE"] = array($val);
168 $arProp["~DESCRIPTION"] = array($arDescTilda[$key]);
169 $arProp["DESCRIPTION"] = array($arDesc[$key]);
170 }
171 }
172 }
173 }
174 }
175 $arAllProps[$PIND]=$arProp;
176 }
177 return $arAllProps;
178 }
179
180 if(array_key_exists("ID", $arFilter) && is_string($arFilter['ID']))
181 {
182 if (!is_numeric(mb_substr($arFilter["ID"], 0, 1)))
183 {
184 $arFilter["CODE"] = $arFilter["ID"];
185 unset($arFilter["ID"]);
186 }
187 }
188
189 if(!array_key_exists("ACTIVE", $arFilter))
190 $arFilter["ACTIVE"]="Y";
191
192 $props = CIBlockElement::GetProperty($this->fields["IBLOCK_ID"], $this->fields["ID"], $arOrder, $arFilter);
193
194 $arAllProps = Array();
195 while($arProp = $props->Fetch())
196 {
197 if(trim($arProp["CODE"]) <> '')
198 $PIND = $arProp["CODE"];
199 else
200 $PIND = $arProp["ID"];
201
202 if($arProp["PROPERTY_TYPE"]=="L")
203 {
204 $arProp["VALUE_ENUM_ID"] = $arProp["VALUE"];
205 $arProp["VALUE"] = $arProp["VALUE_ENUM"];
206 }
207
208 if(is_array($arProp["VALUE"]) || ($arProp["VALUE"] <> ''))
209 {
210 $arProp["~VALUE"] = $arProp["VALUE"];
211 if(is_array($arProp["VALUE"]) || preg_match("/[;&<>\"]/", $arProp["VALUE"]))
212 $arProp["VALUE"] = htmlspecialcharsEx($arProp["VALUE"]);
213 $arProp["~DESCRIPTION"] = $arProp["DESCRIPTION"];
214 if ($arProp["DESCRIPTION"] !== null && preg_match("/[;&<>\"]/", $arProp["DESCRIPTION"]))
215 {
216 $arProp["DESCRIPTION"] = htmlspecialcharsEx($arProp["DESCRIPTION"]);
217 }
218 }
219 else
220 {
221 $arProp['~VALUE'] = '';
222 $arProp['VALUE'] = '';
223 $arProp['~DESCRIPTION'] = '';
224 $arProp['DESCRIPTION'] = '';
225 }
226
227 if($arProp["MULTIPLE"]=="Y")
228 {
229 if (isset($arAllProps[$PIND]))
230 {
231 if ($arAllProps[$PIND]['ID'] != $arProp['ID'])
232 unset($arAllProps[$PIND]);
233 }
234 if (isset($arAllProps[$PIND]))
235 {
236 $arTemp = &$arAllProps[$PIND];
237 if($arProp["VALUE"]!=="")
238 {
239 if(is_array($arTemp["VALUE"]))
240 {
241 $arTemp["VALUE"][] = $arProp["VALUE"];
242 $arTemp["~VALUE"][] = $arProp["~VALUE"];
243 $arTemp["DESCRIPTION"][] = $arProp["DESCRIPTION"];
244 $arTemp["~DESCRIPTION"][] = $arProp["~DESCRIPTION"];
245 $arTemp["PROPERTY_VALUE_ID"][] = $arProp["PROPERTY_VALUE_ID"];
246 if($arProp["PROPERTY_TYPE"]=="L")
247 {
248 $arTemp["VALUE_ENUM_ID"][] = $arProp["VALUE_ENUM_ID"];
249 $arTemp["VALUE_ENUM"][] = $arProp["VALUE_ENUM"];
250 $arTemp["VALUE_XML_ID"][] = $arProp["VALUE_XML_ID"];
251 $arTemp["VALUE_SORT"][] = $arProp["VALUE_SORT"];
252 }
253 }
254 else
255 {
256 $arTemp["VALUE"] = array($arProp["VALUE"]);
257 $arTemp["~VALUE"] = array($arProp["~VALUE"]);
258 $arTemp["DESCRIPTION"] = array($arProp["DESCRIPTION"]);
259 $arTemp["~DESCRIPTION"] = array($arProp["~DESCRIPTION"]);
260 $arTemp["PROPERTY_VALUE_ID"] = array($arProp["PROPERTY_VALUE_ID"]);
261 if($arProp["PROPERTY_TYPE"]=="L")
262 {
263 $arTemp["VALUE_ENUM_ID"] = array($arProp["VALUE_ENUM_ID"]);
264 $arTemp["VALUE_ENUM"] = array($arProp["VALUE_ENUM"]);
265 $arTemp["VALUE_XML_ID"] = array($arProp["VALUE_XML_ID"]);
266 $arTemp["VALUE_SORT"] = array($arProp["VALUE_SORT"]);
267 }
268 }
269 }
270 }
271 else
272 {
273 $arProp["~NAME"] = $arProp["NAME"];
274 if(preg_match("/[;&<>\"]/", $arProp["NAME"]))
275 $arProp["NAME"] = htmlspecialcharsEx($arProp["NAME"]);
276 $arProp["~DEFAULT_VALUE"] = $arProp["DEFAULT_VALUE"];
277 if ($arProp['DEFAULT_VALUE'] !== null)
278 {
279 if (is_array($arProp['DEFAULT_VALUE']) || preg_match("/[;&<>\"]/", $arProp['DEFAULT_VALUE']))
280 {
281 $arProp['DEFAULT_VALUE'] = htmlspecialcharsEx($arProp['DEFAULT_VALUE']);
282 }
283 }
284 if($arProp["VALUE"]!=="")
285 {
286 $arProp["VALUE"] = array($arProp["VALUE"]);
287 $arProp["~VALUE"] = array($arProp["~VALUE"]);
288 $arProp["DESCRIPTION"] = array($arProp["DESCRIPTION"]);
289 $arProp["~DESCRIPTION"] = array($arProp["~DESCRIPTION"]);
290 $arProp["PROPERTY_VALUE_ID"] = array($arProp["PROPERTY_VALUE_ID"]);
291 if($arProp["PROPERTY_TYPE"]=="L")
292 {
293 $arProp["VALUE_ENUM_ID"] = array($arProp["VALUE_ENUM_ID"]);
294 $arProp["VALUE_ENUM"] = array($arProp["VALUE_ENUM"]);
295 $arProp["VALUE_XML_ID"] = array($arProp["VALUE_XML_ID"]);
296 $arProp["VALUE_SORT"] = array($arProp["VALUE_SORT"]);
297 }
298 }
299 else
300 {
301 $arProp["VALUE"] = false;
302 $arProp["~VALUE"] = false;
303 $arProp["DESCRIPTION"] = false;
304 $arProp["~DESCRIPTION"] = false;
305 $arProp["PROPERTY_VALUE_ID"] = false;
306 if($arProp["PROPERTY_TYPE"]=="L")
307 {
308 $arProp["VALUE_ENUM_ID"] = false;
309 $arProp["VALUE_ENUM"] = false;
310 $arProp["VALUE_XML_ID"] = false;
311 $arProp["VALUE_SORT"] = false;
312 }
313 }
314 $arAllProps[$PIND] = $arProp;
315 }
316 }
317 else
318 {
319 $arProp["~NAME"] = $arProp["NAME"];
320 if(preg_match("/[;&<>\"]/", $arProp["NAME"]))
321 $arProp["NAME"] = htmlspecialcharsEx($arProp["NAME"]);
322 $arProp["~DEFAULT_VALUE"] = $arProp["DEFAULT_VALUE"];
323 if ($arProp['DEFAULT_VALUE'] !== null)
324 {
325 if (is_array($arProp['DEFAULT_VALUE']) || preg_match("/[;&<>\"]/", $arProp['DEFAULT_VALUE']))
326 {
327 $arProp['DEFAULT_VALUE'] = htmlspecialcharsEx($arProp['DEFAULT_VALUE']);
328 }
329 }
330 $arAllProps[$PIND] = $arProp;
331 }
332 }
333
334 return $arAllProps;
335 }
336
337 function GetProperty($ID)
338 {
339 $res = $this->GetProperties(array(), array("ID"=>$ID));
340 return reset($res);
341 }
342
343 function GetGroups()
344 {
345 return CIBlockElement::GetElementGroups($this->fields["ID"]);
346 }
347}
Определения iblock_element.php:6
GetProperty($ID)
Определения iblock_element.php:337
GetGroups()
Определения iblock_element.php:343
GetProperties($arOrder=false, $arFilter=array())
Определения iblock_element.php:20
GetFields()
Определения iblock_element.php:10
$fields
Определения iblock_element.php:7
$props
Определения iblock_element.php:8
static GetByID($ID)
Определения iblockpropertyenum.php:217
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$res
Определения filter_act.php:7
if($ajaxMode) $ID
Определения get_user.php:27
htmlspecialcharsEx($str)
Определения tools.php:2685
return false
Определения prolog_main_admin.php:185
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
if(empty($signedUserToken)) $key
Определения quickway.php:257
$val
Определения options.php:1793
$arFilter
Определения user_search.php:106