7 $element_id = (int)$element_id;
8 $element_code = (string)$element_code;
13 elseif ($element_code !=
'')
19 $section_id = (int)$section_id;
20 $section_code = (string)$section_code;
23 elseif ($section_code !=
'')
24 $arFilter[
"SECTION_CODE"] = $section_code;
27 if ($arElement = $rsElement->Fetch())
28 return (
int)$arElement[
"ID"];
35 $section_id = (int)$section_id;
36 $section_code = (string)$section_code;
41 elseif ($section_code !=
'')
48 if ($arSection = $rsSection->Fetch())
49 return (
int)$arSection[
"ID"];
70 static $aSearch =
array(
"<",
">",
""",
"'");
71 static $aReplace =
array(
"<",
">",
"\"",
"'");
73 $component =
$engine->getComponent();
76 $iblock_id = (int)$component->arParams[
"IBLOCK_ID"];
77 $strict_check = ($component->arParams[
"DETAIL_STRICT_SECTION_CHECK"] ??
'') ===
"Y";
82 $strict_check =
false;
86 foreach ($pageCandidates as $pageID => $arVariablesTmp)
88 foreach ($arVariablesTmp as $variableName => $variableValue)
90 if ($variableName ===
"SMART_FILTER_PATH")
91 $pageCandidates[$pageID][$variableName] = str_replace($aSearch, $aReplace, $variableValue);
97 $cacheId = $requestURL.implode(
"|", array_keys($pageCandidates)).
"|".
SITE_ID.
"|".$iblock_id.$engine->cacheSalt;
98 $cache =
new CPHPCache;
99 if ($cache->StartDataCache(3600, $cacheId,
"iblock_find"))
101 if (defined(
"BX_COMP_MANAGED_CACHE"))
104 CIBlock::registerWithTagCache($iblock_id);
107 foreach ($pageCandidates as $pageID => $arVariablesTmp)
110 (isset($arVariablesTmp[
"SECTION_CODE_PATH"]) && $arVariablesTmp[
"SECTION_CODE_PATH"] !==
"")
111 && (isset($arVariablesTmp[
"ELEMENT_ID"]) || isset($arVariablesTmp[
"ELEMENT_CODE"]))
116 $arVariables = $arVariablesTmp;
117 if (defined(
"BX_COMP_MANAGED_CACHE"))
119 $cache->EndDataCache(
array($pageID, $arVariablesTmp));
125 foreach ($pageCandidates as $pageID => $arVariablesTmp)
128 (isset($arVariablesTmp[
"SECTION_CODE_PATH"]) && $arVariablesTmp[
"SECTION_CODE_PATH"] !==
"")
129 && (!isset($arVariablesTmp[
"ELEMENT_ID"]) && !isset($arVariablesTmp[
"ELEMENT_CODE"]))
134 $arVariables = $arVariablesTmp;
135 if (defined(
"BX_COMP_MANAGED_CACHE"))
137 $cache->EndDataCache(
array($pageID, $arVariablesTmp));
143 if (defined(
"BX_COMP_MANAGED_CACHE"))
145 $cache->AbortDataCache();
149 $vars = $cache->GetVars();
151 $arVariables = $vars[1];
156 reset($pageCandidates);
157 $pageID = key($pageCandidates);
158 $arVariables = $pageCandidates[$pageID];
163 public static function checkElement($iblock_id, &$arVariables, $strict_check =
false)
173 $elementId = $arVariables[
"ELEMENT_ID"] ??
'';
174 $elementCode = $arVariables[
"ELEMENT_CODE"] ??
'';
176 " . ($elementId !=
"" ?
"AND BE.ID = " . (int)$elementId :
"") .
"
177 " . ($elementCode !=
"" ?
"AND BE.CODE = '" .
$DB->ForSql($elementCode) .
"'" :
"") .
"
181 isset($arVariables[
"SECTION_CODE_PATH"])
182 && is_string($arVariables[
"SECTION_CODE_PATH"])
183 && $arVariables[
"SECTION_CODE_PATH"] !=
""
186 $select .=
", BS.ID as SECTION_ID, BS.CODE as SECTION_CODE";
189 INNER JOIN b_iblock_section_element BSE ON BSE.IBLOCK_ELEMENT_ID = BE.ID AND BSE.ADDITIONAL_PROPERTY_ID IS NULL
190 INNER JOIN b_iblock_section BS ON BS.ID = BSE.IBLOCK_SECTION_ID
191 INNER JOIN b_iblock_section BSP ON BS.IBLOCK_ID = BSP.IBLOCK_ID AND BS.LEFT_MARGIN >= BSP.LEFT_MARGIN AND BS.RIGHT_MARGIN <= BSP.RIGHT_MARGIN
193 $joinField =
"BSP.ID";
195 $sectionPath = explode(
"/", $arVariables[
"SECTION_CODE_PATH"]);
197 if (
count($sectionPath) > 58)
203 foreach (array_reverse($sectionPath) as
$i => $SECTION_CODE)
206 INNER JOIN b_iblock_section BS".$i.
" ON BS".
$i.
".ID = ".$joinField.
"
208 $joinField =
"BS".$i.
".IBLOCK_SECTION_ID";
210 AND BS".$i.
".CODE = '".
$DB->ForSql($SECTION_CODE).
"'
217 AND BS".$i.
".IBLOCK_SECTION_ID is null
225 WHERE BE.IBLOCK_ID = ".$iblock_id.
"
228 $rs =
$DB->Query($strSql);
233 if (isset($sectionPath) && is_array($sectionPath))
235 $arVariables[
"SECTION_CODE"] = $sectionPath[
count($sectionPath) - 1];
236 if (isset($r[
'SECTION_ID']) && isset($r[
'SECTION_CODE']))
238 if ($arVariables[
"SECTION_CODE"] === $r[
'SECTION_CODE'])
240 $arVariables[
"SECTION_ID"] = $r[
'SECTION_ID'];
241 $arVariables[
"ELEMENT_ID"] = $r[
'ID'];