Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
messagetoloka.php
1
<?php
2
3
namespace
Bitrix\Sender\Integration\Yandex\Toloka
;
4
5
use
Bitrix\Main\Localization\Loc
;
6
use
Bitrix\Sender\Entity
;
7
use
Bitrix\Sender\Message
;
8
use
Bitrix\Sender\Message\iBase
;
9
use
Bitrix\Sender\Message\iToloka
;
10
11
Loc::loadMessages
(__FILE__);
12
13
class
MessageToloka
implements
iBase
,
iToloka
14
{
15
const
CODE
=
'toloka'
;
17
protected
$configuration
;
18
22
public
function
__construct
()
23
{
24
$this->configuration =
new
Message\Configuration
();
25
}
26
30
public
function
getName
()
31
{
32
return
Loc::getMessage
(
'SENDER_INTEGRATION_YANDEX_TOLOKA'
);
33
}
34
38
public
function
getSupportedTransports
()
39
{
40
return
[static::CODE];
41
}
42
50
public
function
loadConfiguration
($id =
null
)
51
{
52
if
(!$this->configuration->hasOptions())
53
{
54
$this->
setConfigurationOptions
();
55
}
56
//
57
$self = $this;
58
$filterParams = $this->configuration->getOption(
'FILTER'
);
59
60
if
($filterParams)
61
{
62
$filterParams->setView(
63
function
() use ($self)
64
{
65
ob_start();
66
$GLOBALS
[
'APPLICATION'
]->includeComponent(
67
"bitrix:main.ui.filter"
,
68
""
,
69
[
70
"FILTER_ID"
=>
"toloka-filter-connector"
,
71
"FILTER"
=> $self->getUiFilterFields(),
72
"FILTER_PRESETS"
=> [],
73
"DISABLE_SEARCH"
=>
true
,
74
"ENABLE_LABEL"
=>
true
,
75
]
76
);
77
78
return
ob_get_clean();
79
}
80
);
81
}
82
83
Entity\Message::create()
84
->setCode($this->
getCode
())
85
->loadConfiguration($id, $this->configuration);
86
87
return
$this->configuration
;
88
}
89
90
protected
function
setConfigurationOptions
()
91
{
92
$this->configuration->setArrayOptions(
93
[
94
[
95
'type'
=>
'string'
,
96
'code'
=>
'PROJECT_ID'
,
97
'name'
=>
Loc::getMessage
(
'SENDER_INTEGRATION_SEO_MESSAGE_CONFIG_PROJECT'
),
98
'required'
=>
false
,
99
'show_in_list'
=>
false
,
100
'value'
=>
''
,
101
],
102
[
103
'type'
=>
'string'
,
104
'code'
=>
'POOL_ID'
,
105
'name'
=>
Loc::getMessage
(
'SENDER_INTEGRATION_SEO_MESSAGE_CONFIG_POOL'
),
106
'required'
=>
false
,
107
'show_in_list'
=>
false
,
108
'value'
=>
''
,
109
],
110
[
111
'type'
=>
'string'
,
112
'code'
=>
'TASK_SUITE_ID'
,
113
'name'
=>
''
,
114
'required'
=>
false
,
115
'show_in_list'
=>
false
,
116
'value'
=>
''
,
117
],
118
[
119
'type'
=>
'text'
,
120
'code'
=>
'INSTRUCTION'
,
121
'name'
=>
Loc::getMessage
(
'SENDER_TOLOKA_PROJECT_INSTRUCTION'
),
122
'required'
=>
true
,
123
'show_in_list'
=>
true
,
124
'max_length'
=> 2048,
125
'value'
=>
''
,
126
],
127
[
128
'type'
=>
'text'
,
129
'code'
=>
'DESCRIPTION'
,
130
'name'
=>
Loc::getMessage
(
'SENDER_TOLOKA_PROJECT_DESCRIPTION'
),
131
'required'
=>
true
,
132
'max_length'
=> 2048,
133
'show_in_list'
=>
true
,
134
'value'
=>
''
,
135
],
136
[
137
'type'
=>
'text'
,
138
'code'
=>
'TASKS'
,
139
'name'
=>
Loc::getMessage
(
'SENDER_TOLOKA_TASKS'
),
140
'required'
=>
true
,
141
'show_in_list'
=>
true
,
142
'value'
=>
''
,
143
],
144
[
145
'type'
=>
'number'
,
146
'code'
=>
'PRICE'
,
147
'name'
=>
Loc::getMessage
(
'SENDER_TOLOKA_PRICE'
),
148
'required'
=>
true
,
149
'show_in_list'
=>
true
,
150
'value'
=>
'0.07'
,
151
'hint'
=>
Loc::getMessage
(
"SENDER_TOLOKA_PRICE_HINT"
)
152
153
],
154
[
155
'type'
=>
'checkbox'
,
156
'code'
=>
'ADULT_CONTENT'
,
157
'name'
=>
Loc::getMessage
(
'SENDER_TOLOKA_ADULT_CONTENT'
),
158
'required'
=>
false
,
159
'show_in_list'
=>
true
,
160
'value'
=>
''
,
161
],
162
[
163
'type'
=>
'number'
,
164
'code'
=>
'OVERLAP'
,
165
'name'
=>
Loc::getMessage
(
'SENDER_TOLOKA_MAX_POEOPLE_COUNT'
),
166
'required'
=>
true
,
167
'show_in_list'
=>
true
,
168
'value'
=>
'100'
,
169
],
170
[
171
'type'
=>
'datetime'
,
172
'code'
=>
'EXPIRE_IN'
,
173
'name'
=>
Loc::getMessage
(
'SENDER_TOLOKA_POOL_EXPIRE_IN'
),
174
'required'
=>
true
,
175
'show_in_list'
=>
true
,
176
'value'
=>
''
,
177
],
178
[
179
'type'
=>
'string'
,
180
'code'
=>
'FILTER'
,
181
'name'
=>
Loc::getMessage
(
'SENDER_CONFIG_FILTER'
),
182
'required'
=>
false
,
183
'show_in_list'
=>
true
,
184
],
185
]
186
);
187
188
$list = [
189
[
190
'type'
=>
'template-type'
,
191
'code'
=>
'TEMPLATE_TYPE'
,
192
'name'
=>
'Template type'
,
193
'value'
=>
''
,
194
],
195
[
196
'type'
=>
'template-id'
,
197
'code'
=>
'TEMPLATE_ID'
,
198
'name'
=>
'Template id'
,
199
'value'
=>
''
,
200
],
201
];
202
203
foreach
($list as $optionData)
204
{
205
$optionData = $optionData + [
206
'type'
=>
'string'
,
207
'name'
=>
''
,
208
'internal'
=>
true
,
209
];
210
$this->configuration->addOption(
new
Message
\
ConfigurationOption
($optionData));
211
}
212
}
213
214
public
function
getUiFilterFields
()
215
{
216
$list = [
217
[
218
'id'
=>
'REGION_BY_PHONE'
,
219
"name"
=>
Loc::getMessage
(
'SEDNER_INTEGRATION_TOLOKA_FILTER_REGION_PHONE'
),
220
'params'
=> [
'multiple'
=>
'Y'
],
221
'type'
=>
'list'
,
222
"default"
=> true
223
],
224
[
225
'id'
=>
'REGION_BY_IP'
,
226
"name"
=>
Loc::getMessage
(
'SEDNER_INTEGRATION_TOLOKA_FILTER_REGION_IP'
),
227
'params'
=> [
'multiple'
=>
'Y'
],
228
'type'
=>
'list'
,
229
"default"
=> true
230
]
231
];
232
233
return
$list;
234
}
235
239
public
function
getCode
()
240
{
241
return
self::CODE
;
242
}
243
251
public
function
saveConfiguration
(
Message
\
Configuration
$configuration
)
252
{
253
$config =
$configuration
;
254
$projectId = $config->getOption(
'PROJECT_ID'
)
255
->getValue();
256
$poolId = $config->getOption(
'POOL_ID'
)
257
->getValue();
258
259
return
Entity\Message::create()
260
->setCode($this->
getCode
())
261
->saveConfiguration($this->configuration);
262
}
263
267
public
function
copyConfiguration
($id)
268
{
269
}
270
}
Bitrix\Main\Config\Configuration
Definition
configuration.php:7
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\Sender\Entity\Message
Definition
message.php:27
Bitrix\Sender\Integration\Yandex\Toloka\MessageToloka
Definition
messagetoloka.php:14
Bitrix\Sender\Integration\Yandex\Toloka\MessageToloka\getUiFilterFields
getUiFilterFields()
Definition
messagetoloka.php:214
Bitrix\Sender\Integration\Yandex\Toloka\MessageToloka\CODE
const CODE
Definition
messagetoloka.php:15
Bitrix\Sender\Integration\Yandex\Toloka\MessageToloka\__construct
__construct()
Definition
messagetoloka.php:22
Bitrix\Sender\Integration\Yandex\Toloka\MessageToloka\setConfigurationOptions
setConfigurationOptions()
Definition
messagetoloka.php:90
Bitrix\Sender\Integration\Yandex\Toloka\MessageToloka\getName
getName()
Definition
messagetoloka.php:30
Bitrix\Sender\Integration\Yandex\Toloka\MessageToloka\loadConfiguration
loadConfiguration($id=null)
Definition
messagetoloka.php:50
Bitrix\Sender\Integration\Yandex\Toloka\MessageToloka\$configuration
$configuration
Definition
messagetoloka.php:17
Bitrix\Sender\Integration\Yandex\Toloka\MessageToloka\getCode
getCode()
Definition
messagetoloka.php:239
Bitrix\Sender\Integration\Yandex\Toloka\MessageToloka\copyConfiguration
copyConfiguration($id)
Definition
messagetoloka.php:267
Bitrix\Sender\Integration\Yandex\Toloka\MessageToloka\saveConfiguration
saveConfiguration(Message\Configuration $configuration)
Definition
messagetoloka.php:251
Bitrix\Sender\Integration\Yandex\Toloka\MessageToloka\getSupportedTransports
getSupportedTransports()
Definition
messagetoloka.php:38
Bitrix\Sender\Message\ConfigurationOption
Definition
configurationoption.php:12
Bitrix\Sender\Message\iBase
Definition
ibase.php:16
Bitrix\Sender\Message\iToloka
Definition
itoloka.php:5
Bitrix\Main\$GLOBALS
$GLOBALS['____1444769544']
Definition
license.php:1
Bitrix\Sender\Entity
Definition
ad.php:8
Bitrix\Sender\Integration\Yandex\Toloka
Definition
apirequest.php:3
Bitrix\Sender\Message
Definition
adapter.php:9
modules
sender
lib
integration
yandex
toloka
messagetoloka.php
Создано системой
1.10.0