Example #1
0
 public static function resolveComponentEngine(CComponentEngine $engine, $pageCandidates, &$arVariables)
 {
     /** @global CMain $APPLICATION */
     global $APPLICATION, $CACHE_MANAGER;
     $component = $engine->GetComponent();
     if ($component) {
         $iblock_id = intval($component->arParams["IBLOCK_ID"]);
     } else {
         $iblock_id = 0;
     }
     $requestURL = $APPLICATION->GetCurPage(true);
     $cacheId = $requestURL . implode("|", array_keys($pageCandidates));
     $cache = new CPHPCache();
     if ($cache->startDataCache(3600, $cacheId, "iblock_find")) {
         if (defined("BX_COMP_MANAGED_CACHE")) {
             $CACHE_MANAGER->StartTagCache("iblock_find");
             CIBlock::registerWithTagCache($iblock_id);
         }
         foreach ($pageCandidates as $pageID => $arVariablesTmp) {
             if ($arVariablesTmp["SECTION_CODE_PATH"] != "" && (isset($arVariablesTmp["ELEMENT_ID"]) || isset($arVariablesTmp["ELEMENT_CODE"]))) {
                 if (CIBlockFindTools::checkElement($iblock_id, $arVariablesTmp)) {
                     $arVariables = $arVariablesTmp;
                     if (defined("BX_COMP_MANAGED_CACHE")) {
                         $CACHE_MANAGER->EndTagCache();
                     }
                     $cache->endDataCache(array($pageID, $arVariablesTmp));
                     return $pageID;
                 }
             }
         }
         foreach ($pageCandidates as $pageID => $arVariablesTmp) {
             if ($arVariablesTmp["SECTION_CODE_PATH"] != "" && (!isset($arVariablesTmp["ELEMENT_ID"]) && !isset($arVariablesTmp["ELEMENT_CODE"]))) {
                 if (CIBlockFindTools::checkSection($iblock_id, $arVariablesTmp)) {
                     $arVariables = $arVariablesTmp;
                     if (defined("BX_COMP_MANAGED_CACHE")) {
                         $CACHE_MANAGER->EndTagCache();
                     }
                     $cache->endDataCache(array($pageID, $arVariablesTmp));
                     return $pageID;
                 }
             }
         }
         if (defined("BX_COMP_MANAGED_CACHE")) {
             $CACHE_MANAGER->AbortTagCache();
         }
         $cache->abortDataCache();
     } else {
         $vars = $cache->getVars();
         $pageID = $vars[0];
         $arVariables = $vars[1];
         return $pageID;
     }
     list($pageID, $arVariables) = each($pageCandidates);
     return $pageID;
 }
Example #2
0
 public static function resolveComponentEngine(CComponentEngine $engine, $pageCandidates, &$arVariables)
 {
     /** @global CMain $APPLICATION */
     global $APPLICATION, $CACHE_MANAGER;
     static $aSearch = array("<", ">", """, "'");
     static $aReplace = array("<", ">", "\"", "'");
     $component = $engine->GetComponent();
     if ($component) {
         $iblock_id = intval($component->arParams["IBLOCK_ID"]);
     } else {
         $iblock_id = 0;
     }
     //To fix GetPagePath security hack for SMART_FILTER_PATH
     foreach ($pageCandidates as $pageID => $arVariablesTmp) {
         foreach ($arVariablesTmp as $variableName => $variableValue) {
             if ($variableName === "SMART_FILTER_PATH") {
                 $pageCandidates[$pageID][$variableName] = str_replace($aSearch, $aReplace, $variableValue);
             }
         }
     }
     $requestURL = $APPLICATION->GetCurPage(true);
     $cacheId = $requestURL . implode("|", array_keys($pageCandidates)) . "|" . SITE_ID;
     $cache = new CPHPCache();
     if ($cache->startDataCache(3600, $cacheId, "iblock_find")) {
         if (defined("BX_COMP_MANAGED_CACHE")) {
             $CACHE_MANAGER->StartTagCache("iblock_find");
             CIBlock::registerWithTagCache($iblock_id);
         }
         foreach ($pageCandidates as $pageID => $arVariablesTmp) {
             if ($arVariablesTmp["SECTION_CODE_PATH"] != "" && (isset($arVariablesTmp["ELEMENT_ID"]) || isset($arVariablesTmp["ELEMENT_CODE"]))) {
                 if (CIBlockFindTools::checkElement($iblock_id, $arVariablesTmp)) {
                     $arVariables = $arVariablesTmp;
                     if (defined("BX_COMP_MANAGED_CACHE")) {
                         $CACHE_MANAGER->EndTagCache();
                     }
                     $cache->endDataCache(array($pageID, $arVariablesTmp));
                     return $pageID;
                 }
             }
         }
         foreach ($pageCandidates as $pageID => $arVariablesTmp) {
             if ($arVariablesTmp["SECTION_CODE_PATH"] != "" && (!isset($arVariablesTmp["ELEMENT_ID"]) && !isset($arVariablesTmp["ELEMENT_CODE"]))) {
                 if (CIBlockFindTools::checkSection($iblock_id, $arVariablesTmp)) {
                     $arVariables = $arVariablesTmp;
                     if (defined("BX_COMP_MANAGED_CACHE")) {
                         $CACHE_MANAGER->EndTagCache();
                     }
                     $cache->endDataCache(array($pageID, $arVariablesTmp));
                     return $pageID;
                 }
             }
         }
         if (defined("BX_COMP_MANAGED_CACHE")) {
             $CACHE_MANAGER->AbortTagCache();
         }
         $cache->abortDataCache();
     } else {
         $vars = $cache->getVars();
         $pageID = $vars[0];
         $arVariables = $vars[1];
         return $pageID;
     }
     reset($pageCandidates);
     list($pageID, $arVariables) = each($pageCandidates);
     return $pageID;
 }