|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace modules\main\controllers\frontend; |
|
4
|
|
|
|
|
5
|
|
|
use Yii; |
|
6
|
|
|
use yii\web\Controller; |
|
7
|
|
|
use modules\main\models\frontend\ContactForm; |
|
8
|
|
|
use modules\main\Module; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Class DefaultController |
|
12
|
|
|
* @package modules\main\controllers\frontend |
|
13
|
|
|
*/ |
|
14
|
|
|
class DefaultController extends Controller |
|
15
|
|
|
{ |
|
16
|
|
|
/** |
|
17
|
|
|
* @inheritdoc |
|
18
|
|
|
* @return array |
|
19
|
|
|
*/ |
|
20
|
|
|
public function actions() |
|
21
|
|
|
{ |
|
22
|
|
|
return [ |
|
23
|
|
|
'error' => [ |
|
24
|
|
|
'class' => 'yii\web\ErrorAction', |
|
25
|
|
|
], |
|
26
|
|
|
'captcha' => [ |
|
27
|
|
|
'class' => 'yii\captcha\CaptchaAction', |
|
28
|
|
|
'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null, |
|
29
|
|
|
'backColor' => 0xF1F1F1, |
|
30
|
|
|
'foreColor' => 0xEE7600, |
|
31
|
|
|
], |
|
32
|
|
|
]; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Renders the index view for the module |
|
37
|
|
|
* @return string |
|
38
|
|
|
*/ |
|
39
|
|
|
public function actionIndex() |
|
40
|
|
|
{ |
|
41
|
|
|
return $this->render('index'); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Displays contact page. |
|
46
|
|
|
* |
|
47
|
|
|
* @return mixed|\yii\web\Response |
|
48
|
|
|
*/ |
|
49
|
|
|
public function actionContact() |
|
50
|
|
|
{ |
|
51
|
|
|
$model = new ContactForm(); |
|
52
|
|
|
if (Yii::$app->user->isGuest) |
|
53
|
|
|
$model->scenario = $model::SCENARIO_GUEST; |
|
54
|
|
|
|
|
55
|
|
|
if ($model->load(Yii::$app->request->post()) && $model->validate()) { |
|
56
|
|
|
return $this->processSendEmail($model); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
return $this->render('contact', [ |
|
60
|
|
|
'model' => $model, |
|
61
|
|
|
]); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @param ContactForm $model |
|
66
|
|
|
* @return \yii\web\Response |
|
67
|
|
|
*/ |
|
68
|
|
|
protected function processSendEmail($model) |
|
69
|
|
|
{ |
|
70
|
|
|
if ($model->sendEmail(Yii::$app->params['adminEmail'])) { |
|
71
|
|
|
Yii::$app->session->setFlash('success', Module::t('module', 'Thank you for contacting us. We will respond to you as soon as possible.')); |
|
72
|
|
|
} else { |
|
73
|
|
|
Yii::$app->session->setFlash('error', Module::t('module', 'There was an error sending email.')); |
|
74
|
|
|
} |
|
75
|
|
|
return $this->refresh(); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* Displays about page. |
|
80
|
|
|
* |
|
81
|
|
|
* @return mixed |
|
82
|
|
|
*/ |
|
83
|
|
|
public function actionAbout() |
|
84
|
|
|
{ |
|
85
|
|
|
return $this->render('about'); |
|
86
|
|
|
} |
|
87
|
|
|
} |
|
88
|
|
|
|