1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
ymap.php
См. документацию.
1<?php
2
3namespace Bitrix\Landing\Hook\Page;
4
5use Bitrix\Landing\Field;
6use Bitrix\Landing\Help;
7use Bitrix\Landing\Hook\Page;
8use Bitrix\Landing\Manager;
9use Bitrix\Main\Localization\Loc;
10use Bitrix\Main\Page\Asset;
11use Bitrix\Main\Text\HtmlFilter;
12
13Loc::loadMessages(__FILE__);
14
15class 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
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"></script>'
96 );
97 }
98}
static getHelpUrl(string $code)
Определения help.php:174
enabled()
Определения ymap.php:44
isPage()
Определения page.php:66
issetCustomExec()
Определения page.php:253
execCustom()
Определения page.php:262
static availableOnlyForZone(string $zone)
Определения manager.php:980
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
Определения options.php:195
Определения aliases.php:54