Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
base.php
1
<?php
2
3
namespace
Bitrix\Mail\Controller
;
4
5
use
Bitrix\Mail\Internals\Entity\UserSignature
;
6
use
Bitrix\Mail\Internals\UserSignatureTable
;
7
use
Bitrix\Main\Engine\Binder
;
8
use
Bitrix\Main\Engine\Controller
;
9
use
Bitrix\Main\Text\StringHelper
;
10
11
abstract
class
Base
extends
Controller
12
{
13
protected
function
init
()
14
{
15
parent::init();
16
17
Binder::registerParameterDependsOnName
(
18
UserSignature::class,
19
function
($className, $id)
20
{
21
return
UserSignatureTable::getById($id)->fetchObject();
22
}
23
);
24
}
25
26
protected
function
sanitize
($text)
27
{
28
$text = preg_replace(
'/<!--.*?-->/is'
,
''
, $text);
29
$text = preg_replace(
'/<script[^>]*>.*?<\/script>/is'
,
''
, $text);
30
$text = preg_replace(
'/<title[^>]*>.*?<\/title>/is'
,
''
, $text);
31
32
$sanitizer = new \CBXSanitizer();
33
$sanitizer->setLevel(\CBXSanitizer::SECURE_LEVEL_LOW);
34
$sanitizer->applyDoubleEncode(
false
);
35
$sanitizer->addTags(array(
'style'
=> array()));
36
37
return
$sanitizer->sanitizeHtml($text);
38
}
39
46
protected
function
convertArrayKeysToCamel
(array $array, $levels = 0, $currentLevel = 0)
47
{
48
$result = [];
49
foreach
($array as $key => $value)
50
{
51
if
($levels > 0 && is_array($value) && $currentLevel < $levels)
52
{
53
$currentLevel++;
54
$value = $this->
convertArrayKeysToCamel
($value, $levels, $currentLevel);
55
$currentLevel--;
56
}
57
$result[$this->
toCamelCase
($key)] = $value;
58
}
59
60
return
$result;
61
}
62
69
protected
function
convertArrayKeysToUpper
(array $array, $levels = 0, $currentLevel = 0)
70
{
71
$result = [];
72
foreach
($array as $key => $value)
73
{
74
if
($levels > 0 && is_array($value) && $currentLevel < $levels)
75
{
76
$currentLevel++;
77
$value = $this->
convertArrayKeysToUpper
($value, $levels, $currentLevel);
78
$currentLevel--;
79
}
80
$result[$this->
toUpperCase
($key)] = $value;
81
}
82
83
return
$result;
84
}
85
90
protected
function
toCamelCase
($string)
91
{
92
if
(is_numeric($string))
93
{
94
return
$string;
95
}
96
97
return
lcfirst(StringHelper::snake2camel($string));
98
}
99
104
protected
function
toUpperCase
($string)
105
{
106
if
(is_numeric($string))
107
{
108
return
$string;
109
}
110
111
return
mb_strtoupper(StringHelper::camel2snake($string));
112
}
113
}
Bitrix\Mail\Controller\Base
Definition
base.php:12
Bitrix\Mail\Controller\Base\convertArrayKeysToUpper
convertArrayKeysToUpper(array $array, $levels=0, $currentLevel=0)
Definition
base.php:69
Bitrix\Mail\Controller\Base\toCamelCase
toCamelCase($string)
Definition
base.php:90
Bitrix\Mail\Controller\Base\init
init()
Definition
base.php:13
Bitrix\Mail\Controller\Base\toUpperCase
toUpperCase($string)
Definition
base.php:104
Bitrix\Mail\Controller\Base\convertArrayKeysToCamel
convertArrayKeysToCamel(array $array, $levels=0, $currentLevel=0)
Definition
base.php:46
Bitrix\Mail\Controller\Base\sanitize
sanitize($text)
Definition
base.php:26
Bitrix\Mail\Internals\Entity\UserSignature
Definition
usersignature.php:8
Bitrix\Mail\Internals\UserSignatureTable
Definition
usersignature.php:26
Bitrix\Main\Engine\AutoWire\Binder
Definition
binder.php:8
Bitrix\Main\Engine\Binder\registerParameterDependsOnName
static registerParameterDependsOnName($className, \Closure $constructObjectByClassAndId, \Closure $constructIdParameterName=null)
Definition
binder.php:108
Bitrix\Main\Engine\Controller
Definition
controller.php:32
Bitrix\Main\Text\StringHelper
Definition
stringhelper.php:17
Bitrix\Mail\Controller
Definition
addressbook.php:3
Bitrix\Sender\Internals\QueryController
Definition
action.php:8
modules
mail
lib
controller
base.php
Создано системой
1.10.0