Commit 6637538fe04ddc776eb32f20688965718a99c5af

Authored by Yarik
1 parent 35af91f6

Preready

frontend/controllers/SiteController.php
1 <?php 1 <?php
2 -namespace frontend\controllers;  
3 -  
4 -use artbox\core\models\Feedback;  
5 -use common\models\Settings;  
6 -use Yii;  
7 -use yii\base\InvalidParamException;  
8 -use yii\web\BadRequestHttpException;  
9 -use yii\web\Controller;  
10 -use yii\filters\VerbFilter;  
11 -use common\models\LoginForm;  
12 -use frontend\models\PasswordResetRequestForm;  
13 -use frontend\models\ResetPasswordForm;  
14 -use frontend\models\SignupForm;  
15 -use yii\web\Response;  
16 -  
17 -/**  
18 - * Site controller  
19 - */  
20 -class SiteController extends Controller  
21 -{  
22 - /**  
23 - * @inheritdoc  
24 - */  
25 - public function actions()  
26 - {  
27 - return [  
28 - 'error' => [  
29 - 'class' => 'yii\web\ErrorAction',  
30 - ],  
31 - ];  
32 - }  
33 -  
34 - /**  
35 - * @inheritdoc  
36 - */  
37 - public function behaviors()  
38 - {  
39 - return [  
40 - 'verbs' => [  
41 - 'class' => VerbFilter::className(),  
42 - 'actions' => [  
43 - 'feedback' => [ 'post' ],  
44 - ],  
45 - ],  
46 - ];  
47 - }  
48 -  
49 - /**  
50 - * Displays homepage.  
51 - *  
52 - * @return mixed  
53 - */  
54 - public function actionIndex()  
55 - {  
56 - return $this->render('index');  
57 - }  
58 -  
59 - /**  
60 - * Displays contact page.  
61 - *  
62 - * @return mixed  
63 - */  
64 - public function actionContact()  
65 - {  
66 - $contact = new Feedback();  
67 - return $this->render(  
68 - 'contact',  
69 - [  
70 - 'contact' => $contact,  
71 - ]  
72 - );  
73 - } 2 + namespace frontend\controllers;
74 3
75 - /**  
76 - * Displays about page.  
77 - *  
78 - * @return mixed  
79 - */  
80 - public function actionAbout()  
81 - {  
82 - return $this->render('about');  
83 - } 4 + use artbox\core\models\Feedback;
  5 + use common\models\Settings;
  6 + use Yii;
  7 + use yii\web\BadRequestHttpException;
  8 + use yii\web\Controller;
  9 + use yii\filters\VerbFilter;
  10 + use yii\web\Response;
84 11
85 /** 12 /**
86 - * Action to view robots.txt file dinamycli  
87 - *  
88 - * @return string 13 + * Site controller
89 */ 14 */
90 - public function actionRobots() 15 + class SiteController extends Controller
91 { 16 {
92 - $response = \Yii::$app->response;  
93 /** 17 /**
94 - * @var Settings $settings 18 + * @inheritdoc
95 */ 19 */
96 - $settings = Settings::find()  
97 - ->one();  
98 - $temp = tmpfile();  
99 - fwrite($temp, $settings->robots);  
100 - $meta = stream_get_meta_data($temp);  
101 - $response->format = $response::FORMAT_RAW;  
102 - $response->headers->set('Content-Type', 'text/plain');  
103 - return $this->renderFile($meta[ 'uri' ]);  
104 - }  
105 -  
106 - public function actionFeedback()  
107 - {  
108 - Yii::$app->response->format = Response::FORMAT_JSON;  
109 - if (empty(Yii::$app->request->post())) {  
110 - throw new BadRequestHttpException();  
111 - } else {  
112 - $model = new Feedback();  
113 - if ($model->load(Yii::$app->request->post()) && $model->save()) {  
114 - return [  
115 - 'success' => true,  
116 - 'message' => 'Success message',  
117 - 'alert' => '<div class="alert alert-success"> 20 + public function actions()
  21 + {
  22 + return [
  23 + 'error' => [
  24 + 'class' => 'yii\web\ErrorAction',
  25 + ],
  26 + ];
  27 + }
  28 +
  29 + /**
  30 + * @inheritdoc
  31 + */
  32 + public function behaviors()
  33 + {
  34 + return [
  35 + 'verbs' => [
  36 + 'class' => VerbFilter::className(),
  37 + 'actions' => [
  38 + 'feedback' => [ 'post' ],
  39 + ],
  40 + ],
  41 + ];
  42 + }
  43 +
  44 + /**
  45 + * Displays homepage.
  46 + *
  47 + * @return mixed
  48 + */
  49 + public function actionIndex()
  50 + {
  51 + return $this->render('index');
  52 + }
  53 +
  54 + /**
  55 + * Displays contact page.
  56 + *
  57 + * @return mixed
  58 + */
  59 + public function actionContact()
  60 + {
  61 + $contact = new Feedback();
  62 + return $this->render(
  63 + 'contact',
  64 + [
  65 + 'contact' => $contact,
  66 + ]
  67 + );
  68 + }
  69 +
  70 + /**
  71 + * Displays about page.
  72 + *
  73 + * @return mixed
  74 + */
  75 + public function actionAbout()
  76 + {
  77 + return $this->render('about');
  78 + }
  79 +
  80 + /**
  81 + * Action to view robots.txt file dinamycli
  82 + *
  83 + * @return string
  84 + */
  85 + public function actionRobots()
  86 + {
  87 + $response = \Yii::$app->response;
  88 + /**
  89 + * @var Settings $settings
  90 + */
  91 + $settings = Settings::find()
  92 + ->one();
  93 + $temp = tmpfile();
  94 + fwrite($temp, $settings->robots);
  95 + $meta = stream_get_meta_data($temp);
  96 + $response->format = $response::FORMAT_RAW;
  97 + $response->headers->set('Content-Type', 'text/plain');
  98 + return $this->renderFile($meta[ 'uri' ]);
  99 + }
  100 +
  101 + public function actionFeedback()
  102 + {
  103 + Yii::$app->response->format = Response::FORMAT_JSON;
  104 + if (empty( Yii::$app->request->post() )) {
  105 + throw new BadRequestHttpException();
  106 + } else {
  107 + $model = new Feedback();
  108 + if ($model->load(Yii::$app->request->post()) && $model->save()) {
  109 + return [
  110 + 'success' => true,
  111 + 'message' => 'Success message',
  112 + 'alert' => '<div class="alert alert-success">
118 <h3>Success</h3> 113 <h3>Success</h3>
119 <p> 114 <p>
120 Success text 115 Success text
121 </p> 116 </p>
122 </div>', 117 </div>',
123 - ];  
124 - } else {  
125 - return [  
126 - 'success' => false,  
127 - 'error' => $model->errors,  
128 - ]; 118 + ];
  119 + } else {
  120 + return [
  121 + 'success' => false,
  122 + 'error' => $model->errors,
  123 + ];
  124 + }
129 } 125 }
130 } 126 }
131 } 127 }
132 -}  
frontend/views/site/about.php
1 <?php 1 <?php
  2 + use artbox\core\components\SeoComponent;
