Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
feedbackform.php
1
<?php
2
namespace
Bitrix\UI\Form
;
3
4
use
Bitrix\Main
;
5
use
Bitrix\Main\ArgumentException
;
6
use
Bitrix\Main\Loader
;
7
use
Bitrix\Main\Localization\Loc
;
8
use
Bitrix\Main\Config\Option
;
9
10
class
FeedbackForm
11
{
12
protected
$id
;
13
protected
$isCloud
;
14
protected
$formParams
= [];
15
protected
$presets
= [];
16
protected
$title
;
17
protected
$portalUri
;
18
19
public
function
__construct
(
string
$id
)
20
{
21
if
(
$id
==
''
)
22
{
23
throw
new
ArgumentException
(
' Feedback form id can not be empty'
);
24
}
25
$this->
id
=
$id
;
26
$this->isCloud = Loader::includeModule(
'bitrix24'
);
27
$this->title =
Loc::getMessage
(
'UI_FEEDBACK_FORM_BUTTON'
);
28
$this->portalUri =
'https://product-feedback.bitrix24.com'
;
29
}
30
31
public
function
getId
()
32
{
33
return
$this->id
;
34
}
35
36
public
function
getFormParams
()
37
{
38
return
$this->formParams
;
39
}
40
41
public
function
setFormParamsDirectly
($form)
42
{
43
$form[
'lang'
] = $form[
'lang'
]??LANGUAGE_ID;
44
$this->formParams = $form;
45
}
46
47
public
function
getPresets
()
48
{
49
$presets
=
$this->presets
;
50
$presets
[
'b24_plan'
] = $this->isCloud ? \CBitrix24::getLicenseType() :
''
;
51
$presets
[
'b24_plan_date_to'
] = (
52
$this->isCloud
53
? ConvertTimeStamp(Option::get(
'main'
,
'~controller_group_till'
, time()))
54
:
''
55
);
56
$presets
[
'b24_partner_id'
] = (
57
($this->isCloud && method_exists(
'CBitrix24'
,
'getPartnerId'
))
58
? \CBitrix24::getPartnerId()
59
:
''
60
);
61
62
$presets
[
'hosturl'
] = Main\Engine\UrlManager::getInstance()->getHostUrl();
63
$presets
[
'hostname'
] = parse_url(
$presets
[
'hosturl'
], PHP_URL_HOST);
64
65
global $USER;
66
$name =
''
;
67
$email =
''
;
68
if
(is_object($USER))
69
{
70
$name = $USER->GetFirstName();
71
if
(!$name)
72
{
73
$name = $USER->GetLogin();
74
}
75
$email = $USER->GetEmail();
76
}
77
$presets
[
'c_name'
] = $name;
78
$presets
[
'c_email'
] = $email;
79
80
return
$presets
;
81
}
82
83
public
function
getTitle
()
84
{
85
return
$this->title
;
86
}
87
88
public
function
getPortalUri
()
89
{
90
return
$this->portalUri
;
91
}
92
93
public
function
getJsObjectParams
()
94
{
95
return
[
96
'id'
=> $this->
getId
(),
97
'form'
=> $this->
getFormParams
(),
98
'presets'
=> $this->
getPresets
(),
99
'title'
=> $this->
getTitle
(),
100
'portal'
=> $this->
getPortalUri
()
101
];
102
}
103
104
public
function
setFormParams
(array $forms)
105
{
106
if
($this->isCloud && isset($forms[
'prefixes'
]))
107
{
108
$zone = \CBitrix24::getLicensePrefix();
109
$defaultForm =
null
;
110
foreach
($forms as $form)
111
{
112
if
(!isset($form[
'licenseZones'
]) || !isset($form[
'zones'
]) || !is_array($forms[
'licenseZones'
]))
113
{
114
continue
;
115
}
116
117
if
(in_array($zone, $forms[
'licenseZones'
]))
118
{
119
$form[
'lang'
] = $form[
'lang'
]??LANGUAGE_ID;
120
$this->formParams = $form;
121
return
;
122
}
123
124
if
(in_array(
'en'
, $forms[
'licenseZones'
]))
125
{
126
$form[
'lang'
] = $form[
'lang'
]??LANGUAGE_ID;
127
$defaultForm = $form;
128
}
129
}
130
131
$this->formParams = $defaultForm;
132
}
133
else
if
($this->isCloud)
134
{
135
$zone = \CBitrix24::getPortalZone();
136
$defaultForm =
null
;
137
foreach
($forms as $form)
138
{
139
if
(!isset($form[
'zones'
]) || !is_array($form[
'zones'
]))
140
{
141
continue
;
142
}
143
144
if
(in_array($zone, $form[
'zones'
]))
145
{
146
$form[
'lang'
] = $form[
'lang'
]??LANGUAGE_ID;
147
$this->formParams = $form;
148
return
;
149
}
150
151
if
(in_array(
'en'
, $form[
'zones'
]))
152
{
153
$form[
'lang'
] = $form[
'lang'
]??LANGUAGE_ID;
154
$defaultForm = $form;
155
}
156
}
157
158
$this->formParams = $defaultForm;
159
}
160
else
161
{
162
$lang = LANGUAGE_ID;
163
$defaultForm =
null
;
164
foreach
($forms as $form)
165
{
166
if
(!isset($form[
'lang'
]))
167
{
168
continue
;
169
}
170
171
if
($lang === $form[
'lang'
])
172
{
173
$this->formParams = $form;
174
return
;
175
}
176
177
if
($form[
'lang'
] ===
'en'
)
178
{
179
$defaultForm = $form;
180
}
181
}
182
183
$this->formParams = $defaultForm;
184
}
185
}
186
187
public
function
setPresets
(array
$presets
= [])
188
{
189
$this->presets =
$presets
;
190
}
191
192
public
function
setTitle
(
string
$title
)
193
{
194
$this->title =
$title
;
195
}
196
197
public
function
setPortalUri
(
string
$portalUri
)
198
{
199
$this->portalUri =
$portalUri
;
200
}
201
}
Bitrix\Main\ArgumentException
Definition
exception.php:34
Bitrix\Main\Config\Option
Definition
option.php:15
Bitrix\Main\Loader
Definition
loader.php:12
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\UI\Form\FeedbackForm
Definition
feedbackform.php:11
Bitrix\UI\Form\FeedbackForm\getId
getId()
Definition
feedbackform.php:31
Bitrix\UI\Form\FeedbackForm\setPresets
setPresets(array $presets=[])
Definition
feedbackform.php:187
Bitrix\UI\Form\FeedbackForm\setPortalUri
setPortalUri(string $portalUri)
Definition
feedbackform.php:197
Bitrix\UI\Form\FeedbackForm\getPresets
getPresets()
Definition
feedbackform.php:47
Bitrix\UI\Form\FeedbackForm\getPortalUri
getPortalUri()
Definition
feedbackform.php:88
Bitrix\UI\Form\FeedbackForm\setTitle
setTitle(string $title)
Definition
feedbackform.php:192
Bitrix\UI\Form\FeedbackForm\getTitle
getTitle()
Definition
feedbackform.php:83
Bitrix\UI\Form\FeedbackForm\$presets
$presets
Definition
feedbackform.php:15
Bitrix\UI\Form\FeedbackForm\getFormParams
getFormParams()
Definition
feedbackform.php:36
Bitrix\UI\Form\FeedbackForm\$portalUri
$portalUri
Definition
feedbackform.php:17
Bitrix\UI\Form\FeedbackForm\$formParams
$formParams
Definition
feedbackform.php:14
Bitrix\UI\Form\FeedbackForm\__construct
__construct(string $id)
Definition
feedbackform.php:19
Bitrix\UI\Form\FeedbackForm\$title
$title
Definition
feedbackform.php:16
Bitrix\UI\Form\FeedbackForm\setFormParams
setFormParams(array $forms)
Definition
feedbackform.php:104
Bitrix\UI\Form\FeedbackForm\$isCloud
$isCloud
Definition
feedbackform.php:13
Bitrix\UI\Form\FeedbackForm\getJsObjectParams
getJsObjectParams()
Definition
feedbackform.php:93
Bitrix\UI\Form\FeedbackForm\$id
$id
Definition
feedbackform.php:12
Bitrix\UI\Form\FeedbackForm\setFormParamsDirectly
setFormParamsDirectly($form)
Definition
feedbackform.php:41
Bitrix\Main
Bitrix\UI\Form
Definition
entityeditorconfigscope.php:2
modules
ui
lib
form
feedbackform.php
Создано системой
1.10.0