From 060b480672b0f189c7bb1ddb2af0a9426c3c14f8 Mon Sep 17 00:00:00 2001 From: Karnovsky A Date: Fri, 20 May 2016 13:31:49 +0300 Subject: [PATCH] - --- backend/controllers/BrandController.php | 6 +----- backend/views/brand/_form.php | 4 +++- common/modules/product/models/Brand.php | 18 +++++++++++++++--- common/modules/product/widgets/lastProducts.php | 1 + common/modules/product/widgets/specialProducts.php | 1 + common/modules/product/widgets/views/products_block.php | 2 +- frontend/views/catalog/product.php | 14 +++++++------- frontend/views/catalog/product_item.php | 2 +- 8 files changed, 30 insertions(+), 18 deletions(-) diff --git a/backend/controllers/BrandController.php b/backend/controllers/BrandController.php index a15be2f..a6243c0 100755 --- a/backend/controllers/BrandController.php +++ b/backend/controllers/BrandController.php @@ -97,11 +97,7 @@ class BrandController extends Controller public function actionUpdate($id) { $model = $this->findModel($id); - - var_dump($_POST); - print "\n+++++++++++++++++++++++++++++++++++++\n"; - var_dump($_FILES); - exit; + $model->setScenario('update'); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->brand_id]); diff --git a/backend/views/brand/_form.php b/backend/views/brand/_form.php index 2e02b74..e2f90b5 100755 --- a/backend/views/brand/_form.php +++ b/backend/views/brand/_form.php @@ -18,7 +18,9 @@ use yii\widgets\ActiveForm; field($model, 'alias')->textInput(['maxlength' => true]) ?> - + + + field($model, 'image')->fileInput(['accept' => 'image/*']) ?> field($model, 'meta_title')->textInput(['maxlength' => true]) ?> diff --git a/common/modules/product/models/Brand.php b/common/modules/product/models/Brand.php index b9ab809..22db37a 100755 --- a/common/modules/product/models/Brand.php +++ b/common/modules/product/models/Brand.php @@ -4,6 +4,8 @@ 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; /** @@ -25,7 +27,6 @@ use Yii; */ class Brand extends \yii\db\ActiveRecord { - public $imageUpload; public function behaviors() { @@ -43,6 +44,18 @@ class Brand extends \yii\db\ActiveRecord 'slugKeyName' => 'alias', 'translit' => true ], + 'uploader' => [ + 'class' => UploadImageBehavior::className(), + 'attribute' => 'image', + 'scenarios' => ['insert', 'update'], +// 'placeholder' => '@app/modules/user/assets/images/userpic.jpg', + 'path' => '@storage/{alias}', + 'url' => '/storage/{alias}', +// 'thumbs' => [ +// 'thumb' => ['width' => 400, 'quality' => 90], +// 'preview' => ['width' => 200, 'height' => 200], +// ], + ], ], ]; } @@ -67,8 +80,7 @@ class Brand extends \yii\db\ActiveRecord [['alias', 'name'], 'string', 'max' => 250], [['image', 'meta_title'], 'string', 'max' => 255], [['meta_robots'], 'string', 'max' => 50], - [['imageUpload'], 'safe'], - [['imageUpload'], 'file', 'extensions' => 'jpg, gif, png'], + ['image', 'file', 'extensions' => 'jpg, gif, png', 'on' => ['insert', 'update']], // [['brand_name_id'], 'exist', 'skipOnError' => true, 'targetClass' => BrandName::className(), 'targetAttribute' => ['brand_name_id' => 'brand_name_id']], ]; } diff --git a/common/modules/product/widgets/lastProducts.php b/common/modules/product/widgets/lastProducts.php index 225b655..ab00838 100644 --- a/common/modules/product/widgets/lastProducts.php +++ b/common/modules/product/widgets/lastProducts.php @@ -15,6 +15,7 @@ class lastProducts extends Widget { public function run() { return $this->render('products_block', [ 'title' => \Yii::t('product', 'Вы недавно просматривали'), + 'class' => 'last-products', 'products' => ProductHelper::getLastProducts(true), ]); } diff --git a/common/modules/product/widgets/specialProducts.php b/common/modules/product/widgets/specialProducts.php index 3f0d5c0..a083696 100644 --- a/common/modules/product/widgets/specialProducts.php +++ b/common/modules/product/widgets/specialProducts.php @@ -40,6 +40,7 @@ class specialProducts extends Widget { return $this->render('products_block', [ 'title' => $this->title, + 'class' => $this->type, 'products' => $products, ]); } diff --git a/common/modules/product/widgets/views/products_block.php b/common/modules/product/widgets/views/products_block.php index 4f0d380..962ee15 100644 --- a/common/modules/product/widgets/views/products_block.php +++ b/common/modules/product/widgets/views/products_block.php @@ -1,4 +1,4 @@ -
+

    diff --git a/frontend/views/catalog/product.php b/frontend/views/catalog/product.php index 22247cb..2731cb3 100755 --- a/frontend/views/catalog/product.php +++ b/frontend/views/catalog/product.php @@ -3,16 +3,16 @@ use yii\widgets\Breadcrumbs; use yii\web\View; use yii\helpers\Url; -$this->title = $product->name; -//$this->title = (! empty($product->meta_title)) ? $product->meta_title : $product->name; -//$this->registerMetaTag (['name' => 'description', 'content' => ((! empty($product->meta_description)) ? $product->meta_description : $product->name)]); +$this->title = $product->fullname; +//$this->title = (! empty($product->meta_title)) ? $product->meta_title : $product->fullname; +//$this->registerMetaTag (['name' => 'description', 'content' => ((! empty($product->meta_description)) ? $product->meta_description : $product->fullname)]); //$this->registerMetaTag (['name' => 'keywords', 'content' => $product->meta_keywords]); foreach($product->category->getParents()->all() as $parent) { $this->params['breadcrumbs'][] = ['label' => $parent->categoryName->value, 'url' => ['catalog/category', 'category' => $parent]]; } $this->params['breadcrumbs'][] = ['label' => $product->category->categoryName->value, 'url' => ['catalog/category', 'category' => $product->category]]; -$this->params['breadcrumbs'][] = $product->name .' #'. $product->variant->sku; +$this->params['breadcrumbs'][] = $product->fullname .' #'. $product->variant->sku; $this->registerJs (' @@ -83,7 +83,7 @@ $this->registerJs (" ['label' => 'Каталог', 'url' => ['catalog/all']], // ['label'=>$catalog->parent->name,'url'=>['catalog/index','translit'=>$catalog->parent->translit]], ['label' => $category->name, 'url' => ['catalog/category', 'category' => $category]], - $product->name, + $product->fullname, ], ]) ?>
    @@ -93,7 +93,7 @@ $this->registerJs ("
    -

    name ?>

    +

    fullname ?>

    Цветовые решения
      variants as $variant): ?> @@ -104,7 +104,7 @@ $this->registerJs (" data-color="name ?>" data-image="imageUrl ?>" data-imageoriginal="imageUrl ?>" - title="name ?>"> + title="fullname ?>"> imageUrl, 'product_variant')?> diff --git a/frontend/views/catalog/product_item.php b/frontend/views/catalog/product_item.php index bbbaacd..d95d8fe 100755 --- a/frontend/views/catalog/product_item.php +++ b/frontend/views/catalog/product_item.php @@ -25,7 +25,7 @@ use yii\helpers\Url; name ?> + ?>" class="name">fullname ?>