From d1d3f8c4801696bc5557ea590a075e4936fea868 Mon Sep 17 00:00:00 2001 From: mDeflotte Date: Thu, 15 Dec 2011 10:50:42 +0000 Subject: [PATCH] // BugFix --- classes/helper/Helper.php | 91 ------------------------ controllers/front/CategoryController.php | 4 +- modules/blockcart/blockcart-ajax.php | 3 +- modules/blocklayered/blocklayered.js | 6 +- modules/blocklayered/blocklayered.php | 68 ++++++++++-------- themes/default/product-sort.tpl | 1 + 6 files changed, 48 insertions(+), 125 deletions(-) diff --git a/classes/helper/Helper.php b/classes/helper/Helper.php index 5c2a9d3fe..9f5a1b6ff 100755 --- a/classes/helper/Helper.php +++ b/classes/helper/Helper.php @@ -345,97 +345,6 @@ class HelperCore 'table' => $this->table )); return $tpl->fetch(); - - /* - //$page = $this->context->smarty->fetch($tpl); - $html = << - $().ready(function() - { - // Click on "all shop" - $('.input_all_shop').click(function() - { - var checked = $(this).attr('checked'); - $('.input_group_shop').attr('checked', checked); - $('.input_shop').attr('checked', checked); - }); - - // Click on a group shop - $('.input_group_shop').click(function() - { - $('.input_shop[value='+$(this).val()+']').attr('checked', $(this).attr('checked')); - check_all_shop(); - }); - - // Click on a shop - $('.input_shop').click(function() - { - check_group_shop_status($(this).val()); - check_all_shop(); - }); - - // Initialize checkbox - $('.input_shop').each(function(k, v) - { - check_group_shop_status($(v).val()); - check_all_shop(); - }); - }); - - function check_group_shop_status(id_group) - { - var groupChecked = true; - $('.input_shop[value='+id_group+']').each(function(k, v) - { - if (!$(v).attr('checked')) - groupChecked = false; - }); - $('.input_group_shop[value='+id_group+']').attr('checked', groupChecked); - } - - function check_all_shop() - { - var allChecked = true; - $('.input_group_shop').each(function(k, v) - { - if (!$(v).attr('checked')) - allChecked = false; - }); - $('.input_all_shop').attr('checked', allChecked); - } - -EOF; - - $html .= '
'; - $html .= ' - '; - $html .= ''; - foreach (Shop::getTree() as $groupID => $groupData) - { - $groupChecked = ($type == 'group_shop' && ((isset($assos[$groupID]) && in_array($this->id, $assos[$groupID])) || !$this->id)); - $html .= ''; - $html .= ''; - $html .= ''; - - if ($type == 'shop') - { - $total = count($groupData['shops']); - $j = 0; - foreach ($groupData['shops'] as $shopID => $shopData) - { - $checked = ((isset($assos[$shopID]) && in_array($this->id, $assos[$shopID])) || !$this->id); - $html .= ''; - $html .= ''; - $html .= ''; - $j++; - } - } - } - $html .= '
'.$this->l('Shop').'
'; - return $html; - */ } } diff --git a/controllers/front/CategoryController.php b/controllers/front/CategoryController.php index 543da1ff2..c88f79e61 100644 --- a/controllers/front/CategoryController.php +++ b/controllers/front/CategoryController.php @@ -86,12 +86,12 @@ class CategoryControllerCore extends FrontController if (isset($this->context->cookie->id_compare)) $this->context->smarty->assign('compareProducts', CompareProduct::getCompareProducts((int)$this->context->cookie->id_compare)); - + $this->productSort(); // Product sort must be called before assignProductList() + $this->assignScenes(); if ($this->category->id != 1) $this->assignProductList(); - $this->productSort(); $this->context->smarty->assign(array( 'category' => $this->category, 'products' => (isset($this->cat_products) && $this->cat_products) ? $this->cat_products : NULL, diff --git a/modules/blockcart/blockcart-ajax.php b/modules/blockcart/blockcart-ajax.php index 86dde0721..fbc52fde7 100644 --- a/modules/blockcart/blockcart-ajax.php +++ b/modules/blockcart/blockcart-ajax.php @@ -24,7 +24,8 @@ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA */ -include(dirname(__FILE__).'/blockcart.php'); +// @TODO Find the reason why the blockcart.php is includ multiple time +include_once(dirname(__FILE__).'/blockcart.php'); $context = Context::getContext(); $blockCart = new BlockCart(); echo $blockCart->hookAjaxCall(array('cookie' => $context->cookie, 'cart' => $context->cart)); \ No newline at end of file diff --git a/modules/blocklayered/blocklayered.js b/modules/blocklayered/blocklayered.js index e4d22fcbf..bd1021c74 100644 --- a/modules/blocklayered/blocklayered.js +++ b/modules/blocklayered/blocklayered.js @@ -422,7 +422,7 @@ function getUrlParams() function updateProductUrl() { // Adding the filters to URL product - $('ul#product_list li.ajax_block_product .product_img_link').attr('href', $('ul#product_list li.ajax_block_product .product_img_link').attr('href') + param_product_url); - $('ul#product_list li.ajax_block_product h3 a').attr('href', $('ul#product_list li.ajax_block_product h3 a').attr('href') + param_product_url); - $('ul#product_list li.ajax_block_product .product_desc a').attr('href', $('ul#product_list li.ajax_block_product .product_desc a').attr('href') + param_product_url); + $.each($('ul#product_list li.ajax_block_product .product_img_link, ul#product_list li.ajax_block_product h3 a, ul#product_list li.ajax_block_product .product_desc a'), function() { + $(this).attr('href', $(this).attr('href') + param_product_url); + }); } diff --git a/modules/blocklayered/blocklayered.php b/modules/blocklayered/blocklayered.php index c059e2d5d..fb15a0e58 100644 --- a/modules/blocklayered/blocklayered.php +++ b/modules/blocklayered/blocklayered.php @@ -1188,14 +1188,19 @@ class BlockLayered extends Module $id_layered_filter = (int)Db::getInstance()->Insert_ID(); $shop_list = array(); - foreach ($_POST['checkBoxShopAsso_layered_filter'] as $id_asso_object => $row) + if (isset($_POST['checkBoxShopAsso_layered_filter'])) { - foreach ($row as $id_shop => $value) + foreach ($_POST['checkBoxShopAsso_layered_filter'] as $id_asso_object => $row) { - $assos[] = array('id_object' => (int)$id_layered_filter, 'id_shop' => (int)$id_shop); - $shop_list[] = (int)$id_shop; + foreach ($row as $id_shop => $value) + { + $assos[] = array('id_object' => (int)$id_layered_filter, 'id_shop' => (int)$id_shop); + $shop_list[] = (int)$id_shop; + } } } + else + $shop_list = array(0); } else $shop_list = array(0); @@ -1277,10 +1282,11 @@ class BlockLayered extends Module if (version_compare(_PS_VERSION_,'1.5','>')) { Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'layered_filter_shop WHERE `id_layered_filter` = '.(int)$id_layered_filter); - - foreach ($assos as $asso) - Db::getInstance()->execute('INSERT INTO layered_filter_shop (`id_layered_filter`, `id_shop`) - VALUES('.$id_layered_filter.', '.(int)$asso['id_shop'].')'); + + if (isset($assos)) + foreach ($assos as $asso) + Db::getInstance()->execute('INSERT INTO layered_filter_shop (`id_layered_filter`, `id_shop`) + VALUES('.$id_layered_filter.', '.(int)$asso['id_shop'].')'); } $html .= '
'.(version_compare(_PS_VERSION_,'1.5','>') ? '' : ''). @@ -1586,8 +1592,11 @@ class BlockLayered extends Module $helper->table = 'layered_filter'; $helper->identifier = 'id_layered_filter'; - $html .= ''.$this->l('Choose shop association:').''; - $html .= '
'.$helper->renderAssoShop().'
'; + if (Shop::isFeatureActive()) + { + $html .= ''.$this->l('Choose shop association:').''; + $html .= '
'.$helper->renderAssoShop().'
'; + } } $html .= ' @@ -3275,25 +3284,28 @@ class BlockLayered extends Module if (version_compare(_PS_VERSION_,'1.5','>') && !empty($id_layered_filter)) { - $helper = new Helper(); - $helper->id = (int)$id_layered_filter; - $helper->table = 'layered_filter'; - $helper->identifier = 'id_layered_filter'; - $helper->base_folder = Tools::getValue('base_folder').'/themes/template/'; - - $html .= ' -
'.$helper->renderAssoShop().'
- '; + '; + } } return $html; diff --git a/themes/default/product-sort.tpl b/themes/default/product-sort.tpl index 2c8260ae4..74617bbff 100644 --- a/themes/default/product-sort.tpl +++ b/themes/default/product-sort.tpl @@ -56,6 +56,7 @@ $(document).ready(function()