Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
htmlcontent.php
1
<?php
2
namespace
Bitrix\Main\Engine\Response
;
3
4
use
Bitrix\Main\Engine\Response\ContentArea\DataSectionInterface
;
5
use
Bitrix\Main\ErrorCollection
;
6
use Bitrix\Main\Page\Asset;
7
use
Bitrix\Main\Page\AssetMode
;
8
use
Bitrix\Main\Engine\Response\ContentArea\ContentAreaInterface
;
9
13
class
HtmlContent
extends
AjaxJson
14
{
15
private
$jsPathList = [];
16
private
$cssPathList = [];
17
24
public
function
__construct
(
ContentAreaInterface
$content
, $status = self::STATUS_SUCCESS,
ErrorCollection
$errorCollection =
null
, array $additionalResponseParams = [])
25
{
26
$html =
$content
->getHtml();
27
28
$this->
collectAssetsPathList
();
29
30
$result = [
31
'html'
=> $html,
32
'assets'
=> [
33
'css'
=> $this->
getCssList
(),
34
'js'
=> $this->
getJsList
(),
35
'string'
=> $this->
getStringList
()
36
],
37
'additionalParams'
=> $additionalResponseParams,
38
];
39
if
(
$content
instanceof
DataSectionInterface
)
40
{
41
$result[
$content
->getSectionName()] =
$content
->getSectionData();
42
}
43
44
parent::__construct($result, $status, $errorCollection);
45
46
$this->
addHeader
(
'X-Process-Assets'
,
'assets'
);
47
}
48
49
final
protected
function
collectAssetsPathList
()
50
{
51
Asset::getInstance()->getCss();
52
Asset::getInstance()->getJs();
53
Asset::getInstance()->getStrings();
54
55
$this->jsPathList = Asset::getInstance()->getTargetList(
'JS'
);
56
$this->cssPathList = Asset::getInstance()->getTargetList(
'CSS'
);
57
}
58
62
final
protected
function
getJsList
()
63
{
64
$jsList = [];
65
foreach
($this->jsPathList as $targetAsset)
66
{
67
$assetInfo = Asset::getInstance()->getAssetInfo($targetAsset[
'NAME'
], AssetMode::ALL);
68
if
(!empty($assetInfo[
'JS'
]))
69
{
70
$jsList = array_merge($jsList, $assetInfo[
'JS'
]);
71
}
72
}
73
74
return
$jsList;
75
}
76
80
final
protected
function
getCssList
()
81
{
82
$cssList = [];
83
foreach
($this->cssPathList as $targetAsset)
84
{
85
$assetInfo = Asset::getInstance()->getAssetInfo($targetAsset[
'NAME'
], AssetMode::ALL);
86
if
(!empty($assetInfo[
'CSS'
]))
87
{
88
$cssList = array_merge($cssList, $assetInfo[
'CSS'
]);
89
}
90
}
91
92
return
$cssList;
93
}
94
98
final
protected
function
getStringList
()
99
{
100
$stringList = [];
101
foreach
($this->cssPathList as $targetAsset)
102
{
103
$assetInfo = Asset::getInstance()->getAssetInfo($targetAsset[
'NAME'
], AssetMode::ALL);
104
if
(!empty($assetInfo[
'STRINGS'
]))
105
{
106
$stringList = array_merge($stringList, $assetInfo[
'STRINGS'
]);
107
}
108
}
109
110
foreach
($this->jsPathList as $targetAsset)
111
{
112
$assetInfo = Asset::getInstance()->getAssetInfo($targetAsset[
'NAME'
], AssetMode::ALL);
113
if
(!empty($assetInfo[
'STRINGS'
]))
114
{
115
$stringList = array_merge($stringList, $assetInfo[
'STRINGS'
]);
116
}
117
}
118
119
$stringList[] = Asset::getInstance()->showFilesList();
120
121
return
$stringList;
122
}
123
}
Bitrix\Main\Engine\Response\AjaxJson
Definition
ajaxjson.php:11
Bitrix\Main\Engine\Response\HtmlContent
Definition
htmlcontent.php:14
Bitrix\Main\Engine\Response\HtmlContent\__construct
__construct(ContentAreaInterface $content, $status=self::STATUS_SUCCESS, ErrorCollection $errorCollection=null, array $additionalResponseParams=[])
Definition
htmlcontent.php:24
Bitrix\Main\Engine\Response\HtmlContent\getStringList
getStringList()
Definition
htmlcontent.php:98
Bitrix\Main\Engine\Response\HtmlContent\getJsList
getJsList()
Definition
htmlcontent.php:62
Bitrix\Main\Engine\Response\HtmlContent\getCssList
getCssList()
Definition
htmlcontent.php:80
Bitrix\Main\Engine\Response\HtmlContent\collectAssetsPathList
collectAssetsPathList()
Definition
htmlcontent.php:49
Bitrix\Main\ErrorCollection
Definition
errorcollection.php:14
Bitrix\Main\HttpResponse\addHeader
addHeader($name, $value='')
Definition
httpresponse.php:72
Bitrix\Main\Page\AssetMode
Definition
assetmode.php:5
Bitrix\Main\Response\$content
$content
Definition
response.php:7
Bitrix\Main\Engine\Response\ContentArea\ContentAreaInterface
Definition
contentareainterface.php:5
Bitrix\Main\Engine\Response\ContentArea\DataSectionInterface
Definition
datasectioninterface.php:5
Bitrix\Main\Engine\Response
Definition
ajaxjson.php:3
modules
main
lib
engine
response
htmlcontent.php
Создано системой
1.10.0