Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
messagecall.php
1<?php
10
15
17use Bitrix\Voximplant\Tts;
19
20Loc::loadMessages(__FILE__);
21
27{
29
31 protected $configuration;
32
36 public function __construct()
37 {
38 $this->configuration = new Message\Configuration();
39 }
40
45 public function getName()
46 {
47 return Loc::getMessage('SENDER_INTEGRATION_CALL_MESSAGE_NAME');
48 }
49
55 public function getCode()
56 {
57 return static::CODE;
58 }
59
65 public function getSupportedTransports()
66 {
67 return array(TransportCall::CODE);
68 }
69
74 protected function setConfigurationOptions()
75 {
76 if ($this->configuration->hasOptions())
77 {
78 return;
79 }
80
81 $this->configuration->setArrayOptions(array(
82 array(
83 'type' => 'list',
84 'code' => 'OUTPUT_NUMBER',
85 'name' => Loc::getMessage('SENDER_INTEGRATION_CALL_MESSAGE_CONFIG_OUTPUT_NUMBER'),
86 'items' => \CVoxImplantConfig::GetPortalNumbers(false),
87 'view' => function ()
88 {
89 ob_start();
90 $GLOBALS['APPLICATION']->includeComponent(
91 "bitrix:sender.call.number", "",
92 array(
93 "INPUT_NAME" => "%INPUT_NAME%",
94 "VALUE" => "%INPUT_VALUE%",
95 "MESSAGE_TYPE" => $this->getCode()
96 )
97 );
98 return ob_get_clean();
99 },
100 'required' => true,
101 'show_in_list' => true,
102 'readonly_view' => function($value)
103 {
105 },
106 ),
107 array(
108 'type' => 'text',
109 'code' => 'MESSAGE_TEXT',
110 'name' => Loc::getMessage('SENDER_INTEGRATION_CALL_MESSAGE_CONFIG_MESSAGE_TEXT'),
111 'required' => true,
112 ),
113 array(
114 'type' => 'list',
115 'code' => 'VOICE_LANGUAGE',
116 'name' => Loc::getMessage('SENDER_INTEGRATION_CALL_MESSAGE_CONFIG_VOICE_LANGUAGE'),
117 'items' => Tts\Language::getList(),
118 'required' => true,
119 'group' => Message\ConfigurationOption::GROUP_ADDITIONAL,
120 ),
121 array(
122 'type' => 'list',
123 'code' => 'VOICE_SPEED',
124 'name' => Loc::getMessage('SENDER_INTEGRATION_CALL_MESSAGE_CONFIG_VOICE_SPEED'),
125 'items' => Tts\Speed::getList(),
126 'required' => true,
127 'group' => Message\ConfigurationOption::GROUP_ADDITIONAL,
128 ),
129 array(
130 'type' => 'list',
131 'code' => 'VOICE_VOLUME',
132 'name' => Loc::getMessage('SENDER_INTEGRATION_CALL_MESSAGE_CONFIG_VOICE_VOLUME'),
133 'items' => Tts\Volume::getList(),
134 'required' => true,
135 'group' => Message\ConfigurationOption::GROUP_ADDITIONAL,
136 ),
137 ));
138
139 TimeLimiter::prepareMessageConfiguration($this->configuration);
140 }
141
149 public function loadConfiguration($id = null)
150 {
152 Entity\Message::create()
153 ->setCode($this->getCode())
154 ->loadConfiguration($id, $this->configuration);
155
156 $defaultValues = array(
157 'VOICE_VOLUME' => Tts\Volume::getDefault(),
158 'VOICE_SPEED' => Tts\Speed::getDefault(),
159 'VOICE_LANGUAGE' => Tts\Language::getDefaultVoice(LANGUAGE_ID),
160 );
161 foreach ($defaultValues as $key => $value)
162 {
163 $option = $this->configuration->getOption($key);
164 if (!$option || $option->hasValue())
165 {
166 continue;
167 }
168
169 $option->setValue($value);
170 }
171
172 $textOption = $this->configuration->getOption('MESSAGE_TEXT');
173 if ($textOption)
174 {
175 $speedOption = $this->configuration->getOption('VOICE_SPEED');
176 $textOption->setView(
177 function () use ($speedOption)
178 {
179 ob_start();
180 $GLOBALS['APPLICATION']->includeComponent(
181 "bitrix:sender.call.text.editor",
182 ".default",
183 array(
184 "INPUT_NAME" => "%INPUT_NAME%",
185 "VALUE" => "%INPUT_VALUE%",
186 "SPEED_INPUT_NAME" => $speedOption
187 ?
188 "%INPUT_NAME_" . $speedOption->getCode() . "%"
189 :
190 ''
191 )
192 );
193
194 return ob_get_clean();
195 }
196 );
197 }
198 TimeLimiter::prepareMessageConfigurationView($this->configuration);
199
201 }
202
211 {
212 return Entity\Message::create()
213 ->setCode($this->getCode())
214 ->saveConfiguration($this->configuration);
215 }
216
223 public function removeConfiguration($id)
224 {
225 $result = Entity\Message::removeById($id);
226 return $result->isSuccess();
227 }
228
235 public function copyConfiguration($id)
236 {
237 return Entity\Message::create()
238 ->setCode($this->getCode())
239 ->copyConfiguration($id);
240 }
241}
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
saveConfiguration(Message\Configuration $configuration)
$GLOBALS['____1444769544']
Definition license.php:1