2 use yii\web\View; 3 use yii\web\View;
3 4
4 /** 5 /**
5 * @var View $this 6 * @var View $this
6 */ 7 */
  8 + /**
  9 + * @var SeoComponent $seo
  10 + */
  11 + $seo = \Yii::$app->get('seo');
  12 + $this->params[ 'breadcrumbs' ][] = $seo->title;
7 ?> 13 ?>
8 <div class="container"> 14 <div class="container">
9 <section> 15 <section>
frontend/views/site/contact.php
@@ -15,7 +15,7 @@ @@ -15,7 +15,7 @@
15 MapAsset::register($this); 15 MapAsset::register($this);
16 $settings = Settings::getInstance(); 16 $settings = Settings::getInstance();
17 17
18 - $this->title = 'Contact'; 18 + $this->title = \Yii::t('app', 'Contact');
19 $this->params[ 'breadcrumbs' ][] = $this->title; 19 $this->params[ 'breadcrumbs' ][] = $this->title;
20 20
21 $js = <<< JS 21 $js = <<< JS
@@ -27,141 +27,171 @@ JS; @@ -27,141 +27,171 @@ JS;
27 ?> 27 ?>
28 28
29 <div id="content"> 29 <div id="content">
30 - <div class="container" id="contact">  
31 -  
32 - <section>  
33 -  
34 - <div class="row">  
35 - <div class="col-md-12">  
36 - <section>  
37 - <div class="heading">  
38 - <h2>We are here to help you</h2>  
39 - </div>  
40 -  
41 - <p class="lead">Are you curious about something? Do you have some kind of problem with our products? As am hastily invited settled at limited civilly fortune me. Really spring in extent an by. Judge but built gay party world. Of so am  
42 - he remember although required. Bachelor unpacked be advanced at. Confined in declared marianne is vicinity.</p>  
43 - <p>Please feel free to contact us, our customer service center is working for you 24/7.</p>  
44 - </section>  
45 - </div>  
46 - </div>  
47 -  
48 - </section>  
49 -  
50 - <section>  
51 -  
52 - <div class="row">  
53 - <div class="col-md-4">  
54 - <div class="box-simple">  
55 - <div class="icon">  
56 - <i class="fa fa-map-marker"></i>  
57 - </div>  
58 - <h3>Address</h3>  
59 - <p>13/25 New Avenue  
60 - <br>New Heaven, 45Y 73J  
61 - <br>England, <strong>Great Britain</strong>  
62 - </p>  
63 - </div>  
64 - <!-- /.box-simple -->  
65 - </div>  
66 - 30 + <div class="container" id="contact">
67 31
68 - <div class="col-md-4">  
69 -  
70 - <div class="box-simple">  
71 - <div class="icon">  
72 - <i class="fa fa-phone"></i> 32 + <section>
  33 +
  34 + <div class="row">
  35 + <div class="col-md-12">
  36 + <section>
  37 + <div class="heading">
  38 + <h2>We are here to help you</h2>
  39 + </div>
  40 +
  41 + <p class="lead">Are you curious about something? Do you have some kind of problem with our products? As am hastily invited settled at limited civilly fortune me. Really spring in extent an by. Judge but built gay party world. Of so am
  42 + he remember although required. Bachelor unpacked be advanced at. Confined in declared marianne is vicinity.</p>
  43 + <p>Please feel free to contact us, our customer service center is working for you 24/7.</p>
  44 + </section>
  45 + </div>
