Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
metamain.php
1<?php
3
4use \Bitrix\Landing\Field;
5use \Bitrix\Landing\Manager;
6use \Bitrix\Landing\Landing\Seo;
7use \Bitrix\Main\Localization\Loc;
8
9Loc::loadMessages(__FILE__);
10
12{
17 protected function getMap()
18 {
19 return array(
20 'USE' => new Field\Checkbox('USE', array(
21 'title' => Loc::getMessage('LANDING_HOOK_METAMAIN_USE'),
22 'help' => Loc::getMessage('LANDING_HOOK_METAMAIN_DESCRIPTION'),
23 )),
24 'TITLE' => new Field\Text('TITLE', array(
25 'title' => Loc::getMessage('LANDING_HOOK_METAMAIN_TITLE'),
26 'placeholder' => Loc::getMessage('LANDING_HOOK_METAMAIN_TITLE_PLACEHOLDER'),
27 'maxlength' => 140,
28 'searchable' => true
29 )),
30 'DESCRIPTION' => new Field\Textarea('DESCRIPTION', array(
31 'title' => Loc::getMessage('LANDING_HOOK_METAMAIN_DESCRIPTION_TITLE'),
32 'placeholder' => Loc::getMessage('LANDING_HOOK_METAMAIN_DESCRIPTION_PLACEHOLDER'),
33 'maxlength' => 300,
34 'searchable' => true
35 )),
36 'KEYWORDS' => new Field\Text('KEYWORDS', array(
37 'title' => Loc::getMessage('LANDING_HOOK_METAMAIN_KEYWORDS_TITLE'),
38 'maxlength' => 250,
39 'searchable' => true
40 ))
41 );
42 }
43
48 public function getTitle()
49 {
50 return Loc::getMessage('LANDING_HOOK_METAMAIN_NAME');
51 }
52
57 public function getDescription(): string
58 {
59 return Loc::getMessage('LANDING_HOOK_METAMAIN_DESCRIPTION');
60 }
61
62
67 public function enabled()
68 {
69 if ($this->issetCustomExec())
70 {
71 return true;
72 }
73
74 return $this->fields['USE']->getValue() == 'Y';
75 }
76
81 public function enabledInEditMode()
82 {
83 return false;
84 }
85
90 public function exec()
91 {
92 if ($this->execCustom())
93 {
94 return;
95 }
96
97 $title = \htmlspecialcharsbx(Seo::processValue('title', $this->fields['TITLE']));
98 $description = Seo::processValue('description', $this->fields['DESCRIPTION']);
99 $keywords = Seo::processValue('keywords', $this->fields['KEYWORDS']);
100
101 if ($title != '')
102 {
103 Manager::setPageTitle($title);
104 }
105 if ($description != '')
106 {
107 Manager::getApplication()->setPageProperty(
108 'description',
109 $description
110 );
111 }
112 if ($keywords != '')
113 {
114 Manager::getApplication()->setPageProperty(
115 'keywords',
116 $keywords
117 );
118 }
119 }
120}
static getApplication()
Definition manager.php:71
static setPageTitle($title, $single=false)
Definition manager.php:211
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29