Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
transition.php
1<?php
2
4
10use Bitrix\Main\Page\Asset;
11
15class Transition extends Hook\Page
16{
17 protected const BASE_COLOR = '#fff';
18
23 protected function getMap(): array
24 {
25 return [
26 'COLOR' => new Field\Text('COLOR', [
27 'title' => Loc::getMessage('LANDING_HOOK_TRANSITION_COLOR'),
28 ]),
29 ];
30 }
31
36 public function enabled(): bool
37 {
38 if ($this->issetCustomExec())
39 {
40 return true;
41 }
42
43 if ($this->isPage())
44 {
45 return false;
46 }
47
48 return true; //always enable on site to default value
49 }
50
55 public function exec(): void
56 {
57 if ($this->execCustom())
58 {
59 return;
60 }
61
62 $type = strtoupper(Landing::getSiteType());
63 if ($type === 'KNOWLEDGE')
64 {
65 return;
66 }
67
68 $color = \htmlspecialcharsbx(trim($this->fields['COLOR']->getValue()));
69 if (!$color)
70 {
71 $color = self::BASE_COLOR;
72 }
73 $this->addTransitionClass();
74 $this->setTransition($color);
75 }
76
77 protected function setTransition($color): void
78 {
79 Asset::getInstance()->addString(
80 '<style>
81 body.landing-page-transition::after {
82 }
83 </style>'
84 );
85 }
86
87 protected function addTransitionClass(): void
88 {
89 //add background on page load
91 'BodyClass',
92 'landing-page-transition'
93 );
94 }
95}
static setPageView(string $marker, string $content, bool $skipTrim=false)
Definition manager.php:465
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29