73 </div> 46 </div>
74 - <h3>Call center</h3>  
75 - <p class="text-muted">This number is toll free if calling from Great Britain otherwise we advise you to use the electronic form of communication.</p>  
76 - <p><strong>+33 555 444 333</strong>  
77 - </p>  
78 - </div>  
79 - <!-- /.box-simple -->  
80 47
81 - </div>  
82 -  
83 - <div class="col-md-4">  
84 -  
85 - <div class="box-simple">  
86 - <div class="icon">  
87 - <i class="fa fa-envelope"></i> 48 + </section>
  49 + <section>
  50 +
  51 + <div class="row">
  52 + <div class="col-md-4">
  53 + <div class="box-simple">
  54 + <div class="icon">
  55 + <i class="fa fa-map-marker"></i>
  56 + </div>
  57 + <h3>Address</h3>
  58 + <p>
  59 + <?php
  60 + if (!empty( $settings->street )) {
  61 + echo $settings->street;
  62 + if (!empty( $settings->house )) {
  63 + echo " " . $settings->house;
  64 + }
  65 + echo Html::tag('br');
  66 + }
  67 + if (!empty( $settings->city )) {
  68 + echo $settings->city;
  69 + if (!empty( $settings->country )) {
  70 + echo Html::tag('strong', ", " . $settings->country);
  71 + }
  72 + }
  73 + ?>
  74 + </p>
  75 + </div>
  76 + <!-- /.box - simple-->
  77 + </div>
  78 +
  79 +
  80 + <div class="col-md-4">
  81 + <?php
  82 + if (!empty( $settings->phone )) {
  83 + ?>
  84 + <div class="box-simple">
  85 + <div class="icon">
  86 + <i class="fa fa-phone"></i>
  87 + </div>
  88 + <h3> Call center </h3>
  89 + <p class="text-muted"> This number is toll free if calling from Great Britain otherwise we advise you to use the electronic form of communication .</p>
  90 + <p>
  91 + <?php
  92 + echo Html::a(Html::tag('strong', $settings->phone), 'tel:' . $settings->phone);
  93 + ?>
  94 + </p>
  95 + </div>
  96 + <!-- /.box - simple-->
  97 + <?php
  98 + }
  99 + ?>
  100 + </div>
  101 +
  102 + <?php
  103 + if (!empty( $settings->email )) {
  104 + ?>
  105 + <div class="col-md-4">
  106 +
  107 + <div class="box-simple">
  108 + <div class="icon">
  109 + <i class="fa fa-envelope"></i>
  110 + </div>
  111 + <h3> Electronic support </h3>
  112 + <p class="text-muted"> Please feel free to write an email to us or to use our electronic ticketing system .</p>
  113 + <ul class="list-style-none">
  114 + <li>
  115 + <?php
  116 + echo Html::a(
  117 + Html::tag('strong', $settings->email),
  118 + 'mailto:' . $settings->email
  119 + );
  120 + ?>
  121 + </li>
  122 + </ul>
  123 + </div>
  124 + <!-- /.box - simple-->
  125 + </div>
  126 + <?php
  127 + }
  128 + ?>
