Linux SRV-16 6.18.44-paas #1 SMP PREEMPT_DYNAMIC Thu Aug 13 10:08:12 UTC 2026 x86_64
/
srv
/
data
/
trash
/
vhost_www.arlenshop.fr_1556185825
/
htdocs
/
modules
/
csstaticblocks
/
/srv/data/trash/vhost_www.arlenshop.fr_1556185825/htdocs/modules/csstaticblocks/csstaticblocks.php
<?php include_once(dirname(__FILE__).'/StaticBlockClass.php'); class csstaticblocks extends Module { protected $error = false; private $_html; private $myHook = array('displaytop','topleft','topcontent','displayleftColumn','displayrightColumn','displayfooter','displayhome', 'csslideshow','footerleft','footerbottom','copyright','csmegamenu','categoryImage'); public function __construct() { $this->name = 'csstaticblocks'; $this->tab = 'MyBlocks'; $this->version = '1.0'; $this->author = 'Codespot'; parent::__construct(); $this->displayName = $this->l('Cs Static block'); $this->description = $this->l('Adds static blocks with free content'); $this->confirmUninstall = $this->l('Are you sure that you want to delete your static blocks?'); } public function init_data() { $content_block1 = '<div class="grid_24 alpha omega">\r\n<div class="grid_8 alpha"><a class="delivery" href="#">Delivery</a>\r\n<h3><a href="#">Free all delivery order over $599</a></h3>\r\n</div>\r\n<div class="grid_8"><a class="return" href="#">Return</a>\r\n<h3><a href="#">Return all us/eu order</a></h3>\r\n</div>\r\n<div class="grid_8 omega"><a class="guarantee" href="#">guarantee</a>\r\n<h3><a href="#">Money back guarantee</a></h3>\r\n</div>\r\n</div>'; $content_block2 = '<div class="grid_8 omega">\r\n<div id="breitling"><a title="" href="#"><img class="img" src="themes/watchstore/img/cms/banner_breitling.jpg" alt="" /></a>\r\n<div class="group">\r\n<h3>VIEW BREITLING</h3>\r\n<div class="btn_go"><a title="" href="#"><img src="themes/watchstore/img/cms/btn_go.png" alt="" /></a></div>\r\n</div>\r\n</div>\r\n<div id="saveup">\r\n<div class="text_left">\r\n<h3><a class="save" title="" href="#">Save</a></h3>\r\n<h3><a title="" href="#">Up to 50% off</a></h3>\r\n<span>Peletesque sit amet</span></div>\r\n<img src="themes/watchstore/img/cms/line_saveUp.png" alt="" />\r\n<div class="text_left">\r\n<h3 class="free_delivery">Free delivery UK all orders</h3>\r\n<span>start 20 April 2013</span></div>\r\n</div>\r\n<div id="left_banner"><a title="" href="#"><img class="img" src="themes/watchstore/img/cms/banner_3.jpg" alt="" /></a>\r\n<div class="group">\r\n<div id="left_banner1">\r\n<h3>SHOP NOW</h3>\r\n<div class="btn_go"><a title="" href="#"><img src="themes/watchstore/img/cms/btn_slide_next.png" alt="" /></a></div>\r\n</div>\r\n<div id="left_banner2">\r\n<h3>FROM $598</h3>\r\n</div>\r\n</div>\r\n</div>\r\n</div>'; $content_block3 = '<div id="banner_home">\r\n<div id="left_banner_home"><a title="" href="#"><img src="themes/watchstore/img/cms/btn_1.png" alt="" /></a>\r\n<h3><a title="" href="#">DELIVERY & 30 RETURNS ON ALL ORDER</a></h3>\r\n</div>\r\n<div id="right_banner_home">\r\n<h3><a title="" href="#">SPECIAL GIFT FOR COUPLE</a></h3>\r\n</div>\r\n</div>'; $content_block4 ='<div id="cat_home"> <ul class="cat_product"> <li class="item first"><a class="img" href="#"><img src="themes/watchstore/img/cms/ADS_1.jpg" alt="" /></a> <h3 class="name_product"><a title="" href="#">Velit latus watches</a></h3> <div class="text">Nam ultrices rhoncus diam id faucibus. Proi eros neque, auctor nonset bibendum facilis mattis luctus nisl. Mauris vitae diam</div> <div class="btn_men"> <div class="btn_men"><a title="" href="?id_category=7&controller=category">Mens</a></div> </div> </li> <li><a class="img" href="#"><img src="themes/watchstore/img/cms/ADS_2.jpg" alt="" /></a> <h3 class="name_product"><a title="" href="#">Massa XL watches</a></h3> <div class="text">Nam ultrices rhoncus diam id faucibus. Proi eros neque, auctor nonset bibendum facilis mattis luctus nisl. Mauris vitae diam</div> <div class="btn_lady"><a title="" href="?id_category=7&controller=category">Ladies</a></div> </li> <li><a class="img" href="#"><img src="themes/watchstore/img/cms/ADS_3.jpg" alt="" /></a> <h3 class="name_product"><a title="" href="#">Citizen’s XXI watches</a></h3> <div class="text">Nam ultrices rhoncus diam id faucibus. Proi eros neque, auctor nonset bibendum facilis mattis luctus nisl. Mauris vitae diam</div> <div class="btn_men"><a title="" href="?id_category=7&controller=category">Mens</a></div> <div class="btn_lady"><a title="" href="?id_category=7&controller=category">Ladies</a></div> </li> <li><a class="img" href="#"><img src="themes/watchstore/img/cms/ADS_4.jpg" alt="" /></a> <h3 class="name_product"><a title="" href="#">Lorst OX watches</a></h3> <div class="text">Nam ultrices rhoncus diam id faucibus. Proi eros neque, auctor nonset bibendum facilis mattis luctus nisl. Mauris vitae diam</div> <div class="btn_men"><a title="" href="?id_category=7&controller=category">Mens</a></div> </li> <li><a class="img" href="#"><img src="themes/watchstore/img/cms/ADS_5.jpg" alt="" /></a> <h3 class="name_product"><a title="" href="#">Interger watches</a></h3> <div class="text">Nam ultrices rhoncus diam id faucibus. Proi eros neque, auctor nonset bibendum facilis mattis luctus nisl. Mauris vitae diam</div> <div class="btn_men"><a title="" href="?id_category=7&controller=category">Mens</a></div> <div class="btn_lady"><a title="" href="?id_category=7&controller=category">Ladies</a></div> </li> </ul> </div>'; $content_block5='<div class="grid_6 alpha"> <div id="aboutstore"> <h3><a title="" href="#">Watch Store</a></h3> <p>Vivamus commodo porttitor neque vulputate nisi varius ac. Suspendisse eget enecest neque pretium dignissim. Integer consequat velit lacus</p> </div> <div id="shop"><a title="" href="#"><img src="themes/watchstore/img/cms/adswatch.jpg" alt="" /></a> <h3><a title="" href="#">Azos Shop</a></h3> <div class="like"> <div id="fb-root"> </div> <div class="fb-like" data-send="false" data-layout="button_count" data-width="200" data-show-faces="true"> </div> </div> </div> </div>'; $content_block6='<div class="grid_6 omega"> <div id="follow"> <h4 class="title_block">Flow us on</h4> <a class="show_hide_footer add_icon" title="" href="javascript:void(0)">footer_icon</a> <div class="block_content"><a title="Facebook" href="#"><img src="themes/watchstore/img/cms/20x18Facebook.png" alt="" /></a> <a title="Twitter" href="#"><img src="themes/watchstore/img/cms/20x18Twitter.png" alt="" /></a> <a title="Social Media" href="#"><img src="themes/watchstore/img/cms/20x18SocialMedia.png" alt="" /></a> <a title="RSS" href="#"><img src="themes/watchstore/img/cms/20x18RSS.png" alt="" /></a> <a title="Google +" href="#"><img src="themes/watchstore/img/cms/20x18google+.png" alt="" /></a> <a title="Pinterest" href="#"><img src="themes/watchstore/img/cms/20x18Rootd.png" alt="" /></a></div> </div> <div id="payment"> <h4 class="title_block">Payment Method</h4> <a class="show_hide_footer add_icon" title="" href="javascript:void(0)">footer_icon</a> <div class="block_content"><a title="" href="#"><img src="themes/watchstore/img/cms/wx14Paypal.png" alt="" /></a> <a title="" href="#"><img src="themes/watchstore/img/cms/wx14Visa.png" alt="" /></a> <a title="" href="#"><img src="themes/watchstore/img/cms/wx14AmericanExpress.png" alt="" /></a> <a title="" href="#"><img src="themes/watchstore/img/cms/wx14MasterCard.png" alt="" /></a></div> </div> </div>'; $content_block7='<p class="copy_right">© 2013 <a href="#">WatchStore Prestashop</a> Store. All rights reserved. PrestaShop Theme by <a href="#">PresThemes</a></p>'; $content_block8='<p><a title="Category image" href="#"><img title="Category Image" src="img/cms/category_img.jpg" alt="Category Image" /></a></p>'; $id_hook1 = Hook::getIdByName('csmegamenu'); $id_hook2 = Hook::getIdByName('csslideshow'); $id_hook3 = Hook::getIdByName('displayHome'); $id_hook4 = Hook::getIdByName('displayFooter'); $id_hook5 = Hook::getIdByName('footerleft'); $id_hook6 = Hook::getIdByName('copyright'); $id_hook7 = Hook::getIdByName('categoryImage'); $id_en = Language::getIdByIso('en'); $id_fr = Language::getIdByIso('fr'); $id_shop = Configuration::get('PS_SHOP_DEFAULT'); //install static Block if(!Db::getInstance()->Execute('INSERT INTO `'._DB_PREFIX_.'staticblock` (`id_block`, `identifier_block`, `hook`, `is_active`) VALUES (1, "top_block","'.$id_hook1.'", 1), (2, "left_block_banner","'.$id_hook2.'", 1), (3, "home-banner","'.$id_hook3.'", 1), (4, "block_cat_img","'.$id_hook3.'", 1), (5, "about_store","'.$id_hook4.'", 1), (6, "flowus_payment","'.$id_hook5.'", 1), (7, "allright_links","'.$id_hook6.'", 1), (8, "cat_img","'.$id_hook7.'", 1) ;') OR // Install Static Block _shop !Db::getInstance()->Execute('INSERT INTO `'._DB_PREFIX_.'staticblock_shop` (`id_block`, `id_shop`, `is_active`) VALUES (1,'.$id_shop.', 1), (2,'.$id_shop.', 1), (3,'.$id_shop.', 1), (4,'.$id_shop.', 1), (5,'.$id_shop.', 1), (6,'.$id_shop.', 1), (7,'.$id_shop.', 1), (8,'.$id_shop.', 1);') OR // static block lang !Db::getInstance()->Execute('INSERT INTO `'._DB_PREFIX_.'staticblock_lang` (`id_block`, `id_lang`, `id_shop`, `title`, `content`) VALUES ( "1", "'.$id_en.'","'.$id_shop.'","Top Block", \''.$content_block1.'\'), ( "1", "'.$id_fr.'","'.$id_shop.'","Top Block", \''.$content_block1.'\'), ( "2", "'.$id_en.'","'.$id_shop.'","Left Block Banner", \''.$content_block2.'\'), ( "2", "'.$id_fr.'","'.$id_shop.'","Left Block Banner", \''.$content_block2.'\'), ( "3", "'.$id_en.'","'.$id_shop.'","Home Banner", \''.$content_block3.'\'), ( "3","'.$id_fr.'","'.$id_shop.'","Home Banner", \''.$content_block3.'\'), ( "4", "'.$id_en.'","'.$id_shop.'","Block Categories Img", \''.$content_block4.'\'), ( "4", "'.$id_fr.'","'.$id_shop.'","Block Categories Img", \''.$content_block4.'\'), ( "5", "'.$id_en.'","'.$id_shop.'","About Store", \''.$content_block5.'\'), ( "5", "'.$id_fr.'","'.$id_shop.'","About Store", \''.$content_block5.'\'), ( "6","'.$id_en.'","'.$id_shop.'","Flow us+Payment", \''.$content_block6.'\'), ( "6", "'.$id_fr.'","'.$id_shop.'","Flow us+Payment", \''.$content_block6.'\'), ( "7", "'.$id_en.'","'.$id_shop.'","All Right + links", \''.$content_block7.'\'), ( "7", "'.$id_fr.'","'.$id_shop.'","All Right + links", \''.$content_block7.'\'), ( "8", "'.$id_en.'","'.$id_shop.'","Category Image", \''.$content_block8.'\'), ( "8", "'.$id_fr.'","'.$id_shop.'","Category Image", \''.$content_block8.'\') ;') ) return false; return true; } public function install() { if (parent::install() == false OR !$this->registerHook('header')) return false; foreach ($this->myHook AS $hook){ if ( !$this->registerHook($hook)) return false; } if (!Db::getInstance()->Execute('CREATE TABLE '._DB_PREFIX_.'staticblock (`id_block` int(10) unsigned NOT NULL AUTO_INCREMENT, `identifier_block` varchar(255) NOT NULL DEFAULT \'\', `hook` int(10) unsigned, `is_active` tinyint(1) NOT NULL DEFAULT \'1\', PRIMARY KEY (`id_block`),UNIQUE KEY `identifier_block` (`identifier_block`)) ENGINE=InnoDB default CHARSET=utf8')) return false; if (!Db::getInstance()->Execute('CREATE TABLE '._DB_PREFIX_.'staticblock_shop (`id_block` int(10) unsigned NOT NULL,`id_shop` int(10) unsigned NOT NULL,`is_active` tinyint(1) NOT NULL DEFAULT \'1\',PRIMARY KEY (`id_block`,`id_shop`)) ENGINE=InnoDB default CHARSET=utf8')) return false; if (!Db::getInstance()->Execute('CREATE TABLE '._DB_PREFIX_.'staticblock_lang (`id_block` int(10) unsigned NOT NULL, `id_lang` int(10) unsigned NOT NULL,`id_shop` int(10) unsigned NOT NULL, `title` varchar(255) NOT NULL DEFAULT \'\', `content` mediumtext, PRIMARY KEY (`id_block`,`id_lang`,`id_shop`)) ENGINE=InnoDB default CHARSET=utf8')) return false; $this->init_data(); return true; } public function uninstall() { if (parent::uninstall() == false) return false; if (!Db::getInstance()->Execute('DROP TABLE '._DB_PREFIX_.'staticblock') OR !Db::getInstance()->Execute('DROP TABLE '._DB_PREFIX_.'staticblock_shop') OR !Db::getInstance()->Execute('DROP TABLE '._DB_PREFIX_.'staticblock_lang')) return false; foreach($this->myHook as $hook) { $this->clearCacheBlockForHook($hook); } return true; } private function _displayHelp() { $this->_html .= ' <br/> <fieldset> <legend><img src="'.$this->_path.'logo.gif" alt="" title="" /> '.$this->l('Static block Helper').'</legend> <div>This module customize static contents on the site. Static contents are displayed at the position of the hook : top, left, home,right, footer.</div> </fieldset>'; } public function getContent() { $this->_html = '<h2>'.$this->displayName.'</h2>'; $this->_postProcess(); if (Tools::isSubmit('addBlock')) $this->_displayAddForm(); elseif (Tools::isSubmit('editBlock')) $this->_displayUpdateForm(); else $this->_displayForm(); $this->_displayHelp(); return $this->_html; } private function _postProcess() { global $currentIndex; $errors = array(); if (Tools::isSubmit('saveBlock')) { $block = new StaticBlockClass(Tools::getValue('id_block')); $block->copyFromPost(); $errors = $block->validateController(); if (sizeof($errors)) { $this->_html .= $this->displayError(implode('<br />', $errors)); } else { Tools::getValue('id_block') ? $block->update() : $block->add(); $this->clearCacheBlockForHook(Tools::getValue('hook')); Tools::redirectAdmin($currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'&saveBlockConfirmation'); } } elseif (Tools::isSubmit('changeStatusStaticblock') AND Tools::getValue('id_block')) { $stblock = new StaticBlockClass(Tools::getValue('id_block')); $stblock->updateStatus(Tools::getValue('status')); $this->clearCacheBlockForHook(Tools::getValue('hook')); Tools::redirectAdmin($currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules')); } elseif (Tools::isSubmit('deleteBlock') AND Tools::getValue('id_block')) { $block = new StaticBlockClass(Tools::getValue('id_block')); $block->delete(); $this->clearCacheBlockForHook(Tools::getValue('hook')); Tools::redirectAdmin($currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'&deleteBlockConfirmation'); } elseif (Tools::isSubmit('saveBlockConfirmation')) $this->_html = $this->displayConfirmation($this->l('Static block has been saved successfully')); elseif (Tools::isSubmit('deleteBlockConfirmation')) $this->_html = $this->displayConfirmation($this->l('Static block deleted successfully')); } private function clearCacheBlockForHook($hook) { $this->_clearCache('csstaticblocks_'.strtolower($this->getHookName($hook)).'.tpl'); } private function getHookName($id_hook,$name=false) { if (!$result = Db::getInstance()->getRow(' SELECT `name`,`title` FROM `'._DB_PREFIX_.'hook` WHERE `id_hook` = '.(int)($id_hook))) return false; return $result['name']; } private function getBlocks() { $this->context = Context::getContext(); $id_lang = $this->context->language->id; $id_shop = $this->context->shop->id; if (!$result = Db::getInstance()->ExecuteS( 'SELECT b.id_block, b.identifier_block, b.hook, bs.is_active, bl.`title`, bl.`content` FROM `'._DB_PREFIX_.'staticblock` b LEFT JOIN `'._DB_PREFIX_.'staticblock_shop` bs ON (b.`id_block` = bs.`id_block` ) LEFT JOIN `'._DB_PREFIX_.'staticblock_lang` bl ON (b.`id_block` = bl.`id_block`'.( $id_shop ? 'AND bl.`id_shop` = '.$id_shop : ' ' ).') WHERE bl.id_lang = '.(int)$id_lang. ( $id_shop ? ' AND bs.`id_shop` = '.$id_shop : ' ' ))) return false; return $result; } private function getHookTitle($id_hook,$name=false) { if (!$result = Db::getInstance()->getRow(' SELECT `name`,`title` FROM `'._DB_PREFIX_.'hook` WHERE `id_hook` = '.(int)($id_hook))) return false; return (($result['title'] != "" && $name) ? $result['title'] : $result['name']); } private function _displayForm() { global $currentIndex, $cookie; $this->_html .= ' <fieldset> <legend><img src="'.$this->_path.'logo.gif" alt="" title="" /> '.$this->l('List of static blocks').'</legend> <p><a href="'.$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'&addBlock"><img src="'._PS_ADMIN_IMG_.'add.gif" alt="" /> '.$this->l('Add a new block').'</a></p><br/> <table width="100%" class="table" cellspacing="0" cellpadding="0"> <thead> <tr class="nodrag nodrop"> <th>'.$this->l('ID').'</th> <th class="center">'.$this->l('Title').'</th> <th class="center">'.$this->l('Identifier').'</th> <th class="center">'.$this->l('Hook into').'</th> <th class="right">'.$this->l('Active').'</th> </tr> </thead> <tbody>'; $s_blocks = $this->getBlocks(); if (is_array($s_blocks)) { static $irow; foreach ($s_blocks as $block) { $this->_html .= ' <tr class="'.($irow++ % 2 ? 'alt_row' : '').'"> <td class="pointer" onclick="document.location = \''.$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'&editBlock&id_block='.$block['id_block'].'\'">'.$block['id_block'].'</td> <td class="pointer center" onclick="document.location = \''.$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'&editBlock&id_block='.$block['id_block'].'\'">'.$block['title'].'</td> <td class="pointer center" onclick="document.location = \''.$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'&editBlock&id_block='.$block['id_block'].'\'">'.$block['identifier_block'].'</td> <td class="pointer center" onclick="document.location = \''.$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'&editBlock&id_block='.$block['id_block'].'\'">'.(Validate::isInt($block['hook']) ? $this->getHookTitle($block['hook']) : '').'</td> <td class="pointer center"> <a href="'.$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'&changeStatusStaticblock&id_block='.$block['id_block'].'&status='.$block['is_active'].'&hook='.$block['hook'].'">'.($block['is_active'] ? '<img src="'._PS_ADMIN_IMG_.'enabled.gif" alt="Enabled" title="Enabled" />' : '<img src="'._PS_ADMIN_IMG_.'disabled.gif" alt="Disabled" title="Disabled" />').'</a> </td> </tr>'; } } $this->_html .= ' </tbody> </table> </fieldset>'; } private function _displayAddForm() { global $currentIndex, $cookie; // Language $defaultLanguage = (int)(Configuration::get('PS_LANG_DEFAULT')); $languages = Language::getLanguages(false); $divLangName = 'titlediv¤contentdiv'; // TinyMCE $iso = Language::getIsoById((int)($cookie->id_lang)); $isoTinyMCE = (file_exists(_PS_ROOT_DIR_.'/js/tiny_mce/langs/'.$iso.'.js') ? $iso : 'en'); $ad = dirname($_SERVER["PHP_SELF"]); $this->_html .= ' <script type="text/javascript"> var iso = \''.$isoTinyMCE.'\' ; var pathCSS = \''._THEME_CSS_DIR_.'\' ; var ad = \''.$ad.'\' ; </script> <script type="text/javascript" src="'.__PS_BASE_URI__.'js/tiny_mce/tiny_mce.js"></script> <script type="text/javascript" src="'.__PS_BASE_URI__.'js/tinymce.inc.js"></script> <script type="text/javascript">id_language = Number('.$defaultLanguage.');</script> <script type="text/javascript"> $(document).ready(function(){ tinySetup({});}); </script> '; // Form $this->_html .= ' <fieldset> <legend><img src="'.$this->_path.'logo.gif" alt="" title="" /> '.$this->l('New block').'</legend> <form method="post" action="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'" enctype="multipart/form-data"> <label>'.$this->l('Title:').'</label> <div class="margin-form">'; foreach ($languages as $language) { $this->_html .= ' <div id="titlediv_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $defaultLanguage ? 'block' : 'none').'; float: left;"> <input type="text" name="title_'.$language['id_lang'].'" value="'.Tools::getValue('title_'.$language['id_lang']).'" size="55" /><sup> *</sup> </div>'; } $this->_html .= $this->displayFlags($languages, $defaultLanguage, $divLangName, 'titlediv', true); $this->_html .= ' <div class="clear"></div> </div> <label>'.$this->l('Identifier:').'</label> <div class="margin-form"> <div id="identifierdiv" style="float: left;"> <input type="text" name="identifier_block" value="'.Tools::getValue('identifier_block').'" size="55" /><sup> *</sup> </div> <p class="clear">'.$this->l('Identifier must be unique').'. '.$this->l('Match a-zA-Z-_0-9').'</p> <div class="clear"></div> </div> <label>'.$this->l('Hook into:').'</label> <div class="margin-form"> <div id="hookdiv" style="float: left;"> <select name="hook"> <option value="0">'.$this->l('None').'</option>'; foreach ($this->myHook AS $hook){ $id_hook = Hook::getIdByName($hook); $this->_html .= '<option value="'.$id_hook.'"'.($id_hook == Tools::getValue('hook') ? 'selected="selected"' : '').'>'.$this->getHookTitle($id_hook).'</option>'; } $this->_html .= ' </select> </div> <div class="clear"></div> </div> <label>'.$this->l('Active:').'</label> <div class="margin-form"> <div id="activediv" style="float: left;"> <input type="radio" name="is_active" value="1"'.(Tools::getValue('is_active',1) ? 'checked="checked"' : '').' /> <label class="t"><img src="'._PS_ADMIN_IMG_.'enabled.gif" alt="Enabled" title="Enabled" /></label> <input type="radio" name="is_active" value="0"'.(Tools::getValue('is_active',1) ? '' : 'checked="checked"').' /> <label class="t"><img src="'._PS_ADMIN_IMG_.'disabled.gif" alt="Disabled" title="Disabled" /></label> </div> <div class="clear"></div> </div> <label>'.$this->l('Content:').'</label> <div class="margin-form">'; foreach ($languages as $language) { $this->_html .= ' <div id="contentdiv_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $defaultLanguage ? 'block' : 'none').'; float: left;"> <textarea class="rte" name="content_'.$language['id_lang'].'" id="contentInput_'.$language['id_lang'].'" cols="100" rows="20">'.Tools::getValue('content_'.$language['id_lang']).'</textarea> </div>'; } $this->_html .= $this->displayFlags($languages, $defaultLanguage, $divLangName, 'contentdiv', true); $this->_html .= ' <div class="clear"></div> </div> <div class="margin-form">'; $this->_html .= '<input type="submit" class="button" name="saveBlock" value="'.$this->l('Save Block').'" id="saveBlock" /> '; $this->_html .= ' </div> </form> <a href="'.$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'"><img src="'._PS_ADMIN_IMG_.'arrow2.gif" alt="" />'.$this->l('Back to list').'</a> </fieldset>'; } private function _displayUpdateForm() { global $currentIndex, $cookie; if (!Tools::getValue('id_block')) { $this->_html .= '<a href="'.$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'"><img src="'._PS_ADMIN_IMG_.'arrow2.gif" alt="" />'.$this->l('Back to list').'</a>'; return; } $block = new StaticBlockClass((int)Tools::getValue('id_block')); // Language $defaultLanguage = (int)(Configuration::get('PS_LANG_DEFAULT')); $languages = Language::getLanguages(false); $divLangName = 'titlediv¤contentdiv'; // TinyMCE $iso = Language::getIsoById((int)($cookie->id_lang)); $isoTinyMCE = (file_exists(_PS_ROOT_DIR_.'/js/tiny_mce/langs/'.$iso.'.js') ? $iso : 'en'); $ad = dirname($_SERVER["PHP_SELF"]); $this->_html .= ' <script type="text/javascript"> var iso = \''.$isoTinyMCE.'\' ; var pathCSS = \''._THEME_CSS_DIR_.'\' ; var ad = \''.$ad.'\' ; </script> <script type="text/javascript" src="'.__PS_BASE_URI__.'js/tiny_mce/tiny_mce.js"></script> <script type="text/javascript" src="'.__PS_BASE_URI__.'js/tinymce.inc.js"></script> <script type="text/javascript">id_language = Number('.$defaultLanguage.');</script> <script type="text/javascript"> $(document).ready(function(){ tinySetup({});}); </script> '; // Form $this->_html .= ' <fieldset> <legend><img src="'.$this->_path.'logo.gif" alt="" title="" /> '.$this->l('Edit block').' '.$block->identifier_block.'</legend> <form method="post" action="'.Tools::safeOutput($_SERVER['REQUEST_URI']).'" enctype="multipart/form-data"> <input type="hidden" name="id_block" value="'.(int)$block->id_block.'" id="id_block" /> <div class="margin-form"> <input type="submit" class="button " name="deleteBlock" value="'.$this->l('Delete Block').'" id="deleteBlock" onclick="if (!confirm(\'Are you sure that you want to delete this static blocks?\')) return false "/> </div> <label>'.$this->l('Title:').'</label> <div class="margin-form">'; foreach ($languages as $language) { $this->_html .= ' <div id="titlediv_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $defaultLanguage ? 'block' : 'none').'; float: left;"> <input type="text" name="title_'.$language['id_lang'].'" value="'.(isset($block->title[$language['id_lang']]) ? $block->title[$language['id_lang']] : '').'" size="55" /><sup> *</sup> </div>'; } $this->_html .= $this->displayFlags($languages, $defaultLanguage, $divLangName, 'titlediv', true); $this->_html .= ' <div class="clear"></div> </div> <label>'.$this->l('Identifier:').'</label> <div class="margin-form"> <div id="identifierdiv" style="float: left;"> <input type="text" name="identifier_block" value="'.$block->identifier_block.'" size="55" /><sup> *</sup> </div> <p class="clear">'.$this->l('Identifier must be unique').'. '.$this->l('Match a-zA-Z-_0-9').'</p> <div class="clear"></div> </div> <label>'.$this->l('Hook into:').'</label> <div class="margin-form"> <div id="hookdiv" style="float: left;"> <select name="hook"> <option value="0">'.$this->l('None').'</option>'; foreach ($this->myHook AS $hook){ $id_hook = Hook::getIdByName($hook); $this->_html .= '<option value="'.$id_hook.'"'.($id_hook == $block->hook ? 'selected="selected"' : '').'>'.$this->getHookTitle($id_hook).'</option>'; } $this->_html .= ' </select> </div> <div class="clear"></div> </div> <label>'.$this->l('Status:').'</label> <div class="margin-form"> <div id="activediv" style="float: left;"> <input type="radio" name="is_active" '.($block->is_active ? 'checked="checked"' : '').' value="1" /> <label class="t"><img src="'._PS_ADMIN_IMG_.'enabled.gif" alt="Enabled" title="Enabled" /></label> <input type="radio" name="is_active" '.($block->is_active ? '' : 'checked="checked"').' value="0" /> <label class="t"><img src="'._PS_ADMIN_IMG_.'disabled.gif" alt="Disabled" title="Disabled" /></label> </div> <div class="clear"></div> </div> <label>'.$this->l('Content:').'</label> <div class="margin-form">'; foreach ($languages as $language) { $this->_html .= ' <div id="contentdiv_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $defaultLanguage ? 'block' : 'none').'; float: left;"> <textarea class="rte" name="content_'.$language['id_lang'].'" id="contentInput_'.$language['id_lang'].'" cols="100" rows="20">'.(isset($block->content[$language['id_lang']]) ? $block->content[$language['id_lang']] : '').'</textarea> </div>'; } $this->_html .= $this->displayFlags($languages, $defaultLanguage, $divLangName, 'contentdiv', true); $this->_html .= ' <div class="clear"></div> </div> <div class="margin-form">'; $this->_html .= '<input type="submit" class="button" name="saveBlock" value="'.$this->l('Save Block').'" id="saveBlock" />'; $this->_html .= ' </div> </form> <a href="'.$currentIndex.'&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'"><img src="'._PS_ADMIN_IMG_.'arrow2.gif" alt="" />'.$this->l('Back to list').'</a> </fieldset>'; } public function contentById($id_block) { global $cookie; $staticblock = new StaticBlockClass($id_block); return ($staticblock->is_active ? $staticblock->content[(int)$cookie->id_lang] : ''); } public function contentByIdentifier($identifier) { global $cookie; if (!$result = Db::getInstance()->getRow(' SELECT `id_block`,`identifier_block` FROM `'._DB_PREFIX_.'staticblock` WHERE `identifier_block` = \''.$identifier.'\'')) return false; $staticblock = new StaticBlockClass($result['id_block']); return ($staticblock->is_active ? $staticblock->content[(int)$cookie->id_lang] : ''); } private function getBlockInHook($hook_name) { $block_list = array(); $this->context = Context::getContext(); $id_shop = $this->context->shop->id; $id_hook = Hook::getIdByName($hook_name); if ($id_hook) { $results = Db::getInstance()->ExecuteS('SELECT b.`id_block` FROM `'._DB_PREFIX_.'staticblock` b LEFT JOIN `'._DB_PREFIX_.'staticblock_shop` bs ON (b.id_block = bs.id_block) WHERE bs.is_active = 1 AND (bs.id_shop = '.(int)$id_shop.') AND b.`hook` = '.(int)($id_hook)); foreach ($results as $row) { $temp = new StaticBlockClass($row['id_block']); $block_list[] = $temp; } } return $block_list; } function hookHeader($params) { global $smarty; $smarty->assign(array( 'HOOK_TOP_CONTENT' => Hook::Exec('topcontent'), 'HOOK_FOOTER_BOTTOM' => Hook::Exec('footerbottom'), 'HOOK_FOOTER_LEFT' => Hook::Exec('footerleft'), 'HOOK_COPYRIGHT' => Hook::Exec('copyright'), 'HOOK_CATEGORY_IMAGE' => Hook::Exec('categoryImage') )); } public function hookCsmegamenu() { global $smarty, $cookie; if (!$this->isCached('csstaticblocks_csmegamenu.tpl', $this->getCacheId('csstaticblocks_csmegamenu'))) { $block_list = $this->getBlockInHook('csmegamenu'); $smarty->assign(array( 'block_list' => $block_list )); } return $this->display(__FILE__, 'csstaticblocks_csmegamenu.tpl', $this->getCacheId('csstaticblocks_csmegamenu')); } public function hookCsSlideShow() { global $smarty, $cookie; if (!$this->isCached('csstaticblocks_csslideshow.tpl', $this->getCacheId('csstaticblocks_csslideshow'))) { $block_list = $this->getBlockInHook('csslideshow'); $smarty->assign(array( 'block_list' => $block_list )); } return $this->display(__FILE__, 'csstaticblocks_csslideshow.tpl', $this->getCacheId('csstaticblocks_csslideshow')); } public function hookDisplayTop() { global $smarty, $cookie; if (!$this->isCached('csstaticblocks_displaytop.tpl', $this->getCacheId('csstaticblocks_displaytop'))) { $block_list = $this->getBlockInHook('displaytop'); $smarty->assign(array( 'block_list' => $block_list )); } return $this->display(__FILE__, 'csstaticblocks_displaytop.tpl', $this->getCacheId('csstaticblocks_displaytop')); } public function hookTopContent() { global $smarty, $cookie; if (!$this->isCached('csstaticblocks_topcontent.tpl', $this->getCacheId('csstaticblocks_topcontent'))) { $block_list = $this->getBlockInHook('topcontent'); $smarty->assign(array( 'block_list' => $block_list )); } return $this->display(__FILE__, 'csstaticblocks_topcontent.tpl', $this->getCacheId('csstaticblocks_topcontent')); } public function hookDisplayLeftColumn() { global $smarty, $cookie; if (!$this->isCached('csstaticblocks_displayleftcolumn.tpl', $this->getCacheId('csstaticblocks_displayleftcolumn'))) { $block_list = $this->getBlockInHook('displayleftColumn'); $smarty->assign(array( 'block_list' => $block_list )); } return $this->display(__FILE__, 'csstaticblocks_displayleftcolumn.tpl', $this->getCacheId('csstaticblocks_displayleftcolumn')); } public function hookDisplayRightColumn() { global $smarty, $cookie; if (!$this->isCached('csstaticblocks_displayrightcolumn.tpl', $this->getCacheId('csstaticblocks_displayrightcolumn'))) { $block_list = $this->getBlockInHook('displayrightColumn'); $smarty->assign(array( 'block_list' => $block_list )); } return $this->display(__FILE__, 'csstaticblocks_displayrightcolumn.tpl', $this->getCacheId('csstaticblocks_displayrightcolumn')); } public function hookDisplayFooter() { global $smarty, $cookie; if (!$this->isCached('csstaticblocks_displayfooter.tpl', $this->getCacheId('csstaticblocks_displayfooter'))) { $block_list = $this->getBlockInHook('displayfooter'); $smarty->assign(array( 'block_list' => $block_list )); } return $this->display(__FILE__, 'csstaticblocks_displayfooter.tpl', $this->getCacheId('csstaticblocks_displayfooter')); } public function hookDisplayHome() { global $smarty, $cookie; if (!$this->isCached('csstaticblocks_displayhome.tpl', $this->getCacheId('csstaticblocks_displayhome'))) { $block_list = $this->getBlockInHook('displayhome'); $smarty->assign(array( 'block_list' => $block_list )); } return $this->display(__FILE__, 'csstaticblocks_displayhome.tpl', $this->getCacheId('csstaticblocks_displayhome')); } public function hookFooterLeft() { global $smarty, $cookie; if (!$this->isCached('csstaticblocks_footerleft.tpl', $this->getCacheId('csstaticblocks_footerleft'))) { $block_list = $this->getBlockInHook('footerleft'); $smarty->assign(array( 'block_list' => $block_list )); } return $this->display(__FILE__, 'csstaticblocks_footerleft.tpl', $this->getCacheId('csstaticblocks_footerleft')); } public function hookFooterBottom() { global $smarty, $cookie; if (!$this->isCached('csstaticblocks_footerbottom.tpl', $this->getCacheId('csstaticblocks_footerbottom'))) { $block_list = $this->getBlockInHook('footerbottom'); $smarty->assign(array( 'block_list' => $block_list )); } return $this->display(__FILE__, 'csstaticblocks_footerbottom.tpl', $this->getCacheId('csstaticblocks_footerbottom')); } public function hookCopyRight() { global $smarty, $cookie; if (!$this->isCached('csstaticblocks_copyright.tpl', $this->getCacheId('csstaticblocks_copyright'))) { $block_list = $this->getBlockInHook('copyright'); $smarty->assign(array( 'block_list' => $block_list )); } return $this->display(__FILE__, 'csstaticblocks_copyright.tpl', $this->getCacheId('csstaticblocks_copyright')); } public function hookcategoryImage() { global $smarty, $cookie; if (!$this->isCached('csstaticblocks_categoryimage.tpl', $this->getCacheId('csstaticblocks_categoryimage'))) { $block_list = $this->getBlockInHook('categoryImage'); $smarty->assign(array( 'block_list' => $block_list )); } return $this->display(__FILE__, 'csstaticblocks_categoryimage.tpl', $this->getCacheId('csstaticblocks_categoryimage')); } } ?>