// Clear smarty cache on entities updates
This commit is contained in:
+5
-3
@@ -1944,9 +1944,11 @@ FileETag INode MTime Size
|
|||||||
*
|
*
|
||||||
* @param Smarty $smarty
|
* @param Smarty $smarty
|
||||||
*/
|
*/
|
||||||
public static function clearCache($smarty)
|
public static function clearCache($smarty, $tpl = false, $cache_id = null, $compile_id = null)
|
||||||
{
|
{
|
||||||
$smarty->clearAllCache();
|
if (!$tpl)
|
||||||
|
return $smarty->clearAllCache();
|
||||||
|
return $smarty->clearCache($tpl, $cache_id, $compile_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1545,9 +1545,11 @@ abstract class ModuleCore
|
|||||||
return $context->smarty->isCached($this->_getApplicableTemplateDir($template).$template, $cacheId, $compileId);
|
return $context->smarty->isCached($this->_getApplicableTemplateDir($template).$template, $cacheId, $compileId);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function _clearCache($template, $cacheId = null, $compileId = null)
|
protected function _clearCache($template, $cache_id = null, $compile_id = null)
|
||||||
{
|
{
|
||||||
Tools::clearCache(Context::getContext()->smarty);
|
Tools::enableCache();
|
||||||
|
Tools::clearCache(Context::getContext()->smarty, $template, $cache_id, $compile_id);
|
||||||
|
Tools::restoreCacheSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function _generateConfigXml()
|
protected function _generateConfigXml()
|
||||||
|
|||||||
@@ -68,6 +68,16 @@ class Blocktopmenu extends Module
|
|||||||
!$this->registerHook('top') ||
|
!$this->registerHook('top') ||
|
||||||
!Configuration::updateGlobalValue('MOD_BLOCKTOPMENU_ITEMS', 'CAT1,CMS1,CMS2,PRD1') ||
|
!Configuration::updateGlobalValue('MOD_BLOCKTOPMENU_ITEMS', 'CAT1,CMS1,CMS2,PRD1') ||
|
||||||
!Configuration::updateGlobalValue('MOD_BLOCKTOPMENU_SEARCH', '1') ||
|
!Configuration::updateGlobalValue('MOD_BLOCKTOPMENU_SEARCH', '1') ||
|
||||||
|
!$this->registerHook('categoryUpdate') ||
|
||||||
|
!$this->registerHook('categoryDeletion') ||
|
||||||
|
!$this->registerHook('cmsUpdate') ||
|
||||||
|
!$this->registerHook('cmsDeletion') ||
|
||||||
|
!$this->registerHook('supplierUpdate') ||
|
||||||
|
!$this->registerHook('supplierDeletion') ||
|
||||||
|
!$this->registerHook('manufacturerUpdate') ||
|
||||||
|
!$this->registerHook('manufacturerDeletion') ||
|
||||||
|
!$this->registerHook('productUpdate') ||
|
||||||
|
!$this->registerHook('productDeletion') ||
|
||||||
!$this->installDB())
|
!$this->installDB())
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
@@ -120,6 +130,8 @@ class Blocktopmenu extends Module
|
|||||||
$links_label = Tools::getValue('link') ? array_filter(Tools::getValue('link'), 'strlen') : array();
|
$links_label = Tools::getValue('link') ? array_filter(Tools::getValue('link'), 'strlen') : array();
|
||||||
$spacer = str_repeat(' ', $this->spacer_size);
|
$spacer = str_repeat(' ', $this->spacer_size);
|
||||||
$divLangName = 'link_label';
|
$divLangName = 'link_label';
|
||||||
|
|
||||||
|
$update_cache = false;
|
||||||
|
|
||||||
if (Tools::isSubmit('submitBlocktopmenu'))
|
if (Tools::isSubmit('submitBlocktopmenu'))
|
||||||
{
|
{
|
||||||
@@ -128,6 +140,7 @@ class Blocktopmenu extends Module
|
|||||||
else
|
else
|
||||||
$this->_html .= $this->displayError($this->l('Unable to update settings'));
|
$this->_html .= $this->displayError($this->l('Unable to update settings'));
|
||||||
Configuration::updateValue('MOD_BLOCKTOPMENU_SEARCH', (bool)Tools::getValue('search'));
|
Configuration::updateValue('MOD_BLOCKTOPMENU_SEARCH', (bool)Tools::getValue('search'));
|
||||||
|
$update_cache = true;
|
||||||
}
|
}
|
||||||
else if (Tools::isSubmit('submitBlocktopmenuLinks'))
|
else if (Tools::isSubmit('submitBlocktopmenuLinks'))
|
||||||
{
|
{
|
||||||
@@ -145,6 +158,7 @@ class Blocktopmenu extends Module
|
|||||||
MenuTopLinks::add(Tools::getValue('link'), Tools::getValue('label'), Tools::getValue('new_window', 0), (int)Shop::getContextShopID());
|
MenuTopLinks::add(Tools::getValue('link'), Tools::getValue('label'), Tools::getValue('new_window', 0), (int)Shop::getContextShopID());
|
||||||
$this->_html .= $this->displayConfirmation($this->l('The link has been added'));
|
$this->_html .= $this->displayConfirmation($this->l('The link has been added'));
|
||||||
}
|
}
|
||||||
|
$update_cache = true;
|
||||||
}
|
}
|
||||||
else if (Tools::isSubmit('submitBlocktopmenuRemove'))
|
else if (Tools::isSubmit('submitBlocktopmenuRemove'))
|
||||||
{
|
{
|
||||||
@@ -152,6 +166,7 @@ class Blocktopmenu extends Module
|
|||||||
MenuTopLinks::remove($id_linksmenutop, (int)Shop::getContextShopID());
|
MenuTopLinks::remove($id_linksmenutop, (int)Shop::getContextShopID());
|
||||||
Configuration::updateValue('MOD_BLOCKTOPMENU_ITEMS', str_replace(array('LNK'.$id_linksmenutop.',', 'LNK'.$id_linksmenutop), '', Configuration::get('MOD_BLOCKTOPMENU_ITEMS')));
|
Configuration::updateValue('MOD_BLOCKTOPMENU_ITEMS', str_replace(array('LNK'.$id_linksmenutop.',', 'LNK'.$id_linksmenutop), '', Configuration::get('MOD_BLOCKTOPMENU_ITEMS')));
|
||||||
$this->_html .= $this->displayConfirmation($this->l('The link has been removed'));
|
$this->_html .= $this->displayConfirmation($this->l('The link has been removed'));
|
||||||
|
$update_cache = true;
|
||||||
}
|
}
|
||||||
else if (Tools::isSubmit('submitBlocktopmenuEdit'))
|
else if (Tools::isSubmit('submitBlocktopmenuEdit'))
|
||||||
{
|
{
|
||||||
@@ -170,8 +185,12 @@ class Blocktopmenu extends Module
|
|||||||
MenuTopLinks::update(Tools::getValue('link'), Tools::getValue('label'), Tools::getValue('new_window', 0), (int)$id_shop, (int)$id_linksmenutop, (int)$id_linksmenutop);
|
MenuTopLinks::update(Tools::getValue('link'), Tools::getValue('label'), Tools::getValue('new_window', 0), (int)$id_shop, (int)$id_linksmenutop, (int)$id_linksmenutop);
|
||||||
$this->_html .= $this->displayConfirmation($this->l('The link has been edited'));
|
$this->_html .= $this->displayConfirmation($this->l('The link has been edited'));
|
||||||
}
|
}
|
||||||
|
$update_cache = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($update_cache)
|
||||||
|
$this->clearMenuCache();
|
||||||
|
|
||||||
$this->_html .= '
|
$this->_html .= '
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<div class="multishop_info">
|
<div class="multishop_info">
|
||||||
@@ -749,4 +768,60 @@ class Blocktopmenu extends Module
|
|||||||
|
|
||||||
return Db::getInstance()->executeS($sql);
|
return Db::getInstance()->executeS($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function hookCategoryUpdate($params)
|
||||||
|
{
|
||||||
|
$this->clearMenuCache();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hookCategoryDeletion($params)
|
||||||
|
{
|
||||||
|
$this->clearMenuCache();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hookCmsUpdate($params)
|
||||||
|
{
|
||||||
|
$this->clearMenuCache();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hookCmsDeletion($params)
|
||||||
|
{
|
||||||
|
$this->clearMenuCache();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hookSupplierUpdate($params)
|
||||||
|
{
|
||||||
|
$this->clearMenuCache();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hookSupplierDeletion($params)
|
||||||
|
{
|
||||||
|
$this->clearMenuCache();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hookManufacturerUpdate($params)
|
||||||
|
{
|
||||||
|
$this->clearMenuCache();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hookManufacturerDeletion($params)
|
||||||
|
{
|
||||||
|
$this->clearMenuCache();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hookProductUpdate($params)
|
||||||
|
{
|
||||||
|
$this->clearMenuCache();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hookProductDeletion($params)
|
||||||
|
{
|
||||||
|
$this->clearMenuCache();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function clearMenuCache()
|
||||||
|
{
|
||||||
|
$this->_clearCache('blocktopmenu.tpl');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user