From d7de507f42aac50d7dbef14558c836e821293d04 Mon Sep 17 00:00:00 2001 From: Jerome Nadaud Date: Fri, 15 Nov 2013 11:49:40 +0100 Subject: [PATCH] // Product comments --- modules/productcomments/config.xml | 2 +- modules/productcomments/productcomments.php | 26 ++++++++++++- .../productcomments_reviews.tpl | 37 +++++++++++++++++++ .../productcomments/productcomments_top.tpl | 6 +++ modules/productcomments/upgrade/index.php | 35 ++++++++++++++++++ .../productcomments/upgrade/install-2.4.php | 9 +++++ themes/default-bootstrap/product-list.tpl | 1 + 7 files changed, 113 insertions(+), 3 deletions(-) create mode 100644 modules/productcomments/productcomments_reviews.tpl create mode 100644 modules/productcomments/productcomments_top.tpl create mode 100644 modules/productcomments/upgrade/index.php create mode 100644 modules/productcomments/upgrade/install-2.4.php diff --git a/modules/productcomments/config.xml b/modules/productcomments/config.xml index d2ca5525e..c9413f84f 100755 --- a/modules/productcomments/config.xml +++ b/modules/productcomments/config.xml @@ -2,7 +2,7 @@ productcomments - + diff --git a/modules/productcomments/productcomments.php b/modules/productcomments/productcomments.php index 20f8d74ba..caea20fb4 100644 --- a/modules/productcomments/productcomments.php +++ b/modules/productcomments/productcomments.php @@ -41,7 +41,7 @@ class ProductComments extends Module { $this->name = 'productcomments'; $this->tab = 'front_office_features'; - $this->version = '2.3'; + $this->version = '2.4'; $this->author = 'PrestaShop'; $this->need_instance = 0; $this->secure_key = Tools::encrypt($this->name); @@ -70,6 +70,8 @@ class ProductComments extends Module !$this->registerHook('productTabContent') || !$this->registerHook('header') || !$this->registerHook('productOutOfStock') || + !$this->registerHook('displayProductListReviews') || + !$this->registerHook('top') || !Configuration::updateValue('PRODUCT_COMMENTS_MINIMAL_TIME', 30) || !Configuration::updateValue('PRODUCT_COMMENTS_ALLOW_GUESTS', 0) || !Configuration::updateValue('PRODUCT_COMMENTS_MODERATE', 1)) @@ -87,7 +89,9 @@ class ProductComments extends Module !$this->unregisterHook('productOutOfStock') || !$this->unregisterHook('productTabContent') || !$this->unregisterHook('header') || - !$this->unregisterHook('productTab')) + !$this->unregisterHook('productTab') || + !$this->unregisterHook('top') || + !$this->unregisterHook('displayProductListReviews')) return false; return true; } @@ -691,6 +695,24 @@ class ProductComments extends Module return ($this->display(__FILE__, '/tab.tpl')); } + public function hookTop($params) + { + $this->context->controller->addJS($this->_path.'js/jquery.rating.pack.js'); + return $this->display(__FILE__, 'productcomments_top.tpl'); + } + + public function hookDisplayProductListReviews($params) + { + require_once(dirname(__FILE__).'/ProductComment.php'); + + $average = ProductComment::getAverageGrade((int)$params['product']['id_product']); + $this->smarty->assign(array( + 'product' => $params['product'], + 'averageTotal' => round($average['grade']), + )); + return $this->display(__FILE__, 'productcomments_reviews.tpl'); + } + public function hookproductOutOfStock($params) { require_once(dirname(__FILE__).'/ProductComment.php'); diff --git a/modules/productcomments/productcomments_reviews.tpl b/modules/productcomments/productcomments_reviews.tpl new file mode 100644 index 000000000..cccaf240b --- /dev/null +++ b/modules/productcomments/productcomments_reviews.tpl @@ -0,0 +1,37 @@ + {* +* 2007-2013 PrestaShop +* +* NOTICE OF LICENSE +* +* This source file is subject to the Academic Free License (AFL 3.0) +* that is bundled with this package in the file LICENSE.txt. +* It is also available through the world-wide-web at this URL: +* http://opensource.org/licenses/afl-3.0.php +* If you did not receive a copy of the license and are unable to +* obtain it through the world-wide-web, please send an email +* to license@prestashop.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade PrestaShop to newer +* versions in the future. If you wish to customize PrestaShop for your +* needs please refer to http://www.prestashop.com for more information. +* +* @author PrestaShop SA +* @copyright 2007-2013 PrestaShop SA +* @version Release: $Revision$ +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*} +
+
+ {section name="i" start=0 loop=5 step=1} + {if $averageTotal le $smarty.section.i.index} +
+ {else} +
+ {/if} + {/section} +
+ {l s='%s Review(s)'|sprintf:$averageTotal mod='productcomments'}  +
\ No newline at end of file diff --git a/modules/productcomments/productcomments_top.tpl b/modules/productcomments/productcomments_top.tpl new file mode 100644 index 000000000..a09be2a77 --- /dev/null +++ b/modules/productcomments/productcomments_top.tpl @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/modules/productcomments/upgrade/index.php b/modules/productcomments/upgrade/index.php new file mode 100644 index 000000000..3f6561f72 --- /dev/null +++ b/modules/productcomments/upgrade/index.php @@ -0,0 +1,35 @@ + +* @copyright 2007-2013 PrestaShop SA +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); +exit; \ No newline at end of file diff --git a/modules/productcomments/upgrade/install-2.4.php b/modules/productcomments/upgrade/install-2.4.php new file mode 100644 index 000000000..8c0ee51f4 --- /dev/null +++ b/modules/productcomments/upgrade/install-2.4.php @@ -0,0 +1,9 @@ +registerHook('displayProductListReviews') && $object->registerHook('top')); +} diff --git a/themes/default-bootstrap/product-list.tpl b/themes/default-bootstrap/product-list.tpl index 532bcde2b..f902f8e78 100644 --- a/themes/default-bootstrap/product-list.tpl +++ b/themes/default-bootstrap/product-list.tpl @@ -91,6 +91,7 @@ {/if}
+ {hook h='displayProductListReviews' product=$product} {if ($product.id_product_attribute == 0 || (isset($add_prod_display) && ($add_prod_display == 1))) && $product.available_for_order && !isset($restricted_country_mode) && $product.minimal_quantity <= 1 && $product.customizable != 2 && !$PS_CATALOG_MODE} {if ($product.allow_oosp || $product.quantity > 0)} {if isset($static_token)}