1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
storechart.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Catalog\Component\Report\StoreChart
;
4
5
use
Bitrix\Main\Error
;
6
use
Bitrix\Main\Errorable
;
7
use
Bitrix\Main\ErrorableImplementation
;
8
use
Bitrix\Main\ErrorCollection
;
9
use
Bitrix\Main\Loader
;
10
use
Bitrix\Main\Localization\Loc
;
11
use
Bitrix\Catalog\Access\AccessController
;
12
use
Bitrix\Catalog\Access\ActionDictionary
;
13
use
Bitrix\Currency\CurrencyManager
;
14
15
abstract
class
StoreChart
extends
\CBitrixComponent
implements
Errorable
16
{
17
use
ErrorableImplementation
;
18
19
abstract
protected
function
getChartId
(): string;
20
abstract
protected
function
getInnerChartData
():
array
;
21
abstract
protected
function
fetchAndBuildStoreColumnData
(
array
$stores):
array
;
22
abstract
protected
function
buildLinkToSliderDetails
(
string
$linkContent): string;
23
abstract
protected
function
initializeAdditionalData
(): void;
24
25
final
public
function
executeComponent
()
26
{
27
$this->errorCollection =
new
ErrorCollection
();
28
29
if
(!Loader::includeModule(
'currency'
))
30
{
31
$this->errorCollection->add([
new
Error
(Loc::getMessage(
'STORE_CHART_REPORT_NO_CURRENCY_ERROR'
))]);
32
}
33
if
(!self::checkDocumentReadRights())
34
{
35
$this->errorCollection->add([
new
Error
(Loc::getMessage(
'STORE_CHART_REPORT_NO_READ_RIGHTS_ERROR'
))]);
36
}
37
38
if
(!$this->
hasErrors
())
39
{
40
$this->
initializeComponent
();
41
}
42
43
$this->arResult[
'ERROR_MESSAGES'
] = array_map(
static
function
(
Error
$error
) {
44
return
$error
->getMessage();
45
}, $this->errorCollection->getValues());
46
47
$this->
includeComponentTemplate
();
48
}
49
50
protected
function
initializeComponent
(): void
51
{
52
$this->
initializeChart
();
53
$this->
initializeAdditionalData
();
54
}
55
56
protected
function
initializeChart
(): void
57
{
58
$innerChartData = $this->
getInnerChartData
();
59
60
$this->arResult[
'chartData'
] = [
61
'chartProps'
=> [
62
'id'
=> $this->
getChartId
(),
63
'detailSliderUrl'
=> $innerChartData[
'isCommonChart'
] ? $innerChartData[
'sliderUrl'
] :
null
,
64
'stores'
=> $this->
fetchAndBuildStoreColumnData
($innerChartData[
'data'
] ?? []),
65
'isPopupEnabled'
=> !$innerChartData[
'isCommonChart'
] || ($innerChartData[
'storesInfo'
][
'storeCount'
] ?? 0) > 0,
66
'label'
=> $this->
formChartLabel
($innerChartData),
67
'isCommonChart'
=> $innerChartData[
'isCommonChart'
],
68
'currency'
=> [
69
'id'
=> $innerChartData[
'currency'
],
70
'symbol'
=> $this->getCurrencySymbol($innerChartData[
'currency'
]),
71
'format'
=> \CCurrencyLang::GetFormatDescription($innerChartData[
'currency'
]),
72
],
73
],
74
];
75
}
76
77
protected
function
formChartLabel
(
array
$chartData): string
78
{
79
if
(!$chartData[
'isCommonChart'
] || $chartData[
'storesInfo'
][
'storeCount'
] <= 0)
80
{
81
return
''
;
82
}
83
84
$storesInfo = $chartData[
'storesInfo'
];
85
$storesList =
htmlspecialcharsbx
($storesInfo[
'cropStoreNamesList'
]);
86
87
$totalLinkContent = Loc::getMessage(
88
'STORE_CHART_REPORT_STORES_TOTAL'
,
89
[
'#TOTAL_NUMBER#'
=> $storesInfo[
'storeCount'
]]
90
);
91
92
$totalLink = $totalLinkContent;
93
if
(isset($chartData[
'sliderUrl'
]))
94
{
95
$totalLink = $this->
buildLinkToSliderDetails
($totalLinkContent);
96
}
97
98
return
Loc::getMessage(
99
'STORE_CHART_REPORT_STORES_LIST_TEMPLATE'
,
100
[
101
'#STORES_LIST#'
=> $storesList,
102
'#STORES_TOTAL_LINK#'
=> $totalLink,
103
]
104
);
105
}
106
107
108
private
function
getCurrencySymbol(
string
$currency
): string
109
{
110
if
(CurrencyManager::isCurrencyExist(
$currency
))
111
{
112
return
CurrencyManager::getSymbolList()[
$currency
];
113
}
114
115
$this->errorCollection->add([
new
Error
(Loc::getMessage(
116
'STORE_CHART_REPORT_UNDEFINED_CURRENCY_ERROR'
,
117
[
'#CURRENCY#'
=>
htmlspecialcharsbx
(
$currency
)]
118
))]);
119
120
return
''
;
121
}
122
123
private
static
function
checkDocumentReadRights(): bool
124
{
125
return
AccessController::getCurrent()->check(ActionDictionary::ACTION_CATALOG_READ);
126
}
127
}
Bitrix\Catalog\Access\AccessController
Определения
AccessController.php:29
Bitrix\Catalog\Access\ActionDictionary
Определения
ActionDictionary.php:17
Bitrix\Catalog\Component\Report\StoreChart\StoreChart
Определения
storechart.php:16
Bitrix\Catalog\Component\Report\StoreChart\StoreChart\fetchAndBuildStoreColumnData
fetchAndBuildStoreColumnData(array $stores)
Bitrix\Catalog\Component\Report\StoreChart\StoreChart\initializeChart
initializeChart()
Определения
storechart.php:56
Bitrix\Catalog\Component\Report\StoreChart\StoreChart\getInnerChartData
getInnerChartData()
Bitrix\Catalog\Component\Report\StoreChart\StoreChart\initializeComponent
initializeComponent()
Определения
storechart.php:50
Bitrix\Catalog\Component\Report\StoreChart\StoreChart\buildLinkToSliderDetails
buildLinkToSliderDetails(string $linkContent)
Bitrix\Catalog\Component\Report\StoreChart\StoreChart\initializeAdditionalData
initializeAdditionalData()
Bitrix\Catalog\Component\Report\StoreChart\StoreChart\formChartLabel
formChartLabel(array $chartData)
Определения
storechart.php:77
Bitrix\Catalog\Component\Report\StoreChart\StoreChart\getChartId
getChartId()
Bitrix\Catalog\Component\Report\StoreChart\StoreChart\executeComponent
executeComponent()
Определения
storechart.php:25
Bitrix\Currency\CurrencyManager
Определения
currencymanager.php:16
Bitrix\Main\ErrorCollection
Определения
errorcollection.php:14
Bitrix\Main\Error
Определения
error.php:15
Bitrix\Main\Loader
Определения
loader.php:13
Bitrix\Main\Localization\Loc
Определения
loc.php:12
CBitrixComponent
Определения
component.php:12
CBitrixComponent\includeComponentTemplate
includeComponentTemplate($templatePage="", $customTemplatePath="")
Определения
component.php:724
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
Bitrix\Main\Errorable
Определения
errorable.php:6
htmlspecialcharsbx
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
Определения
tools.php:2701
Bitrix\Catalog\Component\Report\StoreChart
Определения
storechart.php:3
Bitrix\Main\ErrorableImplementation
trait ErrorableImplementation
Определения
errorableimplementation.php:8
Bitrix\Main\hasErrors
hasErrors()
Определения
errorableimplementation.php:17
$currency
$currency
Определения
template.php:266
$error
$error
Определения
subscription_card_product.php:20
bitrix
modules
catalog
lib
component
report
storechart
storechart.php
Создано системой
1.14.0