1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
httpcontext.php
См. документацию.
1<?php
2
3namespace Bitrix\Main;
4
9class HttpContext extends Context
10{
11 public const CACHE_TTL = 86400;
12
19 {
20 parent::__construct($application);
21 }
22
23 public function rewriteUri($url, $queryString, $redirectStatus = null)
24 {
26 $request->modifyByQueryString($queryString);
27
28 $this->server->rewriteUri($url, $queryString, $redirectStatus);
29 }
30
31 public function transferUri($url, $queryString)
32 {
34 $request->modifyByQueryString($queryString);
35
36 $this->server->transferUri($url, $queryString);
37 }
38
45 public function initializeCulture($definedSite = null, $definedLanguage = null): void
46 {
47 $request = $this->getRequest();
48
49 $language = null;
50 $culture = null;
51 $site = null;
52
53 if ($definedSite === null && $request->isAdminSection())
54 {
55 $lang = $request->get('lang');
56 if ($lang == '')
57 {
58 $lang = Config\Option::get('main', 'admin_lid', 'ru');
59 }
60
61 if ($lang != '')
62 {
64 'filter' => ['=LID' => $lang, '=ACTIVE' => 'Y'],
65 'cache' => ['ttl' => static::CACHE_TTL],
66 ])->fetchObject();
67 }
68
69 if (!$language)
70 {
71 // no language found - get default
73 'filter' => ['=ACTIVE' => 'Y'],
74 'order' => ['DEF' => 'DESC'],
75 'cache' => ['ttl' => static::CACHE_TTL],
76 ])->fetchObject();
77 }
78
79 if ($language)
80 {
81 $culture = Localization\CultureTable::getByPrimary($language->getCultureId(), ['cache' => ['ttl' => static::CACHE_TTL]])->fetchObject();
82 }
83 }
84 else
85 {
86 if ($definedSite !== null)
87 {
88 $site = SiteTable::getByPrimary($definedSite, ['cache' => ['ttl' => static::CACHE_TTL]])->fetch();
89 if (!$site)
90 {
91 throw new SystemException('Incorrect site: ' . $definedSite . '.');
92 }
93 }
94 else
95 {
96 // get the site by domain or path
97 $site = SiteTable::getByDomain($request->getHttpHost(), $request->getRequestedPageDirectory());
98 }
99
100 if ($site)
101 {
102 $languageId = $definedLanguage ?? $site['LANGUAGE_ID'];
103 $language = Localization\LanguageTable::getByPrimary($languageId, ['cache' => ['ttl' => static::CACHE_TTL]])->fetchObject();
104
105 $culture = Localization\CultureTable::getByPrimary($site['CULTURE_ID'], ['cache' => ['ttl' => static::CACHE_TTL]])->fetchObject();
106 }
107 }
108
109 if ($culture === null || $language === null)
110 {
111 throw new SystemException("Culture not found, or there are no active sites or languages.");
112 }
113
114 $this->setLanguage($language);
115 $this->setCulture($culture);
116
117 if ($site)
118 {
120 }
121 }
122}
$application
Определения context.php:18
$language
Определения context.php:30
setLanguage($language)
Определения context.php:199
$site
Определения context.php:33
$request
Определения context.php:24
getRequest()
Определения context.php:106
$culture
Определения context.php:39
setCulture(Context\Culture $culture)
Определения context.php:187
setSite($site)
Определения context.php:219
rewriteUri($url, $queryString, $redirectStatus=null)
Определения httpcontext.php:23
transferUri($url, $queryString)
Определения httpcontext.php:31
initializeCulture($definedSite=null, $definedLanguage=null)
Определения httpcontext.php:45
__construct(HttpApplication $application)
Определения httpcontext.php:18
const CACHE_TTL
Определения httpcontext.php:11
static wakeUpObject($row)
Определения datamanager.php:256
static getList(array $parameters=array())
Определения datamanager.php:431
static getByPrimary($primary, array $parameters=array())
Определения datamanager.php:330
static getByDomain(string $host, string $directory)
Определения site.php:140
if(!defined('SITE_ID')) $lang
Определения include.php:91
Определения culture.php:9
$url
Определения iframe.php:7