Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
menu.php
1
<?php
2
3
namespace
Bitrix\Sale\Delivery
;
4
5
use
Bitrix\Main\Localization\Loc
;
6
Loc::loadMessages
(__FILE__);
7
8
class
Menu
9
{
10
protected
$currentDeliveryId
;
11
12
public
function
__construct
(
$currentDeliveryId
= 0)
13
{
14
$this->currentDeliveryId =
$currentDeliveryId
;
15
}
16
17
public
function
getItems
()
18
{
19
$result = array(
20
"text"
=>
Loc::getMessage
(
"SALE_DELIVERY"
),
21
"title"
=>
Loc::getMessage
(
"SALE_DELIVERY_DESCR"
),
22
"url"
=>
"sale_delivery_service_list.php?lang="
.LANGUAGE_ID.
"&filter_group=0"
,
23
"page_icon"
=>
"sale_page_icon"
,
24
//"icon" => "sale_section_icon",
25
"items_id"
=>
"sale_delivery_service_list"
,
26
"more_url"
=> array(
27
"sale_delivery_service_edit.php?lang="
.LANGUAGE_ID.
"&PARENT_ID=0"
,
28
"sale_delivery_service_edit.php?lang="
.LANGUAGE_ID,
29
"sale_delivery_service_list.php?lang="
.LANGUAGE_ID,
30
"sale_delivery_eservice_edit.php?lang="
.LANGUAGE_ID,
31
"sale_delivery_eservice_list.php?lang="
.LANGUAGE_ID
32
),
33
);
34
35
$children = $this->
getChildren
();
36
37
foreach
($children as $key => $child)
38
if
(!$child[
"can_has_children"
])
39
unset($children[$key]);
40
41
if
(!empty($children))
42
{
43
$result[
"items"
] = array_values($children);
44
$result[
"dynamic"
] =
true
;
45
}
46
47
return
$result;
48
}
49
50
protected
function
getChildren
(array $parentIds = array(0))
51
{
52
if
(empty($parentIds))
53
return
array();
54
55
$result = array();
56
57
$dbRes = \Bitrix\Sale\Delivery\Services\Table::getList(array(
58
"filter"
=> array(
59
"=PARENT_ID"
=> $parentIds
60
),
61
"select"
=> array(
62
"ID"
,
"NAME"
,
"DESCRIPTION"
,
"CLASS_NAME"
63
),
64
"order"
=> array(
65
"SORT"
=>
"ASC"
,
66
"NAME"
=>
"ASC"
67
)
68
));
69
70
$services = array();
71
$parents = array();
72
73
while
($service = $dbRes->fetch())
74
{
75
$services[$service[
"ID"
]] = $service;
76
$result[$service[
"ID"
]] = array();
77
78
if
(is_callable($service[
"CLASS_NAME"
].
'::canHasChildren'
) && $service[
"CLASS_NAME"
]::canHasChildren())
79
$parents[] = $service[
"ID"
];
80
}
81
82
if
(!empty($parents))
83
$childrenList = $this->
getChildren
($parents);
84
85
foreach
($services as $serviceId => $service)
86
{
87
$canHasChildren = in_array($serviceId, $parents);
88
89
if
($canHasChildren && !empty($childrenList[$serviceId]))
90
$children = $childrenList[$serviceId];
91
else
92
$children =array();
93
94
foreach
($children as $key => $child)
95
if
(!$child[
"can_has_children"
])
96
unset($children[$key]);
97
98
$item = array(
99
"text"
=> htmlspecialcharsbx($service[
"NAME"
]),
100
"title"
=> htmlspecialcharsbx($service[
"DESCRIPTION"
]),
101
"url"
=>
"sale_delivery_service_list.php?lang="
.LANGUAGE_ID.
"&filter_group="
.$serviceId.
"&PARENT_ID="
.$serviceId.
"&apply_filter=y"
,
102
"page_icon"
=>
"sale_page_icon"
,
103
//"icon" => $canHasChildren ? "sale_section_icon" : "",
104
"can_has_children"
=> $canHasChildren,
105
"more_url"
=> array(
106
"sale_delivery_service_edit.php?lang="
.LANGUAGE_ID.
"&PARENT_ID="
.$serviceId
107
),
108
"items_id"
=>
"sale_delivery_service_list_"
.$serviceId,
109
);
110
111
if
($canHasChildren && !empty($children))
112
{
113
$item[
"items"
] = $children;
114
$item[
"dynamic"
] =
true
;
115
$item[
"items_id"
] =
"menu_sale_delivery_"
.$serviceId;
116
}
117
118
$result[$serviceId] = $item;
119
}
120
121
return
$result;
122
}
123
}
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Sale\Delivery\Menu
Definition
menu.php:9
Bitrix\Sale\Delivery\Menu\__construct
__construct($currentDeliveryId=0)
Definition
menu.php:12
Bitrix\Sale\Delivery\Menu\$currentDeliveryId
$currentDeliveryId
Definition
menu.php:10
Bitrix\Sale\Delivery\Menu\getChildren
getChildren(array $parentIds=array(0))
Definition
menu.php:50
Bitrix\Sale\Delivery\Menu\getItems
getItems()
Definition
menu.php:17
Bitrix\Sale\Delivery
Definition
calculationresult.php:2
modules
sale
lib
delivery
menu.php
Создано системой
1.10.0