Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
automaticarea.php
1
<?
2
namespace
Bitrix\Main\Composite\Internals
;
3
4
use
Bitrix\Main\Composite
;
5
use
Bitrix\Main\Composite\Helper
;
6
use
Bitrix\Main\Composite\StaticArea
;
7
8
class
AutomaticArea
9
{
11
private
$component =
null
;
12
private
$started =
false
;
13
15
private
static
$currentArea =
null
;
16
17
public
function
__construct
($component)
18
{
19
$this->component = $component;
20
}
21
22
public
function
start
()
23
{
24
if
(!Composite\
Engine::getUseHTMLCache
() || !$this->isFirstLevelComponent())
25
{
26
return
false
;
27
}
28
29
if
(
StaticArea::getCurrentDynamicId
() !==
false
)
30
{
31
return
false
;
32
}
33
34
if
($this->component->getDefaultFrameMode() ===
false
|| $this->getFrameType() ===
"STATIC"
)
35
{
36
return
false
;
37
}
38
39
if
(in_array($this->component->getName(), array(
"bitrix:breadcrumb"
,
"bitrix:main.include"
)))
40
{
41
return
false
;
42
}
43
44
if
($this->component->getName() ===
"bitrix:menu"
&&
45
isset($this->component->arParams[
"DELAY"
]) &&
46
$this->component->arParams[
"DELAY"
] ===
"Y"
47
)
48
{
49
return
false
;
50
}
51
52
$this->started =
true
;
53
static::$currentArea = $this;
54
55
ob_start();
56
57
return
true
;
58
}
59
60
public
function
end
()
61
{
62
if
(!$this->started)
63
{
64
return
false
;
65
}
66
67
$isComponentAdapted =
68
$this->component->getRealFrameMode() !==
null
||
69
($this->component->__template !==
null
&& $this->component->__template->getRealFrameMode() !==
null
);
70
71
if
($isComponentAdapted)
72
{
73
ob_end_flush();
74
}
75
else
76
{
77
$stub = ob_get_contents();
78
ob_end_clean();
79
80
$frame =
new
StaticArea
($this->component->randString());
81
82
if
($this->
getFrameType
() ===
"DYNAMIC_WITH_STUB"
)
83
{
84
$frame->setStub($stub);
85
}
86
elseif ($this->
getFrameType
() ===
"DYNAMIC_WITH_STUB_LOADING"
)
87
{
88
$frame->setStub(
'<div class="bx-composite-loading"></div>'
);
89
}
90
91
$frame->startDynamicArea();
92
echo $stub;
93
$frame->finishDynamicArea();
94
}
95
96
$this->started =
false
;
97
static::$currentArea =
null
;
98
99
return
true
;
100
}
101
102
public
function
getFrameType
()
103
{
104
$componentParams = $this->component->arParams;
105
if
(isset($componentParams[
"COMPOSITE_FRAME_TYPE"
]) && is_string($componentParams[
"COMPOSITE_FRAME_TYPE"
]))
106
{
107
$type = mb_strtoupper($componentParams[
"COMPOSITE_FRAME_TYPE"
]);
108
if
(in_array($type, static::getFrameTypes()))
109
{
110
return
$type;
111
}
112
}
113
114
$compositeOptions =
Helper::getOptions
();
115
if
(isset($compositeOptions[
"FRAME_TYPE"
]) && is_string($compositeOptions[
"FRAME_TYPE"
]))
116
{
117
$type = mb_strtoupper($compositeOptions[
"FRAME_TYPE"
]);
118
if
(in_array($type, static::getFrameTypes()))
119
{
120
return
$type;
121
}
122
}
123
124
return
"STATIC"
;
125
}
126
127
public
static
function
getFrameTypes
()
128
{
129
return
array(
130
"STATIC"
,
131
"DYNAMIC_WITH_STUB"
,
132
"DYNAMIC_WITH_STUB_LOADING"
,
133
"DYNAMIC_WITHOUT_STUB"
,
134
);
135
}
136
140
public
static
function
getCurrentArea
()
141
{
142
return
static::$currentArea;
143
}
144
145
private
function
isFirstLevelComponent()
146
{
147
return
count(
$GLOBALS
[
"APPLICATION"
]->getComponentStack()) <= 1;
148
}
149
}
Bitrix\Main\Composite\Engine\getUseHTMLCache
static getUseHTMLCache()
Definition
engine.php:183
Bitrix\Main\Composite\Helper
Definition
helper.php:13
Bitrix\Main\Composite\Helper\getOptions
static getOptions()
Definition
helper.php:504
Bitrix\Main\Composite\Internals\AutomaticArea
Definition
automaticarea.php:9
Bitrix\Main\Composite\Internals\AutomaticArea\getFrameTypes
static getFrameTypes()
Definition
automaticarea.php:127
Bitrix\Main\Composite\Internals\AutomaticArea\end
end()
Definition
automaticarea.php:60
Bitrix\Main\Composite\Internals\AutomaticArea\getCurrentArea
static getCurrentArea()
Definition
automaticarea.php:140
Bitrix\Main\Composite\Internals\AutomaticArea\getFrameType
getFrameType()
Definition
automaticarea.php:102
Bitrix\Main\Composite\Internals\AutomaticArea\__construct
__construct($component)
Definition
automaticarea.php:17
Bitrix\Main\Composite\Internals\AutomaticArea\start
start()
Definition
automaticarea.php:22
Bitrix\Main\Composite\StaticArea
Definition
staticarea.php:8
Bitrix\Main\Composite\StaticArea\getCurrentDynamicId
static getCurrentDynamicId()
Definition
staticarea.php:109
Bitrix\Main\Composite\Internals
Definition
automaticarea.php:2
Bitrix\Main\Composite
Definition
appcache.php:2
Bitrix\Main\$GLOBALS
$GLOBALS['____1444769544']
Definition
license.php:1
modules
main
lib
composite
internals
automaticarea.php
Создано системой
1.10.0