Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
base.php
1<?php
2
4
10
11abstract class Base extends Controller
12{
13 protected function init()
14 {
15 parent::init();
16
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}
convertArrayKeysToUpper(array $array, $levels=0, $currentLevel=0)
Definition base.php:69
convertArrayKeysToCamel(array $array, $levels=0, $currentLevel=0)
Definition base.php:46
static registerParameterDependsOnName($className, \Closure $constructObjectByClassAndId, \Closure $constructIdParameterName=null)
Definition binder.php:108