1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
selectorprovider.php
См. документацию.
1
<?php
2
namespace
Bitrix\Landing\Connector\Ui
;
3
4
use
Bitrix\Landing\Landing
;
5
use
Bitrix\Landing\Site
;
6
use
Bitrix\Landing\Folder
;
7
use
Bitrix\Landing\Site\Type
;
8
use
Bitrix\UI\EntitySelector\Dialog
;
9
use
Bitrix\UI\EntitySelector\Item
;
10
use
Bitrix\UI\EntitySelector\SearchQuery
;
11
12
class
SelectorProvider
extends
\Bitrix\UI\EntitySelector\BaseProvider
13
{
18
protected
static
$searchPhrase
=
null
;
19
25
public
function
__construct
(
array
$options
= [])
26
{
27
parent::__construct();
28
}
29
34
public
function
isAvailable
(): bool
35
{
36
return
true
;
37
}
38
45
public
static
function
getFolders
(
int
$siteId
, ?
int
$parentId =
null
):
array
46
{
47
$data
= [];
48
$filter
= [];
49
50
if
(self::$searchPhrase)
51
{
52
$filter
[
'?TITLE'
] =
'%'
. self::$searchPhrase .
'%'
;
53
}
54
else
55
{
56
$filter
[
'PARENT_ID'
] = abs($parentId);
57
}
58
59
$folders = Site::getFolders(
$siteId
,
$filter
);
60
61
foreach
($folders as $folder)
62
{
63
$data
[$folder[
'ID'
]] =
new
Item
([
64
'id'
=> -1 * $folder[
'ID'
],
65
'entityId'
=>
'landing'
,
66
'entityType'
=>
'folder'
,
67
'title'
=> $folder[
'TITLE'
],
68
'nodeOptions'
=> [
'dynamic'
=>
true
]
69
]);
70
}
71
72
return
$data
;
73
}
74
82
public
static
function
getLandings
(
int
$siteId
, ?
int
$landingId =
null
, ?
int
$parentId =
null
):
array
83
{
84
$data
= [];
85
$landingFake = Landing::createInstance(0);
86
$filter
= [
'SITE_ID'
=>
$siteId
];
87
88
// search in folders first (if search mode)
89
if
(self::$searchPhrase)
90
{
91
$folders = Site::getFolders(
$siteId
, [
92
'?TITLE'
=>
'%'
. self::$searchPhrase .
'%'
93
]);
94
if
($folders)
95
{
96
$filterSub = [
'LOGIC'
=>
'OR'
];
97
$filterSub[
'?TITLE'
] =
'%'
. self::$searchPhrase .
'%'
;
98
$filterSub[
'FOLDER_ID'
] = [];
99
foreach
($folders as $folder)
100
{
101
$filterSub[
'FOLDER_ID'
][] = $folder[
'ID'
];
102
}
103
$filter
[] = $filterSub;
104
}
105
else
106
{
107
$filter
[
'?TITLE'
] =
'%'
. self::$searchPhrase .
'%'
;
108
}
109
}
110
else
111
{
112
$filter
[
'FOLDER_ID'
] = abs($parentId);
113
}
114
115
$rows
= [];
116
$res
=
Landing::getList
([
117
'select'
=> [
118
'ID'
,
'TITLE'
,
'FOLDER_ID'
,
'SITE_ID'
,
119
'DOMAIN_ID'
=>
'SITE.DOMAIN_ID'
120
],
121
'filter'
=>
$filter
,
122
'order'
=> [
123
'DATE_MODIFY'
=>
'desc'
124
]
125
]);
126
while
($row =
$res
->fetch())
127
{
128
$rows
[$row[
'ID'
]] = $row;
129
}
130
131
if
(
$rows
)
132
{
133
$urls = $landingFake->getPublicUrl(array_keys(
$rows
));
134
}
135
136
foreach
(
$rows
as $row)
137
{
138
$subtitle =
null
;
139
if
(self::$searchPhrase && $row[
'FOLDER_ID'
])
140
{
141
$subtitle =
Folder::getBreadCrumbsString
($row[
'FOLDER_ID'
],
' / '
, $row[
'SITE_ID'
]);
142
}
143
$data
[$row[
'ID'
]] =
new
Item
([
144
'id'
=> $row[
'ID'
],
145
'selected'
=> $row[
'ID'
] == $landingId,
146
'entityId'
=>
'landing'
,
147
'entityType'
=>
'landing'
,
148
'title'
=> $row[
'TITLE'
],
149
'avatar'
=> $landingFake->getPreview($row[
'ID'
], $row[
'DOMAIN_ID'
] == 0, $urls[$row[
'ID'
]]),
150
'subtitle'
=> $subtitle ?:
''
151
]);
152
}
153
154
return
$data
;
155
}
156
162
protected
function
getSiteIdFromDialog
(
Dialog
$dialog): ?int
163
{
164
$entity
= $dialog->
getEntities
()[
'landing'
] ??
null
;
165
if
(
$entity
)
166
{
167
if
(
$siteId
=
$entity
->getOptions()[
'siteId'
] ??
null
)
168
{
169
Type::setScope
(
$entity
->getOptions()[
'siteType'
]);
170
return
$siteId
;
171
}
172
}
173
174
return
null
;
175
}
176
182
protected
function
getLandingIdFromDialog
(
Dialog
$dialog): ?int
183
{
184
$entity
= $dialog->
getEntities
()[
'landing'
] ??
null
;
185
if
(
$entity
)
186
{
187
if
($landingId =
$entity
->getOptions()[
'landingId'
] ??
null
)
188
{
189
return
$landingId;
190
}
191
}
192
193
return
null
;
194
}
195
202
public
function
getChildren
(
Item
$parentItem,
Dialog
$dialog): void
203
{
204
$this::$searchPhrase =
null
;
205
if
(
$siteId
= $this->
getSiteIdFromDialog
($dialog))
206
{
207
$landingId = $this->
getLandingIdFromDialog
($dialog);
208
$dialog->
addItems
($this::getFolders(
$siteId
, $parentItem->
getId
()));
209
$dialog->
addItems
($this::getLandings(
$siteId
, $landingId, $parentItem->
getId
()));
210
}
211
}
212
219
public
function
doSearch
(
SearchQuery
$searchQuery,
Dialog
$dialog): void
220
{
221
$this::$searchPhrase = $searchQuery->
getQuery
();
222
if
(
$siteId
= $this->
getSiteIdFromDialog
($dialog))
223
{
224
$dialog->
addItems
($this::getLandings(
$siteId
));
225
}
226
$this::$searchPhrase =
null
;
227
}
228
234
public
function
getItems
(
array
$ids) :
array
235
{
236
return
[];
237
}
238
244
public
function
getSelectedItems
(
array
$ids) :
array
245
{
246
return
[];
247
}
248
}
Bitrix\Landing\Connector\Ui\SelectorProvider
Определения
selectorprovider.php:13
Bitrix\Landing\Connector\Ui\SelectorProvider\getFolders
static getFolders(int $siteId, ?int $parentId=null)
Определения
selectorprovider.php:45
Bitrix\Landing\Connector\Ui\SelectorProvider\getChildren
getChildren(Item $parentItem, Dialog $dialog)
Определения
selectorprovider.php:202
Bitrix\Landing\Connector\Ui\SelectorProvider\__construct
__construct(array $options=[])
Определения
selectorprovider.php:25
Bitrix\Landing\Connector\Ui\SelectorProvider\getLandingIdFromDialog
getLandingIdFromDialog(Dialog $dialog)
Определения
selectorprovider.php:182
Bitrix\Landing\Connector\Ui\SelectorProvider\$searchPhrase
static $searchPhrase
Определения
selectorprovider.php:18
Bitrix\Landing\Connector\Ui\SelectorProvider\getSiteIdFromDialog
getSiteIdFromDialog(Dialog $dialog)
Определения
selectorprovider.php:162
Bitrix\Landing\Connector\Ui\SelectorProvider\getSelectedItems
getSelectedItems(array $ids)
Определения
selectorprovider.php:244
Bitrix\Landing\Connector\Ui\SelectorProvider\getItems
getItems(array $ids)
Определения
selectorprovider.php:234
Bitrix\Landing\Connector\Ui\SelectorProvider\doSearch
doSearch(SearchQuery $searchQuery, Dialog $dialog)
Определения
selectorprovider.php:219
Bitrix\Landing\Connector\Ui\SelectorProvider\getLandings
static getLandings(int $siteId, ?int $landingId=null, ?int $parentId=null)
Определения
selectorprovider.php:82
Bitrix\Landing\Connector\Ui\SelectorProvider\isAvailable
isAvailable()
Определения
selectorprovider.php:34
Bitrix\Landing\Folder
Определения
folder.php:5
Bitrix\Landing\Folder\getBreadCrumbsString
static getBreadCrumbsString(int $folderId, string $glue, ?int $siteId=null)
Определения
folder.php:208
Bitrix\Landing\Site\Type
Определения
type.php:10
Bitrix\Main\Engine\Controller\setScope
setScope($scope)
Определения
controller.php:373
Bitrix\Main\ORM\Data\DataManager\getList
static getList(array $parameters=array())
Определения
datamanager.php:431
Bitrix\UI\EntitySelector\BaseProvider
Определения
baseprovider.php:5
Bitrix\UI\EntitySelector\BaseProvider\$options
$options
Определения
baseprovider.php:6
Bitrix\UI\EntitySelector\Dialog
Определения
dialog.php:10
Bitrix\UI\EntitySelector\Dialog\getEntities
getEntities()
Определения
dialog.php:288
Bitrix\UI\EntitySelector\Dialog\addItems
addItems(array $items)
Определения
dialog.php:135
Bitrix\UI\EntitySelector\Item
Определения
item.php:8
Bitrix\UI\EntitySelector\Item\getId
getId()
Определения
item.php:180
Bitrix\UI\EntitySelector\SearchQuery
Определения
searchquery.php:5
Bitrix\UI\EntitySelector\SearchQuery\getQuery
getQuery()
Определения
searchquery.php:40
$data
$data['IS_AVAILABLE']
Определения
.description.php:13
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$res
$res
Определения
filter_act.php:7
$entity
$entity
Определения
group_bizproc_workflow_delete.php:17
$filter
$filter
Определения
iblock_catalog_list.php:54
$siteId
$siteId
Определения
ajax.php:8
Bitrix\Landing\Connector\Ui
Определения
selectorprovider.php:2
Bitrix\Landing\Landing
Определения
cache.php:2
Bitrix\Landing\Site
Определения
cookies.php:2
$rows
$rows
Определения
options.php:264
bitrix
modules
landing
lib
connector
ui
selectorprovider.php
Создано системой
1.14.0