public function run()
 {
     // Get number of comments
     $id_product = (int) Tools::getValue('id_product');
     $nb_comments = MyModComment::getProductNbComments((int) $id_product);
     // Init
     $page = 1;
     $nb_per_page = 10;
     $nb_pages = ceil($nb_comments / $nb_per_page);
     if (Tools::getIsset('page')) {
         $page = (int) Tools::getValue('page');
     }
     $limit_start = ($page - 1) * $nb_per_page;
     $limit_end = $nb_per_page;
     // Build actions url
     $ajax_action_url = $this->context->link->getAdminLink('AdminModules', true);
     $ajax_action_url = str_replace('index.php', 'ajax-tab.php', $ajax_action_url);
     $action_url = $this->context->link->getAdminLink('AdminMyModComments', true);
     // Get comments
     $comments = MyModComment::getProductComments((int) $id_product, (int) $limit_start, (int) $limit_end);
     // Assign comments and product object
     $this->context->smarty->assign('page', $page);
     $this->context->smarty->assign('nb_pages', $nb_pages);
     $this->context->smarty->assign('comments', $comments);
     $this->context->smarty->assign('action_url', $action_url);
     $this->context->smarty->assign('ajax_action_url', $ajax_action_url);
     $this->context->smarty->assign('pc_base_dir', __PS_BASE_URI__ . 'modules/' . $this->module->name . '/');
     return $this->module->display($this->file, 'displayAdminProductsExtra.tpl');
 }
 public function assignProductTabContent()
 {
     $enable_grades = Configuration::get('MYMOD_GRADES');
     $enable_comments = Configuration::get('MYMOD_COMMENTS');
     $this->context->controller->addCSS($this->_path . 'views/css/star-rating.css', 'all');
     $this->context->controller->addJS($this->_path . 'views/js/star-rating.js');
     $this->context->controller->addCSS($this->_path . 'views/css/mymodcomments.css', 'all');
     $this->context->controller->addJS($this->_path . 'views/js/mymodcomments.js');
     if (!$this->module->isCached('displayProductTabContent.tpl', $this->cache_id)) {
         $id_product = Tools::getValue('id_product');
         $comments = MyModComment::getProductComments($id_product, 0, 3);
         $product = new Product((int) $id_product, false, $this->context->cookie->id_lang);
         $this->context->smarty->assign('enable_grades', $enable_grades);
         $this->context->smarty->assign('enable_comments', $enable_comments);
         $this->context->smarty->assign('comments', $comments);
         $this->context->smarty->assign('product', $product);
     }
 }
Пример #3
0
 protected function initList()
 {
     // Get number of comments
     $nb_comments = MyModComment::getProductNbComments($this->product->id);
     // Init
     $nb_per_page = 10;
     $nb_pages = ceil($nb_comments / $nb_per_page);
     $page = 1;
     if (Tools::getValue('page') != '') {
         $page = (int) $_GET['page'];
     }
     $limit_start = ($page - 1) * $nb_per_page;
     $limit_end = $nb_per_page;
     // Get comments
     $comments = MyModComment::getProductComments($this->product->id, $limit_start, $limit_end);
     // Assign comments and product object
     $this->context->smarty->assign('comments', $comments);
     $this->context->smarty->assign('product', $this->product);
     $this->context->smarty->assign('page', $page);
     $this->context->smarty->assign('nb_pages', $nb_pages);
     $this->setTemplate('list.tpl');
 }