9namespace Bitrix\Sender\Entity;
12use Bitrix\Main\Localization\Loc;
13use Bitrix\Sender\Internals\Model\MessageFieldTable;
14use Bitrix\Sender\Internals\Model\MessageTable;
15use Bitrix\Sender\Internals\Model\MessageUtmTable;
16use Bitrix\Sender\Message\Configuration;
17use Bitrix\Sender\Message\Result;
19Loc::loadMessages(__FILE__);
42 if ($id && $this->load($id))
45 foreach ($configuration->getOptions() as
$option)
49 if (
$option->getType() === $option::TYPE_FILE)
51 $value = ($value <>
'') ? explode(
',', $value) : $value;
54 $configuration->set(
$key, $value);
57 $configuration->setId($id);
60 return $configuration;
71 $this->setId($configuration->getId());
72 $result = $configuration->checkOptions();
79 foreach ($configuration->getOptions() as
$option)
82 if (
$option->getType() === $option::TYPE_FILE)
84 $value = is_array($value) ? implode(
',', $value) : $value;
103 $result->addErrors($this->errors->toArray());
107 $configuration->setId($this->
getId());
121 $copiedId = $this->copyData($id);
136 $result = static::removeById($id);
148 return MessageTable::delete($id);
160 foreach (
$data[
'FIELDS'] as $field)
162 $result[$field[
'CODE']] = $field[
'VALUE'];
176 $this->
set(
'FIELDS', $fields);
189 foreach (
$data[
'UTM'] as $field)
191 $result[$field[
'CODE']] = $field[
'VALUE'];
205 $this->
set(
'UTM', $utm);
216 return $this->
get(
'CODE');
227 return $this->
set(
'CODE', $code);
252 $data = MessageTable::getRowById($id);
253 if (!is_array(
$data))
262 $data[
'FIELDS'] = [];
263 $fieldsDb = MessageFieldTable::getList([
264 'select' => [
'TYPE',
'CODE',
'VALUE'],
266 '=MESSAGE_ID' => $id,
269 while ($field = $fieldsDb->fetch())
271 $data[
'FIELDS'][] = $field;
291 $utmTags =
$data[
'UTM'];
292 unset(
$data[
'FIELDS']);
297 $this->addError(
'No message fields.');
301 $id = $this->saveByEntity(MessageTable::getEntity(), $id,
$data);
307 MessageFieldTable::deleteByMessageId($id);
315 if (in_array($field[
'CODE'], [
'MESSAGE_PERSONALIZE',
'SUBJECT_PERSONALIZE',
'TITLE_PERSONALIZE']))
320 if (in_array($field[
'CODE'], [
'MESSAGE',
'SUBJECT',
'TITLE']))
322 preg_match_all(
"/#([0-9a-zA-Z_.|]+?)#/", $field[
'VALUE'], $matchesFindPlaceHolders);
323 $matchesFindPlaceHoldersCount =
count($matchesFindPlaceHolders[1]);
324 if ($matchesFindPlaceHoldersCount > 0)
326 $list = json_encode($matchesFindPlaceHolders);
327 MessageFieldTable::add(
330 'TYPE' => $field[
'TYPE'],
331 'CODE' => $field[
'CODE'] .
'_PERSONALIZE',
337 MessageFieldTable::add([
339 'TYPE' => $field[
'TYPE'],
340 'CODE' => $field[
'CODE'],
341 'VALUE' => $field[
'VALUE'],
348 foreach ($utmTags as $utm)
350 if (empty($utm[
'VALUE']) || empty($utm[
'CODE']))
354 MessageUtmTable::add(
357 'CODE' => $utm[
'CODE'],
358 'VALUE' => $utm[
'VALUE'],
parsePersonalizeList($text)
loadConfiguration($id=null, Configuration $configuration=null)
saveData($id, array $data)
saveConfiguration(Configuration $configuration)
static deleteByMessageId($messageId)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
if(empty($signedUserToken)) $key
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"