Commit d6f42b06b4887169207fa94efbf4088285a12ed3

Authored by Eugeny Galkovskiy
2 parents 82063f1d 19235aca

Merge remote-tracking branch 'origin/master'

@@ -37,3 +37,5 @@ phpunit.phar @@ -37,3 +37,5 @@ phpunit.phar
37 /composer.lock 37 /composer.lock
38 storage/* 38 storage/*
39 !storage/.gitignore 39 !storage/.gitignore
  40 +
  41 +/frontend/web/robots.txt
40 \ No newline at end of file 42 \ No newline at end of file
@@ -16,7 +16,7 @@ AddDefaultCharset utf-8 @@ -16,7 +16,7 @@ AddDefaultCharset utf-8
16 RewriteRule ^admin(.*) /backend/web/$1 [L] 16 RewriteRule ^admin(.*) /backend/web/$1 [L]
17 17
18 RewriteCond %{REQUEST_FILENAME} robots.txt 18 RewriteCond %{REQUEST_FILENAME} robots.txt
19 - RewriteRule . /frontend/web/index.php [L] 19 + RewriteRule . robots.txt
20 20
21 # if a directory or a file of the uploads folder exists, use the request directly 21 # if a directory or a file of the uploads folder exists, use the request directly
22 RewriteCond %{REQUEST_URI} ^/storage 22 RewriteCond %{REQUEST_URI} ^/storage
backend/controllers/SettingsController.php
@@ -76,11 +76,21 @@ @@ -76,11 +76,21 @@
76 */ 76 */
77 public function actionRobots() 77 public function actionRobots()
78 { 78 {
  79 + /**
  80 + * @var Settings $model
  81 + */
79 $model = $this->findSettings(); 82 $model = $this->findSettings();
80 $model->scenario = Settings::SCENARIO_ROBOTS; 83 $model->scenario = Settings::SCENARIO_ROBOTS;
81 - 84 +
  85 + $robotsTxt = fopen(\Yii::getAlias("@frontend/web/robots.txt"), "w+");
  86 +
82 if ($model->load(\Yii::$app->request->post()) && $model->save()) { 87 if ($model->load(\Yii::$app->request->post()) && $model->save()) {
83 - \Yii::$app->session->setFlash('success', \Yii::t('core', 'Robots saved')); 88 +
  89 + if (fwrite($robotsTxt, $model->robots)){
  90 + \Yii::$app->session->setFlash('success', \Yii::t('core', 'Robots saved'));
  91 + fclose($robotsTxt);
  92 + }
  93 +
84 } 94 }
85 95
86 return $this->render( 96 return $this->render(
backend/web/robots.txt deleted
1 -User-agent: *  
2 -Disallow: /  
@@ -34,7 +34,8 @@ @@ -34,7 +34,8 @@
34 "artweb/artbox-core": "@dev", 34 "artweb/artbox-core": "@dev",
35 "artweb/artbox-weblog": "@dev", 35 "artweb/artbox-weblog": "@dev",
36 "artweb/artbox-webcomment": "@dev", 36 "artweb/artbox-webcomment": "@dev",
37 - "modernkernel/yii2-photoswipe": "*" 37 + "modernkernel/yii2-photoswipe": "*",
  38 + "udokmeci/yii2-phone-validator" : "dev-master"
38 }, 39 },
39 "require-dev": { 40 "require-dev": {
40 "yiisoft/yii2-debug": "~2.0.0", 41 "yiisoft/yii2-debug": "~2.0.0",
frontend/controllers/SiteController.php
@@ -128,6 +128,13 @@ @@ -128,6 +128,13 @@
128 } else { 128 } else {
129 $model = new Feedback(); 129 $model = new Feedback();
130 if ($model->load(Yii::$app->request->post()) && $model->save()) { 130 if ($model->load(Yii::$app->request->post()) && $model->save()) {
  131 +
  132 + $pattern = '/([a-zA-Z0-9\._-]*@[a-zA-Z0-9\._-]*)([;\s,:]*)/';
  133 + $replacement = '$1; ';
  134 + $emailStr = preg_replace($pattern, $replacement, $settings->email);
  135 + $emailStr = mb_substr($emailStr, 0, -2); // remove last "; " 2 symbols
  136 +
  137 + $emails = explode("; ", $emailStr);
131 138
132 $mailer->compose( 139 $mailer->compose(
133 'feedback', 140 'feedback',
@@ -136,19 +143,21 @@ @@ -136,19 +143,21 @@
136 ] 143 ]
137 ) 144 )
138 ->setFrom('artbox@domain.com') 145 ->setFrom('artbox@domain.com')
139 - ->setTo($settings->email) 146 + ->setTo($emails)
140 ->setSubject(\Yii::t('app', 'Feedback')) 147 ->setSubject(\Yii::t('app', 'Feedback'))
141 ->send(); 148 ->send();
142 149
  150 + $alert = "<div class=\"alert alert-success\">
  151 + <h3>Success</h3>
  152 + <p>
  153 + Success text
  154 + </p>
  155 + </div>";
  156 +
143 return [ 157 return [
144 'success' => true, 158 'success' => true,
145 'message' => 'Success message', 159 'message' => 'Success message',
146 - 'alert' => '<div class="alert alert-success">  
147 - <h3>Success</h3>  
148 - <p>  
149 - Success text  
150 - </p>  
151 - </div>', 160 + 'alert' => $alert,
152 ]; 161 ];
153 } else { 162 } else {
154 return [ 163 return [
frontend/models/Feedback.php 0 → 100644
  1 +<?php
  2 + namespace frontend\models;
  3 +
  4 + /**
  5 + * Created by PhpStorm.
  6 + * User: timur
  7 + * Date: 09.11.17
  8 + * Time: 14:50
  9 + */
  10 +
  11 + class Feedback extends \artbox\core\models\Feedback
  12 + {
  13 + const SCENARIO_WRITE_US = "write_us";
  14 + const SCENARIO_APPOINTMENT = "appointment";
  15 +
  16 + public function scenarios()
  17 + {
  18 + $scenarios = array_merge(
  19 + parent::scenarios(),
  20 + [
  21 + self::SCENARIO_APPOINTMENT=>[
  22 + 'name',
  23 + 'phone',
  24 + 'date',
  25 + 'time',
  26 + 'service',
  27 + 'url'
  28 + ],
  29 +
  30 + self::SCENARIO_WRITE_US => [
  31 + 'name',
  32 + 'email',
  33 + 'phone',
  34 + 'message',
  35 + 'url'
  36 + ]
  37 + ]
  38 + );
  39 +
  40 + return $scenarios;
  41 + }
  42 +
  43 + public function rules()
  44 + {
  45 + return [
  46 + [
  47 + [
  48 + 'name',
  49 + 'phone',
  50 + 'date',
  51 + 'url'
  52 + ],
  53 + 'required',
  54 + 'on' => self::SCENARIO_APPOINTMENT,
  55 + ],
  56 + [
  57 + [
  58 + 'name',
  59 + 'email',
  60 + 'phone',
  61 + 'url',
  62 + ],
  63 + 'required',
  64 + 'on' => self::SCENARIO_WRITE_US,
  65 + ],
  66 + [
  67 + [ 'email' ],
  68 + 'email',
  69 + ],
  70 + [
  71 + [
  72 + 'name',
  73 + 'date',
  74 + 'phone',
  75 + ],
  76 + 'string',
  77 + 'max' => 255,
  78 + ],
  79 + [
  80 + [ 'url' ],
  81 + 'url'
  82 + ],
  83 + [
  84 + [ 'message' ],
  85 + 'string',
  86 + ],
  87 + [
  88 + [ 'status', ],
  89 + 'boolean',
  90 + ],
  91 + ];
  92 + }
  93 +
  94 + }
0 \ No newline at end of file 95 \ No newline at end of file
frontend/views/site/comment/artbox_comment_item.php
@@ -30,7 +30,7 @@ @@ -30,7 +30,7 @@
30 <div class="user_name" itemprop="author"> 30 <div class="user_name" itemprop="author">
31 <?php 31 <?php
32 $nameField = $display_name; 32 $nameField = $display_name;
33 - echo $model->username . ' (' . Yii::t('artbox-comment', 'Guest') . ')'; 33 + echo $model->username;
34 ?> 34 ?>
35 </div> 35 </div>
36 <?php 36 <?php
frontend/web/robots.txt 100755 → 100644
1 User-agent: Google 1 User-agent: Google
2 -Disallow: /en/  
3 -Disallow: /ua/  
4 - 2 +Disallow: 123423413