2013-05-24 10:14:49 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace app\controllers;
|
|
|
|
|
|
|
|
use Yii;
|
2014-04-05 01:00:14 -04:00
|
|
|
use yii\filters\AccessControl;
|
2013-05-24 10:14:49 -04:00
|
|
|
use yii\web\Controller;
|
2014-04-05 01:00:14 -04:00
|
|
|
use yii\filters\VerbFilter;
|
2013-05-24 10:14:49 -04:00
|
|
|
use app\models\LoginForm;
|
|
|
|
use app\models\ContactForm;
|
|
|
|
|
|
|
|
class SiteController extends Controller
|
|
|
|
{
|
2014-03-16 10:46:16 +06:00
|
|
|
public function behaviors()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'access' => [
|
|
|
|
'class' => AccessControl::className(),
|
|
|
|
'only' => ['logout'],
|
|
|
|
'rules' => [
|
|
|
|
[
|
|
|
|
'actions' => ['logout'],
|
|
|
|
'allow' => true,
|
|
|
|
'roles' => ['@'],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'verbs' => [
|
|
|
|
'class' => VerbFilter::className(),
|
|
|
|
'actions' => [
|
|
|
|
'logout' => ['post'],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
];
|
|
|
|
}
|
2013-09-16 02:41:19 +04:00
|
|
|
|
2014-03-16 10:46:16 +06:00
|
|
|
public function actions()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'error' => [
|
|
|
|
'class' => 'yii\web\ErrorAction',
|
|
|
|
],
|
|
|
|
'captcha' => [
|
|
|
|
'class' => 'yii\captcha\CaptchaAction',
|
|
|
|
'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
|
|
|
|
],
|
|
|
|
];
|
|
|
|
}
|
2013-05-24 10:14:49 -04:00
|
|
|
|
2014-03-16 10:46:16 +06:00
|
|
|
public function actionIndex()
|
|
|
|
{
|
|
|
|
return $this->render('index');
|
|
|
|
}
|
2013-05-24 10:14:49 -04:00
|
|
|
|
2014-03-16 10:46:16 +06:00
|
|
|
public function actionLogin()
|
|
|
|
{
|
|
|
|
if (!\Yii::$app->user->isGuest) {
|
|
|
|
return $this->goHome();
|
|
|
|
}
|
2013-11-07 01:19:36 +04:00
|
|
|
|
2014-03-16 10:46:16 +06:00
|
|
|
$model = new LoginForm();
|
|
|
|
if ($model->load(Yii::$app->request->post()) && $model->login()) {
|
|
|
|
return $this->goBack();
|
|
|
|
} else {
|
|
|
|
return $this->render('login', [
|
|
|
|
'model' => $model,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
2013-05-24 10:14:49 -04:00
|
|
|
|
2014-03-16 10:46:16 +06:00
|
|
|
public function actionLogout()
|
|
|
|
{
|
|
|
|
Yii::$app->user->logout();
|
2013-05-24 10:14:49 -04:00
|
|
|
|
2014-03-16 10:46:16 +06:00
|
|
|
return $this->goHome();
|
|
|
|
}
|
2013-05-24 10:14:49 -04:00
|
|
|
|
2014-03-16 10:46:16 +06:00
|
|
|
public function actionContact()
|
|
|
|
{
|
|
|
|
$model = new ContactForm();
|
|
|
|
if ($model->load(Yii::$app->request->post()) && $model->contact(Yii::$app->params['adminEmail'])) {
|
|
|
|
Yii::$app->session->setFlash('contactFormSubmitted');
|
|
|
|
|
|
|
|
return $this->refresh();
|
|
|
|
} else {
|
|
|
|
return $this->render('contact', [
|
|
|
|
'model' => $model,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function actionAbout()
|
|
|
|
{
|
|
|
|
return $this->render('about');
|
|
|
|
}
|
2014-02-16 03:14:28 +01:00
|
|
|
}
|