Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
messagesms.php
1<?php
10
17
18Loc::loadMessages(__FILE__);
19
25{
27
29 protected $configuration;
30
33
37 public function __construct()
38 {
39 $this->configuration = new Message\Configuration();
40 }
41
46 public function getName()
47 {
48 return Loc::getMessage('SENDER_INTEGRATION_SMS_MESSAGE_NAME');
49 }
50
51 public function getCode()
52 {
53 return static::CODE;
54 }
55
56 public function getSupportedTransports()
57 {
58 return array(TransportSms::CODE);
59 }
60
61 protected function setConfigurationOptions()
62 {
63 if ($this->configuration->hasOptions())
64 {
65 return;
66 }
67
68 $this->configuration->setArrayOptions(array(
69 array(
70 'type' => 'string',
71 'code' => 'SENDER',
72 'name' => Loc::getMessage('SENDER_INTEGRATION_SMS_MESSAGE_CONFIG_SENDER'),
73 'required' => true,
74 'show_in_list' => true,
75 'readonly_view' => function($value)
76 {
78 },
79 ),
80 array(
81 'type' => 'text',
82 'code' => 'MESSAGE_TEXT',
83 'name' => Loc::getMessage('SENDER_INTEGRATION_SMS_MESSAGE_CONFIG_MESSAGE_TEXT'),
84 'required' => true,
85 ),
86 ));
87
88 TimeLimiter::prepareMessageConfiguration($this->configuration);
89 }
90
98 public function loadConfiguration($id = null)
99 {
101 Entity\Message::create()
102 ->setCode($this->getCode())
103 ->loadConfiguration($id, $this->configuration);
104
105 $senderOption = $this->configuration->getOption('SENDER');
106 if ($senderOption)
107 {
108 $senderOption->setView(
109 function () use ($senderOption)
110 {
111 ob_start();
112 $GLOBALS['APPLICATION']->includeComponent(
113 "bitrix:sender.sms.sender",
114 ".default",
115 array(
116 "INPUT_NAME" => "%INPUT_NAME%",
117 "SENDER" => $senderOption->getValue()
118 )
119 );
120
121 return ob_get_clean();
122 }
123 );
124 }
125
126 $textOption = $this->configuration->getOption('MESSAGE_TEXT');
127 if ($textOption)
128 {
129 $textOption->setView(
130 function ()
131 {
132 ob_start();
133 $GLOBALS['APPLICATION']->includeComponent(
134 "bitrix:sender.sms.text.editor",
135 ".default",
136 array(
137 "INPUT_NAME" => "%INPUT_NAME%",
138 "VALUE" => "%INPUT_VALUE%",
139 )
140 );
141
142 return ob_get_clean();
143 }
144 );
145 }
146 TimeLimiter::prepareMessageConfigurationView($this->configuration);
147
149 }
150
159 {
160 return Entity\Message::create()
161 ->setCode($this->getCode())
162 ->saveConfiguration($this->configuration);
163 }
164
171 public function removeConfiguration($id)
172 {
173 $result = Entity\Message::removeById($id);
174 return $result->isSuccess();
175 }
176
183 public function copyConfiguration($id)
184 {
185 return Entity\Message::create()
186 ->setCode($this->getCode())
187 ->copyConfiguration($id);
188 }
189
195 public function getSmsSender()
196 {
197 return $this->configuration->getOption('SENDER')->getValue();
198 }
199}
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