* @copyright 2007-2011 PrestaShop SA * @version Release: $Revision: 6899 $ * @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 BlockStore extends Module { function __construct() { $this->name = 'blockstore'; $this->tab = 'front_office_features'; $this->version = 1.0; $this->author = 'PrestaShop'; $this->need_instance = 0; parent::__construct(); $this->displayName = $this->l('Stores block'); $this->description = $this->l('Displays a block with a link to the store locator.'); } function install() { Configuration::updateValue('BLOCKSTORE_IMG', 'store.jpg'); return (parent::install() AND $this->registerHook('rightColumn') AND $this->registerHook('header')); } public function uninstall() { Configuration::deleteByName('BLOCKSTORE_IMG'); return parent::uninstall(); } function hookLeftColumn($params) { return $this->hookRightColumn($params); } function hookRightColumn($params) { global $smarty; $smarty->assign('store_img', Configuration::get('BLOCKSTORE_IMG')); return $this->display(__FILE__, 'blockstore.tpl'); } function hookHeader($params) { Tools::addCSS($this->_path.'/blockstore.css', 'all'); } public function postProcess() { if (Tools::isSubmit('submitStoreConf')) { if (isset($_FILES['store_img']) AND isset($_FILES['store_img']['tmp_name']) AND !empty($_FILES['store_img']['tmp_name'])) { if ($error = checkImage($_FILES['store_img'], 4000000)) return $this->displayError($this->l('invalid image')); else { if (!move_uploaded_file($_FILES['store_img']['tmp_name'], dirname(__FILE__).'/'.$_FILES['store_img']['name'])) return $this->displayError($this->l('an error occurred on uploading file')); else { if (Configuration::get('BLOCKSTORE_IMG') != $_FILES['store_img']['name']) @unlink(dirname(__FILE__).'/'.Configuration::get('BLOCKSTORE_IMG')); Configuration::updateValue('BLOCKSTORE_IMG', $_FILES['store_img']['name']); return $this->displayConfirmation($this->l('Settings are updated')); } } } } return ''; } public function getContent() { $output = $this->postProcess().'
'.$this->l('Store block configuration').''; if (Configuration::get('BLOCKSTORE_IMG')) $output .= '
'.$this->l('Store image').'
'; $output .= '
( '.$this->l('image will be displayed as 174x115').' )

'; return $output; } }