Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
view.php
1<?php
2
4
9
10Loc::loadMessages(__FILE__);
11
12class View extends Page
13{
18 public function getItems(): array
19 {
20 static $items = [];
21 if (empty($items))
22 {
23 $items = [
24 'no' => Loc::getMessage('LANDING_HOOK_VIEW_TYPE_NO'),
25 'ltr' => Loc::getMessage('LANDING_HOOK_VIEW_TYPE_LTR'),
26 'all' => Loc::getMessage('LANDING_HOOK_VIEW_TYPE_ALL'),
27 'mobile' => Loc::getMessage('LANDING_HOOK_VIEW_TYPE_MOBILE'),
28 'adaptive' => Loc::getMessage('LANDING_HOOK_VIEW_TYPE_ADAPTIVE'),
29 ];
30 }
31 return $items;
32 }
33
38 protected function getMap(): array
39 {
40 return [
41 'USE' => new Field\Checkbox('USE', [
42 'title' => Loc::getMessage('LANDING_HOOK_VIEW_USE'),
43 ]),
44 'TYPE' => new Field\Select('TYPE', [
45 'title' => Loc::getMessage('LANDING_HOOK_VIEW_TYPE'),
46 'options' => $this->getItems(),
47 ]),
48 ];
49 }
50
55 public function getTitle(): string
56 {
57 return Loc::getMessage('LANDING_HOOK_VIEW_NAME');
58 }
59
64 public function enabled(): bool
65 {
66 if ($this->issetCustomExec())
67 {
68 return true;
69 }
70
71 return $this->fields['USE']->getValue() === 'Y';
72 }
73
78 public function exec(): void
79 {
80 if ($this->execCustom())
81 {
82 return;
83 }
84
85 $type = trim($this->fields['TYPE']);
86 $bodyClass = '';
87 $mainClasses = '';
88
89 if ($type === 'ltr')
90 {
91 $bodyClass = 'landing-viewtype--ltr';
92 $mainClasses = 'g-pt-6 g-px-10 g-pt-30--md g-px-50--md';
93 }
94 elseif ($type === 'all')
95 {
96 $bodyClass = 'landing-viewtype--all';
97 $mainClasses = 'g-py-6 g-px-10 g-py-30--md g-px-50--md';
98 }
99 elseif ($type === 'mobile')
100 {
101 $bodyClass = 'landing-viewtype--mobile';
102 $mainClasses = 'mx-auto';
103 }
104 elseif ($type === 'adaptive')
105 {
106 $bodyClass = 'landing-viewtype--adaptive';
107 // $mainClasses = 'mx-auto';
108 }
109
110 Manager::setPageView('BodyClass', $bodyClass);
111 Manager::setPageView('MainClass', $mainClasses);
112 }
113}
static setPageView(string $marker, string $content, bool $skipTrim=false)
Definition manager.php:465
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29