Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
ymap.php
1
<?php
2
3
namespace
Bitrix\Landing\Hook\Page
;
4
5
use
Bitrix\Landing\Field
;
6
use
Bitrix\Landing\Help
;
7
use
Bitrix\Landing\Hook\Page
;
8
use
Bitrix\Landing\Manager
;
9
use
Bitrix\Main\Localization\Loc
;
10
use Bitrix\Main\Page\Asset;
11
use
Bitrix\Main\Text\HtmlFilter
;
12
13
Loc::loadMessages
(__FILE__);
14
15
class
YMap
extends
Page
16
{
21
protected
function
getMap
()
22
{
23
$helpUrl =
Help::getHelpUrl
(
'GMAP_EDIT'
);
24
return
[
25
'USE'
=>
new
Field\Checkbox
(
'USE'
, [
26
'title'
=>
Loc::getMessage
(
'LANDING_HOOK_YMAPCODE_USE'
),
27
]),
28
'CODE'
=>
new
Field\Text
(
'CODE'
, [
29
'title'
=>
Loc::getMessage
(
'LANDING_HOOK_YMAPCODE'
),
30
'placeholder'
=>
Loc::getMessage
(
'LANDING_HOOK_YMAPCODE_PLACEHOLDER'
),
31
'help'
=> $helpUrl
32
?
'<a href="'
. $helpUrl .
'" target="_blank">'
33
.
Loc::getMessage
(
'LANDING_HOOK_YMAPCODE_HELP'
)
34
.
'</a>'
35
:
''
,
36
]),
37
];
38
}
39
44
public
function
enabled
()
45
{
46
if
($this->
issetCustomExec
())
47
{
48
return
true
;
49
}
50
51
if
($this->
isPage
())
52
{
53
return
false
;
54
}
55
56
return
57
$this->fields[
'USE'
]->getValue() ===
'Y'
58
&& !empty($this->fields[
'CODE'
]->getValue());
59
}
60
65
public
function
exec
()
66
{
67
if
($this->
execCustom
())
68
{
69
return
;
70
}
71
72
if
(!
Manager::availableOnlyForZone
(
'ru'
))
73
{
74
return
;
75
}
76
77
$code = HtmlFilter::encode(trim($this->fields[
'CODE'
]));
78
$assets = Asset::getInstance();
79
80
$assets->addString(
81
"<script defer>
82
(function(){
83
'use strict';
84
//fake function, if API will loaded fasten than blocks
85
window.onYandexMapApiLoaded = function(){}
86
})();
87
</script>"
88
);
89
90
// todo: lang=language_region https://yandex.ru/dev/maps/jsapi/doc/2.1/dg/concepts/localization.html
91
// todo: load = modules https://yandex.ru/dev/maps/jsapi/doc/2.1/dg/concepts/modules.html
92
$assets->addString(
93
'<script src="https://api-maps.yandex.ru/2.1/?apikey='
94
. $code
95
.
'&lang=ru_RU&onload=onYandexMapApiLoaded" type="text/javascript"></script>'
96
);
97
}
98
}
Bitrix\Landing\Assets\Manager
Definition
manager.php:20
Bitrix\Landing\Field\Checkbox
Definition
checkbox.php:5
Bitrix\Landing\Field\Text
Definition
text.php:5
Bitrix\Landing\Help
Definition
help.php:5
Bitrix\Landing\Help\getHelpUrl
static getHelpUrl(string $code)
Definition
help.php:268
Bitrix\Landing\Hook\Page\YMap
Definition
ymap.php:16
Bitrix\Landing\Hook\Page\YMap\getMap
getMap()
Definition
ymap.php:21
Bitrix\Landing\Hook\Page\YMap\enabled
enabled()
Definition
ymap.php:44
Bitrix\Landing\Hook\Page\YMap\exec
exec()
Definition
ymap.php:65
Bitrix\Landing\Hook\Page
Definition
page.php:7
Bitrix\Landing\Hook\Page\isPage
isPage()
Definition
page.php:66
Bitrix\Landing\Hook\Page\issetCustomExec
issetCustomExec()
Definition
page.php:253
Bitrix\Landing\Hook\Page\execCustom
execCustom()
Definition
page.php:262
Bitrix\Landing\Manager\availableOnlyForZone
static availableOnlyForZone(string $zone)
Definition
manager.php:975
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Main\Text\HtmlFilter
Definition
htmlfilter.php:11
Bitrix\Landing\Field
Definition
checkbox.php:2
Bitrix\Landing\Hook\Page
Definition
b24button.php:2
modules
landing
lib
hook
page
ymap.php
Создано системой
1.10.0