1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
iblockresult.php
См. документацию.
1<?
2class CIBlockResult extends CDBResult
3{
9 var $arIBlockAllProps =false;
13 var $arIBlockLongProps = false;
14
17 var $strDetailUrl = false;
18 var $strSectionUrl = false;
19 var $strListUrl = false;
20 var $arSectionContext = false;
21 var $bIBlockSection = false;
22 var $nameTemplate = "";
23
26
27 public function __construct($res = null)
28 {
29 parent::__construct($res);
30 }
31
32 function SetUrlTemplates($DetailUrl = "", $SectionUrl = "", $ListUrl = "")
33 {
34 $this->strDetailUrl = $DetailUrl;
35 $this->strSectionUrl = $SectionUrl;
36 $this->strListUrl = $ListUrl;
37 }
38
39 function SetSectionContext($arSection)
40 {
41 if (is_array($arSection) && array_key_exists("ID", $arSection))
42 {
43 $code = '';
44 if (isset($arSection['~CODE']))
45 {
46 $code = $arSection['~CODE'];
47 }
48 elseif (isset($arSection['CODE']))
49 {
50 $code = $arSection['CODE'];
51 }
52
53 $this->arSectionContext = array(
54 "ID" => (int)$arSection["ID"] > 0 ? (int)$arSection["ID"] : "",
55 "CODE" => urlencode($code),
56 "IBLOCK_ID" => intval($arSection["IBLOCK_ID"] ?? 0),
57 );
58 }
59 else
60 {
61 $this->arSectionContext = false;
62 }
63 }
64
65 function SetIBlockTag($iblock_id)
66 {
67 if(is_array($iblock_id))
68 {
69 foreach($iblock_id as $id)
70 $this->SetIBlockTag($id);
71 }
72 else
73 {
74 $id = intval($iblock_id);
75 if ($id > 0)
76 $this->_FILTER_IBLOCK_ID[$id] = true;
77 }
78 }
79
81 {
82 $this->nameTemplate = $nameTemplate;
83 }
84
85 function Fetch()
86 {
88 global $DB;
89 $res = parent::Fetch();
90
91 if(!isset($this) || !is_object($this))
92 return $res;
93
94 if($res)
95 {
96 $arUpdate = array();
97 if(!empty($this->arIBlockLongProps) && is_array($this->arIBlockLongProps))
98 {
99 foreach($res as $k=>$v)
100 {
101 if(preg_match("#^ALIAS_(\\d+)_(.*)$#", $k, $match))
102 {
103 $res[$this->arIBlockLongProps[$match[1]].$match[2]] = $v;
104 unset($res[$k]);
105 }
106 }
107 }
108
109 if(
110 isset($res["IBLOCK_ID"])
111 && $res["IBLOCK_ID"] != $this->_LAST_IBLOCK_ID
112 && defined("BX_COMP_MANAGED_CACHE")
113 )
114 {
115 CIBlock::registerWithTagCache($res["IBLOCK_ID"]);
116 $this->_LAST_IBLOCK_ID = $res["IBLOCK_ID"];
117 }
118
119 if(isset($res["ID"]) && $res["ID"] != "" && !empty($this->arIBlockMultProps) && is_array($this->arIBlockMultProps))
120 {
121 foreach($this->arIBlockMultProps as $field_name => $db_prop)
122 {
123 if(array_key_exists($field_name, $res))
124 {
125 if(is_object($res[$field_name]))
126 $res[$field_name]=$res[$field_name]->load();
127
128 if(preg_match("/(_VALUE)$/", $field_name))
129 {
130 $descr_name = preg_replace("/(_VALUE)$/", "_DESCRIPTION", $field_name);
131 $value_id_name = preg_replace("/(_VALUE)$/", "_PROPERTY_VALUE_ID", $field_name);;
132 }
133 else
134 {
135 $descr_name = preg_replace("/^(PROPERTY_)/", "DESCRIPTION_", $field_name);
136 $value_id_name = preg_replace("/^(PROPERTY_)/", "PROPERTY_VALUE_ID_", $field_name);
137 }
138
139 $update = false;
140 if ($res[$field_name] == '')
141 {
142 $update = true;
143 }
144 else
145 {
146 $tmp = unserialize($res[$field_name], ['allowed_classes' => false]);
147 if (!isset($tmp['ID']))
148 $update = true;
149 }
150 if ($update)
151 {
152 $strSql = "
153 SELECT ID, VALUE, DESCRIPTION
154 FROM b_iblock_element_prop_m".$db_prop["IBLOCK_ID"]."
155 WHERE
156 IBLOCK_ELEMENT_ID = ".intval($res["ID"])."
157 AND IBLOCK_PROPERTY_ID = ".intval($db_prop["ORIG_ID"])."
158 ORDER BY ID
159 ";
160 $rs = $DB->Query($strSql);
161 $res[$field_name] = array();
162 $res[$descr_name] = array();
163 $res[$value_id_name] = array();
164 while($ar=$rs->Fetch())
165 {
166 $res[$field_name][]=$ar["VALUE"];
167 $res[$descr_name][]=$ar["DESCRIPTION"];
168 $res[$value_id_name][] = $ar['ID'];
169 }
170 $arUpdate["b_iblock_element_prop_s".$db_prop["IBLOCK_ID"]]["PROPERTY_".$db_prop["ORIG_ID"]] = serialize(array("VALUE"=>$res[$field_name],"DESCRIPTION"=>$res[$descr_name],"ID"=>$res[$value_id_name]));
171 }
172 else
173 {
174 $res[$field_name] = $tmp["VALUE"];
175 $res[$descr_name] = $tmp["DESCRIPTION"];
176 $res[$value_id_name] = $tmp["ID"];
177 }
178
179 if(is_array($res[$field_name]) && $db_prop["PROPERTY_TYPE"]=="L")
180 {
181 $arTemp = array();
182 foreach($res[$field_name] as $key=>$val)
183 {
185 if($arEnum!==false)
186 $arTemp[$val] = $arEnum["VALUE"];
187 }
188 $res[$field_name] = $arTemp;
189 }
190 }
191 }
192
193 if (!empty($arUpdate))
194 {
195 $pool = \Bitrix\Main\Application::getInstance()->getConnectionPool();
196 $pool->useMasterOnly(true);
197 foreach ($arUpdate as $strTable => $arFields)
198 {
199 $strUpdate = $DB->PrepareUpdate($strTable, $arFields);
200 if ($strUpdate != "")
201 {
202 $strSql = "UPDATE ".$strTable." SET ".$strUpdate." WHERE IBLOCK_ELEMENT_ID = ".intval($res["ID"]);
203 $DB->QueryBind($strSql, $arFields);
204 }
205 }
206 $pool->useMasterOnly(false);
207 unset($pool);
208 }
209 }
210 if(!empty($this->arIBlockConvProps) && is_array($this->arIBlockConvProps))
211 {
212 foreach($this->arIBlockConvProps as $strFieldName=>$arCallback)
213 {
214 if(is_array($res[$strFieldName]))
215 {
216 foreach($res[$strFieldName] as $key=>$value)
217 {
218 $arValue = call_user_func_array(
219 $arCallback['ConvertFromDB'],
220 [
221 $arCallback['PROPERTY'],
222 [
223 'VALUE' => $value,
224 'DESCRIPTION' => '',
225 ]
226 ]
227 );
228 $res[$strFieldName][$key] = $arValue['VALUE'] ?? null;
229 }
230 }
231 else
232 {
233 $arValue = call_user_func_array(
234 $arCallback['ConvertFromDB'],
235 [
236 $arCallback['PROPERTY'],
237 [
238 'VALUE' => $res[$strFieldName],
239 'DESCRIPTION' => '',
240 ]
241 ]
242 );
243 $res[$strFieldName] = $arValue['VALUE'] ?? null;
244 }
245 }
246 }
247 if(!empty($this->arIBlockNumProps) && is_array($this->arIBlockNumProps))
248 {
249 foreach($this->arIBlockNumProps as $field_name => $db_prop)
250 {
251 if($res[$field_name] <> '')
252 $res[$field_name] = htmlspecialcharsex(CIBlock::NumberFormat($res[$field_name]));
253 }
254 }
255 if (isset($res["UC_ID"]))
256 {
257 $res["CREATED_BY_FORMATTED"] = CUser::FormatName($this->nameTemplate, array(
258 "NAME" => $res["UC_NAME"],
259 "LAST_NAME" => $res["UC_LAST_NAME"],
260 "SECOND_NAME" => $res["UC_SECOND_NAME"],
261 "EMAIL" => $res["UC_EMAIL"],
262 "ID" => $res["UC_ID"],
263 "LOGIN" => $res["UC_LOGIN"],
264 ), true, false);
265 unset($res["UC_NAME"]);
266 unset($res["UC_LAST_NAME"]);
267 unset($res["UC_SECOND_NAME"]);
268 unset($res["UC_EMAIL"]);
269 unset($res["UC_ID"]);
270 unset($res["UC_LOGIN"]);
271 }
272 unset($arUpdate);
273 }
274 elseif(
275 defined("BX_COMP_MANAGED_CACHE")
276 && $this->_LAST_IBLOCK_ID == ""
277 && count($this->_FILTER_IBLOCK_ID)
278 )
279 {
280 foreach($this->_FILTER_IBLOCK_ID as $iblock_id => $t)
281 CIBlock::registerWithTagCache($iblock_id);
282 }
283
284 return $res;
285 }
286
287 function GetNext($bTextHtmlAuto=true, $use_tilda=true)
288 {
289 static $arSectionPathCache = array();
290
291 $res = parent::GetNext($bTextHtmlAuto, $use_tilda);
292 if($res)
293 {
294 //Handle List URL for Element, Section or IBlock
295 if($this->strListUrl)
296 $TEMPLATE = $this->strListUrl;
297 elseif(array_key_exists("~LIST_PAGE_URL", $res))
298 $TEMPLATE = $res["~LIST_PAGE_URL"];
299 elseif(!$use_tilda && array_key_exists("LIST_PAGE_URL", $res))
300 $TEMPLATE = $res["LIST_PAGE_URL"];
301 else
302 $TEMPLATE = "";
303
304 if($TEMPLATE)
305 {
306 $res_tmp = $res;
307 if((intval(($res["IBLOCK_ID"] ?? 0)) <= 0) && (intval($res["ID"]) > 0))
308 {
309 $res_tmp["IBLOCK_ID"] = $res["ID"];
310 $res_tmp["IBLOCK_CODE"] = $res["CODE"];
311 $res_tmp["IBLOCK_EXTERNAL_ID"] = $res["EXTERNAL_ID"];
312 if($use_tilda)
313 {
314 $res_tmp["~IBLOCK_ID"] = $res["~ID"];
315 $res_tmp["~IBLOCK_CODE"] = $res["~CODE"];
316 $res_tmp["~IBLOCK_EXTERNAL_ID"] = $res["~EXTERNAL_ID"];
317 }
318 }
319
320 if($use_tilda)
321 {
322 $res["~LIST_PAGE_URL"] = CIBlock::ReplaceDetailUrl($TEMPLATE, $res_tmp, true, false);
323 $res["LIST_PAGE_URL"] = htmlspecialcharsbx($res["~LIST_PAGE_URL"]);
324 }
325 else
326 {
327 $res["LIST_PAGE_URL"] = CIBlock::ReplaceDetailUrl($TEMPLATE, $res_tmp, true, false);
328 }
329 }
330
331 //If this is Element or Section then process it's detail and section URLs
332 if(($res["IBLOCK_ID"] ?? '') <> '')
333 {
334
335 if(array_key_exists("GLOBAL_ACTIVE", $res))
336 {
337 $type = "S";
338 }
339 else
340 {
341 $type = "E";
342 }
343
344 if($this->strDetailUrl)
345 {
346 $TEMPLATE = $this->strDetailUrl;
347 }
348 elseif(array_key_exists("~DETAIL_PAGE_URL", $res))
349 {
350 $TEMPLATE = $res["~DETAIL_PAGE_URL"];
351 }
352 elseif(!$use_tilda && array_key_exists("DETAIL_PAGE_URL", $res))
353 {
354 $TEMPLATE = $res["DETAIL_PAGE_URL"];
355 }
356 else
357 {
358 $TEMPLATE = "";
359 }
360
361 if($TEMPLATE)
362 {
363 if($this->arSectionContext)
364 {
365 $TEMPLATE = str_replace("#SECTION_ID#", $this->arSectionContext["ID"], $TEMPLATE);
366 $TEMPLATE = str_replace("#SECTION_CODE#", $this->arSectionContext["CODE"], $TEMPLATE);
367 if(
368 $this->arSectionContext["ID"] > 0
369 && $this->arSectionContext["IBLOCK_ID"] > 0
370 && mb_strpos($TEMPLATE, "#SECTION_CODE_PATH#") !== false
371 )
372 {
373 if(!isset($arSectionPathCache[$this->arSectionContext["ID"]]))
374 {
375 $rs = CIBlockSection::GetNavChain(
376 $this->arSectionContext["IBLOCK_ID"],
377 $this->arSectionContext["ID"],
378 array("ID", "IBLOCK_SECTION_ID", "CODE"),
379 true
380 );
381 if (!empty($rs))
382 {
383 $arSectionPathCache[$this->arSectionContext["ID"]] = '';
384 foreach ($rs as $a)
385 {
386 $arSectionPathCache[$this->arSectionContext["ID"]] .= rawurlencode($a["CODE"])."/";
387 }
388 unset($a);
389 }
390 unset($rs);
391 }
392 if(isset($arSectionPathCache[$this->arSectionContext["ID"]]))
393 {
394 $SECTION_CODE_PATH = rtrim($arSectionPathCache[$this->arSectionContext["ID"]], "/");
395 }
396 else
397 {
398 $SECTION_CODE_PATH = "";
399 }
400 $TEMPLATE = str_replace("#SECTION_CODE_PATH#", $SECTION_CODE_PATH, $TEMPLATE);
401 }
402 }
403
404 if($use_tilda)
405 {
406 $res["~DETAIL_PAGE_URL"] = CIBlock::ReplaceDetailUrl($TEMPLATE, $res, true, $type);
407 $res["DETAIL_PAGE_URL"] = htmlspecialcharsbx($res["~DETAIL_PAGE_URL"]);
408 }
409 else
410 {
411 $res["DETAIL_PAGE_URL"] = CIBlock::ReplaceDetailUrl($TEMPLATE, $res, true, $type);
412 }
413 }
414
415 if($this->strSectionUrl)
416 {
417 $TEMPLATE = $this->strSectionUrl;
418 }
419 elseif(array_key_exists("~SECTION_PAGE_URL", $res))
420 {
421 $TEMPLATE = $res["~SECTION_PAGE_URL"];
422 }
423 elseif(!$use_tilda && array_key_exists("SECTION_PAGE_URL", $res))
424 {
425 $TEMPLATE = $res["SECTION_PAGE_URL"];
426 }
427 else
428 {
429 $TEMPLATE = "";
430 }
431
432 if($TEMPLATE)
433 {
434 if($use_tilda)
435 {
436 $res["~SECTION_PAGE_URL"] = CIBlock::ReplaceSectionUrl($TEMPLATE, $res, true, $type);
437 $res["SECTION_PAGE_URL"] = htmlspecialcharsbx($res["~SECTION_PAGE_URL"]);
438 }
439 else
440 {
441 $res["SECTION_PAGE_URL"] = CIBlock::ReplaceSectionUrl($TEMPLATE, $res, true, $type);
442 }
443 }
444 }
445
446 if(array_key_exists("~CANONICAL_PAGE_URL", $res))
447 $TEMPLATE = $res["~CANONICAL_PAGE_URL"];
448 elseif(!$use_tilda && array_key_exists("CANONICAL_PAGE_URL", $res))
449 $TEMPLATE = $res["CANONICAL_PAGE_URL"];
450 else
451 $TEMPLATE = "";
452
453 if($TEMPLATE)
454 {
455 if($use_tilda)
456 {
457 $res["~CANONICAL_PAGE_URL"] = CIBlock::ReplaceDetailUrl($TEMPLATE, $res, true, "E");
458 $res["CANONICAL_PAGE_URL"] = htmlspecialcharsbx($res["~CANONICAL_PAGE_URL"]);
459 }
460 else
461 {
462 $res["CANONICAL_PAGE_URL"] = CIBlock::ReplaceDetailUrl($TEMPLATE, $res, true, "E");
463 }
464 }
465 }
466 return $res;
467 }
468
469 function GetNextElement($bTextHtmlAuto=true, $use_tilda=true)
470 {
471 if(!($r = $this->GetNext($bTextHtmlAuto, $use_tilda)))
472 return $r;
473
474 $res = new _CIBElement;
475 $res->fields = $r;
476 if(!empty($this->arIBlockAllProps) && is_array($this->arIBlockAllProps))
478 return $res;
479 }
480
482 {
483 $this->table_id = $table_id;
484 }
485
486 function NavStart($nPageSize=20, $bShowAll=true, $iNumPage=false)
487 {
488 if($this->table_id)
489 {
490 if ($_REQUEST["mode"] == "excel")
491 return;
492 $navResult = new CAdminResult(null, '');
493 $nSize = $navResult->GetNavSize($this->table_id, $nPageSize);
494 unset($navResult);
495 if(is_array($nPageSize))
496 {
497 $this->nInitialSize = $nPageSize["nPageSize"];
498 $nPageSize["nPageSize"] = $nSize;
499 }
500 else
501 {
502 $this->nInitialSize = $nPageSize;
503 $nPageSize = $nSize;
504 }
505 }
506 parent::NavStart($nPageSize, $bShowAll, $iNumPage);
507 }
508
509 function GetNavPrint($title, $show_allways=true, $StyleText="", $template_path=false, $arDeleteParam=false)
510 {
511 if($this->table_id && ($template_path === false))
512 $template_path = $_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/interface/navigation.php";
513 return parent::GetNavPrint($title, $show_allways, $StyleText, $template_path, $arDeleteParam);
514 }
515}
$type
Определения options.php:106
Определения iblock_element.php:6
static getInstance()
Определения application.php:98
Определения admin_lib.php:2054
$bShowAll
Определения dbresult.php:21
$DB
Определения dbresult.php:40
static GetByID($ID)
Определения iblockpropertyenum.php:217
Определения iblockresult.php:3
SetIBlockTag($iblock_id)
Определения iblockresult.php:65
$arSectionContext
Определения iblockresult.php:20
$arIBlockMultProps
Определения iblockresult.php:5
SetSectionContext($arSection)
Определения iblockresult.php:39
GetNavPrint($title, $show_allways=true, $StyleText="", $template_path=false, $arDeleteParam=false)
Определения iblockresult.php:509
$bIBlockSection
Определения iblockresult.php:21
$_LAST_IBLOCK_ID
Определения iblockresult.php:24
SetUrlTemplates($DetailUrl="", $SectionUrl="", $ListUrl="")
Определения iblockresult.php:32
$nInitialSize
Определения iblockresult.php:15
$nameTemplate
Определения iblockresult.php:22
$strListUrl
Определения iblockresult.php:19
$arIBlockLongProps
Определения iblockresult.php:13
$strSectionUrl
Определения iblockresult.php:18
Fetch()
Определения iblockresult.php:85
$_FILTER_IBLOCK_ID
Определения iblockresult.php:25
SetNameTemplate($nameTemplate)
Определения iblockresult.php:80
$table_id
Определения iblockresult.php:16
$arIBlockConvProps
Определения iblockresult.php:7
GetNext($bTextHtmlAuto=true, $use_tilda=true)
Определения iblockresult.php:287
NavStart($nPageSize=20, $bShowAll=true, $iNumPage=false)
Определения iblockresult.php:486
__construct($res=null)
Определения iblockresult.php:27
$arIBlockNumProps
Определения iblockresult.php:11
$strDetailUrl
Определения iblockresult.php:17
GetNextElement($bTextHtmlAuto=true, $use_tilda=true)
Определения iblockresult.php:469
$arIBlockAllProps
Определения iblockresult.php:9
SetTableID($table_id)
Определения iblockresult.php:481
if(!is_array($prop["VALUES"])) $tmp
Определения component_props.php:203
$arFields
Определения dblapprove.php:5
</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
$_REQUEST["admin_mnu_menu_id"]
Определения get_menu.php:8
$_SERVER["DOCUMENT_ROOT"]
Определения cron_frame.php:9
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
Определения options.php:195
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
Определения tools.php:2701
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
$ar
Определения options.php:199
if(empty($signedUserToken)) $key
Определения quickway.php:257
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936
else $a
Определения template.php:137
$title
Определения pdf.php:123
$val
Определения options.php:1793
$rs
Определения action.php:82
$k
Определения template_pdf.php:567