* @copyright 2007-2011 PrestaShop SA * @version Release: $Revision: 6828 $ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA */ if (!defined('_CAN_LOAD_FILES_')) exit; class BlockSpecials extends Module { private $_html = ''; private $_postErrors = array(); function __construct() { $this->name = 'blockspecials'; $this->tab = 'pricing_promotion'; $this->version = 0.8; $this->author = 'PrestaShop'; $this->need_instance = 0; parent::__construct(); $this->displayName = $this->l('Specials block'); $this->description = $this->l('Adds a block with current product specials.'); } public function install() { return (parent::install() AND $this->registerHook('rightColumn') AND $this->registerHook('header')); } public function getContent() { $output = '

'.$this->displayName.'

'; if (Tools::isSubmit('submitSpecials')) { Configuration::updateValue('PS_BLOCK_SPECIALS_DISPLAY', (int)(Tools::getValue('always_display'))); $output .= '
'.$this->l('Confirmation').''.$this->l('Settings updated').'
'; } return $output.$this->displayForm(); } public function displayForm() { return '
'.$this->l('Settings').'

'.$this->l('Show the block even if no product is available.').'

'; } public function hookRightColumn($params) { if (Configuration::get('PS_CATALOG_MODE')) return ; global $smarty; if (!$special = Product::getRandomSpecial((int)($params['cookie']->id_lang)) AND !Configuration::get('PS_BLOCK_SPECIALS_DISPLAY')) return; $smarty->assign(array( 'special' => $special, 'priceWithoutReduction_tax_excl' => Tools::ps_round($special['price_without_reduction'], 2), 'mediumSize' => Image::getSize('medium') )); return $this->display(__FILE__, 'blockspecials.tpl'); } public function hookLeftColumn($params) { return $this->hookRightColumn($params); } public function hookHeader($params) { if (Configuration::get('PS_CATALOG_MODE')) return ; Tools::addCSS(($this->_path).'blockspecials.css', 'all'); } }