Commit 82f961f9035a4f8368c6c3f767a38d47072b1026

Authored by Administrator
1 parent 2cbb3bdc

big commti

backend/controllers/ArticlesController.php
@@ -81,18 +81,7 @@ class ArticlesController extends Controller @@ -81,18 +81,7 @@ class ArticlesController extends Controller
81 81
82 if ($model->load(Yii::$app->request->post())) { 82 if ($model->load(Yii::$app->request->post())) {
83 83
84 - if ( ($image = UploadedFile::getInstance($model, 'image')) ) {  
85 - $model->image = $image->name;  
86 - }  
87 -  
88 - $imgDir = Yii::getAlias('@storage/articles/');  
89 -  
90 - if(!is_dir($imgDir)) {  
91 - mkdir($imgDir, 0755, true);  
92 - }  
93 - if ($model->save() && $image) {  
94 - $image->saveAs(Yii::getAlias('@storage/articles/' . $image->name));  
95 - } 84 + $model->save();
96 85
97 return $this->redirect(['view', 'id' => $model->id]); 86 return $this->redirect(['view', 'id' => $model->id]);
98 } else { 87 } else {
@@ -113,18 +102,7 @@ class ArticlesController extends Controller @@ -113,18 +102,7 @@ class ArticlesController extends Controller
113 $model = $this->findModel($id); 102 $model = $this->findModel($id);
114 103
115 if ($model->load(Yii::$app->request->post())) { 104 if ($model->load(Yii::$app->request->post())) {
116 - if ( ($image = UploadedFile::getInstance($model, 'image')) ) {  
117 - $model->image = $image->name;  
118 - }  
119 -  
120 - $imgDir = Yii::getAlias('@storage/articles/');  
121 -  
122 - if(!is_dir($imgDir)) {  
123 - mkdir($imgDir, 0755, true);  
124 - }  
125 - if ($model->save() && $image) {  
126 - $image->saveAs(Yii::getAlias('@storage/articles/' . $image->name));  
127 - } 105 + $model->save();
128 106
129 return $this->redirect(['view', 'id' => $model->id]); 107 return $this->redirect(['view', 'id' => $model->id]);
130 } else { 108 } else {
backend/controllers/SliderImageController.php
@@ -85,19 +85,7 @@ class SliderImageController extends Controller @@ -85,19 +85,7 @@ class SliderImageController extends Controller
85 85
86 if ($model->load(Yii::$app->request->post())) { 86 if ($model->load(Yii::$app->request->post())) {
87 $model->slider_id = $slider_id; 87 $model->slider_id = $slider_id;
88 - if ( ($image = UploadedFile::getInstance($model, 'image')) ) {  
89 - $model->image = $image->name;  
90 - }  
91 - if ($model->save() && $image) {  
92 -  
93 - $imgDir = Yii::getAlias('@storage/slider/');  
94 -  
95 - if(!is_dir($imgDir)) {  
96 - mkdir($imgDir, 0755, true);  
97 - }  
98 -  
99 - $image->saveAs(Yii::getAlias('@storage/slider/' . $image->name));  
100 - } 88 + $model->save();
101 return $this->redirect(['view', 'slider_id'=>$slider_id, 'id' => $model->slider_image_id]); 89 return $this->redirect(['view', 'slider_id'=>$slider_id, 'id' => $model->slider_image_id]);
102 } else { 90 } else {
103 91
@@ -126,23 +114,7 @@ class SliderImageController extends Controller @@ -126,23 +114,7 @@ class SliderImageController extends Controller
126 114
127 115
128 116
129 - if ( ($image = UploadedFile::getInstance($model, 'image')) ) {  
130 - $model->image = $image->name;  
131 - }  
132 -  
133 - if(!$model->image){  
134 - $model->image = $model->getOldAttribute('image');  
135 - }  
136 -  
137 - if ($model->save() && $image) {  
138 - $imgDir = Yii::getAlias('@storage/slider/');  
139 -  
140 - if(!is_dir($imgDir)) {  
141 - mkdir($imgDir, 0755, true);  
142 - }  
143 -  
144 - $image->saveAs(Yii::getAlias('@storage/slider/' . $image->name));  
145 - } 117 + $model->save();
146 return $this->redirect(['view', 'slider_id'=>$slider_id, 'id' => $model->slider_image_id]); 118 return $this->redirect(['view', 'slider_id'=>$slider_id, 'id' => $model->slider_image_id]);
147 } else { 119 } else {
148 120
backend/views/banner/_form.php
@@ -12,7 +12,10 @@ use yii\widgets\ActiveForm; @@ -12,7 +12,10 @@ use yii\widgets\ActiveForm;
12 12
13 <div class="banner-form"> 13 <div class="banner-form">
14 14
15 - <?php $form = ActiveForm::begin(); ?> 15 + <?php $form = ActiveForm::begin([
  16 + 'enableClientValidation' => false,
  17 + 'options' => ['enctype' => 'multipart/form-data']
  18 + ]); ?>
16 19
17 20
18 <?= $form->field($model, 'alt')->textInput(['maxlength' => true]) ?> 21 <?= $form->field($model, 'alt')->textInput(['maxlength' => true]) ?>
@@ -31,27 +34,24 @@ use yii\widgets\ActiveForm; @@ -31,27 +34,24 @@ use yii\widgets\ActiveForm;
31 ] 34 ]
32 ])) ?> 35 ])) ?>
33 36
34 - <?= $form->field($model, 'width')->textInput(['maxlength' => true]) ?>  
35 -  
36 - <?= $form->field($model, 'height')->textInput(['maxlength' => true]) ?>  
37 -  
38 - <p id="save_image_widget_settings" class = "btn btn-primary" >Применить настройки</p>  
39 37
40 <div id="image_widget_block"> 38 <div id="image_widget_block">
41 - <?php if(!empty($model->image)){  
42 - echo ImageUploader::widget([  
43 - 'model'=> $model,  
44 - 'field'=>'image',  
45 - 'size' => [  
46 - [  
47 - 'width'=>$model->width,  
48 - 'height'=>$model->height,  
49 - ],  
50 - ],  
51 - 'gallery' =>$model->image,  
52 - 'name' => "Загрузить баннер"  
53 - ]);  
54 - }?> 39 +
  40 + <?= $form->field($model, 'image')->widget(\kartik\file\FileInput::classname(), [
  41 + 'language' => 'ru',
  42 + 'options' => [
  43 + 'accept' => 'image/*',
  44 + 'multiple' => false,
  45 + ],
  46 + 'pluginOptions' => [
  47 + 'allowedFileExtensions' => ['jpg', 'gif', 'png'],
  48 + 'initialPreview' => !empty($model->imageUrl) ? \common\components\artboximage\ArtboxImageHelper::getImage($model->imageUrl, 'list') : '',
  49 + 'overwriteInitial' => true,
  50 + 'showRemove' => false,
  51 + 'showUpload' => false,
  52 + 'previewFileType' => 'image',
  53 + ],
  54 + ]); ?>
