-
+ false,
+ 'options' => ['enctype' => 'multipart/form-data']
+ ]); ?>
= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
@@ -31,20 +34,21 @@ use common\components\Request;
)
]) ?>
- = ImageUploader::widget([
- 'model'=> $model,
- 'field'=>'cover',
- 'size' => [
- [
- 'width'=>340,
- 'height'=>260,
- ]
+ = $form->field($model, 'imageUpload')->widget(\kartik\file\FileInput::classname(), [
+ 'language' => 'ru',
+ 'options' => [
+ 'accept' => 'image/*',
+ 'multiple' => false,
],
- 'multi'=>true,
- 'gallery' =>$model->cover,
- 'name' => 'Загрузить миниатюру статьи'
- ]);
- ?>
+ 'pluginOptions' => [
+ 'allowedFileExtensions' => ['jpg', 'gif', 'png'],
+ 'initialPreview' => !empty($model->imageUrl) ? \common\components\artboximage\ArtboxImageHelper::getImage($model->imageUrl, 'list') : '',
+ 'overwriteInitial' => true,
+ 'showRemove' => false,
+ 'showUpload' => false,
+ 'previewFileType' => 'image',
+ ],
+ ]); ?>
= FieldEditor::widget([
'template' => 'education',
diff --git a/backend/views/brand/_form.php b/backend/views/brand/_form.php
index 0f2e78a..993a69b 100755
--- a/backend/views/brand/_form.php
+++ b/backend/views/brand/_form.php
@@ -19,7 +19,21 @@ use yii\widgets\ActiveForm;
= $form->field($model, 'alias')->textInput(['maxlength' => true]) ?>
- = $form->field($model, 'image')->fileInput(['accept' => 'image/*']) ?>
+ = $form->field($model, 'imageUpload')->widget(\kartik\file\FileInput::classname(), [
+ 'language' => 'ru',
+ 'options' => [
+ 'accept' => 'image/*',
+ 'multiple' => false,
+ ],
+ 'pluginOptions' => [
+ 'allowedFileExtensions' => ['jpg', 'gif', 'png'],
+ 'initialPreview' => !empty($model->imageUrl) ? \common\components\artboximage\ArtboxImageHelper::getImage($model->imageUrl, 'list') : '',
+ 'overwriteInitial' => true,
+ 'showRemove' => false,
+ 'showUpload' => false,
+ 'previewFileType' => 'image',
+ ],
+ ]); ?>
= $form->field($model, 'meta_title')->textInput(['maxlength' => true]) ?>
diff --git a/backend/views/brand/view.php b/backend/views/brand/view.php
index be314ae..ad1a066 100755
--- a/backend/views/brand/view.php
+++ b/backend/views/brand/view.php
@@ -31,7 +31,7 @@ $this->params['breadcrumbs'][] = $this->title;
'brand_id',
'brand_name_id',
'alias',
- 'image',
+ 'imageUrl:image',
'meta_title',
'meta_desc:ntext',
'meta_robots',
diff --git a/backend/views/category/_form.php b/backend/views/category/_form.php
index 5aae4de..7d3264c 100755
--- a/backend/views/category/_form.php
+++ b/backend/views/category/_form.php
@@ -12,7 +12,10 @@ use kartik\select2\Select2;
-
+ false,
+ 'options' => ['enctype' => 'multipart/form-data']
+ ]); ?>
= $form->field($model, 'name')->textInput() ?>
@@ -25,13 +28,6 @@ use kartik\select2\Select2;
]
])->label(Yii::t('product', 'Parent category')) ?>
- field($model, 'group_to_category')->dropDownList(
- \yii\helpers\ArrayHelper::map(\common\modules\rubrication\models\TaxGroup::find()->all(), 'tax_group_id', 'name'), [
- 'multiple' => true
- ])->label(Yii::t('product', 'Linked options')) ?>
- */?>
-
= $form->field($model, 'group_to_category')->widget(Select2::className(), [
'data' => \yii\helpers\ArrayHelper::map(\common\modules\rubrication\models\TaxGroup::find()->all(), 'tax_group_id', 'name'),
'language' => 'ru',
@@ -45,20 +41,21 @@ use kartik\select2\Select2;
]
) ?>
- = ImageUploader::widget([
- 'model'=> $model,
- 'field'=>'image',
- 'size' => [
- [
- 'width'=>340,
- 'height'=>260,
- ]
+ = $form->field($model, 'imageUpload')->widget(\kartik\file\FileInput::classname(), [
+ 'language' => 'ru',
+ 'options' => [
+ 'accept' => 'image/*',
+ 'multiple' => false,
+ ],
+ 'pluginOptions' => [
+ 'allowedFileExtensions' => ['jpg', 'gif', 'png'],
+ 'initialPreview' => !empty($model->imageUrl) ? \common\components\artboximage\ArtboxImageHelper::getImage($model->imageUrl, 'list') : '',
+ 'overwriteInitial' => true,
+ 'showRemove' => false,
+ 'showUpload' => false,
+ 'previewFileType' => 'image',
],
- 'multi'=>false,
- 'gallery' => $model->image,
- 'name' => 'Загрузить изображение'
- ]);
- ?>
+ ]); ?>
= $form->field($model, 'meta_title')->textInput(['maxlength' => true]) ?>
diff --git a/backend/views/category/view.php b/backend/views/category/view.php
index 987a3d4..fe771c5 100755
--- a/backend/views/category/view.php
+++ b/backend/views/category/view.php
@@ -36,7 +36,7 @@ $this->params['breadcrumbs'][] = $this->title;
'parent_id',
'path',
'depth',
- 'image',
+ 'imageUrl:image',
'meta_title',
'meta_desc:ntext',
'meta_robots',
diff --git a/common/components/artboximage/ArtboxImageBehavior.php b/common/components/artboximage/ArtboxImageBehavior.php
new file mode 100644
index 0000000..51a2c42
--- /dev/null
+++ b/common/components/artboximage/ArtboxImageBehavior.php
@@ -0,0 +1,10 @@
+ 255],
+ [['imageUpload'], 'safe'],
+ [['imageUpload'], 'file', 'extensions' => 'jpg, gif, png'],
];
}
@@ -53,6 +57,7 @@ class Articles extends \yii\db\ActiveRecord
'title' => 'Title',
'body' => 'Body',
'image' => 'Image',
+ 'imageUrl' => Yii::t('app', 'Image'),
'translit' => 'Translit',
'meta_title' => 'Meta Title',
'meta_keywords' => 'Meta Keywords',
@@ -61,4 +66,13 @@ class Articles extends \yii\db\ActiveRecord
'h1' => 'H1',
];
}
+
+ public function getImageFile() {
+ return empty($this->image) ? null : Yii::getAlias('@imagesDir/articles/'. $this->image);
+ }
+
+ public function getImageUrl()
+ {
+ return empty($this->image) ? null : Yii::getAlias('@imagesUrl/articles/' . $this->image);
+ }
}
diff --git a/common/models/Blog.php b/common/models/Blog.php
index 5375804..1cf7239 100755
--- a/common/models/Blog.php
+++ b/common/models/Blog.php
@@ -21,6 +21,7 @@
*/
class Blog extends \yii\db\ActiveRecord
{
+ public $imageUpload;
/**
* @inheritdoc
@@ -80,6 +81,8 @@
'string',
'max' => 255,
],
+ [['imageUpload'], 'safe'],
+ [['imageUpload'], 'file', 'extensions' => 'jpg, gif, png'],
];
}
@@ -102,6 +105,17 @@
'view_count' => Yii::t('app', 'view_count'),
'description' => Yii::t('app', 'description'),
'cover' => Yii::t('app', 'cover'),
+ 'image' => Yii::t('app', 'cover'),
+ 'imageUrl' => Yii::t('app', 'cover'),
];
}
+
+ public function getImageFile() {
+ return empty($this->image) ? null : Yii::getAlias('@imagesDir/brands/'. $this->image);
+ }
+
+ public function getImageUrl()
+ {
+ return empty($this->image) ? null : Yii::getAlias('@imagesUrl/brands/' . $this->image);
+ }
}
diff --git a/common/modules/product/models/Brand.php b/common/modules/product/models/Brand.php
index 8f65f41..3b1ad37 100755
--- a/common/modules/product/models/Brand.php
+++ b/common/modules/product/models/Brand.php
@@ -4,8 +4,7 @@ namespace common\modules\product\models;
use common\behaviors\Slug;
use common\modules\rubrication\behaviors\ArtboxSynonymBehavior;
-use mongosoft\file\UploadBehavior;
-use mongosoft\file\UploadImageBehavior;
+use yii\web\UploadedFile;
use Yii;
/**
@@ -27,6 +26,8 @@ use Yii;
*/
class Brand extends \yii\db\ActiveRecord
{
+ public $imageUpload;
+
public function behaviors()
{
return [
@@ -43,18 +44,6 @@ class Brand extends \yii\db\ActiveRecord
'slugKeyName' => 'alias',
'translit' => true
],
- 'uploader' => [
- 'class' => UploadBehavior::className(),
- 'attribute' => 'fileUpload',
- 'scenarios' => ['insert', 'update'],
-// 'placeholder' => '@app/modules/user/assets/images/userpic.jpg',
- 'path' => '@storage/brands/{alias}',
- 'url' => '/storage/brands/{alias}',
-// 'thumbs' => [
-// 'thumb' => ['width' => 400, 'quality' => 90],
-// 'preview' => ['width' => 200, 'height' => 200],
-// ],
- ],
],
];
}
@@ -77,10 +66,10 @@ class Brand extends \yii\db\ActiveRecord
[['brand_name_id'], 'integer'],
[['meta_desc', 'seo_text'], 'string'],
[['alias', 'name'], 'string', 'max' => 250],
- [['meta_title'], 'string', 'max' => 255],
+ [['meta_title', 'image'], 'string', 'max' => 255],
[['meta_robots'], 'string', 'max' => 50],
- [['fileUpload'], 'file', 'extensions' => 'jpg, gif, png'],
-// [['brand_name_id'], 'exist', 'skipOnError' => true, 'targetClass' => BrandName::className(), 'targetAttribute' => ['brand_name_id' => 'brand_name_id']],
+ [['imageUpload'], 'safe'],
+ [['imageUpload'], 'file', 'extensions' => 'jpg, gif, png'],
];
}
@@ -132,10 +121,11 @@ class Brand extends \yii\db\ActiveRecord
}
public function getImageFile() {
- return empty($this->image) ? null : '/images/brand/'. $this->image;
+ return empty($this->image) ? null : Yii::getAlias('@imagesDir/brands/'. $this->image);
}
- public function getImageUrl() {
- return empty($this->image) ? null : '/images/brand/'. $this->image;
+ public function getImageUrl()
+ {
+ return empty($this->image) ? null : Yii::getAlias('@imagesUrl/brands/' . $this->image);
}
}
diff --git a/common/modules/product/models/Category.php b/common/modules/product/models/Category.php
index 144fee4..8d70776 100755
--- a/common/modules/product/models/Category.php
+++ b/common/modules/product/models/Category.php
@@ -85,7 +85,7 @@ class Category extends \yii\db\ActiveRecord
[['name'], 'string'],
[['parent_id', 'depth', 'category_name_id', 'product_unit_id'], 'integer'],
[['path', 'meta_desc', 'seo_text'], 'string'],
- [['meta_title'], 'string', 'max' => 255],
+ [['meta_title', 'image'], 'string', 'max' => 255],
[['meta_robots'], 'string', 'max' => 50],
[['alias', 'name'], 'string', 'max' => 250],
[['populary'], 'boolean'],
@@ -93,7 +93,6 @@ class Category extends \yii\db\ActiveRecord
[['category_name_id'], 'exist', 'skipOnError' => true, 'targetClass' => CategoryName::className(), 'targetAttribute' => ['category_name_id' => 'category_name_id']],
[['imageUpload'], 'safe'],
[['imageUpload'], 'file', 'extensions' => 'jpg, gif, png'],
-// [['product_unit_id'], 'exist', 'skipOnError' => true, 'targetClass' => ProductUnit::className(), 'targetAttribute' => ['product_unit_id' => 'product_unit_id']],
];
}
@@ -172,14 +171,17 @@ class Category extends \yii\db\ActiveRecord
return $this->hasOne(CategoryName::className(), ['category_name_id' => 'category_name_id']);
}
- public function getName()
- {
+ public function getName() {
return empty($this->categoryName) ? null : $this->categoryName->value;
}
+ public function getImageFile() {
+ return empty($this->image) ? null : Yii::getAlias('@imagesDir/categories/'. $this->image);
+ }
+
public function getImageUrl()
{
- return empty($this->image) ? null : '/images/category/' . $this->image;
+ return empty($this->image) ? null : Yii::getAlias('@imagesUrl/categories/' . $this->image);
}
public function beforeSave($insert)
diff --git a/frontend/views/articles/index.php b/frontend/views/articles/index.php
index fa23016..42e6fad 100755
--- a/frontend/views/articles/index.php
+++ b/frontend/views/articles/index.php
@@ -27,7 +27,9 @@ $this->registerMetaTag(['name' => 'keywords', 'content' => 'Блог']);
diff --git a/frontend/views/articles/show.php b/frontend/views/articles/show.php
index d49604f..90fb49a 100755
--- a/frontend/views/articles/show.php
+++ b/frontend/views/articles/show.php
@@ -22,8 +22,7 @@ $this->registerMetaTag(['name' => 'keywords', 'content' => $news->meta_keywords]
=$news->title?>
-
-

+ = \common\components\artboximage\ArtboxImageHelper::getImage($news->imageUrl, 'product')?>
=$news->body?>
=$news->date?>
diff --git a/frontend/views/catalog/product_item.php b/frontend/views/catalog/product_item.php
index dfcc1c3..995273e 100755
--- a/frontend/views/catalog/product_item.php
+++ b/frontend/views/catalog/product_item.php
@@ -9,11 +9,7 @@ use yii\helpers\Url;
'catalog/product',
'product' => $product])
?>">
- image)) :?>
-

-
- = \common\components\artboximage\ArtboxImageHelper::getImage($product->image->imageUrl, 'list')?>
-
+ = \common\components\artboximage\ArtboxImageHelper::getImage($product->imageUrl, 'list')?>