/** * */ public function hookdisplayHeader() { $this->context->controller->addJqueryPlugin('fancybox'); $loadrlt = true; $cgtheme = _PS_MODE_DEMO_ ? $this->getCustomConfig('themeskin', Configuration::get('PTS_CP_THEME')) : Configuration::get('PTS_CP_THEME'); if (_PS_MODE_DEMO_) { if (Tools::getValue('themeskin') && Tools::getValue('themeskinactived')) { $cgtheme = $this->saveCustomConfig('themeskin', Tools::getValue('themeskin')); if (Tools::getIsset('headers')) { $header = Tools::getValue('headers', 'default'); $this->saveCustomConfig('header', $header); } } if (Tools::getValue('headers') && Tools::getValue('headerctived')) { $header = Tools::getValue('headers', 'default'); $this->saveCustomConfig('header', $header); } if (Tools::getValue('productsstyle') && Tools::getValue('productsstyleactived')) { $productsstyle = Tools::getValue('productsstyle', 'style1'); $this->saveCustomConfig('productsstyle', $productsstyle); } if (Tools::getValue('productdetail') && Tools::getValue('productdetailactived')) { $productdetail = Tools::getValue('productdetail', 'default'); $this->saveCustomConfig('productdetail', $productdetail); } if (Tools::isSubmit('applyCustomSkinChanger')) { $cgtheme = $this->saveCustomConfig('themeskin', Tools::getValue('themeskin')); if (Tools::getIsset('headers')) { $header = Tools::getValue('headers', 'default'); $this->saveCustomConfig('header', $header); } if (Tools::getIsset('productsstyle')) { $productsstyle = Tools::getValue('productsstyle', 'style1'); $this->saveCustomConfig('productsstyle', $productsstyle); } if (Tools::getValue('productdetail') && Tools::getValue('productdetailactived')) { $productdetail = Tools::getValue('productdetail', 'default'); $this->saveCustomConfig('productdetail', $productdetail); } } if (Tools::isSubmit('resetDemoTheme')) { $cgtheme = $this->saveCustomConfig('themeskin', Configuration::get('PTS_CP_THEME')); $this->saveCustomConfig('header', Configuration::get('PTS_CP_HEADER')); } $this->context->smarty->assign('header_cp', $this->getCustomConfig('header', Tools::getValue('headers', Configuration::get('PTS_CP_HEADER')))); } if (!isset($productdetail)) { $productdetail = _PS_MODE_DEMO_ ? $this->getCustomConfig('productdetail', Configuration::get('PTS_CP_PRODUCT_DETAIL')) : Configuration::get('PTS_CP_PRODUCT_DETAIL'); } $this->context->smarty->assign('productdetail', $productdetail); if (!empty($cgtheme)) { $themeskinfile = _PS_ALL_THEMES_DIR_ . $this->theme_name . '/css/global-' . $cgtheme . '.css'; $themeskinfilertl = _PS_ALL_THEMES_DIR_ . $this->theme_name . '/css/global-rtl-' . $cgtheme . '.css'; if ($this->context->language->is_rtl && file_exists($themeskinfilertl)) { $this->reloadGlobalCssFile('global-rtl-' . $cgtheme . '.css'); $loadrlt = false; } elseif (file_exists($themeskinfile)) { $this->reloadGlobalCssFile('global-' . $cgtheme . '.css'); } } if ($this->context->language->is_rtl && $loadrlt) { $this->reloadGlobalCssFile('rtl-global.css'); } if (!$this->is_showed) { return null; } if ($this->checkVisiable()) { $this->context->controller->addCSS($this->_path . 'views/css/panel.css'); $this->context->controller->addJS($this->_path . 'views/js/live_configurator.js'); $this->context->controller->addCSS($this->_path . 'views/css/colorpicker/colorpicker.css', 'all'); $this->context->controller->addJS($this->_path . 'views/js/colorpicker/colorpicker.js'); $this->theme_customize_path = _PS_ALL_THEMES_DIR_ . $this->theme_name . '/css/profiles/'; } if ((int) Configuration::get('PTS_CP_ACTIVE') == 1 && Tools::getValue('live_configurator_token') && $this->checkValidToken()) { if (Tools::isSubmit('submitPtsLiveConfiguratorDelete') && Tools::getValue('saved_file')) { $file = Tools::getValue('saved_file'); if (file_exists($this->theme_customize_path . $file . '.css')) { unlink($this->theme_customize_path . $file . '.css'); } if (file_exists($this->theme_customize_path . $file . '.json')) { unlink($this->theme_customize_path . $file . '.json'); } } if (Tools::isSubmit('submitLiveThemeChanger') && Tools::getValue('themeskin')) { $themeskin = Tools::getValue('themeskin'); if (Tools::getValue($themeskin . '_rehook')) { $sample = new PtsThemeSample($this->theme_name); $sample->reHookBySkin($themeskin); } Configuration::updateValue('PTS_CP_THEME', Tools::getValue('themeskin')); if (Tools::getIsset('headers')) { $header = Tools::getValue('headers', 'default'); Configuration::updateValue('PTS_CP_HEADER', $header); } $id_employee = is_object($this->context->employee) ? (int) $this->context->employee->id : Tools::getValue('id_employee'); $url = $this->context->shop->getBaseURL() . (Configuration::get('PS_REWRITING_SETTINGS') && count(Language::getLanguages(true)) > 1 ? Language::getIsoById($this->context->language->id) . '/' : '') . (Configuration::get('PS_REWRITING_SETTINGS') ? '' : 'index.php') . '?live_configurator_token=' . $this->getLiveConfiguratorToken() . '&id_employee=' . (int) $id_employee . '&id_shop=' . (int) $this->context->shop->id; Tools::redirect($url); } if (Tools::isSubmit('submitPtsLiveConfiguratorActiveProfile') && Tools::getValue('saved_file')) { Configuration::updateValue('PTS_CP_PROFILE', Tools::getValue('saved_file')); } if (Tools::isSubmit('submitPtsLiveConfigurator')) { $data = Tools::getAllValues(); $selectors = $data['customize']; $matches = $data['customize_match']; $output = ''; $cache = array(); $tmpss = array(); foreach ($selectors as $match => $customizes) { foreach ($customizes as $key => $customize) { if (isset($matches[$match]) && isset($matches[$match][$key])) { $tmp = explode('|', $matches[$match][$key]); if (trim($customize)) { if (Tools::strtolower(trim($tmp[1])) == 'background-image') { $tmpss[$tmp[0]][] = $tmp[1] . ':url(' . $customize . ')'; } else { $prefix = preg_match('#color#i', $tmp[1]) ? '#' : ''; $suffix = preg_match('#size#i', $tmp[1]) ? 'px' : ''; $tmpss[$tmp[0]][] = $tmp[1] . ':' . $prefix . $customize . $suffix; } } $cache[$match][] = array('val' => $customize, 'selector' => $tmp[0], 'attr' => $tmp[1]); } } } $output = ''; foreach ($tmpss as $key => $values) { $output .= "\r\n/* customize for {$key} */ \r\n"; $output .= $key . " { \r\n" . implode(";\r\n", $values) . " \r\n} \r\n"; } if (!empty($data['saved_file'])) { if ($data['saved_file'] && file_exists($this->theme_customize_path . $data['saved_file'] . '.css')) { unlink($this->theme_customize_path . $data['saved_file'] . '.css'); } if ($data['saved_file'] && file_exists($this->theme_customize_path . $data['saved_file'] . '.json')) { unlink($this->theme_customize_path . $data['saved_file'] . '.json'); } } if (empty($data['newfile'])) { $name_file = $data['saved_file'] ? $data['saved_file'] : 'profile-' . time(); } else { $name_file = preg_replace('#\\s+#', '-', trim($data['newfile'])); } if ($data['action-mode'] != 'save-delete') { if (!empty($output)) { PtsThemePanelHelper::writeToCache($this->theme_customize_path, $name_file, $output); } if (!empty($cache)) { PtsThemePanelHelper::writeToCache($this->theme_customize_path, $name_file, Tools::jsonEncode($cache), 'json'); } } } } if ($cgtheme != '') { $this->context->controller->addCss(_PS_THEME_DIR_ . 'css/themes/' . $cgtheme . '.css', 'all'); } if (Configuration::get('PTS_CP_PROFILE')) { $this->context->controller->addCss(_PS_THEME_DIR_ . 'css/profiles/' . Configuration::get('PTS_CP_PROFILE') . '.css', 'all'); } $this->context->smarty->registerPlugin('function', 'plugin', array('PtsthemePanel', 'smartyplugin')); $this->context->smarty->assign('LANG_DIRECTION', $this->context->language->is_rtl ? 'rtl' : 'ltr'); if (!isset($productsstyle)) { $productsstyle = _PS_MODE_DEMO_ ? $this->getCustomConfig('productsstyle', Configuration::get('PTS_CP_PRODUCT_STYLE')) : Configuration::get('PTS_CP_PRODUCT_STYLE'); } $this->context->smarty->assign('product_style', $productsstyle); $this->context->smarty->assign(array('DEFAUTL_LAYOUT' => $this->getConfigValue('layout'), 'PRODUCTS_ITEMSROW' => $this->getConfigValue('products_itemrow'), 'DEFAUTL_LANGUAGEID' => $this->context->language->id, 'DEFAULT_THEMESKIN' => $cgtheme, 'CURRENT_THEMEDIR' => _PS_ALL_THEMES_DIR_ . $this->theme_name . '/', 'THEME_SKIN_DIR' => _PS_ALL_THEMES_DIR_ . $this->theme_name . '/sub/themes/' . $cgtheme . '/', 'THEME_HEADER_FILE' => _PS_ALL_THEMES_DIR_ . $this->theme_name . '/sub/themes/' . $cgtheme . '/header.tpl')); $output = ''; if ($this->getConfigValue('product_layout') == 'gallery') { $this->context->controller->addJS($this->_path . 'views/js/gallery.js'); } if ($customcss = $this->getConfigValue('customcss')) { $output .= '<style type="text/css">' . $customcss . '</style>'; } if ($customjs = $this->getConfigValue('customjs')) { $output .= '\\r\\n<script type="text/javascript">' . $customjs . '</script>'; } return $output; }
public function backup() { $modules = self::getModuleSamples($this->theme); //d( $modules ); if (is_array($modules) && !empty($modules)) { foreach ($modules as $module) { if (isset($module['name'])) { $string = $this->exportModule($module); PtsThemePanelHelper::writeToCache($this->backup_dir, $module['name'], $string, 'xml'); } } } }