Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
consent.php
1<?php
9
13use Bitrix\UI;
14
15Loc::loadMessages(__FILE__);
16
22{
23 const LOCAL_DIR = '/modules/sender/preset/consent/';
24
25 private static function getFileContent($fileName)
26 {
27 $path = Loader::getLocal(self::LOCAL_DIR . bx_basename($fileName) . '.php');
28 if ($path && File::isFileExists($path))
29 {
30 return File::getFileContents($path);
31 }
32
33 return '';
34 }
35
42 public static function replaceTemplateHtml($content, $replace = [])
43 {
44 $content = str_replace(
45 array(
46 '%SUBJECT%',
47 '%CONSENT_BODY%',
48 '%APPROVE%',
49 '%REJECT%',
50 '%CONSENT_FOOTER%',
51 '%FONTS_PROXY_DOMAIN%',
52 '#SENDER_CONSENT_APPLY#',
53 '#SENDER_CONSENT_REJECT#',
54 ),
55 array(
56 Loc::getMessage('SENDER_PRESET_TEMPLATE_CONSENT_SUBJECT'),
57 $replace['CONSENT_BODY'],
58 Loc::getMessage('SENDER_PRESET_TEMPLATE_CONSENT_APPROVE'),
59 Loc::getMessage('SENDER_PRESET_TEMPLATE_CONSENT_REJECT'),
60 $replace['CONSENT_FOOTER'],
61 UI\Fonts\Proxy::resolveDomain(),
62 $replace['APPLY_URL'],
63 $replace['REJECT_URL'],
64 ),
65 $content
66 );
67
68 return Texts::replace($content);
69 }
70
71 public static function getApproveBtnText($agreement)
72 {
73 return $agreement && $agreement->getLabelText()
74 ? $agreement->getLabelText() : Loc::getMessage('SENDER_PRESET_TEMPLATE_CONSENT_APPROVE');
75 }
76
77 public static function getRejectnBtnText()
78 {
79 return Loc::getMessage('SENDER_PRESET_TEMPLATE_CONSENT_REJECT');
80 }
81
87 public static function getTemplateHtml()
88 {
89 $fileContent = self::getFileContent('template');
90
91 if (!$fileContent)
92 {
93 return null;
94 }
95
96 return $fileContent;
97 }
98}
static isFileExists($path)
Definition file.php:256
static getFileContents($path)
Definition file.php:262
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29