[*] BO : Add clear smarty cache button

This commit is contained in:
gRoussac
2013-08-13 15:11:00 +02:00
parent b1b636a911
commit e8685b1430
4 changed files with 23 additions and 13 deletions
@@ -40,6 +40,9 @@
</div>
{/if}
{$smarty.block.parent}
{if $input.type == 'radio' && $input.name == 'smarty_cache'}
<a href="{$current}&token={$token}&empty_smarty_cache=1" class="clear button" href="">{l s='Clear Smarty cache'}</a>
{/if}
{/block}
{block name="description"}
+12
View File
@@ -704,6 +704,18 @@ class ToolsCore
}
return false;
}
/**
* Clear smarty cache folders
*/
public static function clearSmartyCache()
{
foreach (array(_PS_CACHE_DIR_.'smarty/cache', _PS_CACHE_DIR_.'smarty/compile') as $dir)
if (file_exists($dir))
foreach (scandir($dir) as $file)
if ($file[0] != '.' && $file != 'index.php')
self::deleteDirectory($dir.DIRECTORY_SEPARATOR.$file);
}
/**
* Display an error according to an error code
@@ -791,6 +791,13 @@ class AdminPerformanceControllerCore extends AdminController
else
$this->errors[] = Tools::displayError('You do not have permission to edit this.');
}
if ((bool)Tools::getValue('empty_smarty_cache'))
{
$redirectAdmin = true;
Tools::clearSmartyCache();
}
if ($redirectAdmin && (!isset($this->errors) || !count($this->errors)))
{
Hook::exec('action'.get_class($this).ucfirst($this->action).'After', array('controller' => $this, 'return' => ''));
+1 -13
View File
@@ -368,7 +368,7 @@ class InstallModelInstall extends InstallAbstractModel
public function configureShop(array $data = array())
{
// Clear smarty cache
$this->clearSmartyCache();
Tools::clearSmartyCache();
//clear image cache in tmp folder
Tools::deleteDirectory(_PS_TMP_IMG_DIR_, false);
@@ -494,18 +494,6 @@ class InstallModelInstall extends InstallAbstractModel
return true;
}
/**
* Clear smarty cache folders
*/
public function clearSmartyCache()
{
foreach (array(_PS_CACHE_DIR_.'smarty/cache', _PS_CACHE_DIR_.'smarty/compile') as $dir)
if (file_exists($dir))
foreach (scandir($dir) as $file)
if ($file[0] != '.' && $file != 'index.php')
Tools::deleteDirectory($dir.DIRECTORY_SEPARATOR.$file);
}
public function getModulesList()
{
// @todo REMOVE DEV MODE