* @copyright 2007-2011 PrestaShop SA * @version Release: $Revision: 7541 $ * @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 Editorial extends Module { /** @var max image size */ protected $maxImageSize = 307200; public function __construct() { $this->name = 'editorial'; $this->tab = 'front_office_features'; $this->version = '1.6'; $this->author = 'PrestaShop'; $this->need_instance = 0; parent::__construct(); $this->displayName = $this->l('Home text editor'); $this->description = $this->l('A text editor module for your homepage.'); $path = dirname(__FILE__); if (strpos(__FILE__, 'Module.php') !== false) $path .= '/../modules/'.$this->name; include_once($path.'/EditorialClass.php'); } public function install() { if (!parent::install() OR !$this->registerHook('home') OR !$this->registerHook('header')) return false; if (!Db::getInstance()->Execute(' CREATE TABLE `'._DB_PREFIX_.'editorial` ( `id_editorial` int(10) unsigned NOT NULL auto_increment, `body_home_logo_link` varchar(255) NOT NULL, PRIMARY KEY (`id_editorial`)) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8')) return false; if (!Db::getInstance()->Execute(' CREATE TABLE `'._DB_PREFIX_.'editorial_lang` ( `id_editorial` int(10) unsigned NOT NULL, `id_lang` int(10) unsigned NOT NULL, `body_title` varchar(255) NOT NULL, `body_subheading` varchar(255) NOT NULL, `body_paragraph` text NOT NULL, `body_logo_subheading` varchar(255) NOT NULL, PRIMARY KEY (`id_editorial`, `id_lang`)) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8')) return false; if (!Db::getInstance()->Execute(' INSERT INTO `'._DB_PREFIX_.'editorial`(`id_editorial`, `body_home_logo_link`) VALUES(1, "http://www.prestashop.com")')) return false; if (!Db::getInstance()->Execute(' INSERT INTO `'._DB_PREFIX_.'editorial_lang`(`id_editorial`, `id_lang`, `body_title`, `body_subheading`, `body_paragraph`, `body_logo_subheading`) VALUES(1, 1, "Lorem ipsum dolor sit amet", "Consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua", "<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>", "Excepteur sint prestashop cupidatat non proident")')) return false; if (!Db::getInstance()->Execute(' INSERT INTO `'._DB_PREFIX_.'editorial_lang`(`id_editorial`, `id_lang`, `body_title`, `body_subheading`, `body_paragraph`, `body_logo_subheading`) VALUES(1, 2, "Lorem ipsum dolor sit amet", "Excepteur sint occaecat cupidatat non proident", "<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>", "Lorem ipsum presta shop amet")')) return false; return true; } public function uninstall() { if (!parent::uninstall()) return false; return (Db::getInstance()->Execute('DROP TABLE `'._DB_PREFIX_.'editorial`') AND Db::getInstance()->Execute('DROP TABLE `'._DB_PREFIX_.'editorial_lang`')); } public function putContent($xml_data, $key, $field, $forbidden, $section) { foreach ($forbidden AS $line) if ($key == $line) return 0; if (!preg_match('/^'.$section.'_/i', $key)) return 0; $key = preg_replace('/^'.$section.'_/i', '', $key); $field = htmlspecialchars($field); if (!$field) return 0; return ("\n".' <'.$key.'>'.$field.''.$key.'>'); } public function getContent() { global $cookie; /* display the module name */ $this->_html = '