1755c393
Yarik
Basic template in...
|
1
|
<?php
|
543b9b1c
Yarik
Composer ready
|
2
|
namespace backend\controllers;
|
3cae1b75
Alexey Boroda
-Analytics almost...
|
3
|
|
3cae1b75
Alexey Boroda
-Analytics almost...
|
4
|
use common\models\Settings;
|
543b9b1c
Yarik
Composer ready
|
5
6
7
8
9
|
use Yii;
use yii\web\Controller;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
use common\models\LoginForm;
|
6b69a279
Alexey Boroda
-GA js ready
|
10
|
|
1755c393
Yarik
Basic template in...
|
11
|
/**
|
543b9b1c
Yarik
Composer ready
|
12
|
* Site controller
|
1755c393
Yarik
Basic template in...
|
13
|
*/
|
543b9b1c
Yarik
Composer ready
|
14
|
class SiteController extends Controller
|
1755c393
Yarik
Basic template in...
|
15
|
{
|
543b9b1c
Yarik
Composer ready
|
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
/**
* @inheritdoc
*/
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::className(),
'rules' => [
[
'actions' => [
'login',
'error',
],
'allow' => true,
],
[
'actions' => [
'logout',
'index',
|
6b69a279
Alexey Boroda
-GA js ready
|
36
|
'analytics',
|
543b9b1c
Yarik
Composer ready
|
37
38
39
|
],
'allow' => true,
'roles' => [ '@' ],
|
0bdfedea
Alexey Boroda
-Analytics started
|
40
|
],
|
1755c393
Yarik
Basic template in...
|
41
42
|
],
],
|
543b9b1c
Yarik
Composer ready
|
43
44
45
|
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
|
6b69a279
Alexey Boroda
-GA js ready
|
46
47
|
'logout' => [ 'post' ],
'analytics' => [ 'post' ],
|
543b9b1c
Yarik
Composer ready
|
48
|
],
|
1755c393
Yarik
Basic template in...
|
49
|
],
|
543b9b1c
Yarik
Composer ready
|
50
51
|
];
}
|
3cae1b75
Alexey Boroda
-Analytics almost...
|
52
|
|
543b9b1c
Yarik
Composer ready
|
53
54
55
56
57
58
59
60
61
62
63
|
/**
* @inheritdoc
*/
public function actions()
{
return [
'error' => [
'class' => 'yii\web\ErrorAction',
],
];
}
|
3cae1b75
Alexey Boroda
-Analytics almost...
|
64
|
|
543b9b1c
Yarik
Composer ready
|
65
66
67
68
69
70
71
|
/**
* Displays homepage.
*
* @return string
*/
public function actionIndex()
{
|
198ca6c0
Alexey Boroda
-Animations ready...
|
72
73
74
75
76
77
78
|
$settings = Settings::getInstance();
if (empty($settings->analytics_key)) {
return $this->render('instruction');
} else {
return $this->render('index');
}
|
3cae1b75
Alexey Boroda
-Analytics almost...
|
79
80
|
}
|
543b9b1c
Yarik
Composer ready
|
81
82
83
84
85
86
87
88
89
90
|
/**
* Login action.
*
* @return string
*/
public function actionLogin()
{
if (!Yii::$app->user->isGuest) {
return $this->goHome();
}
|
5e021d7a
Alexey Boroda
-Tabs for analyti...
|
91
|
|
543b9b1c
Yarik
Composer ready
|
92
93
94
95
96
97
98
99
100
101
102
103
|
$model = new LoginForm();
if ($model->load(Yii::$app->request->post()) && $model->login()) {
return $this->goBack();
} else {
return $this->renderPartial(
'login',
[
'model' => $model,
]
);
}
}
|
3cae1b75
Alexey Boroda
-Analytics almost...
|
104
|
|
543b9b1c
Yarik
Composer ready
|
105
106
107
108
109
110
111
112
|
/**
* Logout action.
*
* @return string
*/
public function actionLogout()
{
Yii::$app->user->logout();
|
5e021d7a
Alexey Boroda
-Tabs for analyti...
|
113
|
|
1755c393
Yarik
Basic template in...
|
114
115
|
return $this->goHome();
}
|
1755c393
Yarik
Basic template in...
|
116
|
}
|