From 4d2740eb3540e024bcf3e96ebd577c3704df78c4 Mon Sep 17 00:00:00 2001 From: gBrunier Date: Fri, 5 Aug 2011 15:09:46 +0000 Subject: [PATCH] [*] MO : Review of the productcomments module - Part1 git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@7918 b9a71923-0436-4b27-9f14-aed3839534dd --- modules/productcomments/fr.php | 19 ++- .../productcomments/productcomments-extra.tpl | 130 +++++++++++++++++ modules/productcomments/productcomments.css | 124 ++++++++++++++++ modules/productcomments/productcomments.php | 35 ++++- modules/productcomments/productcomments.tpl | 134 ++++-------------- modules/productcomments/tab.tpl | 2 +- 6 files changed, 326 insertions(+), 118 deletions(-) create mode 100644 modules/productcomments/productcomments-extra.tpl create mode 100644 modules/productcomments/productcomments.css diff --git a/modules/productcomments/fr.php b/modules/productcomments/fr.php index 67b610f07..3be648027 100644 --- a/modules/productcomments/fr.php +++ b/modules/productcomments/fr.php @@ -2,6 +2,15 @@ global $_MODULE; $_MODULE = array(); +$_MODULE['<{productcomments}prestashop>productcomments-extra_7c3b0e9898b88deee7ea75aafd2e37e2'] = 'Note moyenne'; +$_MODULE['<{productcomments}prestashop>productcomments-extra_a71a0229e164fecdcde3c4e0f40473fa'] = 'Lire les avis utilisateurs'; +$_MODULE['<{productcomments}prestashop>productcomments-extra_4ce7fa08d440a1e0fb369b1273e52ac3'] = 'Donner votre avis'; +$_MODULE['<{productcomments}prestashop>productcomments-extra_b78a3223503896721cca1303f776159b'] = 'Titre'; +$_MODULE['<{productcomments}prestashop>productcomments-extra_0be8406951cdfda82f00f79328cf4efc'] = 'Commentaire'; +$_MODULE['<{productcomments}prestashop>productcomments-extra_a2ed44743411cf8b80e397448fce104c'] = 'Votre nom'; +$_MODULE['<{productcomments}prestashop>productcomments-extra_94966d90747b97d1f0f206c98a8b1ac3'] = 'Envoyer'; +$_MODULE['<{productcomments}prestashop>productcomments-extra_e81c4e4f2b7b93b481e13a8553c2ae1b'] = 'ou'; +$_MODULE['<{productcomments}prestashop>productcomments-extra_ea4788705e6873b424c65e91c2846b19'] = 'Annuler'; $_MODULE['<{productcomments}prestashop>productcomments_b91c4e8b229a399a3bc911d352524a9b'] = 'Commentaires produits'; $_MODULE['<{productcomments}prestashop>productcomments_0c21532dfd3476791e5aab1aa7fa7405'] = 'Autorise les utilisateurs à poster des commentaires sur les produits'; $_MODULE['<{productcomments}prestashop>productcomments_f4d1ea475eaa85102e2b4e6d95da84bd'] = 'Confirmation'; @@ -56,17 +65,7 @@ $_MODULE['<{productcomments}prestashop>productcomments_6bf852d9850445291f5e9d474 $_MODULE['<{productcomments}prestashop>productcomments_6d28f2900adb9e500868166f6d04da92'] = 'Vous devez attendre'; $_MODULE['<{productcomments}prestashop>productcomments_ba8d7ae5dcadfba739f28a777378f208'] = 'secondes avant de poster un nouveau commentaire.'; $_MODULE['<{productcomments}prestashop>productcomments_7c3b0e9898b88deee7ea75aafd2e37e2'] = 'Note moyenne'; -$_MODULE['<{productcomments}prestashop>productcomments_b1897515d548a960afe49ecf66a29021'] = 'Moyenne'; -$_MODULE['<{productcomments}prestashop>productcomments_5da618e8e4b89c66fe86e32cdafde142'] = 'De'; -$_MODULE['<{productcomments}prestashop>productcomments_b78a3223503896721cca1303f776159b'] = 'Titre'; $_MODULE['<{productcomments}prestashop>productcomments_08621d00a3a801b9159a11b8bbd69f89'] = 'Aucun commentaire n\'a été publié pour le moment.'; -$_MODULE['<{productcomments}prestashop>productcomments_30b3dbf8b5c381c2e8d62189048ab37c'] = 'seconde(s) avant de poster un nouveau commentaire.'; -$_MODULE['<{productcomments}prestashop>productcomments_c3edcf2cedbd4ce230fd6d4ea8915718'] = 'Ajouter un commentaire'; -$_MODULE['<{productcomments}prestashop>productcomments_a2ed44743411cf8b80e397448fce104c'] = 'Votre nom :'; -$_MODULE['<{productcomments}prestashop>productcomments_51ec9bf4aaeab1b25bb57f9f8d4de557'] = 'Titre : '; -$_MODULE['<{productcomments}prestashop>productcomments_240f3031f25601fa128bd4e15f0a37de'] = 'Commentaire :'; -$_MODULE['<{productcomments}prestashop>productcomments_94966d90747b97d1f0f206c98a8b1ac3'] = 'Envoyer'; -$_MODULE['<{productcomments}prestashop>productcomments_720fae7db6e6055d2b47890240bb3598'] = 'Seuls les utilisateurs enregistrés peuvent poster des commentaires.'; $_MODULE['<{productcomments}prestashop>products-comparison_8413c683b4b27cc3f4dbd4c90329d8ba'] = 'Commentaires'; $_MODULE['<{productcomments}prestashop>products-comparison_b1897515d548a960afe49ecf66a29021'] = 'Moyenne'; $_MODULE['<{productcomments}prestashop>products-comparison_bc976f6c3405523cde61f63a7cbe224b'] = 'Voir les avis'; diff --git a/modules/productcomments/productcomments-extra.tpl b/modules/productcomments/productcomments-extra.tpl new file mode 100644 index 000000000..46affc747 --- /dev/null +++ b/modules/productcomments/productcomments-extra.tpl @@ -0,0 +1,130 @@ +{* +* 2007-2011 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-2011 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 +*} + + + +
+
+ {l s='Average grade' mod='productcomments'}  + {section name="i" start=0 loop=5 step=1} + {if $averageTotal le $smarty.section.i.index} +
+ {else} +
+ {/if} + {/section} +
+
+
+ {l s='Read user reviews' mod='productcomments'} ({$nbComments})
+ {if ($too_early == false AND ($cookie->isLogged() == true OR $allow_guests == true))} + {if $cookie->isLogged() == true || $allow_guests == true} + {l s='Give your advice' mod='productcomments'} + {/if} + {/if} +
+
+
+
+
+ {l s='Give your advice' mod='productcomments'} +
+ {$product->name|escape:html:'UTF-8'} +
+ {$product->name} + {$product->description_short} +
+
+
+
+ {if $criterions|@count > 0} + + {section loop=$criterions name=i start=0 step=1} + + + + + {/section} +
+ + {$criterions[i].name|escape:'html':'UTF-8'}:  + + + + + + +
+ {/if} + +
+ + + {if $allow_guests == true && $cookie->isLogged() == false} + +
+ {/if} +

+   + {l s='or' mod='productcomments'} {l s='Cancel' mod='productcomments'} +

+
+
+
+
+
+
+
\ No newline at end of file diff --git a/modules/productcomments/productcomments.css b/modules/productcomments/productcomments.css new file mode 100644 index 000000000..fe6b8b848 --- /dev/null +++ b/modules/productcomments/productcomments.css @@ -0,0 +1,124 @@ +#product_comments_block_extra { + border: 1px solid #D0D3D8; + background: #F1F2F4; + padding: 10px +} + +#product_comments_block_extra a { + text-decoration: none; + font-weight: bold +} + +#product_comments_block_extra a:hover { + text-decoration: underline +} + +#product_comments_block_extra div.star { + background: url("img/star.gif") no-repeat scroll 0 0 transparent +} + +#product_comments_block_extra div.star_on { + background: url("img/star.gif") no-repeat scroll 0 0 transparent; + background-position: 0 -16px +} + +#new_comment_form { + color: #333; + background-color: #fff; + padding: 10px; + width: 565px; + text-align: left; +} + +#new_comment_form .title { + padding: 15px; + background: #333; + color: #fff; + font-size: 13px; + font-weight: bold; + padding: 5px; + text-align: left; + text-transform: uppercase; + display: block; + margin: 5px 0 +} + +#new_comment_form label { + display: block; + margin: 5px 0; + text-align: left; + font-weight: bold +} + +#new_comment_form textarea { + width: 100%; + min-height: 100px; + margin: 5px 0 +} + +#new_comment_form input[type=text] { + width: 100%; + height: 30px; + margin: 5px 0 +} + +#new_comment_form th { + font-size: 11px; + text-align: left; + font-weight: bold; + color: #333 +} + +#new_comment_form button { + background-color: #333; + border: solid 1px #BDC2C9; + padding: 3px 5px; + cursor: pointer; + color: #fff +} + +#product_comments_block_tab div.comment { + border-bottom: solid 1px #ccc; + padding: 5px +} + +#product_comments_block_tab div.comment div.comment_author { + float: left; + width: 200px +} + +#product_comments_block_tab div.comment div.comment_details { + float: left; + width: 320px +} + +#product_comments_block_tab div.comment_details p{ + padding: 0 +} + +#product_comments_block_tab a { + text-decoration: none; + font-weight: bold +} + +#product_comments_block_tab a:hover { + text-decoration: underline +} + +#product_comments_block_tab div.star { + background: url("img/star.gif") no-repeat scroll 0 0 transparent +} + +#product_comments_block_tab div.star_on { + background: url("img/star.gif") no-repeat scroll 0 0 transparent; + background-position: 0 -16px +} + +#product_comments_block_tab button { + background-color: #bbb; + border: solid 1px #999; + padding: 1px; + cursor: pointer; + color: #fff; + border-radius: 3px +} \ No newline at end of file diff --git a/modules/productcomments/productcomments.php b/modules/productcomments/productcomments.php index 69273d76b..bfeacb61a 100644 --- a/modules/productcomments/productcomments.php +++ b/modules/productcomments/productcomments.php @@ -66,7 +66,7 @@ class ProductComments extends Module return false; if (parent::install() == false OR $this->registerHook('productTab') == false OR $this->registerHook('extraProductComparison') == false OR $this->registerHook('productTabContent') == false - OR $this->registerHook('header') == false OR !Configuration::updateValue('PRODUCT_COMMENTS_MINIMAL_TIME', 30) + OR $this->registerHook('header') == false OR $this->registerHook('extraRight') == false OR !Configuration::updateValue('PRODUCT_COMMENTS_MINIMAL_TIME', 30) OR !Configuration::updateValue('PRODUCT_COMMENTS_ALLOW_GUESTS', 0) OR !Configuration::updateValue('PRODUCT_COMMENTS_MODERATE', 1)) return false; @@ -494,6 +494,38 @@ class ProductComments extends Module return ($this->display(__FILE__, '/tab.tpl')); } + + public function hookExtraRight($params) + { + require_once(dirname(__FILE__).'/ProductComment.php'); + require_once(dirname(__FILE__).'/ProductCommentCriterion.php'); + + $id_guest = (!$id_customer = (int)Context::getContext()->cookie->id_customer) ? (int)Context::getContext()->cookie->id_guest : false; + $customerComment = ProductComment::getByCustomer((int)(Tools::getValue('id_product')), (int)Context::getContext()->cookie->id_customer, true, (int)$id_guest); + + $averages = ProductComment::getAveragesByProduct((int)Tools::getValue('id_product'), Context::getContext()->language->id); + + $averageTotal = 0; + foreach ($averages AS $average) + $averageTotal += (float)($average); + $averageTotal = count($averages) ? ($averageTotal / count($averages)) : 0; + + $image = Product::getCover((int)($_GET['id_product'])); + + Context::getContext()->smarty->assign(array( + 'logged' => (int)Context::getContext()->cookie->id_customer, + 'allow_guests' => (int)Configuration::get('PRODUCT_COMMENTS_ALLOW_GUESTS'), + 'productcomment_cover' => (int)Tools::getValue('id_product').'-'.(int)$image['id_image'], + 'mediumSize' => Image::getSize('medium'), + 'criterions' => ProductCommentCriterion::getByProduct((int)Tools::getValue('id_product'), Context::getContext()->language->id), + 'action_url' => '', + 'averageTotal' => (int)$averageTotal, + 'too_early' => ($customerComment AND (strtotime($customerComment['date_add']) + Configuration::get('PRODUCT_COMMENTS_MINIMAL_TIME')) > time()), + 'nbComments' => (int)(ProductComment::getCommentNumber((int)($_GET['id_product']))) + )); + + return ($this->display(__FILE__, '/productcomments-extra.tpl')); + } private function _frontOfficePostProcess() { @@ -583,6 +615,7 @@ class ProductComments extends Module public function hookHeader() { + $this->context->controller->addCSS($this->_path.'productcomments.css', 'all'); $this->_frontOfficePostProcess(); } diff --git a/modules/productcomments/productcomments.tpl b/modules/productcomments/productcomments.tpl index c89815168..862155536 100644 --- a/modules/productcomments/productcomments.tpl +++ b/modules/productcomments/productcomments.tpl @@ -25,113 +25,35 @@ *}
- - -{if $comments} - {if $criterions|@count > 0} -

{l s='Average grade' mod='productcomments'}

-
- {l s='Average' mod='productcomments'}:
- {section loop=6 step=1 start=1 name=average} - - {/section} -
-
- {foreach from=$criterions item=c} -
- {$c.name|escape:'html':'UTF-8'}
- {section loop=6 step=1 start=1 name=average} - - {/section} +
+ {if $comments} + {foreach from=$comments item=comment} + {if $comment.content} +
+
+ {l s='Average grade' mod='productcomments'}  + {section name="i" start=0 loop=5 step=1} + {if $comment.grade le $smarty.section.i.index} +
+ {else} +
+ {/if} + {/section} +
+
+ {$comment.customer_name|escape:'html':'UTF-8'}
+ {dateFormat date=$comment.date_add|escape:'html':'UTF-8' full=0} +
+
+
+

{$comment.title}

+

{$comment.content|escape:'html':'UTF-8'|nl2br}

+
+ {/if} {/foreach} -
- {/if} -
- - - - - - - - - - {foreach from=$comments item=comment} - {if $comment.content} - - - - - - {/if} - {/foreach} - -
{l s='From' mod='productcomments'}{l s='Title' mod='productcomments'}{l s='Comment' mod='productcomments'}
- {dateFormat date=$comment.date_add|escape:'html':'UTF-8' full=0} - {$comment.customer_name|escape:'html':'UTF-8'}. - - {$comment.title} - - {$comment.content|escape:'html':'UTF-8'|nl2br} -
+ {else} +

{l s='No customer comments for the moment.' mod='productcomments'}

+ {/if}
-{else} -

{l s='No customer comments for the moment.' mod='productcomments'}

-{/if} - -{if $too_early == true} -

{l s='You should wait' mod='productcomments'} {$delay} {l s='second(s) before posting a new comment' mod='productcomments'}

-{elseif $cookie->isLogged() == true || $allow_guests == true} -

- -{else} -

{l s='Only registered users can post a new comment.' mod='productcomments'}

-{/if}
\ No newline at end of file diff --git a/modules/productcomments/tab.tpl b/modules/productcomments/tab.tpl index fda062f4d..1ac3d1cbf 100644 --- a/modules/productcomments/tab.tpl +++ b/modules/productcomments/tab.tpl @@ -24,4 +24,4 @@ * International Registered Trademark & Property of PrestaShop SA *} -
  • {l s='Comments' mod='productcomments'} ({$nbComments})
  • \ No newline at end of file +
  • {l s='Comments' mod='productcomments'}
  • \ No newline at end of file