public function display($file, $template, $cacheId = null, $compileId = null) { require_once dirname(__FILE__) . '../../../../modules/designerpreview/defines.inc.php'; if (($overloaded = Module::_isTemplateOverloadedStatic(basename($file, '.php'), $template)) === null) { return Tools::displayError('No template found for module') . ' ' . basename($file, '.php'); } else { $this->smarty->assign(array('module_dir' => __PS_BASE_URI__ . 'modules/' . basename($file, '.php') . '/', 'module_template_dir' => ($overloaded ? getThemeUrl() : __PS_BASE_URI__) . 'modules/' . basename($file, '.php') . '/', 'module_name' => $this->name)); if ($cacheId !== null) { Tools::enableCache(); } $result = $this->getCurrentSubTemplate($template, $cacheId, $compileId)->fetch(); if ($cacheId !== null) { Tools::restoreCacheSettings(); } $this->resetCurrentSubTemplate($template, $cacheId, $compileId); return $result; } }
public function clearSmartyCache() { Tools::enableCache(); Tools::clearCache($this->context->smarty); Tools::restoreCacheSettings(); }
protected function _clearCache($template, $cache_id = null, $compile_id = null) { Tools::enableCache(); if ($cache_id === null) { $cache_id = $this->name; } Tools::clearCache(Context::getContext()->smarty, $this->getTemplatePath($template), $cache_id, $compile_id); Tools::restoreCacheSettings(); }
protected function _clearCache($template, $cache_id = null, $compile_id = null) { if (Configuration::get('PS_SMARTY_CLEAR_CACHE') == 'never') { return 0; } if ($cache_id === null) { $cache_id = $this->name; } Tools::enableCache(); $number_of_template_cleared = Tools::clearCache(Context::getContext()->smarty, $this->getTemplatePath($template), $cache_id, $compile_id); Tools::restoreCacheSettings(); return $number_of_template_cleared; }
public function hookFooter($params) { $id_customer = (int) $params['cookie']->id_customer; // Get all groups for this customer and concatenate them as a string: "1,2,3..." $groups = $id_customer ? implode(', ', Customer::getGroupsStatic($id_customer)) : _PS_DEFAULT_CUSTOMER_GROUP_; $id_product = (int) Tools::getValue('id_product', 0); $id_category = (int) Tools::getValue('id_category', 0); $id_lang = (int) $params['cookie']->id_lang; $smartyCacheId = 'blockcategories|' . $this->context->shop->id . '_' . $groups . '_' . $id_lang . '_' . $id_product . '_' . $id_category; $this->context->smarty->cache_lifetime = 31536000; // 1 Year Tools::enableCache(); if (!$this->isCached('blockcategories_footer.tpl', $smartyCacheId)) { $maxdepth = Configuration::get('BLOCK_CATEG_MAX_DEPTH'); if (!($result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT c.id_parent, c.id_category, cl.name, cl.description, cl.link_rewrite FROM `' . _DB_PREFIX_ . 'category` c ' . Shop::addSqlAssociation('category', 'c') . ' LEFT JOIN `' . _DB_PREFIX_ . 'category_lang` cl ON (c.`id_category` = cl.`id_category` AND cl.`id_lang` = ' . $id_lang . Shop::addSqlRestrictionOnLang('cl') . ') LEFT JOIN `' . _DB_PREFIX_ . 'category_group` cg ON (cg.`id_category` = c.`id_category`) WHERE (c.`active` = 1 OR c.`id_category` = 1) ' . ((int) $maxdepth != 0 ? ' AND `level_depth` <= ' . (int) $maxdepth : '') . ' AND cg.`id_group` IN (' . pSQL($groups) . ') ORDER BY `level_depth` ASC, ' . (Configuration::get('BLOCK_CATEG_SORT') ? 'cl.`name`' : 'category_shop.`position`') . ' ' . (Configuration::get('BLOCK_CATEG_SORT_WAY') ? 'DESC' : 'ASC')))) { return; } $resultParents = array(); $resultIds = array(); foreach ($result as &$row) { $resultParents[$row['id_parent']][] =& $row; $resultIds[$row['id_category']] =& $row; } //$nbrColumns = Configuration::get('BLOCK_CATEG_NBR_COLUMNS_FOOTER'); $nbrColumns = Configuration::get('BLOCK_CATEG_NBR_COLUMN_FOOTER'); if (!$nbrColumns) { $nbrColumns = 3; } $numberColumn = abs(count($result) / $nbrColumns); $widthColumn = floor(100 / $nbrColumns); $this->smarty->assign('numberColumn', $numberColumn); $this->smarty->assign('widthColumn', $widthColumn); $blockCategTree = $this->getTree($resultParents, $resultIds, Configuration::get('BLOCK_CATEG_MAX_DEPTH')); unset($resultParents, $resultIds); $isDhtml = Configuration::get('BLOCK_CATEG_DHTML') == 1 ? true : false; if (Tools::isSubmit('id_category')) { $this->context->cookie->last_visited_category = $id_category; $this->smarty->assign('currentCategoryId', $this->context->cookie->last_visited_category); } if (Tools::isSubmit('id_product')) { if (!isset($this->context->cookie->last_visited_category) || !Product::idIsOnCategoryId($id_product, array('0' => array('id_category' => $this->context->cookie->last_visited_category)))) { $product = new Product($id_product); if (isset($product) && Validate::isLoadedObject($product)) { $this->context->cookie->last_visited_category = (int) $product->id_category_default; } } $this->smarty->assign('currentCategoryId', (int) $this->context->cookie->last_visited_category); } $this->smarty->assign('blockCategTree', $blockCategTree); if (file_exists(_PS_THEME_DIR_ . 'modules/blockcategories/blockcategories_footer.tpl')) { $this->smarty->assign('branche_tpl_path', _PS_THEME_DIR_ . 'modules/blockcategories/category-tree-branch.tpl'); } else { $this->smarty->assign('branche_tpl_path', _PS_MODULE_DIR_ . 'blockcategories/category-tree-branch.tpl'); } $this->smarty->assign('isDhtml', $isDhtml); } $display = $this->display(__FILE__, 'blockcategories_footer.tpl', $smartyCacheId); Tools::restoreCacheSettings(); return $display; }
public static function _deferedClearCache($template_path, $cache_id, $compile_id) { Tools::enableCache(); $number_of_template_cleared = Tools::clearCache(Context::getContext()->smarty, $template_path, $cache_id, $compile_id); Tools::restoreCacheSettings(); return $number_of_template_cleared; }
public static function post_update_uri() { $context = Context::getContext(); $htaccess = _PS_ROOT_DIR_ . '/.htaccess'; if (!is_writable($htaccess)) { echo "Error, htaccess file not writable\n"; return false; } $disableMultiviews = Configuration::get('PS_HTACCESS_DISABLE_MULTIVIEWS'); $htaccessModSec = Configuration::get('PS_HTACCESS_MODSEC'); if (Tools::generateHtaccess($htaccess, null, null, '', $disableMultiviews, false, $htaccessModSec)) { Tools::enableCache(); Tools::clearCache($context->smarty); Tools::restoreCacheSettings(); echo "Htaccess file regenerated\n"; return true; } else { echo "Error, could not update htaccess file\n"; return false; } }
protected function isCached($template, $cacheId = null, $compileId = null) { Tools::enableCache(); $res = $this->context->smarty->isCached($template, $cacheId, $compileId); Tools::restoreCacheSettings(); return $res; }
function _clearmegamenuCache() { $this->_clearCache('megamenu.tpl'); Tools::restoreCacheSettings(); }
/** * Called when PS_REWRITING_SETTINGS option is saved */ public function updateOptionPsRewritingSettings() { Configuration::updateValue('PS_REWRITING_SETTINGS', (int) Tools::getValue('PS_REWRITING_SETTINGS')); Tools::generateHtaccess($this->ht_file, null, null, '', Tools::getValue('PS_HTACCESS_DISABLE_MULTIVIEWS')); Tools::enableCache(); Tools::clearCache($this->context->smarty); Tools::restoreCacheSettings(); }
protected function _clearCache($template, $cache_id = null, $compile_id = null) { Tools::enableCache(); Tools::clearCache(Context::getContext()->smarty, $template, $cache_id, $compile_id); Tools::restoreCacheSettings(); }
private function _clearBlockconfiguradorCache() { Tools::restoreCacheSettings(); }
private function _clearBlockconfiguradorCache() { $this->_clearCache('blockwebpay.tpl'); Tools::restoreCacheSettings(); }
/** * Called when PS_REWRITING_SETTINGS option is saved */ public function updateOptionPsRewritingSettings() { Configuration::updateValue('PS_REWRITING_SETTINGS', (int) Tools::getValue('PS_REWRITING_SETTINGS')); if (Tools::generateHtaccess($this->ht_file, null, null, '', Tools::getValue('PS_HTACCESS_DISABLE_MULTIVIEWS'), false, Tools::getValue('PS_HTACCESS_DISABLE_MODSEC'))) { Tools::enableCache(); Tools::clearCache($this->context->smarty); Tools::restoreCacheSettings(); } else { Configuration::updateValue('PS_REWRITING_SETTINGS', 0); // Message copied/pasted from the information tip $message = $this->l('Before being able to use this tool, you need to:'); $message .= '<br />- ' . $this->l('Create a blank .htaccess in your root directory.'); $message .= '<br />- ' . $this->l('Give it write permissions (CHMOD 666 on Unix system)'); $this->errors[] = $message; } }
private function _clearBlockcategoriesCache() { $this->_clearCache('blockcategories.tpl'); Tools::restoreCacheSettings(); }
public function hookDisplayNavigationBar($param) { $this->_itemClass = isset($param['itemClass']) ? $param['itemClass'] : ''; $this->_itemHead = isset($param['itemHead']) ? $param['itemHead'] : ''; $this->_itemTail = isset($param['itemTail']) ? $param['itemTail'] : ''; $this->_subMenuHead = isset($param['submenuHead']) ? $param['submenuHead'] : ''; $this->_subMenuTail = isset($param['submenuTail']) ? $param['submenuTail'] : ''; $this->_subMenuClass = isset($param['submenuClass']) ? $param['submenuClass'] : ''; $this->_subItemClass = isset($param['subitemClass']) ? $param['subitemClass'] : ''; $this->_subItemHead = isset($param['subitemHead']) ? $param['subitemHead'] : ''; $this->_subItemtail = isset($param['subitemTail']) ? $param['subitemTail'] : ''; $this->_showAll = isset($param['showAll']) ? $param['showAll'] : ''; $this->_showAllResponsive = isset($param['showAllResponsive']) ? $param['showAllResponsive'] : ''; $this->user_groups = $this->context->customer->isLogged() ? $this->context->customer->getGroups() : array(Configuration::get('PS_UNIDENTIFIED_GROUP')); $this->page_name = Dispatcher::getInstance()->getController(); $smarty_cache_id = 'blocktopmenu_mod-' . $this->page_name . '-' . (int) $this->context->shop->id . '-' . implode(', ', $this->user_groups) . '-' . (int) $this->context->language->id . '-' . (int) Tools::getValue('id_category') . '-' . (int) Tools::getValue('id_manufacturer') . '-' . (int) Tools::getValue('id_supplier') . '-' . (int) Tools::getValue('id_cms') . '-' . (int) Tools::getValue('id_product'); $this->context->smarty->cache_lifetime = 31536000; Tools::enableCache(); if (!$this->isCached('blocktopmenu_mod.tpl', $smarty_cache_id)) { $menu = $this->makeMenu(); $this->smarty->assign('MENU_HOME', Configuration::get('MOD_BLOCKTOPMENU_HOME')); $this->smarty->assign('MENU', $menu); $this->smarty->assign('this_path', $this->_path); $this->smarty->assign('subMenuClass', $this->_subMenuClass); $this->smarty->assign('menuItemClass', $this->_itemClass); $this->smarty->assign('submenuItemClassName', $this->_subItemClass); } $html = $this->display(__FILE__, 'blocktopmenu_mod.tpl', $smarty_cache_id); Tools::restoreCacheSettings(); return $html; }
public function hookDisplayTop($param) { $this->user_groups = $this->context->customer->isLogged() ? $this->context->customer->getGroups() : array(Configuration::get('PS_UNIDENTIFIED_GROUP')); $this->page_name = Dispatcher::getInstance()->getController(); $smarty_cache_id = 'blocktopmenu-' . $this->page_name . '-' . (int) $this->context->shop->id . '-' . implode(', ', $this->user_groups) . '-' . (int) $this->context->language->id . '-' . (int) Tools::getValue('id_category') . '-' . (int) Tools::getValue('id_manufacturer') . '-' . (int) Tools::getValue('id_supplier') . '-' . (int) Tools::getValue('id_cms') . '-' . (int) Tools::getValue('id_product'); $this->context->smarty->cache_lifetime = 31536000; Tools::enableCache(); if (!$this->isCached('blocktopmenu.tpl', $smarty_cache_id)) { $this->makeMenu(); $this->smarty->assign('MENU_SEARCH', Configuration::get('MOD_BLOCKTOPMENU_SEARCH')); $this->smarty->assign('MENU', $this->_menu); $this->smarty->assign('this_path', $this->_path); } $this->context->controller->addJS($this->_path . 'js/hoverIntent.js'); $this->context->controller->addJS($this->_path . 'js/superfish-modified.js'); $this->context->controller->addCSS($this->_path . 'css/superfish-modified.css'); $html = $this->display(__FILE__, 'blocktopmenu.tpl', $smarty_cache_id); Tools::restoreCacheSettings(); return $html; }
public function addColorsToProductList(&$products) { if (!is_array($products) || !count($products) || !file_exists(_PS_THEME_DIR_ . 'product-list-colors.tpl')) { return; } $products_need_cache = array(); foreach ($products as &$product) { if (!$this->isCached(_PS_THEME_DIR_ . 'product-list-colors.tpl', $this->getColorsListCacheId($product['id_product']))) { $products_need_cache[] = (int) $product['id_product']; } } unset($product); $colors = false; if (count($products_need_cache)) { $colors = Product::getAttributesColorList($products_need_cache); } Tools::enableCache(); foreach ($products as &$product) { $tpl = $this->context->smarty->createTemplate(_PS_THEME_DIR_ . 'product-list-colors.tpl'); if (isset($colors[$product['id_product']])) { $tpl->assign(array('id_product' => $product['id_product'], 'colors_list' => $colors[$product['id_product']], 'link' => Context::getContext()->link, 'img_col_dir' => _THEME_COL_DIR_, 'col_img_dir' => _PS_COL_IMG_DIR_)); } if (!in_array($product['id_product'], $products_need_cache) || isset($colors[$product['id_product']])) { $product['color_list'] = $tpl->fetch(_PS_THEME_DIR_ . 'product-list-colors.tpl', $this->getColorsListCacheId($product['id_product'])); } else { $product['color_list'] = ''; } } Tools::restoreCacheSettings(); }
function hookDisplayHeader($params) { $this->user_groups = $this->context->customer->isLogged() ? $this->context->customer->getGroups() : array(Configuration::get('PS_UNIDENTIFIED_GROUP')); $this->page_name = Dispatcher::getInstance()->getController(); $smarty_cache_id = 'navmegadrownevo-' . $this->page_name . '-' . (int) $this->context->shop->id . '-' . implode(', ', $this->user_groups) . '-' . (int) $this->context->language->id . '-' . (int) Tools::getValue('id_category') . '-' . (int) Tools::getValue('id_manufacturer') . '-' . (int) Tools::getValue('id_supplier') . '-' . (int) Tools::getValue('id_cms') . '-' . (int) Tools::getValue('id_product'); $this->context->smarty->cache_lifetime = 31536000; Tools::enableCache(); if (!$this->isCached('views/templates/front/cssnavmegadrownevo.tpl', $smarty_cache_id)) { $MDParameters = array(); $MDParameters = $this->getParameters(); $MDParameters[0]['bg_menu'] = $this->checkIfImageExist('bg_menu', $MDParameters[0]['extensionMenu']); $MDParameters[0]['bg_bout'] = $this->checkIfImageExist('bg_bout', $MDParameters[0]['extensionBout']); $MDParameters[0]['navlist_arrow'] = $this->checkIfImageExist('navlist_arrow', $MDParameters[0]['extensionArro']); $MDParameters[0]['sub_bg'] = $this->checkIfImageExist('sub_bg', $MDParameters[0]['extensionBack']); if ($MDParameters[0]['FontSizeSubMenu'] != 0) { $HeightCalculate = round($MDParameters[0]['MenuHeight'] / 2 + $MDParameters[0]['FontSizeSubMenu'] / 2 + $MDParameters[0]['MenuHeight'] / $MDParameters[0]['FontSizeSubMenu'], 0); $PaddingTopCalculate = round($MDParameters[0]['MenuHeight'] - ($MDParameters[0]['MenuHeight'] / 2 + $MDParameters[0]['FontSizeSubMenu'] / 2 + $MDParameters[0]['MenuHeight'] / $MDParameters[0]['FontSizeSubMenu']), 0); } else { $HeightCalculate = round($MDParameters[0]['MenuHeight'] / 2 + $MDParameters[0]['FontSizeSubMenu'] / 2, 0); $PaddingTopCalculate = round($MDParameters[0]['MenuHeight'] - $MDParameters[0]['MenuHeight'] / 2, 0); } $this->context->smarty->assign(array('MenuWidthEvo' => $MDParameters[0]['MenuWidth'] - $MDParameters[0]['paddingLeft'], 'MenuHeightEvo' => $MDParameters[0]['MenuHeight'], 'MinButtonWidthEvo' => $MDParameters[0]['MinButtonWidth'], 'MaxButtonWidthEvo' => $MDParameters[0]['MaxButtonWidth'], 'GeneralColorEvo' => $MDParameters[0]['GeneralColor'], 'FontSizeMenuEvo' => $MDParameters[0]['FontSizeMenu'], 'FontSizeSubMenuEvo' => $MDParameters[0]['FontSizeSubMenu'], 'FontSizeSubSubMenuEvo' => $MDParameters[0]['FontSizeSubSubMenu'], 'ColorFontMenuEvo' => $MDParameters[0]['ColorFontMenu'], 'ColorFontSubMenuEvo' => $MDParameters[0]['ColorFontSubMenu'], 'ColorFontSubSubMenuEvo' => $MDParameters[0]['ColorFontSubSubMenu'], 'ColorFontMenuHoverEvo' => $MDParameters[0]['ColorFontMenuHover'], 'ColorFontSubMenuHoverEvo' => $MDParameters[0]['ColorFontSubMenuHover'], 'ColorFontSubSubMenuHoverEvo' => $MDParameters[0]['ColorFontSubSubMenuHover'], 'widthTD1Evo' => $MDParameters[0]['widthTD1'], 'widthTD3Evo' => $MDParameters[0]['widthTD3'], 'bgColorTR1Evo' => $MDParameters[0]['backgroundTR1'], 'bgColorTD1Evo' => $MDParameters[0]['backgroundTD1'], 'bgColorTD2Evo' => $MDParameters[0]['backgroundTD2'], 'bgColorTD3Evo' => $MDParameters[0]['backgroundTD3'], 'VerticalPaddingEvo' => $MDParameters[0]['VerticalPadding'], 'HeightCalculateEvo' => $HeightCalculate, 'ColumnWidthEvo' => $MDParameters[0]['columnSize'], 'PaddingTopCalculateEvo' => $PaddingTopCalculate, 'PaddingLeftEvo' => $MDParameters[0]['paddingLeft'], 'MarginTopEvo' => $MDParameters[0]['marginTop'], 'MarginBottomEvo' => $MDParameters[0]['marginBottom'], 'bg_menuEvo' => $MDParameters[0]['bg_menu'], 'bg_boutEvo' => $MDParameters[0]['bg_bout'], 'navlist_arrowEvo' => $MDParameters[0]['navlist_arrow'], 'sub_bgEvo' => $MDParameters[0]['sub_bg'])); $this->context->smarty->assign('pathMDEvo', $this->_path); $this->context->smarty->assign('menuMDEvo', $this->_menu); } $this->context->controller->addJS($this->_path . '/views/js/jquery.hoverIntent.minified.js', 'all'); $this->context->controller->addCSS($this->_path . '/views/css/navmegadrownEvo.css', 'all'); $this->context->controller->addJS($this->_path . '/views/js/navmegadrownEvo.js'); $html = $this->display(__FILE__, 'views/templates/front/cssnavmegadrownevo.tpl', $smarty_cache_id); Tools::restoreCacheSettings(); return $html; }