/**
  * Constructor
  */
 public function __construct()
 {
     $this->bootstrap = true;
     $this->table = 'leohook';
     $this->className = 'LeotempcpPanel';
     $this->lang = true;
     $this->context = Context::getContext();
     parent::__construct();
     $this->display_key = (int) Tools::getValue('show_modules');
     $this->ownPositions = array('displayHeaderRight', 'displaySlideshow', 'topNavigation', 'displayPromoteTop', 'displayBottom', 'displayMassBottom');
     $this->hookspos = LeoFrameworkHelper::getHookPositions();
     $this->theme_name = Context::getContext()->shop->getTheme();
 }
 /**
  * Proccess Hook Header
  */
 public function hookHeader($params)
 {
     global $smarty;
     $output = '';
     if ($this->themeInfo) {
         $isRTL = $this->context->language->is_rtl;
         $id_shop = $this->context->shop->id;
         $helper = LeoFrameworkHelper::getInstance();
         $helper->setActivedTheme($this->themeName)->loadOverridedHooks(Context::getContext()->shop->id);
         $panelTool = $this->getConfig('PANELTOOL');
         $backGroundValue = '';
         //get skin in config in font office when turn on paneltool
         if ($panelTool) {
             $this->context->controller->addJqueryPlugin('cooki-plugin');
             $this->context->controller->addCss(__PS_BASE_URI__ . 'themes/' . $this->themeName . '/css/paneltool.css');
             $this->context->controller->addJs($this->_path . '/assets/admin/colorpicker/js/colorpicker.js', 'all');
             $this->context->controller->addCss($this->_path . '/assets/admin/colorpicker/css/colorpicker.css', 'all');
             $this->context->controller->addJS($this->_path . 'assets/admin/paneltool.js', 'all');
             //$helper->triggerUserParams(array('header_style', 'layout_mode', 'skin'));
             //load skin, header float, layout mode, menu left
             $skin = $this->getPanelConfig('default_skin');
             $layout_mode = $this->getPanelConfig('layout_mode');
             $header_style = $this->getPanelConfig('header_style');
             $enable_fheader = $this->getPanelConfig('enable_fheader');
             $sidebar_menu = $this->getPanelConfig('sidebarmenu');
             $backGroundValue = array("attachment" => array("scroll", "fixed", "local", "initial", "inherit"), "repeat" => array("repeat", "repeat-x", "repeat-y", "no-repeat", "initial", "inherit"), "position" => array("left top", "left center", "left bottom", "right top", "right center", "right bottom", "center top", "center center", "center bottom"));
         } else {
             $skin = $this->getConfig('default_skin');
             $layout_mode = $this->getConfig('layout_mode');
             $header_style = $this->getConfig('header_style');
             $enable_fheader = $this->getConfig('enable_fheader');
             $sidebar_menu = $this->getConfig('sidebarmenu');
         }
         $css_custom = array();
         if ($isRTL && file_exists(_PS_THEME_DIR_ . 'css/custom-rtl.css')) {
             $css_custom[__PS_BASE_URI__ . 'themes/' . $this->themeName . '/css/custom-rtl.css'] = 'all';
         }
         //only load mobile.css when disable responsive
         if ($this->context->getMobileDevice() != false && !$this->getConfig('enable_responsive')) {
             if (file_exists(_PS_THEME_DIR_ . '/css/mobile.css')) {
                 $css_custom[__PS_BASE_URI__ . 'themes/' . $this->themeName . '/css/mobile.css'] = 'all';
             }
         }
         /* load custom css profile */
         if ($profile = $this->getConfig('c_profile')) {
             if (file_exists(_PS_THEME_DIR_ . '/css/customize/' . $profile . '.css')) {
                 $css_custom[__PS_BASE_URI__ . 'themes/' . $this->themeName . '/css/customize/' . $profile . '.css'] = 'all';
             }
         }
         /* load css custom for this shop only */
         $css = $id_shop . 'custom.css';
         if (file_exists(_PS_THEME_DIR_ . 'css/local/' . $css) && trim(Tools::file_get_contents(_PS_THEME_DIR_ . 'css/local/' . $css))) {
             $css_custom[__PS_BASE_URI__ . 'themes/' . $this->themeName . '/css/local/' . $css] = 'all';
         }
         $css_custom_skin = array();
         /* load skin css file */
         if (file_exists(_PS_THEME_DIR_ . 'css/skins/' . $skin . '/skin.css')) {
             $skinFileUrl = __PS_BASE_URI__ . 'themes/' . $this->themeName . '/css/skins/' . $skin . '/skin.css';
             $css_custom_skin[] = '<link rel="stylesheet" id="leo-dynamic-skin-css" href="' . $skinFileUrl . '" type="text/css" media="all" />';
         }
         if ($isRTL && file_exists(_PS_THEME_DIR_ . 'css/skins/' . $skin . '/custom-rtl.css')) {
             $skinFileUrl = __PS_BASE_URI__ . 'themes/' . $this->themeName . '/css/skins/' . $skin . '/custom-rtl.css';
             $css_custom_skin[] = '<link rel="stylesheet" id="leo-dynamic-skin-css-rtl" href="' . $skinFileUrl . '" type="text/css" media="all" />';
         }
         $js = $id_shop . 'custom.js';
         /* load and add custom js file in local folder */
         if (file_exists(_PS_THEME_DIR_ . '/js/local/' . $js) && trim(Tools::file_get_contents(_PS_THEME_DIR_ . '/js/local/' . $js))) {
             $this->context->controller->addJS(__PS_BASE_URI__ . 'themes/' . $this->themeName . '/js/local/' . $js, 'all');
         }
         $customFont = '';
         /* check enable customize font */
         if ($this->getConfig('ENABLE_CUSTOMFONT')) {
             $selector = $this->getConfig('FONT1_SELECTOR');
             if ($selector = $this->getConfig('FONT1_SELECTOR')) {
                 $customFont .= $helper->loadLocalFont()->renderFontTagHeader($this->getConfig('FONT_ENGINE1'), $this->getConfig('ENGINE1_LOCAL_FONT'), $this->getConfig('ENGINE1_GOOGLE_LINK'), $this->getConfig('ENGINE1_GOOGLE_FONT'), $selector);
             }
             if ($selector = $this->getConfig('FONT2_SELECTOR')) {
                 $customFont .= $helper->loadLocalFont()->renderFontTagHeader($this->getConfig('FONT_ENGINE2'), $this->getConfig('ENGINE2_LOCAL_FONT'), $this->getConfig('ENGINE2_GOOGLE_LINK'), $this->getConfig('ENGINE2_GOOGLE_FONT'), $selector);
             }
             if ($selector = $this->getConfig('FONT3_SELECTOR')) {
                 $customFont .= $helper->loadLocalFont()->renderFontTagHeader($this->getConfig('FONT_ENGINE3'), $this->getConfig('ENGINE3_LOCAL_FONT'), $this->getConfig('ENGINE3_GOOGLE_LINK'), $this->getConfig('ENGINE3_GOOGLE_FONT'), $selector);
             }
         }
         $layout_width_val = '';
         $layout_width = $this->getConfig('layout_width');
         if (trim($layout_width) != 'auto' && trim($layout_width) != '') {
             $layout_width = str_replace('px', '', $layout_width);
             $layout_width_val = '<style type="text/css">.container{max-width:' . $layout_width . 'px}</style>';
             if (is_numeric($layout_width)) {
                 $layout_width_val .= '<script type="text/javascript">layout_width = ' . $layout_width . ';</script>';
             }
         }
         //  'FOOTER_BUIDER'      => $this->getFooterBuilder(),
         /* Asign to vars */
         $ps = array('HOOK_TOPNAVIGATION' => $helper->exec('topNavigation'), 'HOOK_SLIDESHOW' => $helper->exec('displaySlideshow'), 'HOOK_HEADERRIGHT' => $helper->exec('displayHeaderRight'), 'HOOK_BOTTOM' => $helper->exec('displayBottom'), 'HOOK_CONTENTBOTTOM' => $helper->exec('displayContentBottom'), 'HOOK_FOOTERTOP' => $helper->exec('displayFooterTop'), 'HOOK_FOOTERBOTTOM' => $helper->exec('displayFooterBottom'), 'HOOK_FOOTNAV' => $helper->exec('displayFootNav'), 'CUSTOM_FONT' => $customFont, 'LEO_THEMENAME' => $this->themeName, 'LEO_PANELTOOL' => $panelTool, 'LEO_HEADER_STYLE' => $header_style, 'LEO_SIDEBAR_MENU' => $sidebar_menu, 'LEO_DEFAULT_SKIN' => $skin, 'LEO_LAYOUT_MODE' => $layout_mode, 'CUSTOM_COPYRIGHT' => $this->getConfig('COPYRIGHT', '', $this->context->language->id), 'ENABLE_COPYRIGHT' => $this->getConfig('ENABLE_COPYRIGHT'), 'BACKGROUNDVALUE' => $backGroundValue, 'LAYOUT_WIDTH' => $layout_width_val, 'LEO_CSS' => $css_custom, 'LEO_SKIN_CSS' => $css_custom_skin, 'IS_RTL' => $isRTL, 'USE_PTABS' => $this->getConfig('ENABLE_PTAB'), 'USE_FHEADER' => $enable_fheader, 'LEO_COOKIE_THEME' => $this->themeCookieName);
         $smarty->assign($ps);
     }
     return $output;
 }
 /**
  * render list of modules following positions in the layout editor.
  */
 public function renderList()
 {
     $filePath = _PS_ALL_THEMES_DIR_ . $this->themeName . '';
     $xml = simplexml_load_file($filePath . '/config.xml');
     if (!isset($xml->theme_key) || empty($xml->theme_key)) {
         return '<div class="panel"><div class="panel-content"><div class="alert alert-danger">' . $this->l('This function is only avariable using for theme From <b>leotheme.com</b> or using theme built-in <b>Leo Framework</b>') . '</div></div></div>';
     }
     $tpl = $this->createTemplate('themeeditor.tpl');
     $this->context->controller->addCss(__PS_BASE_URI__ . str_replace("//", "/", 'modules/leotempcp') . '/assets/admin/themeeditor.css', 'all');
     $this->context->controller->addCss(__PS_BASE_URI__ . str_replace("//", "/", 'modules/leotempcp') . '/assets/admin/colorpicker/css/colorpicker.css', 'all');
     $this->context->controller->addJs(__PS_BASE_URI__ . str_replace("//", "/", 'modules/leotempcp') . '/assets/admin/themeeditor.js', 'all');
     $this->context->controller->addJs(__PS_BASE_URI__ . str_replace("//", "/", 'modules/leotempcp') . '/assets/admin/colorpicker/js/colorpicker.js', 'all');
     $this->context->controller->addCss(__PS_BASE_URI__ . 'themes/' . $this->themeName . '/css/paneltool.css');
     $output = LeoFrameworkHelper::renderEdtiorThemeForm($this->themeName);
     /*         * */
     $profiles = $this->getFileList($this->themeCustomizePath, '.css', true);
     $patterns = $this->getFileList(_PS_ALL_THEMES_DIR_ . $this->themeName . '/img/patterns/', '.png');
     $patternsjpg = $this->getFileList(_PS_ALL_THEMES_DIR_ . $this->themeName . '/img/patterns/', '.jpg');
     $patterns = array_merge($patterns, $patternsjpg);
     $backGroundValue = array("attachment" => array("scroll", "fixed", "local", "initial", "inherit"), "repeat" => array("repeat", "repeat-x", "repeat-y", "no-repeat", "initial", "inherit"), "position" => array("left top", "left center", "left bottom", "right top", "right center", "right bottom", "center top", "center center", "center bottom"));
     $siteURL = $this->context->shop->getBaseURL();
     $imgLink = Context::getContext()->link->getAdminLink('AdminLeotempcpImages');
     $backgroundImageURL = $this->context->shop->getBaseURL() . '/themes/' . $this->themeName . '/img/patterns/';
     $ssl_enable = Configuration::get('PS_SSL_ENABLED');
     if ($ssl_enable) {
         $siteURL = str_replace("http:", "https:", $siteURL);
         $imgLink = str_replace("http:", "https:", $imgLink);
         $backgroundImageURL = str_replace("http:", "https:", $backgroundImageURL);
     }
     $tpl->assign(array('actionURL' => 'index.php?tab=AdminLeotempcpTheme&token=' . Tools::getAdminTokenLite('AdminLeotempcpTheme') . '&action=savedata', 'text_layout' => $this->l('Layout'), 'text_elements' => $this->l('Elements'), 'profiles' => $profiles, 'xmlselectors' => $output, 'themeName' => $this->themeName, 'patterns' => $patterns, 'backgroundImageURL' => $backgroundImageURL, 'siteURL' => $siteURL, 'customizeFolderURL' => $this->themeCustomizeURL, 'backLink' => 'index.php?tab=AdminLeotempcpModule&token=' . Tools::getAdminTokenLite('AdminLeotempcpModule') . '&action=back', 'imgLink' => $imgLink, 'backGroundValue' => $backGroundValue));
     return $tpl->fetch();
 }
    function content_56b31247240509_61413481($_smarty_tpl)
    {
        if (class_exists("LeoFrameworkHelper")) {
            $_smarty_tpl->tpl_vars['skins'] = new Smarty_variable(LeoFrameworkHelper::getSkins($_smarty_tpl->tpl_vars['LEO_THEMENAME']->value), null, 0);
            $_smarty_tpl->tpl_vars['header_styles'] = new Smarty_variable(LeoFrameworkHelper::getPanelConfigByTheme('header', $_smarty_tpl->tpl_vars['LEO_THEMENAME']->value), null, 0);
            $_smarty_tpl->tpl_vars['sidebarmenu'] = new Smarty_variable(LeoFrameworkHelper::getPanelConfigByTheme('sidebarmenu', $_smarty_tpl->tpl_vars['LEO_THEMENAME']->value), null, 0);
            $_smarty_tpl->tpl_vars['theme_customizations'] = new Smarty_variable(LeoFrameworkHelper::getLayoutSettingByTheme($_smarty_tpl->tpl_vars['LEO_THEMENAME']->value), null, 0);
            ?>
<div id="leo-paneltool" class="hidden-sm hidden-xs" data-cname="<?php 
            echo $_smarty_tpl->tpl_vars['LEO_COOKIE_THEME']->value;
            ?>
">
<?php 
            if ($_smarty_tpl->tpl_vars['skins']->value || $_smarty_tpl->tpl_vars['header_styles']->value || $_smarty_tpl->tpl_vars['theme_customizations']->value || $_smarty_tpl->tpl_vars['sidebarmenu']->value) {
                ?>
  <div class="paneltool themetool">
    <div class="panelbutton">
      <i class="fa fa-sliders"></i>
    </div>
    <div class="block-panelcontent">
        <div class="panelcontent">
            <div class="panelinner">
              <h4><?php 
                echo smartyTranslate(array('s' => 'Panel Tool'), $_smarty_tpl);
                ?>
</h4>
                          <!-- Theme layout mod section -->
              <?php 
                if ($_smarty_tpl->tpl_vars['theme_customizations']->value && isset($_smarty_tpl->tpl_vars['theme_customizations']->value['layout']) && isset($_smarty_tpl->tpl_vars['theme_customizations']->value['layout']['layout_mode']) && isset($_smarty_tpl->tpl_vars['theme_customizations']->value['layout']['layout_mode']['option'])) {
                    ?>
                <div class="group-input clearfix layout">
                  <label class="col-sm-12 control-label"><i class="fa fa-desktop"></i><?php 
                    echo smartyTranslate(array('s' => 'Layout Mod'), $_smarty_tpl);
                    ?>
</label>
                  <div class="col-sm-12">
                    <?php 
                    $_smarty_tpl->tpl_vars['layout'] = new Smarty_Variable();
                    $_smarty_tpl->tpl_vars['layout']->_loop = false;
                    $_from = $_smarty_tpl->tpl_vars['theme_customizations']->value['layout']['layout_mode']['option'];
                    if (!is_array($_from) && !is_object($_from)) {
                        settype($_from, 'array');
                    }
                    foreach ($_from as $_smarty_tpl->tpl_vars['layout']->key => $_smarty_tpl->tpl_vars['layout']->value) {
                        $_smarty_tpl->tpl_vars['layout']->_loop = true;
                        ?>
                      <span class="leo-dynamic-update-layout <?php 
                        if ($_smarty_tpl->tpl_vars['LEO_LAYOUT_MODE']->value == $_smarty_tpl->tpl_vars['layout']->value['id']) {
                            ?>
current-layout-mod<?php 
                        }
                        ?>
" data-layout-mod="<?php 
                        echo $_smarty_tpl->tpl_vars['layout']->value['id'];
                        ?>
">
                        <?php 
                        echo $_smarty_tpl->tpl_vars['layout']->value['name'];
                        ?>

                      </span>
                    <?php 
                    }
                    ?>
                  </div>
                </div>
              <?php 
                }
                ?>
              <!-- Theme skin section -->
              <?php 
                if ($_smarty_tpl->tpl_vars['skins']->value) {
                    ?>
              <div class="group-input clearfix">
                <label class="col-sm-12 control-label"><i class="fa fa-paint-brush"></i><?php 
                    echo smartyTranslate(array('s' => 'Theme'), $_smarty_tpl);
                    ?>
</label>
                <div class="col-sm-12">
                  <div data-theme-skin-id="default" class="skin-default leo-dynamic-theme-skin<?php 
                    if ($_smarty_tpl->tpl_vars['LEO_DEFAULT_SKIN']->value == 'default') {
                        ?>
 current-theme-skin<?php 
                    }
                    ?>
">
                      <label><?php 
                    echo smartyTranslate(array('s' => 'Default'), $_smarty_tpl);
                    ?>
</label>
                  </div>
                  <?php 
                    $_smarty_tpl->tpl_vars['skin'] = new Smarty_Variable();
                    $_smarty_tpl->tpl_vars['skin']->_loop = false;
                    $_from = $_smarty_tpl->tpl_vars['skins']->value;
                    if (!is_array($_from) && !is_object($_from)) {
                        settype($_from, 'array');
                    }
                    foreach ($_from as $_smarty_tpl->tpl_vars['skin']->key => $_smarty_tpl->tpl_vars['skin']->value) {
                        $_smarty_tpl->tpl_vars['skin']->_loop = true;
                        ?>
                  <div data-theme-skin-id="<?php 
                        echo $_smarty_tpl->tpl_vars['skin']->value['id'];
                        ?>
" data-theme-skin-css="<?php 
                        echo $_smarty_tpl->tpl_vars['skin']->value['css'];
                        ?>
" data-theme-skin-rtl="<?php 
                        echo $_smarty_tpl->tpl_vars['skin']->value['rtl'];
                        ?>
" class="leo-dynamic-theme-skin<?php 
                        if (isset($_smarty_tpl->tpl_vars['skin']->value['icon']) && $_smarty_tpl->tpl_vars['skin']->value['icon']) {
                            ?>
 theme-skin-type-image<?php 
                        }
                        if ($_smarty_tpl->tpl_vars['LEO_DEFAULT_SKIN']->value == $_smarty_tpl->tpl_vars['skin']->value['id']) {
                            ?>
 current-theme-skin<?php 
                        }
                        ?>
">
                    <?php 
                        if (isset($_smarty_tpl->tpl_vars['skin']->value['icon']) && $_smarty_tpl->tpl_vars['skin']->value['icon']) {
                            ?>
                      <img src="<?php 
                            echo $_smarty_tpl->tpl_vars['skin']->value['icon'];
                            ?>
" width="36" height="36" alt="" />
                    <?php 
                        } else {
                            ?>
                      <label class="<?php 
                            echo $_smarty_tpl->tpl_vars['skin']->value['name'];
                            ?>
"><?php 
                            echo $_smarty_tpl->tpl_vars['skin']->value['name'];
                            ?>
</label>
                    <?php 
                        }
                        ?>
                  </div>
                  <?php 
                    }
                    ?>
                </div>
              </div>
              <?php 
                }
                ?>
              <div class="group-input clearfix">
                <label class="col-sm-12 control-label"><i class="fa fa-credit-card"></i><?php 
                echo smartyTranslate(array('s' => 'Float Header'), $_smarty_tpl);
                ?>
</label>
                <div class="col-sm-12">
                  <div class="btn_enable_fheader">
                      <span class="enable_fheader btn_yes <?php 
                if ($_smarty_tpl->tpl_vars['USE_FHEADER']->value) {
                    ?>
current<?php 
                }
                ?>
" data-value="1">
                         <i><?php 
                echo smartyTranslate(array('s' => 'Yes'), $_smarty_tpl);
                ?>
</i>
                      </span>
                      <span class="enable_fheader btn_no <?php 
                if (!$_smarty_tpl->tpl_vars['USE_FHEADER']->value) {
                    ?>
current<?php 
                }
                ?>
" data-value="0">
                        <i><?php 
                echo smartyTranslate(array('s' => 'No'), $_smarty_tpl);
                ?>
</i>
                      </span>
                  </div>
                </div>
              </div>
              <!-- Theme header style section -->
              <!-- Theme slidebar menu section -->
              <?php 
                if ($_smarty_tpl->tpl_vars['sidebarmenu']->value && isset($_smarty_tpl->tpl_vars['sidebarmenu']->value['configs']) && isset($_smarty_tpl->tpl_vars['sidebarmenu']->value['configs']['sidebarmenu']) && isset($_smarty_tpl->tpl_vars['sidebarmenu']->value['configs']['sidebarmenu']['option'])) {
                    ?>
              <div class="group-input clearfix siderbar">
                <label class="col-sm-12 control-label"><i class="fa fa-columns"></i><?php 
                    echo smartyTranslate(array('s' => 'SideBar Menu'), $_smarty_tpl);
                    ?>
</label>
                <div class="col-sm-12">
                  <?php 
                    $_smarty_tpl->tpl_vars['sidebar_menu'] = new Smarty_Variable();
                    $_smarty_tpl->tpl_vars['sidebar_menu']->_loop = false;
                    $_from = $_smarty_tpl->tpl_vars['sidebarmenu']->value['configs']['sidebarmenu']['option'];
                    if (!is_array($_from) && !is_object($_from)) {
                        settype($_from, 'array');
                    }
                    foreach ($_from as $_smarty_tpl->tpl_vars['sidebar_menu']->key => $_smarty_tpl->tpl_vars['sidebar_menu']->value) {
                        $_smarty_tpl->tpl_vars['sidebar_menu']->_loop = true;
                        ?>
                    <span class="leo-dynamic-update-side <?php 
                        if ($_smarty_tpl->tpl_vars['sidebar_menu']->value['id'] == $_smarty_tpl->tpl_vars['LEO_SIDEBAR_MENU']->value) {
                            ?>
current-sidebar<?php 
                        }
                        ?>
" data-sidebar="<?php 
                        echo $_smarty_tpl->tpl_vars['sidebar_menu']->value['id'];
                        ?>
">
                      <?php 
                        echo $_smarty_tpl->tpl_vars['sidebar_menu']->value['name'];
                        ?>

                    </span>
                  <?php 
                    }
                    ?>
                </div>
              </div>
              <?php 
                }
                ?>
              <?php 
                if ($_smarty_tpl->tpl_vars['header_styles']->value && isset($_smarty_tpl->tpl_vars['header_styles']->value['configs']) && isset($_smarty_tpl->tpl_vars['header_styles']->value['configs']['header_style']) && isset($_smarty_tpl->tpl_vars['header_styles']->value['configs']['header_style']['option'])) {
                    ?>
              <div class="group-input clearfix">
                <label class="col-sm-12 control-label"><i class="fa fa-list-alt"></i><?php 
                    echo smartyTranslate(array('s' => 'Header Style'), $_smarty_tpl);
                    ?>
</label>
                <div class="col-sm-12">
                  <?php 
                    $_smarty_tpl->tpl_vars['header_style'] = new Smarty_Variable();
                    $_smarty_tpl->tpl_vars['header_style']->_loop = false;
                    $_from = $_smarty_tpl->tpl_vars['header_styles']->value['configs']['header_style']['option'];
                    if (!is_array($_from) && !is_object($_from)) {
                        settype($_from, 'array');
                    }
                    foreach ($_from as $_smarty_tpl->tpl_vars['header_style']->key => $_smarty_tpl->tpl_vars['header_style']->value) {
                        $_smarty_tpl->tpl_vars['header_style']->_loop = true;
                        ?>
                    <span class="leo-dynamic-update-header <?php 
                        if ($_smarty_tpl->tpl_vars['header_style']->value['id'] == $_smarty_tpl->tpl_vars['LEO_HEADER_STYLE']->value) {
                            ?>
current-header<?php 
                        }
                        ?>
" data-header-style="<?php 
                        echo $_smarty_tpl->tpl_vars['header_style']->value['id'];
                        ?>
">
                      <?php 
                        echo $_smarty_tpl->tpl_vars['header_style']->value['name'];
                        ?>

                    </span>
                  <?php 
                    }
                    ?>
                </div>
              </div>
              <?php 
                }
                ?>
            </div>
        </div>
    </div>
  </div>
<?php 
            }
            ?>

<div class="paneltool editortool">
  <div class="panelbutton">
    <i class="fa fa-sun-o"></i>
  </div>
  <div class="panelcontent editortool">
		<div class="panelinner">
			<h4>Live Theme Editor</h4>
            <?php 
            $_smarty_tpl->tpl_vars['xmlselectors'] = new Smarty_variable(LeoFrameworkHelper::renderEdtiorThemeForm($_smarty_tpl->tpl_vars['LEO_THEMENAME']->value), null, 0);
            ?>
            <?php 
            $_smarty_tpl->tpl_vars['patterns'] = new Smarty_variable(LeoFrameworkHelper::getPattern($_smarty_tpl->tpl_vars['LEO_THEMENAME']->value), null, 0);
            ?>
            <div class="clearfix" id="customize-body">
              <ul class="nav nav-tabs" id="panelTab">
                <?php 
            $_smarty_tpl->tpl_vars['output'] = new Smarty_Variable();
            $_smarty_tpl->tpl_vars['output']->_loop = false;
            $_smarty_tpl->tpl_vars['for'] = new Smarty_Variable();
            $_from = $_smarty_tpl->tpl_vars['xmlselectors']->value;
            if (!is_array($_from) && !is_object($_from)) {
                settype($_from, 'array');
            }
            foreach ($_from as $_smarty_tpl->tpl_vars['output']->key => $_smarty_tpl->tpl_vars['output']->value) {
                $_smarty_tpl->tpl_vars['output']->_loop = true;
                $_smarty_tpl->tpl_vars['for']->value = $_smarty_tpl->tpl_vars['output']->key;
                ?>
                <li><a href="#tab-<?php 
                echo $_smarty_tpl->tpl_vars['for']->value;
                ?>
"><?php 
                echo $_smarty_tpl->tpl_vars['for']->value;
                ?>
</a></li>
                <?php 
            }
            ?>
              </ul>
            <div class="tab-content" >
            <?php 
            $_smarty_tpl->tpl_vars['items'] = new Smarty_Variable();
            $_smarty_tpl->tpl_vars['items']->_loop = false;
            $_smarty_tpl->tpl_vars['for'] = new Smarty_Variable();
            $_from = $_smarty_tpl->tpl_vars['xmlselectors']->value;
            if (!is_array($_from) && !is_object($_from)) {
                settype($_from, 'array');
            }
            foreach ($_from as $_smarty_tpl->tpl_vars['items']->key => $_smarty_tpl->tpl_vars['items']->value) {
                $_smarty_tpl->tpl_vars['items']->_loop = true;
                $_smarty_tpl->tpl_vars['for']->value = $_smarty_tpl->tpl_vars['items']->key;
                ?>
            <div class="tab-pane" id="tab-<?php 
                echo $_smarty_tpl->tpl_vars['for']->value;
                ?>
">
            <?php 
                if (!empty($_smarty_tpl->tpl_vars['items']->value)) {
                    ?>
              <div class="accordion"  id="accordion-<?php 
                    echo $_smarty_tpl->tpl_vars['for']->value;
                    ?>
">
              <?php 
                    $_smarty_tpl->tpl_vars['group'] = new Smarty_Variable();
                    $_smarty_tpl->tpl_vars['group']->_loop = false;
                    $_from = $_smarty_tpl->tpl_vars['items']->value;
                    if (!is_array($_from) && !is_object($_from)) {
                        settype($_from, 'array');
                    }
                    $_smarty_tpl->tpl_vars['group']->iteration = 0;
                    foreach ($_from as $_smarty_tpl->tpl_vars['group']->key => $_smarty_tpl->tpl_vars['group']->value) {
                        $_smarty_tpl->tpl_vars['group']->_loop = true;
                        $_smarty_tpl->tpl_vars['group']->iteration++;
                        ?>
                 <div class="accordion-group panel panel-default">
                    <div class="accordion-headingt panel-heading">
                      <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion-<?php 
                        echo $_smarty_tpl->tpl_vars['for']->value;
                        ?>
" href="#collapse<?php 
                        echo $_smarty_tpl->tpl_vars['group']->value['match'];
                        ?>
">
                          <?php 
                        echo $_smarty_tpl->tpl_vars['group']->value['header'];
                        ?>

                      </a>
                    </div>
                    <div id="collapse<?php 
                        echo $_smarty_tpl->tpl_vars['group']->value['match'];
                        ?>
" class="accordion-body  <?php 
                        if ($_smarty_tpl->tpl_vars['group']->iteration == 1) {
                            ?>
 in<?php 
                        }
                        ?>
 collapse">
                      <div class="accordion-inner panel-body clearfix">
                      <?php 
                        $_smarty_tpl->tpl_vars['item'] = new Smarty_Variable();
                        $_smarty_tpl->tpl_vars['item']->_loop = false;
                        $_from = $_smarty_tpl->tpl_vars['group']->value['selector'];
                        if (!is_array($_from) && !is_object($_from)) {
                            settype($_from, 'array');
                        }
                        foreach ($_from as $_smarty_tpl->tpl_vars['item']->key => $_smarty_tpl->tpl_vars['item']->value) {
                            $_smarty_tpl->tpl_vars['item']->_loop = true;
                            ?>
                        <?php 
                            if (isset($_smarty_tpl->tpl_vars['item']->value['type']) && $_smarty_tpl->tpl_vars['item']->value['type'] == "image") {
                                ?>
                        <div class="form-group background-images cleafix">
                          <label><?php 
                                echo $_smarty_tpl->tpl_vars['item']->value['label'];
                                ?>
</label>
                          <input value="" type="hidden" name="customize[<?php 
                                echo $_smarty_tpl->tpl_vars['group']->value['match'];
                                ?>
][]" data-match="<?php 
                                echo $_smarty_tpl->tpl_vars['group']->value['match'];
                                ?>
" class="input-setting" data-selector="<?php 
                                echo $_smarty_tpl->tpl_vars['item']->value['selector'];
                                ?>
" data-attrs="background-image">
                          <a class="clear-bg label label-success" href="#"><?php 
                                echo smartyTranslate(array('s' => 'Clear'), $_smarty_tpl);
                                ?>
</a>

                          <div class="clearfix"></div>
                           <p><em style="font-size:10px"><?php 
                                echo smartyTranslate(array('s' => 'Those Images in folder YOURTHEME/img/patterns/'), $_smarty_tpl);
                                ?>
</em></p>
                          <div class="bi-wrapper clearfix">
                          <?php 
                                $_smarty_tpl->tpl_vars['pattern'] = new Smarty_Variable();
                                $_smarty_tpl->tpl_vars['pattern']->_loop = false;
                                $_from = $_smarty_tpl->tpl_vars['patterns']->value;
                                if (!is_array($_from) && !is_object($_from)) {
                                    settype($_from, 'array');
                                }
                                foreach ($_from as $_smarty_tpl->tpl_vars['pattern']->key => $_smarty_tpl->tpl_vars['pattern']->value) {
                                    $_smarty_tpl->tpl_vars['pattern']->_loop = true;
                                    ?>
                            <div style="background:url('<?php 
                                    echo $_smarty_tpl->tpl_vars['content_dir']->value;
                                    ?>
themes/<?php 
                                    echo $_smarty_tpl->tpl_vars['LEO_THEMENAME']->value;
                                    ?>
/img/patterns/<?php 
                                    echo $_smarty_tpl->tpl_vars['pattern']->value;
                                    ?>
') no-repeat center center;" class="pull-left" data-image="<?php 
                                    echo $_smarty_tpl->tpl_vars['content_dir']->value;
                                    ?>
themes/<?php 
                                    echo $_smarty_tpl->tpl_vars['LEO_THEMENAME']->value;
                                    ?>
/img/patterns/<?php 
                                    echo $_smarty_tpl->tpl_vars['pattern']->value;
                                    ?>
" data-val="../../img/patterns/<?php 
                                    echo $_smarty_tpl->tpl_vars['pattern']->value;
                                    ?>
">

                            </div>
                          <?php 
                                }
                                ?>
                          </div>

                           <ul class="bg-config">
                                            <li>
                                                <div><?php 
                                echo smartyTranslate(array('s' => 'Attachment'), $_smarty_tpl);
                                ?>
</div>
                                                <select class="form-control" data-attrs="background-attachment" name="customize[body][]" data-selector="<?php 
                                echo $_smarty_tpl->tpl_vars['item']->value['selector'];
                                ?>
" data-match="<?php 
                                echo $_smarty_tpl->tpl_vars['group']->value['match'];
                                ?>
">
                                                    <option value=""><?php 
                                echo smartyTranslate(array('s' => 'Not set'), $_smarty_tpl);
                                ?>
</option>
                                                    <?php 
                                $_smarty_tpl->tpl_vars['attachment'] = new Smarty_Variable();
                                $_smarty_tpl->tpl_vars['attachment']->_loop = false;
                                $_from = $_smarty_tpl->tpl_vars['BACKGROUNDVALUE']->value['attachment'];
                                if (!is_array($_from) && !is_object($_from)) {
                                    settype($_from, 'array');
                                }
                                foreach ($_from as $_smarty_tpl->tpl_vars['attachment']->key => $_smarty_tpl->tpl_vars['attachment']->value) {
                                    $_smarty_tpl->tpl_vars['attachment']->_loop = true;
                                    ?>
                                                        <option value="<?php 
                                    echo $_smarty_tpl->tpl_vars['attachment']->value;
                                    ?>
"><?php 
                                    echo $_smarty_tpl->tpl_vars['attachment']->value;
                                    ?>
</option>
                                                    <?php 
                                }
                                ?>
                                                </select>
                                            </li>
                                            <li>
                                                <div><?php 
                                echo smartyTranslate(array('s' => 'Position'), $_smarty_tpl);
                                ?>
</div>
                                                <select class="form-control" data-attrs="background-position" name="customize[body][]" data-selector="<?php 
                                echo $_smarty_tpl->tpl_vars['item']->value['selector'];
                                ?>
" data-match="<?php 
                                echo $_smarty_tpl->tpl_vars['group']->value['match'];
                                ?>
">
                                                    <option value=""><?php 
                                echo smartyTranslate(array('s' => 'Not set'), $_smarty_tpl);
                                ?>
</option>
                                                    <?php 
                                $_smarty_tpl->tpl_vars['position'] = new Smarty_Variable();
                                $_smarty_tpl->tpl_vars['position']->_loop = false;
                                $_from = $_smarty_tpl->tpl_vars['BACKGROUNDVALUE']->value['position'];
                                if (!is_array($_from) && !is_object($_from)) {
                                    settype($_from, 'array');
                                }
                                foreach ($_from as $_smarty_tpl->tpl_vars['position']->key => $_smarty_tpl->tpl_vars['position']->value) {
                                    $_smarty_tpl->tpl_vars['position']->_loop = true;
                                    ?>
                                                        <option value="<?php 
                                    echo $_smarty_tpl->tpl_vars['position']->value;
                                    ?>
"><?php 
                                    echo $_smarty_tpl->tpl_vars['position']->value;
                                    ?>
</option>
                                                    <?php 
                                }
                                ?>
                                                </select>
                                            </li>
                                            <li>
                                                <div><?php 
                                echo smartyTranslate(array('s' => 'Repeat'), $_smarty_tpl);
                                ?>
</div>
                                                <select class="form-control" data-attrs="background-repeat" name="customize[body][]" data-selector="<?php 
                                echo $_smarty_tpl->tpl_vars['item']->value['selector'];
                                ?>
" data-match="<?php 
                                echo $_smarty_tpl->tpl_vars['group']->value['match'];
                                ?>
">
                                                    <option value=""><?php 
                                echo smartyTranslate(array('s' => 'Not set'), $_smarty_tpl);
                                ?>
</option>
                                                    <?php 
                                $_smarty_tpl->tpl_vars['repeat'] = new Smarty_Variable();
                                $_smarty_tpl->tpl_vars['repeat']->_loop = false;
                                $_from = $_smarty_tpl->tpl_vars['BACKGROUNDVALUE']->value['repeat'];
                                if (!is_array($_from) && !is_object($_from)) {
                                    settype($_from, 'array');
                                }
                                foreach ($_from as $_smarty_tpl->tpl_vars['repeat']->key => $_smarty_tpl->tpl_vars['repeat']->value) {
                                    $_smarty_tpl->tpl_vars['repeat']->_loop = true;
                                    ?>
                                                        <option value="<?php 
                                    echo $_smarty_tpl->tpl_vars['repeat']->value;
                                    ?>
"><?php 
                                    echo $_smarty_tpl->tpl_vars['repeat']->value;
                                    ?>
</option>
                                                    <?php 
                                }
                                ?>
                                                </select>
                                            </li>
                                        </ul>
                        </div>
                        <?php 
                            } elseif ($_smarty_tpl->tpl_vars['item']->value['type'] == "fontsize") {
                                ?>
                         <div class="form-group cleafix">
                          <label><?php 
                                echo $_smarty_tpl->tpl_vars['item']->value['label'];
                                ?>
</label>
                            <select class="form-control input-setting" name="customize[<?php 
                                echo $_smarty_tpl->tpl_vars['group']->value['match'];
                                ?>
][]" data-match="<?php 
                                echo $_smarty_tpl->tpl_vars['group']->value['match'];
                                ?>
"  data-selector="<?php 
                                echo $_smarty_tpl->tpl_vars['item']->value['selector'];
                                ?>
" data-attrs="<?php 
                                echo $_smarty_tpl->tpl_vars['item']->value['attrs'];
                                ?>
">
                              <option value="">Inherit</option>
                              <?php 
                                $_smarty_tpl->tpl_vars['i'] = new Smarty_Variable();
                                $_smarty_tpl->tpl_vars['i']->step = 1;
                                $_smarty_tpl->tpl_vars['i']->total = (int) ceil(($_smarty_tpl->tpl_vars['i']->step > 0 ? 16 + 1 - 9 : 9 - 16 + 1) / abs($_smarty_tpl->tpl_vars['i']->step));
                                if ($_smarty_tpl->tpl_vars['i']->total > 0) {
                                    for ($_smarty_tpl->tpl_vars['i']->value = 9, $_smarty_tpl->tpl_vars['i']->iteration = 1; $_smarty_tpl->tpl_vars['i']->iteration <= $_smarty_tpl->tpl_vars['i']->total; $_smarty_tpl->tpl_vars['i']->value += $_smarty_tpl->tpl_vars['i']->step, $_smarty_tpl->tpl_vars['i']->iteration++) {
                                        $_smarty_tpl->tpl_vars['i']->first = $_smarty_tpl->tpl_vars['i']->iteration == 1;
                                        $_smarty_tpl->tpl_vars['i']->last = $_smarty_tpl->tpl_vars['i']->iteration == $_smarty_tpl->tpl_vars['i']->total;
                                        ?>
                              <option value="<?php 
                                        echo $_smarty_tpl->tpl_vars['i']->value;
                                        ?>
"><?php 
                                        echo $_smarty_tpl->tpl_vars['i']->value;
                                        ?>
</option>
                              <?php 
                                    }
                                }
                                ?>
                            </select>
                            <a href="#" class="clear-bg label label-success"><?php 
                                echo smartyTranslate(array('s' => 'Clear'), $_smarty_tpl);
                                ?>
</a>
                        </div>
                        <?php 
                            } else {
                                ?>
                        <div class="form-group cleafix">
                          <label><?php 
                                echo $_smarty_tpl->tpl_vars['item']->value['label'];
                                ?>
</label>
                          <input value="" size="10" name="customize[<?php 
                                echo $_smarty_tpl->tpl_vars['group']->value['match'];
                                ?>
][]" data-match="<?php 
                                echo $_smarty_tpl->tpl_vars['group']->value['match'];
                                ?>
" type="text" class="input-setting" data-selector="<?php 
                                echo $_smarty_tpl->tpl_vars['item']->value['selector'];
                                ?>
" data-attrs="<?php 
                                echo $_smarty_tpl->tpl_vars['item']->value['attrs'];
                                ?>
"><a href="#" class="clear-bg label label-success"><?php 
                                echo smartyTranslate(array('s' => 'Clear'), $_smarty_tpl);
                                ?>
</a>
                        </div>
                        <?php 
                            }
                            ?>
                        <?php 
                        }
                        ?>
                      </div>
                    </div>
                  </div>
                 <?php 
                    }
                    ?>
               </div>
              <?php 
                }
                ?>
            </div>
          <?php 
            }
            ?>
          </div>
        </div>
      </div>
    </div>
	<div class="panelbutton label-customize"></div>
  </div>