55 </div> 55 </div>
56 56
57 <div class="form-group"> 57 <div class="form-group">
backend/views/bg/_form.php
@@ -10,13 +10,30 @@ use yii\widgets\ActiveForm; @@ -10,13 +10,30 @@ use yii\widgets\ActiveForm;
10 10
11 <div class="bg-form"> 11 <div class="bg-form">
12 12
13 - <?php $form = ActiveForm::begin(); ?> 13 + <?php $form = ActiveForm::begin([
  14 + 'enableClientValidation' => false,
  15 + 'options' => ['enctype' => 'multipart/form-data']
  16 + ]); ?>
14 17
15 <?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?> 18 <?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
16 19
17 <?= $form->field($model, 'url')->textInput(['maxlength' => true]) ?> 20 <?= $form->field($model, 'url')->textInput(['maxlength' => true]) ?>
18 21
19 - <?= $form->field($model, 'image')->textInput(['maxlength' => true]) ?> 22 + <?= $form->field($model, 'image')->widget(\kartik\file\FileInput::classname(), [
  23 + 'language' => 'ru',
  24 + 'options' => [
  25 + 'accept' => 'image/*',
  26 + 'multiple' => false,
  27 + ],
  28 + 'pluginOptions' => [
  29 + 'allowedFileExtensions' => ['jpg', 'gif', 'png'],
  30 + 'initialPreview' => !empty($model->imageUrl) ? \common\components\artboximage\ArtboxImageHelper::getImage($model->imageUrl, 'list') : '',
  31 + 'overwriteInitial' => true,
  32 + 'showRemove' => false,
  33 + 'showUpload' => false,
  34 + 'previewFileType' => 'image',
  35 + ],
  36 + ]); ?>
20 37
21 <div class="form-group"> 38 <div class="form-group">
22 <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> 39 <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
backend/views/brand/_form.php
@@ -43,6 +43,8 @@ use yii\widgets\ActiveForm; @@ -43,6 +43,8 @@ use yii\widgets\ActiveForm;
43 43
44 <?= $form->field($model, 'seo_text')->textarea(['rows' => 6]) ?> 44 <?= $form->field($model, 'seo_text')->textarea(['rows' => 6]) ?>
45 45
  46 + <?= $form->field($model, 'in_menu')->checkbox()?>
  47 +