88 </div> 129 </div>
89 - <h3>Electronic support</h3>  
90 - <p class="text-muted">Please feel free to write an email to us or to use our electronic ticketing system.</p>  
91 - <ul class="list-style-none">  
92 - <li><strong><a href="mailto:">info@fakeemail.com</a></strong>  
93 - </li>  
94 - <li><strong><a href="#">Ticketio</a></strong> - our ticketing support platform</li>  
95 - </ul>  
96 - </div>  
97 - <!-- /.box-simple -->  
98 - </div>  
99 - </div>  
100 -  
101 - </section>  
102 -  
103 - <section>  
104 -  
105 - <div class="row text-center">  
106 130
107 - <div class="col-md-12">  
108 - <div class="heading">  
109 - <h2>Contact form</h2>  
110 - </div>  
111 - </div> 131 + </section>
112 132
113 - <div class="col-md-8 col-md-offset-2">  
114 - <?php $form = ActiveForm::begin(  
115 - [  
116 - 'id' => 'contact-form',  
117 - 'method' => 'POST',  
118 - 'action' => '/site/feedback',  
119 - ]  
120 - ); ?>  
121 - <div class="row">  
122 - <div class="col-sm-12">  
123 - <?= $form->field($contact, 'name')  
124 - ->textInput(); ?>  
125 - </div>  
126 -  
127 - <div class="col-sm-6">  
128 - <?= $form->field($contact, 'email')  
129 - ->textInput(); ?>  
130 - </div>  
131 - <div class="col-sm-6">  
132 - <?= $form->field($contact, 'phone')  
133 - ->textInput(); ?>  
134 - </div>  
135 - <div class="col-sm-12">  
136 - <?= $form->field($contact, 'message')  
137 - ->textarea(  
138 - [  
139 - 'rows' => 3,  
140 - ]  
141 - ); ?>  
142 - </div>  
143 -  
144 - <div class="col-sm-12 text-center">  
145 - <?= Html::submitButton(  
146 - '<i class="fa fa-envelope-o"></i> Send message',  
147 - [  
148 - 'class' => 'btn btn-template-main',  
149 - ]  
150 - ) ?> 133 + <section>
151 134
  135 + <div class="row text-center">
  136 +
  137 + <div class="col-md-12">
  138 + <div class="heading">
  139 + <h2> Contact form </h2>
  140 + </div>
  141 + </div>
  142 +
  143 + <div class="col-md-8 col-md-offset-2">
  144 + <?php $form = ActiveForm::begin(
  145 + [
  146 + 'id' => 'contact-form',
  147 + 'method' => 'POST',
  148 + 'action' => '/site/feedback',
  149 + ]
  150 + ); ?>
  151 + <div class="row">
  152 + <div class="col-sm-12">
  153 + <?= $form->field($contact, 'name')
  154 + ->textInput(); ?>
  155 + </div>
  156 +
  157 + <div class="col-sm-6">
  158 + <?= $form->field($contact, 'email')
  159 + ->textInput(); ?>
  160 + </div>
  161 + <div class="col-sm-6">
  162 + <?= $form->field($contact, 'phone')
  163 + ->textInput(); ?>
  164 + </div>
  165 + <div class="col-sm-12">
  166 + <?= $form->field($contact, 'message')
  167 + ->textarea(
  168 + [
  169 + 'rows' => 3,
  170 + ]
  171 + ); ?>
  172 + </div>
  173 +
  174 + <div class="col-sm-12 text-center">
  175 + <?= Html::submitButton(
  176 + '<i class="fa fa-envelope-o"></i> Send message',
  177 + [
  178 + 'class' => 'btn btn-template-main',
  179 + ]
  180 + ) ?>
  181 +
  182 + </div>
  183 + </div>
  184 + <!-- /.row -->
  185 + <?php ActiveForm::end(); ?>
  186 + </div>
152 </div> 187 </div>
153 - </div>  
154 - <!-- /.row -->  
155 - <?php ActiveForm::end(); ?>  
156 - </div>  
157 - </div>  
158 - <!-- /.row --> 188 + <!-- /.row -->
  189 +
  190 + </section>
  191 +
159 192
160 - </section>  
161 -  
162 -  
163 - </div>  
164 - <!-- /#contact.container --> 193 + </div>
  194 + <!-- /#contact.container -->
165 </div> 195 </div>
166 <!-- /#content --> 196 <!-- /#content -->
167 197