diff --git a/frontend/assets/AppAsset.php b/frontend/assets/AppAsset.php index fb502d3..43e0171 100644 --- a/frontend/assets/AppAsset.php +++ b/frontend/assets/AppAsset.php @@ -15,11 +15,11 @@ 'css/site.css', 'css/animate.css', 'css/style.css', - 'css/custom.css', 'css/style.default.css', 'css/owl.carousel.css', 'css/owl.theme.css', '//fonts.googleapis.com/css?family=Roboto:400,100,100italic,300,300italic,500,700,800', + 'css/custom.css', ]; public $js = [ 'js/jquery.cookie.js', @@ -28,6 +28,7 @@ 'js/jquery.parallax-1.1.3.js', 'js/front.js', 'js/owl.carousel.min.js', + 'js/script.js', ]; public $depends = [ 'yii\web\YiiAsset', diff --git a/frontend/assets/MapAsset.php b/frontend/assets/MapAsset.php new file mode 100644 index 0000000..03bc41b --- /dev/null +++ b/frontend/assets/MapAsset.php @@ -0,0 +1,25 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'feedback' => [ 'post' ], + ], + ], + ]; + } + /** * Displays homepage. * @@ -40,7 +55,7 @@ class SiteController extends Controller { return $this->render('index'); } - + /** * Logs in a user. * @@ -51,7 +66,7 @@ class SiteController extends Controller if (!Yii::$app->user->isGuest) { return $this->goHome(); } - + $model = new LoginForm(); if ($model->load(Yii::$app->request->post()) && $model->login()) { return $this->goBack(); @@ -61,7 +76,7 @@ class SiteController extends Controller ]); } } - + /** * Logs out the current user. * @@ -70,10 +85,10 @@ class SiteController extends Controller public function actionLogout() { Yii::$app->user->logout(); - + return $this->goHome(); } - + /** * Displays contact page. * @@ -81,22 +96,15 @@ class SiteController extends Controller */ public function actionContact() { - $model = new ContactForm(); - if ($model->load(Yii::$app->request->post()) && $model->validate()) { - if ($model->sendEmail(Yii::$app->params['adminEmail'])) { - Yii::$app->session->setFlash('success', 'Thank you for contacting us. We will respond to you as soon as possible.'); - } else { - Yii::$app->session->setFlash('error', 'There was an error sending your message.'); - } - - return $this->refresh(); - } else { - return $this->render('contact', [ - 'model' => $model, - ]); - } + $contact = new Feedback(); + return $this->render( + 'contact', + [ + 'contact' => $contact, + ] + ); } - + /** * Displays about page. * @@ -106,7 +114,7 @@ class SiteController extends Controller { return $this->render('about'); } - + /** * Signs user up. * @@ -122,12 +130,12 @@ class SiteController extends Controller } } } - + return $this->render('signup', [ 'model' => $model, ]); } - + /** * Requests password reset. * @@ -139,18 +147,18 @@ class SiteController extends Controller if ($model->load(Yii::$app->request->post()) && $model->validate()) { if ($model->sendEmail()) { Yii::$app->session->setFlash('success', 'Check your email for further instructions.'); - + return $this->goHome(); } else { Yii::$app->session->setFlash('error', 'Sorry, we are unable to reset password for the provided email address.'); } } - + return $this->render('requestPasswordResetToken', [ 'model' => $model, ]); } - + /** * Resets password. * @@ -165,18 +173,23 @@ class SiteController extends Controller } catch (InvalidParamException $e) { throw new BadRequestHttpException($e->getMessage()); } - + if ($model->load(Yii::$app->request->post()) && $model->validate() && $model->resetPassword()) { Yii::$app->session->setFlash('success', 'New password saved.'); - + return $this->goHome(); } - + return $this->render('resetPassword', [ 'model' => $model, ]); } + /** + * Action to view robots.txt file dinamycli + * + * @return string + */ public function actionRobots() { $response = \Yii::$app->response; @@ -192,4 +205,25 @@ class SiteController extends Controller $response->headers->set('Content-Type', 'text/plain'); return $this->renderFile($meta[ 'uri' ]); } + + 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', + ]; + } else { + return [ + 'success' => false, + 'error' => $model->errors, + ]; + } + } + } } diff --git a/frontend/views/layouts/main.php b/frontend/views/layouts/main.php index fee6025..fed59a5 100644 --- a/frontend/views/layouts/main.php +++ b/frontend/views/layouts/main.php @@ -7,15 +7,19 @@ */ use artbox\core\components\SeoComponent; + use artbox\core\models\Feedback; use artbox\core\models\User; use frontend\assets\AppAsset; + use yii\bootstrap\ActiveForm; use yii\bootstrap\Nav; use yii\helpers\Html; use yii\web\View; + use yii\widgets\Breadcrumbs; AppAsset::register($this); $user = \Yii::$app->user->identity; $seo = Yii::$app->get('seo'); + $feedback = new Feedback(); ?> beginPage() ?> @@ -61,16 +65,16 @@ _________________________________________________________ --> - + - + - + - + - - - -