46 <div class="form-group"> 48 <div class="form-group">
47 <?= Html::submitButton($model->isNewRecord ? Yii::t('product', 'Create') : Yii::t('product', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> 49 <?= Html::submitButton($model->isNewRecord ? Yii::t('product', 'Create') : Yii::t('product', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
48 <?php if ($model->isNewRecord) :?> 50 <?php if ($model->isNewRecord) :?>
backend/views/brand/index.php
1 <?php 1 <?php
2 2
  3 +use common\components\artboximage\ArtboxImageHelper;
3 use yii\helpers\Html; 4 use yii\helpers\Html;
4 use yii\grid\GridView; 5 use yii\grid\GridView;
5 6
@@ -27,10 +28,10 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title; @@ -27,10 +28,10 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
27 'name', 28 'name',
28 'alias', 29 'alias',
29 [ 30 [
30 - 'attribute' => 'title',  
31 - 'format' => 'html', 31 + 'attribute' => 'image',
  32 + 'format' => 'image',
32 'value' => function($data) { 33 'value' => function($data) {
33 - return Html::img($data->imageUrl, ['width'=>'100']); 34 + return ArtboxImageHelper::getImageSrc($data->imageUrl, 'brand_item');
34 }, 35 },
35 ], 36 ],
36 37
backend/views/customer/_form.php
@@ -12,11 +12,10 @@ use yii\widgets\ActiveForm; @@ -12,11 +12,10 @@ use yii\widgets\ActiveForm;
12 12
13 <?php $form = ActiveForm::begin(); ?> 13 <?php $form = ActiveForm::begin(); ?>
14 14
15 - <?= $form->field($model, 'id')->textInput() ?>  
16 15
17 <?= $form->field($model, 'username')->textInput(['maxlength' => true]) ?> 16 <?= $form->field($model, 'username')->textInput(['maxlength' => true]) ?>
18 17
19 - <?= $form->field($model, 'password')->passwordInput(['maxlength' => true]) ?> 18 +
20 19
21 <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?> 20 <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
22 21
@@ -26,8 +25,6 @@ use yii\widgets\ActiveForm; @@ -26,8 +25,6 @@ use yii\widgets\ActiveForm;
26 25
27 <?= $form->field($model, 'date_time')->textInput() ?> 26 <?= $form->field($model, 'date_time')->textInput() ?>
28 27
29 - <?= $form->field($model, 'sex')->textInput(['maxlength' => true]) ?>  
30 -  
31 <?= $form->field($model, 'birth_day')->textInput() ?> 28 <?= $form->field($model, 'birth_day')->textInput() ?>
32 29
33 <?= $form->field($model, 'birth_month')->textInput() ?> 30 <?= $form->field($model, 'birth_month')->textInput() ?>
backend/views/customer/index.php
@@ -26,7 +26,6 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title; @@ -26,7 +26,6 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
26 26
27 'id', 27 'id',
28 'username', 28 'username',
29 - 'password',  
30 'name', 29 'name',
31 'surname', 30 'surname',
32 // 'phone', 31 // 'phone',
backend/views/slider-image/_form.php
@@ -16,6 +16,7 @@ use yii\widgets\ActiveForm; @@ -16,6 +16,7 @@ use yii\widgets\ActiveForm;
16 16
17 <?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]); ?> 17 <?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]); ?>
18 18
  19 +
