Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
sitelocationhelper.php
1
<?
9
namespace
Bitrix\Sale\Location\Admin
;
10
11
use
Bitrix\Main\Localization\Loc
;
12
use
Bitrix\Sale\Location
;
13
use
Bitrix\Main
;
14
15
Loc::loadMessages
(__FILE__);
16
17
class
SiteLocationHelper
extends
Helper
18
{
19
const
LIST_PAGE_URL
=
'sale_location_zone_list.php'
;
20
const
EDIT_PAGE_URL
=
'sale_location_zone_edit.php'
;
21
22
#####################################
23
#### Entity settings
24
#####################################
25
30
public
static
function
getEntityRoadMap
()
31
{
32
return
array(
33
'main'
=> array(
34
'name'
=>
'Bitrix\Main\Site'
,
35
'pages'
=> array(
36
'list'
=> array(
37
'includedColumns'
=> array(
'SITE_NAME'
/*, 'COUNT'*/
)
38
),
39
'detail'
=> array(
40
'includedColumns'
=> array()
41
)
42
),
43
'additional'
=> array(
44
'SITE_NAME'
=> array(
45
'data_type'
=>
'string'
,
46
'title'
=>
Loc::getMessage
(
'SALE_LOCATION_ADMIN_SITE_LOCATION_HELPER_ENTITY_SITE_NAME_FIELD'
)
47
),
48
/*
49
'COUNT' => array(
50
'data_type' => 'integer',
51
'title' => Loc::getMessage('SALE_LOCATION_ADMIN_DEFAULT_SITE_HELPER_ENTITY_COUNT_FIELD')
52
),
53
*/
54
),
55
'primaryFieldName'
=>
'LID'
56
),
57
'link'
=> array(
58
'name'
=>
'Bitrix\Sale\Location\SiteLocation'
59
)
60
);
61
}
62
63
#####################################
64
#### CRUD wrappers
65
#####################################
66
67
public
static
function
proxyUpdateRequest
($data)
68
{
69
unset($data[
'ID'
]);
70
71
$entityClass = static::getEntityClass(
'link'
);
72
$data[
'LOC'
] = self::prepareLinksForSaving($entityClass, $data[
'LOC'
]);
73
74
return
$data;
75
}
76
77
public
static
function
proxyListRequest
($page)
78
{
79
$request = array();
80
81
if
($page ==
'list'
)
82
{
83
$request[
'runtime'
][
'DEFAULT_LOCATION'
] = array(
84
'data_type'
=>
'\Bitrix\Sale\Location\DefaultSite'
,
85
'reference'
=> array(
86
'=this.LID'
=>
'ref.SITE_ID'
87
),
88
'join_type'
=>
'left'
89
);
90
91
/*
92
$request['runtime']['COUNT'] = array(
93
'data_type' => 'integer',
94
'expression' => array(
95
'count(%s)',
96
'DEFAULT_LOCATION.LOCATION_ID'
97
)
98
);
99
*/
100
101
$request[
'select'
] = array(
102
//'COUNT',
103
'NAME'
,
104
'SITE_ID'
=>
'LID'
105
);
106
107
$request[
'group'
] = array(
'SITE_ID'
);
108
}
109
elseif($page ==
'detail'
)
110
{
111
$id = $_REQUEST[
'id'
] <>
''
?
self::tryParseSiteId
($_REQUEST[
'id'
]) :
false
;
112
113
if
($id)
114
$request[
'filter'
][
'=LID'
] = $id;
115
}
116
117
return
$request;
118
}
119
120
// block add handle, nothing to add
121
public
static
function
add
($data)
122
{
123
throw
new
Main\NotSupportedException
(
Loc::getMessage
(
'SALE_LOCATION_ADMIN_SITE_LOCATION_HELPER_ADD_OP_UNSUPPORTED'
));
124
}
125
126
// specific updater
127
public
static
function
update
($siteId, $data)
128
{
129
$success =
true
;
130
131
$entityClass = static::getEntityClass(
'link'
);
132
133
$data = static::proxyUpdateRequest($data);
134
135
$entityClass::resetMultipleForOwner($siteId, $data[
'LOC'
]);
136
137
return
array(
138
'success'
=> $success,
139
'errors'
=> array()
140
);
141
}
142
143
// block delete handle, nothing to delete
144
public
static
function
delete
($primary)
145
{
146
throw
new
Main\NotSupportedException
(
Loc::getMessage
(
'SALE_LOCATION_ADMIN_SITE_LOCATION_HELPER_DELETE_OP_UNSUPPORTED'
));
147
}
148
149
// avoid paging here, kz its based on ID which is absent for this table
150
public
static
function
getList
($parameters = array(), $tableId =
false
, $navigation = 20, $params = array())
151
{
152
$entityClass = static::getEntityClass();
153
154
// only active sites to show
155
if
(is_array($parameters))
156
{
157
$parameters[
'filter'
][
'=ACTIVE'
] =
'Y'
;
158
}
159
160
return
new \CAdminResult($entityClass::getList($parameters), $tableId);
161
}
162
163
public
static
function
getFormData
($id)
164
{
165
$formData = parent::getFormData($id);
166
//$formData = array_merge($formData, static::getDefaultLocationList($id));
167
168
return
$formData;
169
}
170
171
public
static
function
getNameToDisplay
($siteId)
172
{
173
$entityClass = static::getEntityClass(
'main'
);
174
175
$site = $entityClass::getById($siteId)->fetch();
176
return
$site[
'SITE_NAME'
];
177
}
178
179
#####################################
180
#### Entity-specific
181
#####################################
182
183
public
static
function
tryParseSiteId
($sid)
184
{
185
return
htmlspecialcharsbx(mb_substr($sid, 0, 2));
186
}
187
}
Bitrix\Main\Diag\Helper
Definition
helper.php:5
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\Main\NotSupportedException
Definition
exception.php:159
Bitrix\Sale\Location\Admin\SiteLocationHelper
Definition
sitelocationhelper.php:18
Bitrix\Sale\Location\Admin\SiteLocationHelper\getList
static getList($parameters=array(), $tableId=false, $navigation=20, $params=array())
Definition
sitelocationhelper.php:150
Bitrix\Sale\Location\Admin\SiteLocationHelper\tryParseSiteId
static tryParseSiteId($sid)
Definition
sitelocationhelper.php:183
Bitrix\Sale\Location\Admin\SiteLocationHelper\getEntityRoadMap
static getEntityRoadMap()
Definition
sitelocationhelper.php:30
Bitrix\Sale\Location\Admin\SiteLocationHelper\LIST_PAGE_URL
const LIST_PAGE_URL
Definition
sitelocationhelper.php:19
Bitrix\Sale\Location\Admin\SiteLocationHelper\getNameToDisplay
static getNameToDisplay($siteId)
Definition
sitelocationhelper.php:171
Bitrix\Sale\Location\Admin\SiteLocationHelper\proxyUpdateRequest
static proxyUpdateRequest($data)
Definition
sitelocationhelper.php:67
Bitrix\Sale\Location\Admin\SiteLocationHelper\add
static add($data)
Definition
sitelocationhelper.php:121
Bitrix\Sale\Location\Admin\SiteLocationHelper\EDIT_PAGE_URL
const EDIT_PAGE_URL
Definition
sitelocationhelper.php:20
Bitrix\Sale\Location\Admin\SiteLocationHelper\update
static update($siteId, $data)
Definition
sitelocationhelper.php:127
Bitrix\Sale\Location\Admin\SiteLocationHelper\getFormData
static getFormData($id)
Definition
sitelocationhelper.php:163
Bitrix\Sale\Location\Admin\SiteLocationHelper\proxyListRequest
static proxyListRequest($page)
Definition
sitelocationhelper.php:77
Bitrix\Main
Bitrix\Sale\Location\Admin
Definition
defaultsitehelper.php:9
Bitrix\Sale\Location
modules
sale
lib
location
admin
sitelocationhelper.php
Создано системой
1.10.0