</div>
<?php 
        }
    }
 public function postProcess()
 {
     if ((Tools::isSubmit('saveleotempcp') || Tools::isSubmit('saveandstayleotempcp')) && Tools::isSubmit('widgets')) {
         if (!Tools::getValue('widget_name')) {
             $this->errors[] = Tools::displayError('Widget Name Empty !');
         }
         if (!count($this->errors)) {
             if (Tools::getValue('id_leowidgets')) {
                 $model = new LeoTempcpWidget((int) Tools::getValue('id_leowidgets'));
             } else {
                 $model = $this->widget;
             }
             $model->loadEngines();
             $model->id_shop = Context::getContext()->shop->id;
             //				$id_lang_default = (int)Configuration::get('PS_LANG_DEFAULT');
             $languages = Language::getLanguages(false);
             $tmp = array();
             # GET POST - BEGIN
             $widget_type = Tools::getValue('widget_type');
             $file_name = _PS_MODULE_DIR_ . 'leotempcp/classes/widget/' . $widget_type . '.php';
             require_once $file_name;
             $class_name = 'LeoWidget' . Tools::ucfirst($widget_type);
             $widget = new $class_name();
             $keys = array('addleowidgets', 'id_leowidgets', 'widget_name', 'widget_type', 'saveandstayleotempcp');
             $post = LeoFrameworkHelper::getPost($keys, 0);
             $keys = array('widget_title');
             $post += LeoFrameworkHelper::getPost($keys, 1);
             $keys = $widget->getConfigKey(0);
             $post += LeoFrameworkHelper::getPost($keys, 0);
             $keys = $widget->getConfigKey(1);
             $post += LeoFrameworkHelper::getPost($keys, 1);
             $keys = $widget->getConfigKey(2);
             $post += LeoFrameworkHelper::getPost($keys, 2);
             # GET POST - END
             foreach ($post as $key => $value) {
                 $tmp[$key] = str_replace(array('\'', '\\"'), array("'", '"'), $value);
                 foreach ($this->_langField as $fVal) {
                     if (strpos($key, $fVal) !== false) {
                         foreach ($languages as $language) {
                             if (!Tools::getValue($fVal . '_' . $language['id_lang'])) {
                                 $tmp[$fVal . '_' . $language['id_lang']] = $value;
                             }
                         }
                     }
                 }
             }
             $data = array('id' => Tools::getValue('id_leowidgets'), 'params' => call_user_func('base64' . '_encode', Tools::jsonEncode($tmp)), 'type' => Tools::getValue('widget_type'), 'name' => Tools::getValue('widget_name'));
             foreach ($data as $k => $v) {
                 $model->{$k} = $v;
             }
             if ($model->id) {
                 if (!$model->update()) {
                     $this->errors[] = Tools::displayError('Can not update new widget');
                 } else {
                     $model->clearCaches();
                     if (Tools::isSubmit('saveandstayleotempcp')) {
                         $this->confirmations[] = $this->l('Update successful');
                         Tools::redirectAdmin(self::$currentIndex . '&id_leowidgets=' . $model->id . '&updateleowidgets&token=' . $this->token . '&conf=4');
                     } else {
                         Tools::redirectAdmin(self::$currentIndex . '&token=' . $this->token . '&conf=4');
                     }
                 }
             } else {
                 $model->key_widget = time();
                 if (!$model->add()) {
                     $this->errors[] = Tools::displayError('Can not add new widget');
                 } else {
                     $model->clearCaches();
                     if (Tools::isSubmit('saveandstayleotempcp')) {
                         $this->confirmations[] = $this->l('Update successful');
                         Tools::redirectAdmin(self::$currentIndex . '&id_leowidgets=' . $model->id . '&updateleowidgets&token=' . $this->token . '&conf=4');
                     } else {
                         Tools::redirectAdmin(self::$currentIndex . '&token=' . $this->token . '&conf=4');
                     }
                 }
             }
         }
     }
     if (Tools::isSubmit('submitBulkcorrectlinkleowidgets')) {
         $leowidgetsBox = Tools::getValue('leowidgetsBox');
         if ($leowidgetsBox) {
             foreach ($leowidgetsBox as $widgetID) {
                 $model = new LeoTempcpWidget($widgetID);
                 $params = Tools::jsonDecode(call_user_func('base64' . '_decode', $model->params), true);
                 $tmp = array();
                 foreach ($params as $widKey => $widValue) {
                     foreach ($this->_imageField as $fVal) {
                         if (strpos($widKey, $fVal) !== false && strpos($widValue, 'img') !== false) {
                             //                            $widValue = str_replace('src="' . __PS_BASE_URI__ . 'modules/', 'src="' . __PS_BASE_URI__ . 'themes/'.$this->_theme_dir.'/img/modules/', $widValue);
                             //                            $patterns = array('/\/leomanagewidgets\/data\//','/\/leobootstrapmenu\/img\//','/\/leobootstrapmenu\/images\//'
                             //                                ,'/\/leomanagewidgets\/images\//','/\/leomenusidebar\/images\//');
                             //                            $replacements = array('/leomanagewidgets/','/leobootstrapmenu/','/leobootstrapmenu/','/leomanagewidgets/','/leomenusidebar/');
                             //                            $widValue = preg_replace($patterns, $replacements, $widValue);
                             //remove comment when install theme base
                             //$widValue = str_replace('/prestashop/base-theme/themes/', __PS_BASE_URI__. 'themes/', $widValue);
                             $widValue = preg_replace('/\\/themes\\/(\\w+)\\/img/', '/themes/' . $this->_theme_dir . '/img', $widValue);
                             break;
                         }
                     }
                     $tmp[$widKey] = $widValue;
                 }
                 $model->params = call_user_func('base64' . '_encode', Tools::jsonEncode($tmp));
                 $model->save();
             }
         }
     }
     if (Tools::isSubmit('submitBulkinsertLangleowidgets')) {
         $leowidgetsBox = Tools::getValue('leowidgetsBox');
         $id_currentLang = $this->context->language->id;
         $languages = Language::getLanguages(false);
         if ($leowidgetsBox) {
             foreach ($leowidgetsBox as $widgetID) {
                 $model = new LeoTempcpWidget($widgetID);
                 $tmp = Tools::jsonDecode(call_user_func('base64' . '_decode', $model->params), true);
                 $defauleVal = array();
                 if ($tmp) {
                     foreach ($tmp as $widKey => $widValue) {
                         $defaulArray = explode('_', $widKey);
                         if (strpos($widKey, '_' . $id_currentLang) !== false && $defaulArray[count($defaulArray) - 1] == $id_currentLang) {
                             $defauleVal[$widKey] = $widValue;
                         }
                     }
                 }
                 if ($defauleVal) {
                     foreach ($languages as $lang) {
                         if ($lang['id_lang'] == $id_currentLang) {
                             continue;
                         }
                         foreach ($defauleVal as $widKey => $widValue) {
                             $keyRemove = Tools::substr($widKey, 0, -Tools::strlen('_' . $id_currentLang));
                             $keyReal = $keyRemove . '_' . $lang['id_lang'];
                             if (!isset($tmp[$keyReal]) || trim($tmp[$keyReal]) == '') {
                                 $tmp[$keyReal] = $widValue;
                             }
                         }
                     }
                 }
                 if ($defauleVal) {
                     $model->params = call_user_func('base64' . '_encode', Tools::jsonEncode($tmp));
                     $model->save();
                 }
             }
         }
     }
     if (Tools::isSubmit('submitBulkcorrectContentleowidgets')) {
         $leowidgetsBox = Tools::getValue('leowidgetsBox');
         $id_currentLang = $this->context->language->id;
         $languages = Language::getLanguages(false);
         if ($leowidgetsBox) {
             foreach ($leowidgetsBox as $widgetID) {
                 $model = new LeoTempcpWidget($widgetID);
                 $tmp = @unserialize($model->params);
                 if (!$tmp) {
                     $tmp = Tools::json_decode($model->params, true);
                 }
                 if ($tmp) {
                     $model->params = call_user_func('base64' . '_encode', Tools::jsonEncode($tmp));
                     $model->save();
                 }
             }
         }
     }
     parent::postProcess();
 }