1755c393
Yarik
Basic template in...
|
1
|
<?php
|
1755c393
Yarik
Basic template in...
|
2
3
|
namespace frontend\controllers;
|
6748c345
Alexey Boroda
-Forms almost ready
|
4
|
use artbox\core\models\Feedback;
|
15b8e84d
Yarik
Different Seo tasks
|
5
|
use common\models\Settings;
|
1755c393
Yarik
Basic template in...
|
6
7
8
9
10
|
use Yii;
use yii\base\InvalidParamException;
use yii\web\BadRequestHttpException;
use yii\web\Controller;
use yii\filters\VerbFilter;
|
1755c393
Yarik
Basic template in...
|
11
12
13
14
|
use common\models\LoginForm;
use frontend\models\PasswordResetRequestForm;
use frontend\models\ResetPasswordForm;
use frontend\models\SignupForm;
|
6748c345
Alexey Boroda
-Forms almost ready
|
15
|
use yii\web\Response;
|
1755c393
Yarik
Basic template in...
|
16
17
18
19
20
21
22
23
24
|
/**
* Site controller
*/
class SiteController extends Controller
{
/**
* @inheritdoc
*/
|
1755c393
Yarik
Basic template in...
|
25
26
27
28
29
30
|
public function actions()
{
return [
'error' => [
'class' => 'yii\web\ErrorAction',
],
|
1755c393
Yarik
Basic template in...
|
31
32
|
];
}
|
6748c345
Alexey Boroda
-Forms almost ready
|
33
|
|
1755c393
Yarik
Basic template in...
|
34
|
/**
|
6748c345
Alexey Boroda
-Forms almost ready
|
35
|
* @inheritdoc
|
1755c393
Yarik
Basic template in...
|
36
|
*/
|
6748c345
Alexey Boroda
-Forms almost ready
|
37
|
public function behaviors()
|
1755c393
Yarik
Basic template in...
|
38
|
{
|
6748c345
Alexey Boroda
-Forms almost ready
|
39
40
41
42
43
|
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'feedback' => [ 'post' ],
|
69ab7048
Yarik
About page
|
44
|
],
|
6748c345
Alexey Boroda
-Forms almost ready
|
45
46
47
48
|
],
];
}
|
1755c393
Yarik
Basic template in...
|
49
50
51
52
53
54
55
56
57
|
/**
* Displays homepage.
*
* @return mixed
*/
public function actionIndex()
{
return $this->render('index');
}
|
6748c345
Alexey Boroda
-Forms almost ready
|
58
|
|
1755c393
Yarik
Basic template in...
|
59
|
/**
|
1755c393
Yarik
Basic template in...
|
60
61
62
63
64
65
|
* Displays contact page.
*
* @return mixed
*/
public function actionContact()
{
|
6748c345
Alexey Boroda
-Forms almost ready
|
66
67
68
69
70
71
72
|
$contact = new Feedback();
return $this->render(
'contact',
[
'contact' => $contact,
]
);
|
1755c393
Yarik
Basic template in...
|
73
|
}
|
6748c345
Alexey Boroda
-Forms almost ready
|
74
|
|
1755c393
Yarik
Basic template in...
|
75
76
77
78
79
80
81
82
83
|
/**
* Displays about page.
*
* @return mixed
*/
public function actionAbout()
{
return $this->render('about');
}
|
6748c345
Alexey Boroda
-Forms almost ready
|
84
|
|
1755c393
Yarik
Basic template in...
|
85
|
/**
|
6748c345
Alexey Boroda
-Forms almost ready
|
86
87
88
89
|
* Action to view robots.txt file dinamycli
*
* @return string
*/
|
15b8e84d
Yarik
Different Seo tasks
|
90
91
92
|
public function actionRobots()
{
$response = \Yii::$app->response;
|
69ab7048
Yarik
About page
|
93
|
/**
|
15b8e84d
Yarik
Different Seo tasks
|
94
|
* @var Settings $settings
|
69ab7048
Yarik
About page
|
95
|
*/
|
15b8e84d
Yarik
Different Seo tasks
|
96
97
98
99
100
101
102
103
104
|
$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' ]);
}
|
6748c345
Alexey Boroda
-Forms almost ready
|
105
106
107
108
109
110
111
112
113
114
115
116
|
public function actionFeedback()
{
Yii::$app->response->format = Response::FORMAT_JSON;
if (empty(Yii::$app->request->post())) {
throw new BadRequestHttpException();
} else {
$model = new Feedback();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return [
'success' => true,
'message' => 'Success message',
|
83309611
Alexey Boroda
-Map in process
|
117
118
119
120
121
122
|
'alert' => '<div class="alert alert-success">
<h3>Success</h3>
<p>
Success text
</p>
</div>',
|
6748c345
Alexey Boroda
-Forms almost ready
|
123
|
];
|
6748c345
Alexey Boroda
-Forms almost ready
|
124
|
} else {
|
6748c345
Alexey Boroda
-Forms almost ready
|
125
126
127
128
|
return [
'success' => false,
'error' => $model->errors,
];
|
6748c345
Alexey Boroda
-Forms almost ready
|
129
130
131
|
}
}
}
|
1755c393
Yarik
Basic template in...
|
132
|
}
|