Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
request.php
1<?php
2
3namespace Bitrix\Main;
4
9abstract class Request extends Type\ParameterDictionary
10{
14 protected $server;
15 protected $requestedPage = null;
16 protected $requestedPageDirectory = null;
17
18 public function __construct(Server $server, array $request)
19 {
20 parent::__construct($request);
21
22 $this->server = $server;
23 }
24
25 public function addFilter(Type\IRequestFilter $filter)
26 {
27 $filteredValues = $filter->filter($this->values);
28
29 if ($filteredValues != null)
30 {
31 $this->setValuesNoDemand($filteredValues);
32 }
33 }
34
38 public function getServer()
39 {
40 return $this->server;
41 }
42
43 public function getPhpSelf()
44 {
45 return $this->server->getPhpSelf();
46 }
47
48 public function getScriptName()
49 {
50 return $this->server->getScriptName();
51 }
52
53 public function getRequestedPage()
54 {
55 if ($this->requestedPage === null)
56 {
57 $page = $this->getScriptName();
58 if (!empty($page))
59 {
60 $page = IO\Path::normalize($page);
61
62 if (mb_substr($page, 0, 1) !== "/" && !preg_match("#^[a-z]:[/\\\\]#i", $page))
63 {
64 $page = "/" . $page;
65 }
66 }
67 $this->requestedPage = $page;
68 }
69
71 }
72
77 public function getRequestedPageDirectory()
78 {
79 if ($this->requestedPageDirectory === null)
80 {
82 $this->requestedPageDirectory = IO\Path::getDirectory($requestedPage) . '/';
83 }
85 }
86
87 public function isAdminSection()
88 {
89 $requestedDir = $this->getRequestedPageDirectory();
90 return (str_starts_with($requestedDir, "/bitrix/admin/")
91 || str_starts_with($requestedDir, "/bitrix/updates/")
92 || (defined("ADMIN_SECTION") && ADMIN_SECTION === true)
93 || (defined("BX_PUBLIC_TOOLS") && BX_PUBLIC_TOOLS === true)
94 );
95 }
96
101 public function isAjaxRequest()
102 {
103 return
104 $this->server->get("HTTP_BX_AJAX") !== null ||
105 $this->server->get("HTTP_X_REQUESTED_WITH") === "XMLHttpRequest";
106 }
107}
__construct(Server $server, array $request)
Definition request.php:18
addFilter(Type\IRequestFilter $filter)
Definition request.php:25