From 50e38c821c7e99b75ee7d496d74f747c879c8e6d Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Tue, 30 Aug 2016 18:36:58 +0300 Subject: [PATCH] big commti --- common/components/artboximage/ArtboxImageHelper.php | 1 + common/config/main.php | 4 ++-- common/models/Slider.php | 20 ++++++++++++++++++++ common/modules/product/widgets/views/products_block.php | 6 +++--- frontend/controllers/SearchController.php | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ frontend/views/catalog/products.php | 26 ++++++++++---------------- frontend/views/layouts/main.php | 8 +++++--- frontend/views/modal/my_callback_modal_window.php | 13 ++++++++----- frontend/views/search/_product_search_item.php | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ frontend/views/search/index.php | 329 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ frontend/views/site/index.php | 144 +++++------------------------------------------------------------------------------------------------------------------------------------------- frontend/web/css/css_header.css | 11 ++++++++++- frontend/web/css/owl.carousel.css | 216 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ frontend/web/js/owl.carousel.js | 3069 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ frontend/widgets/Slider.php | 9 ++++++--- frontend/widgets/views/slider.php | 65 ++++++++++++++++++++--------------------------------------------- 16 files changed, 3872 insertions(+), 217 deletions(-) create mode 100755 frontend/controllers/SearchController.php create mode 100755 frontend/views/search/_product_search_item.php create mode 100755 frontend/views/search/index.php create mode 100644 frontend/web/css/owl.carousel.css create mode 100644 frontend/web/js/owl.carousel.js diff --git a/common/components/artboximage/ArtboxImageHelper.php b/common/components/artboximage/ArtboxImageHelper.php index a6c6ae5..0735f98 100755 --- a/common/components/artboximage/ArtboxImageHelper.php +++ b/common/components/artboximage/ArtboxImageHelper.php @@ -21,6 +21,7 @@ class ArtboxImageHelper extends Object { } public function getPreset($preset) { + if (empty(self::$presets)) { self::$presets = self::getDriver()->presets; } diff --git a/common/config/main.php b/common/config/main.php index ef64fab..5a3ace9 100755 --- a/common/config/main.php +++ b/common/config/main.php @@ -98,8 +98,8 @@ return [ ], 'slider' => [ 'resize' => [ - 'width' => 720, - 'height' => 340, + 'width' => 1400, + 'height' => 600, 'master' => null ], ], diff --git a/common/models/Slider.php b/common/models/Slider.php index 4ce0975..e1d5520 100755 --- a/common/models/Slider.php +++ b/common/models/Slider.php @@ -65,4 +65,24 @@ class Slider extends \yii\db\ActiveRecord { return $this->hasMany(SliderImage::className(), ['slider_id' => 'slider_id'])->where([SliderImage::tableName().'.status'=>1]); } + + + /** + * fetch stored image file name with complete path + * @return string + */ + public function getImageFile() + { + return isset($this->image) ? '/storage/slider/' . $this->image : null; + } + + /** + * fetch stored image url + * @return string + */ + public function getImageUrl() + { + // return a default image placeholder if your source image is not found + return isset($this->image) ? '/storage/slider/'. $this->image : '/storage/no_photo.png'; + } } diff --git a/common/modules/product/widgets/views/products_block.php b/common/modules/product/widgets/views/products_block.php index feae4a3..59152aa 100755 --- a/common/modules/product/widgets/views/products_block.php +++ b/common/modules/product/widgets/views/products_block.php @@ -12,7 +12,7 @@ use yii\web\View; -webkit-margin-start: 0px; -webkit-margin-end: 0px; font-weight: bold;"> - - registerJs($js, View::POS_READY); ?> \ No newline at end of file diff --git a/frontend/controllers/SearchController.php b/frontend/controllers/SearchController.php new file mode 100755 index 0000000..a60e80c --- /dev/null +++ b/frontend/controllers/SearchController.php @@ -0,0 +1,76 @@ +request->get('word', '')); + + if (!empty($word)) + { + + + if( preg_match('/^\+?\d+$/', $word) && (iconv_strlen($word) > 4)){ + + $params['keywords'][] = $word; + + $categoriesQuery = Category::find() + ->innerJoin(ProductCategory::tableName(), ProductCategory::tableName() .'.category_id = '. Category::tableName() .'.category_id') + ->innerJoin(Product::tableName(), Product::tableName() .'.product_id = '. ProductCategory::tableName() .'.product_id') + ->innerJoin(ProductVariant::tableName(), ProductVariant::tableName() .'.product_id = '. ProductCategory::tableName() .'.product_id'); + $categoriesQuery->andWhere(['ilike', 'product.name', $params['keywords'][0]]); + $categories = $categoriesQuery->all(); + + } else { + + $params['keywords'] = explode(' ', preg_replace("|[\s,.!:&?~();-]|i", " ", $word)); + + foreach($params['keywords'] as $i => &$keyword) { + $keyword = trim($keyword); + if (empty($keyword)) { + unset($params['keywords'][$i]); + } + } + array_unshift($params['keywords'], $word); + + $categoriesQuery = Category::find() + ->innerJoin(ProductCategory::tableName(), ProductCategory::tableName() .'.category_id = '. Category::tableName() .'.category_id') + ->innerJoin(Product::tableName(), Product::tableName() .'.product_id = '. ProductCategory::tableName() .'.product_id') + ->innerJoin(ProductVariant::tableName(), ProductVariant::tableName() .'.product_id = '. ProductCategory::tableName() .'.product_id'); + foreach ($params['keywords'] as $keyword) { + $categoriesQuery->andWhere(['ilike', 'product.name', $keyword]); + } + $categoriesQuery->andWhere(['!=', ProductVariant::tableName() .'.stock', 0]); + $categories = $categoriesQuery->all(); + } + + $productModel = new ProductFrontendSearch(); + $productProvider = $productModel->search(null, $params); + + + return $this->render( + 'index', + [ + 'keywords' => $params['keywords'], + 'productModel' => $productModel, + 'productProvider' => $productProvider, + 'categories' => $categories, + ] + ); + } + else + { + throw new HttpException(404, 'Данной странице не существует!'); + } + } +} \ No newline at end of file diff --git a/frontend/views/catalog/products.php b/frontend/views/catalog/products.php index 70586e5..ba6e08a 100755 --- a/frontend/views/catalog/products.php +++ b/frontend/views/catalog/products.php @@ -229,22 +229,16 @@ use yii\helpers\Url;
  • - +
    + Сортировка: + $productProvider->sort, + 'attributes' => [ + 'price', + ] + ]); + ?> +
    diff --git a/frontend/views/layouts/main.php b/frontend/views/layouts/main.php index 716acea..704e4ca 100755 --- a/frontend/views/layouts/main.php +++ b/frontend/views/layouts/main.php @@ -150,17 +150,19 @@ AppAsset::register($this);
    + +
    diff --git a/frontend/views/modal/my_callback_modal_window.php b/frontend/views/modal/my_callback_modal_window.php index 1356a6a..3d37a84 100644 --- a/frontend/views/modal/my_callback_modal_window.php +++ b/frontend/views/modal/my_callback_modal_window.php @@ -1,3 +1,8 @@ +