toutpratique/modules/cms_comments/cms_comments.php
Thibault GUILLAUME f2c577864a recette
2015-10-14 14:43:03 +02:00

62 lines
1.4 KiB
PHP

<?php
if (!defined('_CAN_LOAD_FILES_'))
exit;
include_once dirname(__FILE__).'/classes/CmsComments.php';
class Cms_Comments extends Module
{
public function __construct()
{
$this->name = 'cms_comments';
$this->tab = 'front_office_features';
$this->version = '1.0';
$this->author = 'Antadis';
$this->need_instance = 0;
$this->bootstrap = true;
parent::__construct();
$this->displayName = $this->l('Comments CMS ANTADIS');
$this->description = $this->l('Manage your comments in CMS Antadis');
$this->secure_key = Tools::encrypt($this->name);
$this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_);
}
public function install()
{
if (Shop::isFeatureActive())
Shop::setContext(Shop::CONTEXT_ALL);
if (!parent::install()
|| !$this->registerHook('footer')
|| !$this->registerHook('productComments')
|| !$this->createTables()
)
return false;
}
public function createTables (){
return true;
}
public function hookdisplayFooter() {
$this->context->controller->addJS(($this->_path).'comments.js', 'all');
}
public function hookproductComments($params) {
$id_element = $params['element'];
if (!Validate::isInt($id_element)) {
return false;
}
$comments = CmsComments::loadComments($id_element);
$this->smarty->assign(array(
'comments' => $comments,
'id_element' => $id_element
));
return $this->display(__FILE__, 'comments.tpl');
}
}