// Product comments

This commit is contained in:
Jerome Nadaud
2013-11-15 11:49:40 +01:00
parent a66d2e1ab6
commit d7de507f42
7 changed files with 113 additions and 3 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
<module>
<name>productcomments</name>
<displayName><![CDATA[Product Comments]]></displayName>
<version><![CDATA[2.3]]></version>
<version><![CDATA[2.4]]></version>
<description><![CDATA[Allows users to post reviews.]]></description>
<author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[front_office_features]]></tab>
+24 -2
View File
@@ -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');
@@ -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 <contact@prestashop.com>
* @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
*}
<div class="comments_note">
<div class="star_content clearfix">
{section name="i" start=0 loop=5 step=1}
{if $averageTotal le $smarty.section.i.index}
<div class="star"></div>
{else}
<div class="star star_on"></div>
{/if}
{/section}
</div>
<span>{l s='%s Review(s)'|sprintf:$averageTotal mod='productcomments'}&nbsp</span>
</div>
@@ -0,0 +1,6 @@
<script type="text/javascript">
$( document ).ready(function() {
$('input[@type=radio].star').rating();
$('.auto-submit-star').rating();
});
</script>
+35
View File
@@ -0,0 +1,35 @@
<?php
/*
* 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 <contact@prestashop.com>
* @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;
@@ -0,0 +1,9 @@
<?php
if (!defined('_PS_VERSION_'))
exit;
function upgrade_module_2_4($object)
{
return ($object->registerHook('displayProductListReviews') && $object->registerHook('top'));
}
@@ -91,6 +91,7 @@
</div>
{/if}
<div class="button-container">
{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)}