Commit 69ab7048575bf10a2789d14b5598a6692990631d
1 parent
6e516b40
About page
Showing
2 changed files
with
332 additions
and
215 deletions
Show diff stats
frontend/controllers/SiteController.php
1 | 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 | - } | |
2 | + namespace frontend\controllers; | |
48 | 3 | |
49 | - /** | |
50 | - * Displays homepage. | |
51 | - * | |
52 | - * @return mixed | |
53 | - */ | |
54 | - public function actionIndex() | |
55 | - { | |
56 | - return $this->render('index'); | |
57 | - } | |
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; | |
58 | 16 | |
59 | 17 | /** |
60 | - * Logs in a user. | |
61 | - * | |
62 | - * @return mixed | |
18 | + * Site controller | |
63 | 19 | */ |
64 | - public function actionLogin() | |
20 | + class SiteController extends Controller | |
65 | 21 | { |
66 | - if (!Yii::$app->user->isGuest) { | |
67 | - return $this->goHome(); | |
22 | + /** | |
23 | + * @inheritdoc | |
24 | + */ | |
25 | + public function actions() | |
26 | + { | |
27 | + return [ | |
28 | + 'error' => [ | |
29 | + 'class' => 'yii\web\ErrorAction', | |
30 | + ], | |
31 | + ]; | |
68 | 32 | } |
69 | 33 | |
70 | - $model = new LoginForm(); | |
71 | - if ($model->load(Yii::$app->request->post()) && $model->login()) { | |
72 | - return $this->goBack(); | |
73 | - } else { | |
74 | - return $this->render('login', [ | |
75 | - 'model' => $model, | |
76 | - ]); | |
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 | + ]; | |
77 | 47 | } |
78 | - } | |
79 | - | |
80 | - /** | |
81 | - * Logs out the current user. | |
82 | - * | |
83 | - * @return mixed | |
84 | - */ | |
85 | - public function actionLogout() | |
86 | - { | |
87 | - Yii::$app->user->logout(); | |
88 | 48 | |
89 | - return $this->goHome(); | |
90 | - } | |
91 | - | |
92 | - /** | |
93 | - * Displays contact page. | |
94 | - * | |
95 | - * @return mixed | |
96 | - */ | |
97 | - public function actionContact() | |
98 | - { | |
99 | - $contact = new Feedback(); | |
100 | - return $this->render( | |
101 | - 'contact', | |
102 | - [ | |
103 | - 'contact' => $contact, | |
104 | - ] | |
105 | - ); | |
106 | - } | |
107 | - | |
108 | - /** | |
109 | - * Displays about page. | |
110 | - * | |
111 | - * @return mixed | |
112 | - */ | |
113 | - public function actionAbout() | |
114 | - { | |
115 | - return $this->render('about'); | |
116 | - } | |
117 | - | |
118 | - /** | |
119 | - * Signs user up. | |
120 | - * | |
121 | - * @return mixed | |
122 | - */ | |
123 | - public function actionSignup() | |
124 | - { | |
125 | - $model = new SignupForm(); | |
126 | - if ($model->load(Yii::$app->request->post())) { | |
127 | - if ($user = $model->signup()) { | |
128 | - if (Yii::$app->getUser()->login($user)) { | |
129 | - return $this->goHome(); | |
130 | - } | |
131 | - } | |
49 | + /** | |
50 | + * Displays homepage. | |
51 | + * | |
52 | + * @return mixed | |
53 | + */ | |
54 | + public function actionIndex() | |
55 | + { | |
56 | + return $this->render('index'); | |
132 | 57 | } |
133 | 58 | |
134 | - return $this->render('signup', [ | |
135 | - 'model' => $model, | |
136 | - ]); | |
137 | - } | |
138 | - | |
139 | - /** | |
140 | - * Requests password reset. | |
141 | - * | |
142 | - * @return mixed | |
143 | - */ | |
144 | - public function actionRequestPasswordReset() | |
145 | - { | |
146 | - $model = new PasswordResetRequestForm(); | |
147 | - if ($model->load(Yii::$app->request->post()) && $model->validate()) { | |
148 | - if ($model->sendEmail()) { | |
149 | - Yii::$app->session->setFlash('success', 'Check your email for further instructions.'); | |
150 | - | |
59 | + /** | |
60 | + * Logs in a user. | |
61 | + * | |
62 | + * @return mixed | |
63 | + */ | |
64 | + public function actionLogin() | |
65 | + { | |
66 | + if (!Yii::$app->user->isGuest) { | |
151 | 67 | return $this->goHome(); |
68 | + } | |
69 | + | |
70 | + $model = new LoginForm(); | |
71 | + if ($model->load(Yii::$app->request->post()) && $model->login()) { | |
72 | + return $this->goBack(); | |
152 | 73 | } else { |
153 | - Yii::$app->session->setFlash('error', 'Sorry, we are unable to reset password for the provided email address.'); | |
74 | + return $this->render( | |
75 | + 'login', | |
76 | + [ | |
77 | + 'model' => $model, | |
78 | + ] | |
79 | + ); | |
154 | 80 | } |
155 | 81 | } |
156 | 82 | |
157 | - return $this->render('requestPasswordResetToken', [ | |
158 | - 'model' => $model, | |
159 | - ]); | |
160 | - } | |
161 | - | |
162 | - /** | |
163 | - * Resets password. | |
164 | - * | |
165 | - * @param string $token | |
166 | - * @return mixed | |
167 | - * @throws BadRequestHttpException | |
168 | - */ | |
169 | - public function actionResetPassword($token) | |
170 | - { | |
171 | - try { | |
172 | - $model = new ResetPasswordForm($token); | |
173 | - } catch (InvalidParamException $e) { | |
174 | - throw new BadRequestHttpException($e->getMessage()); | |
83 | + /** | |
84 | + * Logs out the current user. | |
85 | + * | |
86 | + * @return mixed | |
87 | + */ | |
88 | + public function actionLogout() | |
89 | + { | |
90 | + Yii::$app->user->logout(); | |
91 | + | |
92 | + return $this->goHome(); | |
175 | 93 | } |
176 | 94 | |
177 | - if ($model->load(Yii::$app->request->post()) && $model->validate() && $model->resetPassword()) { | |
178 | - Yii::$app->session->setFlash('success', 'New password saved.'); | |
95 | + /** | |
96 | + * Displays contact page. | |
97 | + * | |
98 | + * @return mixed | |
99 | + */ | |
100 | + public function actionContact() | |
101 | + { | |
102 | + $contact = new Feedback(); | |
103 | + return $this->render( | |
104 | + 'contact', | |
105 | + [ | |
106 | + 'contact' => $contact, | |
107 | + ] | |
108 | + ); | |
109 | + } | |
110 | + | |
111 | + /** | |
112 | + * Displays about page. | |
113 | + * | |
114 | + * @return mixed | |
115 | + */ | |
116 | + public function actionAbout() | |
117 | + { | |
118 | + return $this->render('about'); | |
119 | + } | |
120 | + | |
121 | + /** | |
122 | + * Signs user up. | |
123 | + * | |
124 | + * @return mixed | |
125 | + */ | |
126 | + public function actionSignup() | |
127 | + { | |
128 | + $model = new SignupForm(); | |
129 | + if ($model->load(Yii::$app->request->post())) { | |
130 | + if ($user = $model->signup()) { | |
131 | + if (Yii::$app->getUser() | |
132 | + ->login($user) | |
133 | + ) { | |
134 | + return $this->goHome(); | |
135 | + } | |
136 | + } | |
137 | + } | |
179 | 138 | |
180 | - return $this->goHome(); | |
139 | + return $this->render( | |
140 | + 'signup', | |
141 | + [ | |
142 | + 'model' => $model, | |
143 | + ] | |
144 | + ); | |
181 | 145 | } |
182 | 146 | |
183 | - return $this->render('resetPassword', [ | |
184 | - 'model' => $model, | |
185 | - ]); | |
186 | - } | |
187 | - | |
188 | - /** | |
189 | - * Action to view robots.txt file dinamycli | |
190 | - * | |
191 | - * @return string | |
192 | - */ | |
193 | - public function actionRobots() | |
194 | - { | |
195 | - $response = \Yii::$app->response; | |
196 | 147 | /** |
197 | - * @var Settings $settings | |
148 | + * Requests password reset. | |
149 | + * | |
150 | + * @return mixed | |
198 | 151 | */ |
199 | - $settings = Settings::find() | |
200 | - ->one(); | |
201 | - $temp = tmpfile(); | |
202 | - fwrite($temp, $settings->robots); | |
203 | - $meta = stream_get_meta_data($temp); | |
204 | - $response->format = $response::FORMAT_RAW; | |
205 | - $response->headers->set('Content-Type', 'text/plain'); | |
206 | - return $this->renderFile($meta[ 'uri' ]); | |
207 | - } | |
208 | - | |
209 | - public function actionFeedback() | |
210 | - { | |
211 | - Yii::$app->response->format = Response::FORMAT_JSON; | |
212 | - if (empty(Yii::$app->request->post())) { | |
213 | - throw new BadRequestHttpException(); | |
214 | - } else { | |
215 | - $model = new Feedback(); | |
216 | - if ($model->load(Yii::$app->request->post()) && $model->save()) { | |
217 | - return [ | |
218 | - 'success' => true, | |
219 | - 'message' => 'Success message', | |
220 | - ]; | |
152 | + public function actionRequestPasswordReset() | |
153 | + { | |
154 | + $model = new PasswordResetRequestForm(); | |
155 | + if ($model->load(Yii::$app->request->post()) && $model->validate()) { | |
156 | + if ($model->sendEmail()) { | |
157 | + Yii::$app->session->setFlash('success', 'Check your email for further instructions.'); | |
158 | + | |
159 | + return $this->goHome(); | |
160 | + } else { | |
161 | + Yii::$app->session->setFlash( | |
162 | + 'error', | |
163 | + 'Sorry, we are unable to reset password for the provided email address.' | |
164 | + ); | |
165 | + } | |
166 | + } | |
167 | + | |
168 | + return $this->render( | |
169 | + 'requestPasswordResetToken', | |
170 | + [ | |
171 | + 'model' => $model, | |
172 | + ] | |
173 | + ); | |
174 | + } | |
175 | + | |
176 | + /** | |
177 | + * Resets password. | |
178 | + * | |
179 | + * @param string $token | |
180 | + * | |
181 | + * @return mixed | |
182 | + * @throws BadRequestHttpException | |
183 | + */ | |
184 | + public function actionResetPassword($token) | |
185 | + { | |
186 | + try { | |
187 | + $model = new ResetPasswordForm($token); | |
188 | + } catch (InvalidParamException $e) { | |
189 | + throw new BadRequestHttpException($e->getMessage()); | |
190 | + } | |
191 | + | |
192 | + if ($model->load(Yii::$app->request->post()) && $model->validate() && $model->resetPassword()) { | |
193 | + Yii::$app->session->setFlash('success', 'New password saved.'); | |
194 | + | |
195 | + return $this->goHome(); | |
196 | + } | |
197 | + | |
198 | + return $this->render( | |
199 | + 'resetPassword', | |
200 | + [ | |
201 | + 'model' => $model, | |
202 | + ] | |
203 | + ); | |
204 | + } | |
205 | + | |
206 | + /** | |
207 | + * Action to view robots.txt file dinamycli | |
208 | + * | |
209 | + * @return string | |
210 | + */ | |
211 | + public function actionRobots() | |
212 | + { | |
213 | + $response = \Yii::$app->response; | |
214 | + /** | |
215 | + * @var Settings $settings | |
216 | + */ | |
217 | + $settings = Settings::find() | |
218 | + ->one(); | |
219 | + $temp = tmpfile(); | |
220 | + fwrite($temp, $settings->robots); | |
221 | + $meta = stream_get_meta_data($temp); | |
222 | + $response->format = $response::FORMAT_RAW; | |
223 | + $response->headers->set('Content-Type', 'text/plain'); | |
224 | + return $this->renderFile($meta[ 'uri' ]); | |
225 | + } | |
226 | + | |
227 | + public function actionFeedback() | |
228 | + { | |
229 | + Yii::$app->response->format = Response::FORMAT_JSON; | |
230 | + if (empty( Yii::$app->request->post() )) { | |
231 | + throw new BadRequestHttpException(); | |
221 | 232 | } else { |
222 | - return [ | |
223 | - 'success' => false, | |
224 | - 'error' => $model->errors, | |
225 | - ]; | |
233 | + $model = new Feedback(); | |
234 | + if ($model->load(Yii::$app->request->post()) && $model->save()) { | |
235 | + return [ | |
236 | + 'success' => true, | |
237 | + 'message' => 'Success message', | |
238 | + ]; | |
239 | + } else { | |
240 | + return [ | |
241 | + 'success' => false, | |
242 | + 'error' => $model->errors, | |
243 | + ]; | |
244 | + } | |
226 | 245 | } |
227 | 246 | } |
228 | 247 | } |
229 | -} | ... | ... |
frontend/views/site/about.php
1 | 1 | <?php |
2 | - | |
3 | -/* @var $this yii\web\View */ | |
4 | - | |
5 | -use yii\helpers\Html; | |
6 | - | |
7 | -$this->title = 'About'; | |
8 | -$this->params['breadcrumbs'][] = $this->title; | |
2 | + use yii\web\View; | |
3 | + | |
4 | + /** | |
5 | + * @var View $this | |
6 | + */ | |
9 | 7 | ?> |
10 | -<div class="site-about"> | |
11 | - <h1><?= Html::encode($this->title) ?></h1> | |
12 | - | |
13 | - <p>This is the About page. You may modify the following file to customize its content:</p> | |
14 | - | |
15 | - <code><?= __FILE__ ?></code> | |
16 | -</div> | |
8 | +<section> | |
9 | + <div class="row"> | |
10 | + <div class="col-md-12"> | |
11 | + | |
12 | + <div class="heading"> | |
13 | + <h2>About Universal</h2> | |
14 | + </div> | |
15 | + | |
16 | + <p class="lead">Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean | |
17 | + ultricies mi vitae est. Mauris placerat eleifend leo.</p> | |
18 | + | |
19 | + </div> | |
20 | + </div> | |
21 | + | |
22 | + <div class="row"> | |
23 | + <div class="col-md-8"> | |
24 | + <div class="panel-group accordion" id="accordionThree"> | |
25 | + <div class="panel panel-default"> | |
26 | + <div class="panel-heading"> | |
27 | + <h4 class="panel-title"> | |
28 | + | |
29 | + <a data-toggle="collapse" data-parent="#accordionThree" href="#collapse3a"> | |
30 | + | |
31 | + Accordion item no.1 | |
32 | + | |
33 | + </a> | |
34 | + | |
35 | + </h4> | |
36 | + </div> | |
37 | + <div id="collapse3a" class="panel-collapse collapse in"> | |
38 | + <div class="panel-body"> | |
39 | + <div class="row"> | |
40 | + <div class="col-md-4"> | |
41 | + <img src="img/template-easy-customize.png" alt="" class="img-responsive"> | |
42 | + </div> | |
43 | + <div class="col-md-8"> | |
44 | + <p>One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin. He lay on his armour-like back, and if he lifted his head a little he could see | |
45 | + his brown belly, slightly domed and divided by arches into stiff sections.</p> | |
46 | + <p>One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin. He lay on his armour-like back, and if he lifted his head a little he could see | |
47 | + his brown belly, slightly domed and divided by arches into stiff sections.</p> | |
48 | + </div> | |
49 | + </div> | |
50 | + </div> | |
51 | + </div> | |
52 | + </div> | |
53 | + <div class="panel panel-default"> | |
54 | + <div class="panel-heading"> | |
55 | + <h4 class="panel-title"> | |
56 | + | |
57 | + <a data-toggle="collapse" data-parent="#accordionThree" href="#collapse3b"> | |
58 | + | |
59 | + Accordion item no.2 | |
60 | + | |
61 | + </a> | |
62 | + | |
63 | + </h4> | |
64 | + </div> | |
65 | + <div id="collapse3b" class="panel-collapse collapse"> | |
66 | + <div class="panel-body"> | |
67 | + <div class="row"> | |
68 | + <div class="col-md-4"> | |
69 | + <img src="img/template-easy-code.png" alt="" class="img-responsive"> | |
70 | + </div> | |
71 | + <div class="col-md-8"> | |
72 | + <p>It showed a lady fitted out with a fur hat and fur boa who sat upright, raising a heavy fur muff that covered the whole of her lower arm towards the viewer. Gregor then turned to look out the window | |
73 | + at the dull weather. Drops of rain could be heard hitting the pane, which made him feel quite sad.</p> | |
74 | + <p>It showed a lady fitted out with a fur hat and fur boa who sat upright, raising a heavy fur muff that covered the whole of her lower arm towards the viewer. Gregor then turned to look out the window | |
75 | + at the dull weather. Drops of rain could be heard hitting the pane, which made him feel quite sad.</p> | |
76 | + </div> | |
77 | + </div> | |
78 | + </div> | |
79 | + </div> | |
80 | + </div> | |
81 | + <div class="panel panel-default"> | |
82 | + <div class="panel-heading"> | |
83 | + <h4 class="panel-title"> | |
84 | + | |
85 | + <a data-toggle="collapse" data-parent="#accordionThree" href="#collapse3c"> | |
86 | + | |
87 | + Accordion item no.3 a little too small | |
88 | + | |
89 | + </a> | |
90 | + | |
91 | + </h4> | |
92 | + </div> | |
93 | + <div id="collapse3c" class="panel-collapse collapse"> | |
94 | + <div class="panel-body"> | |
95 | + <p>His room, a proper human room although a little too small, lay peacefully between its four familiar walls.</p> | |
96 | + | |
97 | + <p>A collection of textile samples lay spread out on the table - Samsa was a travelling salesman - and above it there hung a picture that he had recently cut out of an illustrated magazine and housed in a nice, | |
98 | + gilded frame.</p> | |
99 | + </div> | |
100 | + </div> | |
101 | + </div> | |
102 | + </div> | |
103 | + </div> | |
104 | + | |
105 | + <div class="col-md-4"> | |
106 | + <div class="video"> | |
107 | + <div class="embed-responsive embed-responsive-4by3"> | |
108 | + <iframe class="embed-responsive-item" src="//www.youtube.com/embed/upZJpGrppJA"></iframe> | |
109 | + </div> | |
110 | + | |
111 | + </div> | |
112 | + </div> | |
113 | + </div> | |
114 | +</section> | |
115 | +use yii\web\View; | |
17 | 116 | \ No newline at end of file | ... | ... |