Файловый менеджер - Редактировать - /var/www/axolotl/data/www/axolotls.ru/www/bitrix/modules/aspro.next/classes/general/_CNextRegionality.php.back1.0.1
Назад
<? if(!defined('ASPRO_NEXT_MODULE_ID')) define('ASPRO_NEXT_MODULE_ID', 'aspro.next'); use \Bitrix\Main\Localization\Loc; Loc::loadMessages(__FILE__); if(!class_exists('CNextRegionality')) { class CNextRegionality{ public static $arSeoMarks = array( '#REGION_NAME#' => 'NAME', '#REGION_NAME_DECLINE_RP#' => 'PROPERTY_REGION_NAME_DECLINE_RP_VALUE', '#REGION_NAME_DECLINE_PP#' => 'PROPERTY_REGION_NAME_DECLINE_PP_VALUE', '#REGION_NAME_DECLINE_TP#' => 'PROPERTY_REGION_NAME_DECLINE_TP_VALUE', ); public static function checkUseRegionality(){ if(\Bitrix\Main\Loader::includeModule(ASPRO_NEXT_MODULE_ID) && isset($_SERVER['HTTP_COOKIE'])) return CNext::GetFrontParametrValue('USE_REGIONALITY'); return 'N'; } public static function getRegionIBlockID(){ static $iRegionIBlockID; if($iRegionIBlockID === NULL) { if(isset(CNextCache::$arIBlocks[SITE_ID]['aspro_next_regionality']['aspro_next_regions'][0]) && CNextCache::$arIBlocks[SITE_ID]['aspro_next_regionality']['aspro_next_regions'][0]) { $iRegionIBlockID = CNextCache::$arIBlocks[SITE_ID]['aspro_next_regionality']['aspro_next_regions'][0]; } else { return; } } return $iRegionIBlockID; } public static function addSeoMarks($arMarks = array()){ self::$arSeoMarks = array_merge(self::$arSeoMarks, $arMarks); } public static function replaceSeoMarks(){ global $APPLICATION, $arSite, $arRegion; $page_title = $APPLICATION->GetTitle(); $page_seo_title = ((strlen($APPLICATION->GetPageProperty('title')) > 1) ? $APPLICATION->GetPageProperty('title') : $page_title); if($arRegion && $page_title) { foreach(CNextRegionality::$arSeoMarks as $mark => $field) { if(strpos($page_title, $mark) !== false) $page_title = str_replace($mark, $arRegion[$field], $page_title); if(strpos($page_seo_title, $mark) !== false) $page_seo_title = str_replace($mark, $arRegion[$field], $page_seo_title); } if(!CNext::IsMainPage()) { $bShowSiteName = (\Bitrix\Main\Config\Option::get(ASPRO_NEXT_MODULE_ID, "HIDE_SITE_NAME_TITLE", "N") == "N"); $sPostfix = ($bShowSiteName ? ' - '.$arSite['SITE_NAME'] : ''); $APPLICATION->SetPageProperty("title", $page_seo_title.$sPostfix); $APPLICATION->SetTitle($page_title); } else { if(!empty($page_seo_title)) $APPLICATION->SetPageProperty("title", $page_seo_title); else $APPLICATION->SetPageProperty("title", $arSite['SITE_NAME']); if(!empty($page_title)) $APPLICATION->SetTitle($title); else $APPLICATION->SetTitle($arSite['SITE_NAME']); } } return true; } public static function getRegions(){ static $arRegions; if($arRegions === NULL) { $arRegions = array(); if($iRegionIBlockID = self::getRegionIBlockID()) { if(self::checkUseRegionality() == 'N') return false; $cache = new CPHPCache(); $cache_time = 86400; $cache_path = __CLASS__.'/'.__FUNCTION__; $cache_id = 'aspro_next_regions'.$iRegionIBlockID; if(\Bitrix\Main\Config\Option::get('main', 'component_cache_on', 'Y') == 'Y' && $cache->InitCache($cache_time, $cache_id, $cache_path)) { $res = $cache->GetVars(); $arRegions = $res['arRegions']; } else { // get all items $arFilter = array('ACTIVE' => 'Y', 'IBLOCK_ID' => $iRegionIBlockID); $arItems = CNextCache::CIBLockElement_GetList(array('SORT' => 'ASC', 'NAME' => 'ASC', 'CACHE' => array('TAG' => CNextCache::GetIBlockCacheTag($iRegionIBlockID), 'GROUP' => 'ID')), $arFilter, false, false, array('ID', 'NAME', 'IBLOCK_ID', 'IBLOCK_SECTION_ID', 'DETAIL_TEXT', 'PROPERTY_DEFAULT', 'PROPERTY_DOMAINS', 'PROPERTY_MAIN_DOMAIN', 'PROPERTY_FAVORIT_LOCATION', 'PROPERTY_PHONES', 'PROPERTY_PRICES_LINK', 'PROPERTY_LOCATION_LINK', 'PROPERTY_STORES_LINK', 'PROPERTY_REGION_NAME_DECLINE_RP', 'PROPERTY_REGION_NAME_DECLINE_PP', 'PROPERTY_REGION_NAME_DECLINE_TP')); foreach(GetModuleEvents(ASPRO_NEXT_MODULE_ID, 'OnAsproRegionalityGetElements', true) as $arEvent) // event for manipulation with region elements ExecuteModuleEventEx($arEvent, array(&$arItems)); if($arItems && \Bitrix\Main\Loader::includeModule('catalog')) { foreach($arItems as $key => $arItem) { if(!$arItem['PROPERTY_MAIN_DOMAIN'] && $arItem['PROPERTY_DEFAULT_VALUE'] == 'Y') $arItems[$key]['PROPERTY_MAIN_DOMAIN'] = $_SERVER['HTTP_HOST']; //domains props if(!is_array($arItem['PROPERTY_DOMAINS_VALUE'])) $arItem['PROPERTY_DOMAINS_VALUE'] = (array)$arItem['PROPERTY_DOMAINS_VALUE']; $arItems[$key]['LIST_DOMAINS'] = array_merge((array)$arItem['PROPERTY_MAIN_DOMAIN_VALUE'], $arItem['PROPERTY_DOMAINS_VALUE']); unset($arItems[$key]['PROPERTY_DOMAINS_VALUE']); unset($arItems[$key]['PROPERTY_DOMAINS_VALUE_ID']); //stores props if(!is_array($arItem['PROPERTY_STORES_LINK_VALUE'])) $arItem['PROPERTY_STORES_LINK_VALUE'] = (array)$arItem['PROPERTY_STORES_LINK_VALUE']; $arItems[$key]['LIST_STORES'] = $arItem['PROPERTY_STORES_LINK_VALUE']; unset($arItems[$key]['PROPERTY_STORES_LINK_VALUE']); unset($arItems[$key]['PROPERTY_STORES_LINK_VALUE_ID']); //location props $arItems[$key]['LOCATION'] = $arItem['PROPERTY_LOCATION_LINK_VALUE']; unset($arItems[$key]['PROPERTY_LOCATION_LINK_VALUE']); unset($arItems[$key]['PROPERTY_LOCATION_LINK_VALUE_ID']); //prices props if(!is_array($arItem['PROPERTY_PRICES_LINK_VALUE'])) $arItem['PROPERTY_PRICES_LINK_VALUE'] = (array)$arItem['PROPERTY_PRICES_LINK_VALUE']; if($arItem['PROPERTY_PRICES_LINK_VALUE']) { if(reset($arItem['PROPERTY_PRICES_LINK_VALUE']) != 'component') { $dbPriceType = CCatalogGroup::GetList(array('SORT' => 'ASC'),array('ID' => $arItem['PROPERTY_PRICES_LINK_VALUE']), false, false, array('ID', 'NAME', 'CAN_BUY')); while($arPriceType = $dbPriceType->Fetch()) { $arItems[$key]['LIST_PRICES'][$arPriceType['NAME']] = $arPriceType; } } else $arItems[$key]['LIST_PRICES'] = $arItem['PROPERTY_PRICES_LINK_VALUE']; } else { $arItems[$key]['LIST_PRICES'] = array(); } unset($arItems[$key]['PROPERTY_PRICES_LINK_VALUE']); unset($arItems[$key]['PROPERTY_PRICES_LINK_VALUE_ID']); //phones props if(!is_array($arItem['PROPERTY_PHONES_VALUE'])) $arItem['PROPERTY_PHONES_VALUE'] = (array)$arItem['PROPERTY_PHONES_VALUE']; $arItems[$key]['PHONES'] = $arItem['PROPERTY_PHONES_VALUE']; unset($arItems[$key]['PROPERTY_PHONES_VALUE']); unset($arItems[$key]['PROPERTY_PHONES_VALUE_ID']); } $arRegions = $arItems; $cache->StartDataCache($cache_time, $cache_id, $cache_path); global $CACHE_MANAGER; $CACHE_MANAGER->StartTagCache($cache_path); $CACHE_MANAGER->RegisterTag($cache_id); $CACHE_MANAGER->EndTagCache(); $cache->EndDataCache( array( "arRegions" => $arRegions ) ); } } } } return $arRegions; } public static function getCurrentRegion(){ static $arRegion; if($arRegion === NULL) { $arRegions = self::getRegions(); $bFindDomain = false; if($arRegions){ global $arTheme; if(!$arTheme) $arTheme = CNext::GetFrontParametrsValues(SITE_ID); if($arTheme['REGIONALITY_TYPE'] == 'ONE_DOMAIN') { if(isset($_COOKIE['current_region']) && $_COOKIE['current_region']) { if($arRegions[$_COOKIE['current_region']]) { $arRegion = $arRegions[$_COOKIE['current_region']]; $bFindDomain = true; return $arRegion; } } } else { if(!isset($_COOKIE['current_region']) || !$_COOKIE['current_region']) { if(\Bitrix\Main\Loader::includeModule('altasib.geoip')) { $arData = ALX_GeoIP::GetAddr(); if(isset($arData['city']) && $arData['city']) { foreach($arRegions as $key => $arItem) { if($arData['city'] == $arItem['NAME']) { $arRegion = $arItem; $bFindDomain = true; return $arRegion; } } } } } foreach($arRegions as $arItem) { if(in_array($_SERVER['HTTP_HOST'], $arItem['LIST_DOMAINS'])) { $arRegion = $arItem; $bFindDomain = true; return $arRegion; } } } if(!$bFindDomain) { foreach($arRegions as $arItem) { if($arItem['PROPERTY_DEFAULT_VALUE'] == 'Y') { $arRegion = $arItem; $bFindDomain = true; return $arRegion; } } } if(!$bFindDomain) { if(\Bitrix\Main\Loader::includeModule('altasib.geoip')) { $arData = ALX_GeoIP::GetAddr(); if(isset($arData['city']) && $arData['city']) { foreach($arRegions as $key => $arItem) { if($arData['city'] == $arItem['NAME']) { $arRegion = $arItem; $bFindDomain = true; return $arRegion; } } } } $arRegion = reset($arRegions); } } else return false; } return $arRegion; } } }
| ver. 1.4 |
Github
|
.
| PHP 7.4.8 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка