Advertisement
candh

Untitled

Mar 10th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.51 KB | None | 0 0
  1.     public function hookProductTabContent($params)
  2.     {
  3.         $this->context->controller->addJS($this->_path.'js/jquery.rating.pack.js');
  4.         $this->context->controller->addJS($this->_path.'js/jquery.textareaCounter.plugin.js');
  5.         $this->context->controller->addJS($this->_path.'js/productcomments.js');
  6.  
  7.         $id_guest = (!$id_customer = (int)$this->context->cookie->id_customer) ? (int)$this->context->cookie->id_guest : false;
  8.         $customerComment = ProductComment::getByCustomer((int)(Tools::getValue('id_product')), (int)$this->context->cookie->id_customer, true, (int)$id_guest);
  9.  
  10.         $averages = ProductComment::getAveragesByProduct((int)Tools::getValue('id_product'), $this->context->language->id);
  11.         $averageTotal = 0;
  12.         foreach ($averages as $average)
  13.             $averageTotal += (float)($average);
  14.         $averageTotal = count($averages) ? ($averageTotal / count($averages)) : 0;
  15.  
  16.         $image = Product::getCover((int)Tools::getValue('id_product'));
  17.  
  18.         $this->context->smarty->assign(array(
  19.             'logged' => $this->context->customer->isLogged(true),
  20.             'action_url' => '',
  21.             'comments' => ProductComment::getByProduct((int)Tools::getValue('id_product'), 1, null, $this->context->cookie->id_customer),
  22.             'criterions' => ProductCommentCriterion::getByProduct((int)Tools::getValue('id_product'), $this->context->language->id),
  23.             'averages' => $averages,
  24.             'product_comment_path' => $this->_path,
  25.             'averageTotal' => $averageTotal,
  26.             'allow_guests' => (int)Configuration::get('PRODUCT_COMMENTS_ALLOW_GUESTS'),
  27.             'too_early' => ($customerComment && (strtotime($customerComment['date_add']) + Configuration::get('PRODUCT_COMMENTS_MINIMAL_TIME')) > time()),
  28.             'delay' => Configuration::get('PRODUCT_COMMENTS_MINIMAL_TIME'),
  29.             'id_product_comment_form' => (int)Tools::getValue('id_product'),
  30.             'secure_key' => $this->secure_key,
  31.             'productcomment_cover' => (int)Tools::getValue('id_product').'-'.(int)$image['id_image'],
  32.             'mediumSize' => Image::getSize(ImageType::getFormatedName('medium')),
  33.             'nbComments' => (int)ProductComment::getCommentNumber((int)Tools::getValue('id_product')),
  34.             'productcomments_controller_url' => $this->context->link->getModuleLink('productcomments'),
  35.             'productcomments_url_rewriting_activated' => Configuration::get('PS_REWRITING_SETTINGS', 0),
  36.             'moderation_active' => (int)Configuration::get('PRODUCT_COMMENTS_MODERATE')
  37.        ));
  38.  
  39.         $this->context->controller->pagination((int)ProductComment::getCommentNumber((int)Tools::getValue('id_product')));
  40.  
  41.         return ($this->display(__FILE__, '/productcomments.tpl'));
  42.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement