* @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
*/
if (!defined('_PS_VERSION_'))
exit;
class BlockPaymentLogo extends Module
{
public function __construct()
{
$this->name = 'blockpaymentlogo';
$this->tab = 'front_office_features';
$this->version = '0.2';
$this->author = 'PrestaShop';
$this->need_instance = 0;
parent::__construct();
$this->displayName = $this->l('Payment logo block.');
$this->description = $this->l('This block will display all of your payment logos.');
}
public function install()
{
Configuration::updateValue('PS_PAYMENT_LOGO_CMS_ID', 0);
if (!parent::install())
return false;
if (!$this->registerHook('leftColumn'))
return false;
if (!$this->registerHook('header'))
return false;
return true;
}
public function uninstall()
{
Configuration::deleteByName('PS_PAYMENT_LOGO_CMS_ID');
return parent::uninstall();
}
public function getContent()
{
$html = '
'.$this->l('Payment logo.').'
';
if (Tools::isSubmit('submitConfiguration'))
if (Validate::isUnsignedInt(Tools::getValue('id_cms')))
{
Configuration::updateValue('PS_PAYMENT_LOGO_CMS_ID', (int)(Tools::getValue('id_cms')));
$this->_clearCache('blockpaymentlogo.tpl');
$html .= $this->displayConfirmation($this->l('The settings have been updated.'));
}
$cmss = CMS::listCms($this->context->language->id);
if (!count($cmss))
$html .= $this->displayError($this->l('No CMS page is available.'));
else
{
$html .= '
';
}
return $html;
}
/**
* Returns module content
*
* @param array $params Parameters
* @return string Content
*/
public function hookLeftColumn($params)
{
if (Configuration::get('PS_CATALOG_MODE'))
return;
if (!$this->isCached('blockpaymentlogo.tpl', $this->getCacheId()))
{
if (!Configuration::get('PS_PAYMENT_LOGO_CMS_ID'))
return;
$cms = new CMS(Configuration::get('PS_PAYMENT_LOGO_CMS_ID'), $this->context->language->id);
if (!Validate::isLoadedObject($cms))
return;
$this->smarty->assign('cms_payement_logo', $cms);
}
return $this->display(__FILE__, 'blockpaymentlogo.tpl', $this->getCacheId());
}
public function hookRightColumn($params)
{
return $this->hookLeftColumn($params);
}
public function hookFooter($params)
{
return $this->hookLeftColumn($params);
}
public function hookHeader($params)
{
if (Configuration::get('PS_CATALOG_MODE'))
return;
$this->context->controller->addCSS(($this->_path).'blockpaymentlogo.css', 'all');
}
}