06692811
Eugeny Galkovskiy
first commit
|
1
|
<?php
|
f62062ac
mzavalniuk
added legal-form
|
2
|
|
16a2d769
Alexey Boroda
-Main page SEO
|
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
namespace frontend\controllers;
use artbox\core\models\Alias;
use artbox\core\models\Language;
use artbox\core\models\Page;
use common\models\Feedback;
use common\models\Settings;
use common\models\Slider;
use Yii;
use yii\filters\VerbFilter;
use yii\swiftmailer\Mailer;
use yii\web\BadRequestHttpException;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\web\Response;
use common\models\Objectkb;
/**
* Site controller
*/
class SiteController extends Controller
{
|
06692811
Eugeny Galkovskiy
first commit
|
25
|
/**
|
16a2d769
Alexey Boroda
-Main page SEO
|
26
|
* @inheritdoc
|
06692811
Eugeny Galkovskiy
first commit
|
27
|
*/
|
16a2d769
Alexey Boroda
-Main page SEO
|
28
|
public function actions()
|
06692811
Eugeny Galkovskiy
first commit
|
29
|
{
|
16a2d769
Alexey Boroda
-Main page SEO
|
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
return [
'error' => [
'class' => 'yii\web\ErrorAction',
],
];
}
/**
* @inheritdoc
*/
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'feedback' => ['post'],
|
06692811
Eugeny Galkovskiy
first commit
|
47
|
],
|
16a2d769
Alexey Boroda
-Main page SEO
|
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
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
|
],
];
}
/**
* Displays homepage.
*
* @return mixed
*/
public function actionIndex()
{
$slider = Slider::find()
->with("slides.lang.image")
->where(['on_home_page' => true])
->one();
$objects = Objectkb::find()
->with('lang.alias')
->where(
[
'id' => [
7,
37,
38,
43,
],
]
)
->orderBy('id')
->all();
$alias = Alias::find()
->where(
[
'language_id' => Language::getCurrent()->id,
'route' => '{"0":"site/index"}',
]
)
->one();
return $this->render(
'index',
[
'slider' => $slider,
'objects' => $objects,
'alias' => $alias,
]
);
}
/**
* Displays contact page.
*
* @return mixed
*/
public function actionContact()
{
$contact = new Feedback();
return $this->render(
'contact',
[
'contact' => $contact,
]
);
}
/**
* Displays about page.
*
* @return mixed
*/
public function actionAbout()
{
$page = Page::find()
->with('lang')
->where(['id' => 3])
->one();
if ($page) {
|
cf67df18
Timur Kastemirov
карусель
|
129
|
return $this->render(
|
16a2d769
Alexey Boroda
-Main page SEO
|
130
|
'about',
|
cf67df18
Timur Kastemirov
карусель
|
131
|
[
|
16a2d769
Alexey Boroda
-Main page SEO
|
132
|
'page' => $page,
|
cf67df18
Timur Kastemirov
карусель
|
133
134
|
]
);
|
16a2d769
Alexey Boroda
-Main page SEO
|
135
136
137
|
} else {
throw new NotFoundHttpException();
|
06692811
Eugeny Galkovskiy
first commit
|
138
|
}
|
16a2d769
Alexey Boroda
-Main page SEO
|
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
|
}
public function actionIndividual()
{
$idsArray = [
25,
37,
12,
42,
];
$objects = Objectkb::find()
->with('lang.alias')
->where(
[
'id' => $idsArray,
]
)
->indexBy('id')
->all();
return $this->render(
'individual',
[
'objects' => $objects,
'idsArray' => $idsArray,
]
);
} // частное лицо
public function actionLegal()
{
$legal = new Feedback();
return $this->render(
'legal',
[
'legal' => $legal,
]
);
} // юридическое
public function actionMediaAbout()
{
return $this->render('media-about');
} // СМИ о нас
/**
* Action to view robots.txt file dinamycli
*
* @return string
*/
public function actionRobots()
{
$response = \Yii::$app->response;
|
06692811
Eugeny Galkovskiy
first commit
|
196
|
/**
|
16a2d769
Alexey Boroda
-Main page SEO
|
197
|
* @var Settings $settings
|
06692811
Eugeny Galkovskiy
first commit
|
198
|
*/
|
16a2d769
Alexey Boroda
-Main page SEO
|
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
|
$settings = Settings::find()
->one();
$temp = tmpfile();
fwrite($temp, $settings->robots);
$meta = stream_get_meta_data($temp);
$response->format = $response::FORMAT_RAW;
$response->headers->set('Content-Type', 'text/plain');
return $this->renderFile($meta[ 'uri' ]);
}
public function actionFeedback()
{
Yii::$app->response->format = Response::FORMAT_JSON;
|
06692811
Eugeny Galkovskiy
first commit
|
215
|
/**
|
16a2d769
Alexey Boroda
-Main page SEO
|
216
|
* @var Mailer $mailer
|
06692811
Eugeny Galkovskiy
first commit
|
217
|
*/
|
16a2d769
Alexey Boroda
-Main page SEO
|
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
|
$mailer = \Yii::$app->get('smtpmailer');
$settings = Settings::getInstance();
if (empty(Yii::$app->request->post())) {
throw new BadRequestHttpException();
} else {
$post = Yii::$app->request->post('Feedback');
switch ($post[ 'topic' ]) {
case Feedback::SCENARIO_FEEDBACK :
$model = new Feedback(['scenario' => Feedback::SCENARIO_FEEDBACK]);
$view = 'feedback';
$isLoaded = $model->load(Yii::$app->request->post());
break;
case Feedback::SCENARIO_CALLBACK :
$model = new Feedback(['scenario' => Feedback::SCENARIO_CALLBACK]);
$view = 'feedback';
$isLoaded = $model->load(Yii::$app->request->post());
break;
case Feedback::SCENARIO_CALCULATOR:
$model = new Feedback(['scenario' => Feedback::SCENARIO_CALCULATOR]);
$view = 'calculator';
$isLoaded = $model->load(Yii::$app->request->post());
$model->setCalcJsonInfo();
break;
case Feedback::SCENARIO_LEGAL_FEEDBACK:
$model = new Feedback(['scenario' => Feedback::SCENARIO_LEGAL_FEEDBACK]);
$view = 'legalfeedback';
$isLoaded = $model->load(Yii::$app->request->post());
$email = 'haichenko_ky@kbenergy.com.ua';
$model->setCalcJsonInfo();
break;
default:
$model = new Feedback();
$view = 'feedback';
$isLoaded = $model->load(Yii::$app->request->post());
|
a6fd2619
Eugeny Galkovskiy
правки
|
259
|
}
|
16a2d769
Alexey Boroda
-Main page SEO
|
260
261
262
263
264
|
if ($isLoaded && $model->save()) {
$mailer->compose(
$view,
|
45dc5d70
Eugeny Galkovskiy
individual page
|
265
|
[
|
16a2d769
Alexey Boroda
-Main page SEO
|
266
|
'model' => $model,
|
45dc5d70
Eugeny Galkovskiy
individual page
|
267
268
|
]
)
|
16a2d769
Alexey Boroda
-Main page SEO
|
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
|
->setFrom(['artbox@domain.com'])
->setTo(
[
!empty($email) ? $email : $settings->email,
]
)
->setSubject(\Yii::t('app', 'Feedback'))
->send();
return [
'success' => true,
'message' => 'Success message',
'view' => $view,
'model' => $model->attributeValues,
'alert' => $this->renderPartial('success_alert'),
];
|
06692811
Eugeny Galkovskiy
first commit
|
285
|
} else {
|
16a2d769
Alexey Boroda
-Main page SEO
|
286
287
288
289
290
291
|
Yii::$app->response->setStatusCode(500);
return [
'success' => false,
'error' => $model->errors,
];
|
06692811
Eugeny Galkovskiy
first commit
|
292
293
294
|
}
}
}
|
16a2d769
Alexey Boroda
-Main page SEO
|
295
|
}
|