2f3cd090
Yarik
Setting migrate
|
1
2
|
<?php
namespace common\models;
|
9af79e71
Yarik
Sitemap and slugb...
|
3
|
|
3e6486de
Alexey Boroda
-Gallery attached...
|
4
|
use artbox\core\components\imagemanager\models\ImageManager;
|
2f3cd090
Yarik
Setting migrate
|
5
6
7
8
9
|
use yii2tech\filedb\ActiveRecord;
use Yii;
/**
* Class Settings
|
2f3cd090
Yarik
Setting migrate
|
10
|
*
|
3e16e218
Yarik
Admin fixes
|
11
|
* @package artbox\core\models
|
3cae1b75
Alexey Boroda
-Analytics almost...
|
12
|
* @property string $analytics_key
|
3e16e218
Yarik
Admin fixes
|
13
|
* @property string $robots
|
15b8e84d
Yarik
Different Seo tasks
|
14
15
16
|
* @property string $ga_code
* @property string $ya_code
* @property string $tag_manager
|
9af79e71
Yarik
Sitemap and slugb...
|
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
* @property string $phone
* @property string $phone2
* @property string $skype
* @property string $email
* @property string $house
* @property string $street
* @property string $office
* @property string $city
* @property string $country
* @property float $lat
* @property float $lon
* @property string $facebook
* @property string $vk
* @property string $ok
* @property string $google
* @property string $twitter
* @property string name
* @property int $logo
* @property string $about
|
2f3cd090
Yarik
Setting migrate
|
36
37
38
|
*/
class Settings extends ActiveRecord
{
|
3e16e218
Yarik
Admin fixes
|
39
|
const SCENARIO_ROBOTS = 'robots';
|
15b8e84d
Yarik
Different Seo tasks
|
40
|
const SCENARIO_CODES = 'codes';
|
3e16e218
Yarik
Admin fixes
|
41
|
|
3cae1b75
Alexey Boroda
-Analytics almost...
|
42
43
|
private static $instance;
|
2f3cd090
Yarik
Setting migrate
|
44
45
46
|
/**
* @inheritdoc
*/
|
3e16e218
Yarik
Admin fixes
|
47
48
49
50
51
52
|
public function scenarios()
{
return array_merge(
parent::scenarios(),
[
self::SCENARIO_ROBOTS => [ 'robots' ],
|
15b8e84d
Yarik
Different Seo tasks
|
53
54
55
56
57
|
self::SCENARIO_CODES => [
'ga_code',
'ya_code',
'tag_manager',
],
|
3e16e218
Yarik
Admin fixes
|
58
59
60
61
62
63
64
|
]
);
}
/**
* @inheritdoc
*/
|
2f3cd090
Yarik
Setting migrate
|
65
66
67
68
69
|
public function rules()
{
return [
[
[
|
3cae1b75
Alexey Boroda
-Analytics almost...
|
70
|
'analytics_key',
|
3e16e218
Yarik
Admin fixes
|
71
|
'robots',
|
15b8e84d
Yarik
Different Seo tasks
|
72
73
74
|
'ga_code',
'ya_code',
'tag_manager',
|
9af79e71
Yarik
Sitemap and slugb...
|
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
'phone',
'phone2',
'skype',
'email',
'house',
'street',
'office',
'city',
'country',
'facebook',
'vk',
'google',
'twitter',
'name',
'about',
'ok',
|
2f3cd090
Yarik
Setting migrate
|
91
92
93
|
],
'string',
],
|
9af79e71
Yarik
Sitemap and slugb...
|
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
[
[
'lat',
'lon',
],
'double',
],
[
[
'email',
],
'email',
],
[
[
'logo',
],
'integer',
],
[
[
'logo',
],
'exist',
'targetClass' => ImageManager::className(),
'targetAttribute' => 'id',
],
[
[
'logo',
],
'filter',
'filter' => function ($value) {
if (empty( $value )) {
return null;
} else {
return $value;
}
},
],
|
2f3cd090
Yarik
Setting migrate
|
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
];
}
/**
* @inheritdoc
*/
public static function fileName()
{
return 'settings';
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
|
3cae1b75
Alexey Boroda
-Analytics almost...
|
151
|
'analytics_key' => Yii::t('core', 'Google Analytics Key'),
|
3e16e218
Yarik
Admin fixes
|
152
|
'robots' => Yii::t('core', 'Robots'),
|
15b8e84d
Yarik
Different Seo tasks
|
153
154
155
|
'ga_code' => Yii::t('core', 'Google analytics code'),
'ya_code' => Yii::t('core', 'Yandex metrics code'),
'tag_manager' => Yii::t('core', 'Tag Manager code'),
|
9af79e71
Yarik
Sitemap and slugb...
|
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
'phone' => Yii::t('core', 'Phone'),
'phone2' => Yii::t('core', 'Additional phone'),
'skype' => Yii::t('core', 'Skype'),
'name' => Yii::t('core', 'Company name'),
'email' => Yii::t('core', 'Email'),
'house' => Yii::t('core', 'House'),
'street' => Yii::t('core', 'Street'),
'office' => Yii::t('core', 'Office'),
'city' => Yii::t('core', 'City'),
'country' => Yii::t('core', 'Country'),
'lat' => Yii::t('core', 'Latitude'),
'lon' => Yii::t('core', 'Longitude'),
'facebook' => Yii::t('core', 'Facebook'),
'vk' => Yii::t('core', 'VK'),
'google' => Yii::t('core', 'Google'),
'twitter' => Yii::t('core', 'Twitter'),
'logo' => Yii::t('core', 'Company logo'),
'about' => Yii::t('core', 'About us'),
'ok' => Yii::t('core', 'Odnoklassniki'),
|
2f3cd090
Yarik
Setting migrate
|
175
176
|
];
}
|
19296686
Yarik
Page and settings...
|
177
178
179
180
181
182
183
184
185
|
public function afterFind()
{
if ($this->logo === '') {
$this->logo = null;
}
parent::afterFind();
}
|
2f3cd090
Yarik
Setting migrate
|
186
187
188
189
190
191
192
|
/**
* Get Settings model instance
*
* @return Settings
*/
public static function getInstance()
{
|
3e16e218
Yarik
Admin fixes
|
193
|
if (empty( self::$instance )) {
|
3cae1b75
Alexey Boroda
-Analytics almost...
|
194
195
196
197
198
|
self::$instance = self::findOne([ 'id' => 1 ]);
return self::$instance;
}
return self::$instance;
|
2f3cd090
Yarik
Setting migrate
|
199
200
201
|
}
}
|