Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
htmlbuilder.php
1<?php
2
4
7
13{
14 protected $userTypeId;
15
16 public function __construct($userTypeId)
17 {
18 $this->userTypeId = $userTypeId;
19 }
20
21 public function getCssClassName(array $additionalCss = array())
22 {
23 return trim('fields ' . $this->userTypeId . ' ' . implode(' ', $additionalCss));
24 }
25
26 public function wrapSingleField($html, array $additionalCss = array())
27 {
28 return '<span class="' . HtmlFilter::encode(static::getCssClassName($additionalCss)) . ' field-item">' . $html . '</span>';
29 }
30
31 public function wrapDisplayResult($html, $additionalCss = array())
32 {
33 return '<span class="' . HtmlFilter::encode(static::getCssClassName($additionalCss)) . ' field-wrap">' . $html . '</span>';
34 }
35
37 {
38 return '<span class="fields separator"></span>';
39 }
40
41 public function getCloneButton($fieldName)
42 {
43 return '<input type="button" value="' . HtmlFilter::encode(Loc::getMessage('USER_TYPE_PROP_ADD')) . '" onclick="BX.Main.UF.Factory.get(\'' . $this->userTypeId . '\').addRow(\'' . \CUtil::jsEscape($fieldName) . '\', this);" />';
44 }
45
46 public function getMobileCloneButton($fieldName)
47 {
48 return '<div class="add-field-button" onclick="BX.Main.UF.Factory.get(\'' .
49 $this->userTypeId . '\').addMobileRow(\'' . \CUtil::jsEscape($fieldName) . '\', this);" >' . Loc::getMessage('CRM_FIELDS_ADD_FIELD') . '</div>';
50 }
51
57 public function buildTagAttributes(?array $attributes, bool $encode = true): ?string
58 {
59 $s = '';
60 if($attributes)
61 {
62 foreach($attributes as $attribute => $value)
63 {
64 if($encode)
65 {
66 $s .= htmlspecialcharsbx($attribute) . '="' . htmlspecialcharsbx($value) . '" ';
67 }
68 else
69 {
70 $s .= $attribute . '="' . $value . '" ';
71 }
72 }
73 }
74
75 return $s;
76 }
77
82 public function encodeUrl(?string $url): string
83 {
84 if(!preg_match('/^(callto:|mailto:|[a-z0-9]+:\/\/)/i', $url))
85 {
86 $url = 'http://' . $url;
87 }
88
89 return (new Uri($url))->getUri();
90 }
91}
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
static encode($string, $flags=ENT_COMPAT, $doubleEncode=true)
wrapDisplayResult($html, $additionalCss=array())
wrapSingleField($html, array $additionalCss=array())
getCssClassName(array $additionalCss=array())