19 <?= $form->field($model, 'image')->widget(\kartik\file\FileInput::classname(), [ 20 <?= $form->field($model, 'image')->widget(\kartik\file\FileInput::classname(), [
20 'model' => $model, 21 'model' => $model,
21 'attribute' => 'image', 22 'attribute' => 'image',
common/behaviors/SaveImgBehavior.php 0 → 100644
  1 +<?php
  2 +
  3 +namespace common\behaviors;
  4 +
  5 +use common\modules\comment\models\CommentModel;
  6 +use yii\base\Behavior;
  7 +use yii\db\ActiveRecord;
  8 +use yii\web\UploadedFile;
  9 +/**
  10 + * Class RatingBehavior
  11 + * @property CommentModel $owner
  12 + * @package common\behaviors
  13 + */
  14 +class SaveImgBehavior extends Behavior
  15 +{
  16 +
  17 +
  18 + public $directory;
  19 +
  20 + public function events()
  21 + {
  22 + return [
  23 + ActiveRecord::EVENT_BEFORE_UPDATE => 'beforeUpdate',
  24 + ActiveRecord::EVENT_BEFORE_INSERT => 'beforeInsert',
  25 + ];
  26 + }
  27 +
  28 + public function beforeUpdate($event)
  29 + {
  30 +
  31 +
  32 + if ( ($image = UploadedFile::getInstance($this->owner, 'image')) ) {
  33 + $this->owner->image = $image->name;
  34 + }
  35 +
  36 + if(!$this->owner->image){
  37 + $this->owner->image = $this->owner->getOldAttribute('image');
  38 + }
  39 +
  40 +
  41 + if ($image) {
  42 + $imgDir = \Yii::getAlias('@storage/'.$this->directory.'/');
  43 +
  44 + if(!is_dir($imgDir)) {
  45 + mkdir($imgDir, 0755, true);
  46 + }
  47 +
  48 + $image->saveAs(\Yii::getAlias('@storage/'.$this->directory.'/' . $image->name));
  49 + }
  50 + }
  51 +
  52 +
  53 + public function beforeInsert($event)
  54 + {
  55 +
  56 +
  57 + if ( ($image = UploadedFile::getInstance($this->owner, 'image')) ) {
  58 + $this->owner->image = $image->name;
  59 + }
  60 +
  61 +
  62 +
  63 + if ($image) {
  64 + $imgDir = \Yii::getAlias('@storage/'.$this->directory.'/');
  65 +
  66 + if(!is_dir($imgDir)) {
  67 + mkdir($imgDir, 0755, true);
  68 + }
  69 +
  70 + $image->saveAs(\Yii::getAlias('@storage/'.$this->directory.'/' . $image->name));
  71 + }
  72 + }
  73 +
  74 +
  75 +
  76 + public function getImageFile() {
  77 + return empty($this->owner->image) ? null : '/storage/'.$this->directory.'/'. $this->owner->image;
  78 + }
  79 +
  80 + public function getImageUrl() {
  81 + return empty($this->owner->image) ? null : '/storage/'.$this->directory.'/'. $this->owner->image;
  82 + }
  83 +}
0 \ No newline at end of file 84 \ No newline at end of file
common/models/Articles.php
@@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
3 namespace common\models; 3 namespace common\models;
4 4
5 use common\behaviors\RatingBehavior; 5 use common\behaviors\RatingBehavior;
  6 +use common\behaviors\SaveImgBehavior;
6 use common\modules\comment\models\CommentModel; 7 use common\modules\comment\models\CommentModel;
7 use Yii; 8 use Yii;
8 9
@@ -33,12 +34,18 @@ class Articles extends \yii\db\ActiveRecord @@ -33,12 +34,18 @@ class Articles extends \yii\db\ActiveRecord
33 return 'articles'; 34 return 'articles';
34 } 35 }
35 36
  37 +
  38 +
36 /** 39 /**
37 * @inheritdoc 40 * @inheritdoc
38 */ 41 */
39 public function behaviors() 42 public function behaviors()
40 { 43 {
41 return [ 44 return [
  45 + [
  46 + 'class' => SaveImgBehavior::className(),
  47 + 'directory' => 'articles'
  48 + ],
42 'slug' => [ 49 'slug' => [
43 'class' => 'common\behaviors\Slug', 50 'class' => 'common\behaviors\Slug',
44 'in_attribute' => 'title', 51 'in_attribute' => 'title',
@@ -84,15 +91,6 @@ class Articles extends \yii\db\ActiveRecord @@ -84,15 +91,6 @@ class Articles extends \yii\db\ActiveRecord
84 ]; 91 ];
85 } 92 }
86 93
87 - public function getImageFile() {  
88 - return empty($this->image) ? null : Yii::getAlias('@imagesDir/articles/'. $this->image);  
89 - }  
90 -  
91 - public function getImageUrl()  
92 - {  
93 - return empty($this->image) ? null : Yii::getAlias('@imagesUrl/articles/' . $this->image);  
94 - }  
95 -  
96 public function recalculateRating() { 94 public function recalculateRating() {
97 /** 95 /**
98 * @var ArticleToRating $averageRating 96 * @var ArticleToRating $averageRating
common/models/Banner.php
@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 2
3 namespace common\models; 3 namespace common\models;
4 4
  5 +use common\behaviors\SaveImgBehavior;
5 use Yii; 6 use Yii;
6 7
7 /** 8 /**
@@ -26,6 +27,21 @@ class Banner extends \yii\db\ActiveRecord @@ -26,6 +27,21 @@ class Banner extends \yii\db\ActiveRecord
26 return 'banner'; 27 return 'banner';
27 } 28 }
28 29
  30 +
  31 +
  32 + /**
  33 + * @inheritdoc
  34 + */
  35 + public function behaviors()
  36 + {
  37 + return [
  38 + [
  39 + 'class' => SaveImgBehavior::className(),
  40 + 'directory' => 'banner'
  41 + ],
  42 + ];
  43 + }
  44 +
29 /** 45 /**
30 * @inheritdoc 46 * @inheritdoc
31 */ 47 */
common/models/Basket.php
@@ -20,7 +20,7 @@ @@ -20,7 +20,7 @@
20 parent::__construct($config); 20 parent::__construct($config);
21 } 21 }
22 22
23 - public function add( $product_variant_id, $count) 23 + public function add(int $product_variant_id, int $count)
24 { 24 {
25 $data = $this->getData(); 25 $data = $this->getData();
26 if(array_key_exists($product_variant_id, $data)) { 26 if(array_key_exists($product_variant_id, $data)) {
@@ -38,7 +38,7 @@ @@ -38,7 +38,7 @@
38 $this->setData($data); 38 $this->setData($data);
39 } 39 }
40 40
41 - public function set( $product_variant_id, $count) 41 + public function set(int $product_variant_id, int $count)
42 { 42 {
43 $data = $this->getData(); 43 $data = $this->getData();
44 if(array_key_exists($product_variant_id, $data)) { 44 if(array_key_exists($product_variant_id, $data)) {
@@ -56,12 +56,12 @@ @@ -56,12 +56,12 @@
56 $this->setData($data); 56 $this->setData($data);
57 } 57 }
58 58
59 - public function getData() 59 + public function getData(): array
60 { 60 {
61 return $this->session->get('basket'); 61 return $this->session->get('basket');
62 } 62 }
63 63
64 - public function getItem( $product_variant_id) { 64 + public function getItem(int $product_variant_id) {
65 $data = $this->getData(); 65 $data = $this->getData();
66 if(!empty($data[$product_variant_id])) { 66 if(!empty($data[$product_variant_id])) {
67 return $data[$product_variant_id]; 67 return $data[$product_variant_id];
@@ -75,7 +75,7 @@ @@ -75,7 +75,7 @@
75 $this->session->set('basket', $data); 75 $this->session->set('basket', $data);
76 } 76 }
77 77
78 - public function getSum() 78 + public function getSum(): float
79 { 79 {
80 $data = $this->getData(); 80 $data = $this->getData();
81 $sum = 0; 81 $sum = 0;
@@ -85,12 +85,12 @@ @@ -85,12 +85,12 @@
85 return $sum; 85 return $sum;
86 } 86 }
87 87
88 - public function getCount() { 88 + public function getCount(): int {
89 $data = $this->getData(); 89 $data = $this->getData();
90 return count($data); 90 return count($data);
91 } 91 }
92 92
93 - public function findModel( $product_variant_id) 93 + public function findModel(int $product_variant_id): ProductVariant
94 { 94 {
95 $model = ProductVariant::find() 95 $model = ProductVariant::find()
96 ->where([ 'product_variant_id' => $product_variant_id ]) 96 ->where([ 'product_variant_id' => $product_variant_id ])
common/models/Bg.php
@@ -2,6 +2,8 @@ @@ -2,6 +2,8 @@
2 2
3 namespace common\models; 3 namespace common\models;
4 4
  5 +use common\behaviors\SaveImgBehavior;
  6 +
5 class Bg extends \yii\db\ActiveRecord 7 class Bg extends \yii\db\ActiveRecord
6 { 8 {
7 public $old_image; 9 public $old_image;
@@ -10,7 +12,20 @@ class Bg extends \yii\db\ActiveRecord @@ -10,7 +12,20 @@ class Bg extends \yii\db\ActiveRecord
10 { 12 {
11 return 'bg'; 13 return 'bg';
12 } 14 }
13 - 15 +
  16 + /**
  17 + * @inheritdoc
  18 + */
  19 + public function behaviors()
  20 + {
  21 + return [
  22 + [
  23 + 'class' => SaveImgBehavior::className(),
  24 + 'directory' => 'bg'
  25 + ],
  26 + ];
  27 + }
  28 +
14 public function rules() 29 public function rules()
15 { 30 {
16 return [ 31 return [
common/models/Customer.php
@@ -88,30 +88,6 @@ class Customer extends User implements \yii\web\IdentityInterface @@ -88,30 +88,6 @@ class Customer extends User implements \yii\web\IdentityInterface
88 /** 88 /**
89 * @return \yii\db\ActiveQuery 89 * @return \yii\db\ActiveQuery
90 */ 90 */
91 - public function getArtboxComments()  
92 - {  
93 - return $this->hasMany(ArtboxComment::className(), ['user_id' => 'id']);  
94 - }  
95 -  
96 - /**  
97 - * @return \yii\db\ActiveQuery  
98 - */  
99 - public function getArtboxCommentRatings()  
100 - {  
101 - return $this->hasMany(ArtboxCommentRating::className(), ['user_id' => 'id']);  
102 - }  
103 -  
104 - /**  
105 - * @return \yii\db\ActiveQuery  
106 - */  
107 - public function getArtboxLikes()  
108 - {  
109 - return $this->hasMany(ArtboxLike::className(), ['user_id' => 'id']);  
110 - }  
111 -  
112 - /**  
113 - * @return \yii\db\ActiveQuery  
114 - */  
115 public function getShares() 91 public function getShares()
116 { 92 {
117 return $this->hasMany(Share::className(), ['user_id' => 'id']); 93 return $this->hasMany(Share::className(), ['user_id' => 'id']);
common/models/CustomerSearch.php
@@ -18,8 +18,12 @@ class CustomerSearch extends Customer @@ -18,8 +18,12 @@ class CustomerSearch extends Customer
18 public function rules() 18 public function rules()
19 { 19 {
20 return [ 20 return [
21 - [['id', 'birth_day', 'birth_month', 'birth_year', 'group_id'], 'integer'],  
22 - [['username', 'password', 'name', 'surname', 'phone', 'date_time', 'sex', 'body'], 'safe'], 21 + [['date_time'], 'safe'],
  22 + [['birth_day', 'birth_month', 'birth_year', 'group_id', 'status', 'created_at', 'updated_at'], 'integer'],
  23 + [['body'], 'string'],
  24 + [['status'],'default', 'value' => '10'],
  25 + [['username', 'name', 'surname', 'phone', 'email', 'password_reset_token','username', 'password_hash'], 'string', 'max' => 255],
  26 + [['gender', 'auth_key'], 'string', 'max' => 32],
23 ]; 27 ];
24 } 28 }
25 29
@@ -68,11 +72,9 @@ class CustomerSearch extends Customer @@ -68,11 +72,9 @@ class CustomerSearch extends Customer
68 ]); 72 ]);
69 73
70 $query->andFilterWhere(['like', 'username', $this->username]) 74 $query->andFilterWhere(['like', 'username', $this->username])
71 - ->andFilterWhere(['like', 'password', $this->password])  
72 ->andFilterWhere(['like', 'name', $this->name]) 75 ->andFilterWhere(['like', 'name', $this->name])
73 ->andFilterWhere(['like', 'surname', $this->surname]) 76 ->andFilterWhere(['like', 'surname', $this->surname])
74 ->andFilterWhere(['like', 'phone', $this->phone]) 77 ->andFilterWhere(['like', 'phone', $this->phone])
75 - ->andFilterWhere(['like', 'sex', $this->sex])  
76 ->andFilterWhere(['like', 'body', $this->body]); 78 ->andFilterWhere(['like', 'body', $this->body]);
77 79
78 return $dataProvider; 80 return $dataProvider;
common/models/SliderImage.php
@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 2
3 namespace common\models; 3 namespace common\models;
4 4
  5 +use common\behaviors\SaveImgBehavior;
5 use Yii; 6 use Yii;
6 7
7 /** 8 /**
@@ -20,6 +21,23 @@ use Yii; @@ -20,6 +21,23 @@ use Yii;
20 */ 21 */
21 class SliderImage extends \yii\db\ActiveRecord 22 class SliderImage extends \yii\db\ActiveRecord
22 { 23 {
  24 +
  25 +
  26 +
  27 + /**
  28 + * @inheritdoc
  29 + */
  30 + public function behaviors()
  31 + {
  32 + return [
  33 + [
  34 + 'class' => SaveImgBehavior::className(),
  35 + 'directory' => 'slider'
  36 + ]
  37 + ];
  38 + }
  39 +
  40 +
23 /** 41 /**
24 * @inheritdoc 42 * @inheritdoc
25 */ 43 */
@@ -57,6 +75,8 @@ class SliderImage extends \yii\db\ActiveRecord @@ -57,6 +75,8 @@ class SliderImage extends \yii\db\ActiveRecord
57 ]; 75 ];
58 } 76 }
59 77
  78 +
  79 +
60 /** 80 /**
61 * @return \yii\db\ActiveQuery 81 * @return \yii\db\ActiveQuery
62 */ 82 */
@@ -65,12 +85,6 @@ class SliderImage extends \yii\db\ActiveRecord @@ -65,12 +85,6 @@ class SliderImage extends \yii\db\ActiveRecord
65 return $this->hasOne(Slider::className(), ['slider_id' => 'slider_id']); 85 return $this->hasOne(Slider::className(), ['slider_id' => 'slider_id']);
66 } 86 }
67 87
68 - public function getImageFile() {  
69 - return empty($this->image) ? null : '/storage/slider/'. $this->image;  
70 - }  
71 88
72 - public function getImageUrl() {  
73 - return empty($this->image) ? null : '/storage/slider/'. $this->image;  
74 - }  
75 89
76 } 90 }
common/modules/comment/widgets/CommentWidget.php
@@ -270,7 +270,7 @@ @@ -270,7 +270,7 @@
270 * @return CommentInterface Comment model 270 * @return CommentInterface Comment model
271 * @throws InvalidConfigException If object not instance of \yii\base\Model 271 * @throws InvalidConfigException If object not instance of \yii\base\Model
272 */ 272 */
273 - protected function createModel( $className, $config = [ ]) 273 + protected function createModel(string $className, array $config = [ ]): CommentInterface
274 { 274 {
275 $options = array_merge($config, [ 'class' => $className ]); 275 $options = array_merge($config, [ 'class' => $className ]);
276 $object = Yii::createObject($options); 276 $object = Yii::createObject($options);
@@ -289,7 +289,7 @@ @@ -289,7 +289,7 @@
289 * @return CommentInterface Comment model 289 * @return CommentInterface Comment model
290 * @throws InvalidConfigException If object not instance of \yii\base\Model 290 * @throws InvalidConfigException If object not instance of \yii\base\Model
291 */ 291 */
292 - protected function createRating( $className, $config = [ ]) 292 + protected function createRating(string $className, array $config = [ ]): RatingModel
293 { 293 {
294 $options = array_merge($config, [ 'class' => $className ]); 294 $options = array_merge($config, [ 'class' => $className ]);
295 $object = Yii::createObject($options); 295 $object = Yii::createObject($options);
@@ -340,7 +340,7 @@ @@ -340,7 +340,7 @@
340 /** 340 /**
341 * @return string 341 * @return string
342 */ 342 */
343 - protected function renderWidget() 343 + protected function renderWidget(): string
344 { 344 {
345 $layout = $this->layout; 345 $layout = $this->layout;
346 $parts = $this->parts; 346 $parts = $this->parts;
common/modules/product/models/Brand.php
@@ -60,6 +60,7 @@ class Brand extends \yii\db\ActiveRecord @@ -60,6 +60,7 @@ class Brand extends \yii\db\ActiveRecord
60 return [ 60 return [
61 [['name'], 'string'], 61 [['name'], 'string'],
62 [['brand_name_id'], 'integer'], 62 [['brand_name_id'], 'integer'],
  63 + [['in_menu'], 'boolean'],
63 [['meta_desc', 'seo_text'], 'string'], 64 [['meta_desc', 'seo_text'], 'string'],
64 [['alias', 'name'], 'string', 'max' => 250], 65 [['alias', 'name'], 'string', 'max' => 250],
65 [['meta_title', 'image'], 'string', 'max' => 255], 66 [['meta_title', 'image'], 'string', 'max' => 255],
@@ -85,6 +86,7 @@ class Brand extends \yii\db\ActiveRecord @@ -85,6 +86,7 @@ class Brand extends \yii\db\ActiveRecord
85 'meta_desc' => Yii::t('product', 'Meta Desc'), 86 'meta_desc' => Yii::t('product', 'Meta Desc'),
86 'meta_robots' => Yii::t('product', 'Meta Robots'), 87 'meta_robots' => Yii::t('product', 'Meta Robots'),
87 'seo_text' => Yii::t('product', 'Seo Text'), 88 'seo_text' => Yii::t('product', 'Seo Text'),
  89 + 'in_menu' => Yii::t('product', 'Выводить в меню'),
88 ]; 90 ];
89 } 91 }
90 92
frontend/views/catalog/brand.php 0 → 100644
  1 +<?php
  2 +/**
  3 + * @var $productProvider \yii\data\ActiveDataProvider
  4 + * @var View $this
  5 + */
  6 +use frontend\widgets\FilterWidget;
  7 +use frontend\widgets\Seo;
  8 +use yii\helpers\Url;
  9 +use yii\web\View;
  10 +use yii\widgets\ListView;
  11 +$this->params['seo']['title'] = !empty($category->meta_title) ? $category->meta_title : '';
  12 +
  13 +$this->params['seo']['fields']['meta-title'] = $category->meta_title;
  14 +$this->params['seo']['h1'] = !empty($category->h1) ? $category->h1 : $category->name;
  15 +$this->params['seo']['seo_text'] = $category->seo_text;
  16 +$this->params['seo']['description'] = $category->meta_desc;
  17 +$this->params['seo']['meta'] = $category->meta_robots;
  18 +$this->params['seo']['category_name'] = $category->name;
  19 +
  20 +$this->params['breadcrumbs'][] = $category->name;
  21 +?>
  22 +<!-- Табы для слайдера -->
  23 +<div class="bigSlidertabs fixed" style="position:fixed;">
  24 + <div class="block-100">
  25 + <div class="tab1">
  26 + <a href="actionlist.htm">
  27 + <div class="tab_bg_1"></div>
  28 + <p>В данный момент у нас проходит <a href="actionlist.htm">25 акций</p></a>
  29 + </a>
  30 + </div>
  31 + <!--
  32 + <div class="tab2" style="display: none;">
  33 + <div class="tab_bg_2"></div>
  34 + <p>Поступило на продажу <a href="#">10 новинок</a></p>
  35 + </div>
  36 + -->
  37 + </div>
  38 +</div>
  39 +<div class="container">
  40 + <div class="block-25" style="position: relative;">
  41 +
  42 +
  43 +
  44 + <div class="columnLeftInfo">
  45 + <!-- del_columnLeftInfo -->
  46 +
  47 +
  48 +
  49 +
  50 +
  51 + <a href="http://ventolux.ua/"><img src="http://www.linija-svitla.ua/res/custom/images/banner/ventolux1.jpg"></a><br><br>
  52 +
  53 +
  54 + <table border="0" cellspacing="0" cellpadding="0" class="boxGen articleBox">
  55 + <tr class="bxhead">
  56 + <th class="bxhl"></th>
  57 + <th class="bxhc"><div class="h3">
  58 + <a href="view-articles/">Статьи</a>
  59 + </div></th>
  60 +
  61 + <th class="bxhr"></th>
  62 + </tr>
  63 +
  64 + <tr class="bxdelim">
  65 + <td></td>
  66 + <td></td>
  67 + <td></td>
  68 + </tr>
  69 + <tr class="bxmiddle">
  70 + <td class="bxl"></td>
  71 + <td class="bxc"> <div width="100%" class="articlesBox"><!-- cats_table-->
  72 + <div width="100%">
  73 + <div class="articleItem">
  74 + <span class="image">
  75 + </span>
  76 + <span align="left" class="title">
  77 + <a href="liniya-sveta-predstavila-trendovye-modeli-na-interior-mebel-85.htm" >
  78 + Линия света представила трендовые модели на Interior Mebel
  79 + </a>
  80 + </span>
  81 +
  82 + <div align="left" class="desc">
  83 + <p>В Киеве прошла выставка Interior Mebel, которая уже традиционно собирает лучшие образцы дизайна интерьера. На...
  84 + <a href="liniya-sveta-predstavila-trendovye-modeli-na-interior-mebel-85.htm" >
  85 + подробнее
  86 + </a>
  87 + </div>
  88 +
  89 + </div>
  90 +
  91 +
  92 + <div class="articleItem">
  93 + <span class="image">
  94 + </span>
  95 + <span align="left" class="title">
  96 + <a href="svetodiodnoe-osveschenie-light-topps-svetodiodnye-lampochki-lampy-colon-kupit-dlya-doma-ceny-v-ukraine-84.htm" >
  97 + Светодиодное освещение Light Topps | Светодиодные...
  98 + </a>
  99 + </span>
  100 +
  101 + <div align="left" class="desc">
  102 + О светодиодных лампах и светильниках, в которых используются светодиодные модули, написано немало и наверняка уже...
  103 + <a href="svetodiodnoe-osveschenie-light-topps-svetodiodnye-lampochki-lampy-colon-kupit-dlya-doma-ceny-v-ukraine-84.htm" >
  104 + подробнее
  105 + </a>
  106 + </div>
  107 +
  108 + </div>
  109 +
  110 +
  111 + <div class="articleItem">
  112 + <span class="image">
  113 + </span>
  114 + <span align="left" class="title">
  115 + <a href="lyustry-potolochnye-novye-vozmojnosti-upravleniya-svetom-82.htm" >
  116 + Люстры потолочные. Новые возможности управления светом
  117 + </a>
  118 + </span>
  119 +
  120 + <div align="left" class="desc">
  121 + Люстры потолочные оснащенные пультом дистанционного управления, позволяют включать/выключать, а также регулировать...
  122 + <a href="lyustry-potolochnye-novye-vozmojnosti-upravleniya-svetom-82.htm" >
  123 + подробнее
  124 + </a>
  125 + </div>
  126 +
  127 + </div>
  128 +
  129 +
  130 +
  131 +
  132 +
  133 +
  134 +
  135 +
  136 +
  137 +
  138 + <div style="clear: left;"></div>
  139 +
  140 +
  141 + </div>
  142 +
  143 +
  144 + </td>
  145 + <td class="bxr"></td>
  146 + </tr>
  147 + <tr class="bxbottom">
  148 + <td class="bxbl"></td>
  149 + <td class="bxbc"></td>
  150 + <td class="bxbr"></td>
  151 + </tr>
  152 + </table>
  153 +
  154 + <div class="clearfix"></div>
  155 +
  156 +
  157 + <!-- del_columnLeftInfo_end -->
  158 + </div>
  159 +
  160 +
  161 + <br />
  162 +
  163 +
  164 +
  165 + </div>
  166 + <div class="block-75" itemscope itemtype="http://schema.org/Product">
  167 +
  168 +
  169 +
  170 +
  171 + <script>
  172 +
  173 +
  174 + </script>
  175 +
  176 +
  177 +
  178 + <h1 class="title"><?= Seo::widget([ 'row'=>'h1'])?></h1>
  179 +
  180 +
  181 + <div class="list_filters_links">
  182 + <div class="sort_block">
  183 + <span>Сортировка:</span>
  184 + <?= \yii\widgets\LinkSorter::widget([
  185 + 'sort' => $productProvider->sort,
  186 + 'attributes' => [
  187 + 'price',
  188 + ]
  189 + ]);
  190 + ?>
  191 + </div>
  192 + <div class="clearfix"></div>
  193 + </div>
  194 +
  195 +
  196 +
  197 + <div class="clearfix"></div>
  198 +
  199 +
  200 + <div class="catalog_product_list view_table">
  201 +
  202 +
  203 + <?= ListView::widget([
  204 + 'dataProvider' => $productProvider,
  205 + 'itemView' => function ($model, $key, $index, $widget) use($category) {
  206 + return $this->render('_product_item',[
  207 + 'model' => $model,
  208 + 'category' => $category
  209 + ]);
  210 + },
  211 + 'layout' => "{items}<div class=\"clearfix\"></div>{pager}",
  212 + ])
  213 +
  214 + ?>
  215 +
  216 +
  217 +
  218 +
  219 + <div class="clearfix"></div>
  220 + </div>
  221 +
  222 + <br>
  223 +
  224 +
  225 +
  226 +
  227 +
  228 +
  229 +
  230 + <div class="clearfix"></div>
  231 +
  232 +
  233 +
  234 +
  235 + <div class="clearfix"></div>
  236 +
  237 +
  238 + </div>
  239 +</div>
  240 +
  241 +
frontend/views/partial/brand_list.php 0 → 100644
  1 +<?php
  2 +use common\modules\product\models\Brand;
  3 +use yii\helpers\Html;
  4 +use common\components\artboximage\ArtboxImageHelper;
  5 +
  6 +$brands = Brand::find()->where(['in_menu' => 1])->all();
  7 +$content = '';
  8 +
  9 +foreach($brands as $brand){
  10 + $content .= Html::tag('li', Html::a(Html::img(ArtboxImageHelper::getImageSrc($brand->imageUrl, 'brand_item')),\yii\helpers\Url::to(['catalog/brand', 'brand' => $brand->alias]) ));
  11 +
  12 +}
  13 +
  14 +
  15 +echo Html::tag('ul',$content);
  16 +
frontend/views/partial/main-menu.php 0 → 100644
  1 +<?php
  2 +use common\components\artboximage\ArtboxImageHelper;
  3 +use common\modules\product\models\Category;
  4 +use yii\helpers\Html;
  5 +use yii\helpers\Url;
  6 +
  7 +$models = Category::find()->all();
  8 +?>
  9 +
  10 +
  11 +<div id="mainmenu">
  12 + <div class="container">
  13 + <ul id="menu-bar">
  14 +
  15 +
  16 + <?php foreach($models as $model):?>
  17 + <li>
  18 +
  19 +
  20 + <a href="<?= Url::to(['catalog/category','category' => $model['alias']]) ?>">
  21 + <?= $model->name?>
  22 + <div class="main_menu_divider"></div>
  23 + <div class="main_menu_down_arrow"></div>
  24 + </a>
  25 +
  26 +
  27 + <ul>
  28 +
  29 + <?php foreach($model->getTaxGroupsForMenu() as $group): ?>
  30 + <li>
  31 +
  32 + <a href="<?= Url::to(['catalog/category','category' => $model['alias'],'filters' => [$group['alias'] => [$group['option_alias']]]]) ?>">
  33 + <div class="option_image_block">
  34 + <?= Html::img(ArtboxImageHelper::getImageSrc(Yii::getAlias('@imagesUrl/tax_option/'. $group['image']), 'option_menu'))?>
  35 + </div>
  36 + <div class="clearfix"></div>
  37 + <span class="menu-bar-cat-name"><?=$group['value']?></span>
  38 + </a>
  39 + </li>
  40 + <?php endforeach;?>
  41 +
  42 +
  43 + </ul>
  44 +
  45 + </li>
  46 + <?php endforeach; ?>
  47 +
  48 +
  49 +
  50 +
  51 +
  52 + </ul>
  53 + </div>
  54 +</div>
0 \ No newline at end of file 55 \ No newline at end of file