[*] BO : improved performances (cache systems) and countries tabs
This commit is contained in:
@@ -24,15 +24,6 @@
|
|||||||
*}
|
*}
|
||||||
{extends file="helpers/form/form.tpl"}
|
{extends file="helpers/form/form.tpl"}
|
||||||
|
|
||||||
{block name="label"}
|
|
||||||
{if $input.type == 'text' && $input.name == 'ps_cache_fs_directory_depth'}
|
|
||||||
<div id="directory_depth" class="col-lg-9 col-lg-push-3">
|
|
||||||
<div class="alert alert-warning">{l s='The CacheFS system should be used only when the infrastructure contains one front-end server. If you are not sure, ask your hosting company.'}</div>
|
|
||||||
{else}
|
|
||||||
{$smarty.block.parent}
|
|
||||||
{/if}
|
|
||||||
{/block}
|
|
||||||
|
|
||||||
{block name="input"}
|
{block name="input"}
|
||||||
{if $input.type == 'radio' && $input.name == 'combination' && $input.disabled}
|
{if $input.type == 'radio' && $input.name == 'combination' && $input.disabled}
|
||||||
<div class="alert alert-warning">
|
<div class="alert alert-warning">
|
||||||
@@ -62,13 +53,6 @@
|
|||||||
{/if}
|
{/if}
|
||||||
{/block}
|
{/block}
|
||||||
|
|
||||||
{block name="field"}
|
|
||||||
{$smarty.block.parent}
|
|
||||||
{if $input.type == 'text' && $input.name == 'ps_cache_fs_directory_depth'}
|
|
||||||
</div>
|
|
||||||
{/if}
|
|
||||||
{/block}
|
|
||||||
|
|
||||||
{block name="other_input"}
|
{block name="other_input"}
|
||||||
{if $key == 'memcachedServers'}
|
{if $key == 'memcachedServers'}
|
||||||
<div id="memcachedServers">
|
<div id="memcachedServers">
|
||||||
@@ -145,15 +129,15 @@
|
|||||||
|
|
||||||
function showMemcached()
|
function showMemcached()
|
||||||
{
|
{
|
||||||
if ($('#caching_system option:selected').val() == 'CacheMemcache')
|
if ($('input[name="caching_system"]:radio:checked').val() == 'CacheMemcache')
|
||||||
{
|
{
|
||||||
$('#memcachedServers').show();
|
$('#memcachedServers').show();
|
||||||
$('#directory_depth').hide();
|
$('#ps_cache_fs_directory_depth').parent().parent().hide();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$('#memcachedServers').hide();
|
$('#memcachedServers').hide();
|
||||||
$('#directory_depth').show();
|
$('#ps_cache_fs_directory_depth').parent().parent().show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,7 +145,8 @@
|
|||||||
|
|
||||||
showMemcached();
|
showMemcached();
|
||||||
|
|
||||||
$('#caching_system').change(function() {
|
$('input[name="caching_system"]').change(function() {
|
||||||
|
$('#cache_up').val(1);
|
||||||
showMemcached();
|
showMemcached();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -221,10 +206,9 @@
|
|||||||
$('#ciphering_up').val(1);
|
$('#ciphering_up').val(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('input[name="active"], select[name="caching_system"]').change(function(){
|
$('input[name="cache_active"]').change(function(){
|
||||||
$('#cache_up').val(1);
|
$('#cache_up').val(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
{/block}
|
{/block}
|
||||||
|
|||||||
@@ -334,7 +334,7 @@
|
|||||||
|
|
||||||
<div class="radio {if isset($input.class)}"{$input.class}"{/if}">
|
<div class="radio {if isset($input.class)}"{$input.class}"{/if}">
|
||||||
<label>
|
<label>
|
||||||
<input type="radio" name="{$input.name}"id="{$value.id}" value="{$value.value|escape:'htmlall':'UTF-8'}"
|
<input type="radio" name="{$input.name}" id="{$value.id}" value="{$value.value|escape:'htmlall':'UTF-8'}"
|
||||||
{if $fields_value[$input.name] == $value.value}checked="checked"{/if}
|
{if $fields_value[$input.name] == $value.value}checked="checked"{/if}
|
||||||
{if isset($input.disabled) && $input.disabled}disabled="disabled"{/if} />
|
{if isset($input.disabled) && $input.disabled}disabled="disabled"{/if} />
|
||||||
{$value.label}
|
{$value.label}
|
||||||
|
|||||||
@@ -66,6 +66,11 @@ class AdminCountriesControllerCore extends AdminController
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$zones_array = array();
|
||||||
|
$this->zones = Zone::getZones();
|
||||||
|
foreach ($this->zones as $zone)
|
||||||
|
$zones_array[$zone['id_zone']] = $zone['name'];
|
||||||
|
|
||||||
$this->fields_list = array(
|
$this->fields_list = array(
|
||||||
'id_country' => array(
|
'id_country' => array(
|
||||||
'title' => $this->l('ID'),
|
'title' => $this->l('ID'),
|
||||||
@@ -86,7 +91,11 @@ class AdminCountriesControllerCore extends AdminController
|
|||||||
),
|
),
|
||||||
'zone' => array(
|
'zone' => array(
|
||||||
'title' => $this->l('Zone'),
|
'title' => $this->l('Zone'),
|
||||||
'filter_key' => 'z!name'
|
'type' => 'select',
|
||||||
|
'list' => $zones_array,
|
||||||
|
'filter_key' => 'z!id_zone',
|
||||||
|
'filter_type' => 'int',
|
||||||
|
'order_key' => 'zone'
|
||||||
),
|
),
|
||||||
'active' => array(
|
'active' => array(
|
||||||
'title' => $this->l('Enabled'),
|
'title' => $this->l('Enabled'),
|
||||||
|
|||||||
@@ -375,31 +375,28 @@ class AdminPerformanceControllerCore extends AdminController
|
|||||||
|
|
||||||
public function initFieldsetCaching()
|
public function initFieldsetCaching()
|
||||||
{
|
{
|
||||||
$caching_system = array(
|
$phpdoc_langs = array('en', 'zh', 'fr', 'de', 'ja', 'pl', 'ro', 'ru', 'fa', 'es', 'tr');
|
||||||
0 => array(
|
$php_lang = in_array($this->context->language->iso_code, $phpdoc_langs) ? $this->context->language->iso_code : 'en';
|
||||||
'id' => 'CacheMemcache',
|
|
||||||
'name' => $this->l('Memcached')
|
$warning_memcached = ' '.$this->l('(you must install the [a]Memcache PECL extension[/a])');
|
||||||
),
|
$warning_memcached = str_replace('[a]', '<a href="http://www.php.net/manual/'.substr($php_lang, 0, 2).'/memcache.installation.php" target="_blank">', $warning_memcached);
|
||||||
1 => array(
|
$warning_memcached = str_replace('[/a]', '</a>', $warning_memcached);
|
||||||
'id' => 'CacheApc',
|
|
||||||
'name' => $this->l('APC')
|
$warning_apc = ' '.$this->l('(you must install the [a]APC PECL extension[/a])');
|
||||||
),
|
$warning_apc = str_replace('[a]', '<a href="http://php.net/manual/'.substr($php_lang, 0, 2).'/apc.installation.php" target="_blank">', $warning_apc);
|
||||||
2 => array(
|
$warning_apc = str_replace('[/a]', '</a>', $warning_apc);
|
||||||
'id' => 'CacheXcache',
|
|
||||||
'name' => $this->l('Xcache')
|
$warning_xcache = ' '.$this->l('(you must install the [a]Xcache extension[/a])');
|
||||||
),
|
$warning_xcache = str_replace('[a]', '<a href="http://xcache.lighttpd.net" target="_blank">', $warning_xcache);
|
||||||
3 => array(
|
$warning_xcache = str_replace('[/a]', '</a>', $warning_xcache);
|
||||||
'id' => 'CacheFs',
|
|
||||||
'name' => $this->l('File System')
|
$warning_fs = ' '.sprintf($this->l('(the directory %s must be writable)'), realpath(_PS_CACHEFS_DIRECTORY_));
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->fields_form[5]['form'] = array(
|
$this->fields_form[5]['form'] = array(
|
||||||
'legend' => array(
|
'legend' => array(
|
||||||
'title' => $this->l('Caching'),
|
'title' => $this->l('Caching'),
|
||||||
'icon' => 'icon-desktop'
|
'icon' => 'icon-desktop'
|
||||||
),
|
),
|
||||||
'hint' => $this->l('Caching systems are used to speed up your store by caching data into the server\'s memory, avoiding the exhausting task of querying the database.'),
|
|
||||||
'input' => array(
|
'input' => array(
|
||||||
array(
|
array(
|
||||||
'type' => 'hidden',
|
'type' => 'hidden',
|
||||||
@@ -408,30 +405,48 @@ class AdminPerformanceControllerCore extends AdminController
|
|||||||
array(
|
array(
|
||||||
'type' => 'switch',
|
'type' => 'switch',
|
||||||
'label' => $this->l('Use cache'),
|
'label' => $this->l('Use cache'),
|
||||||
'name' => 'active',
|
'name' => 'cache_active',
|
||||||
'is_bool' => true,
|
'is_bool' => true,
|
||||||
'values' => array(
|
'values' => array(
|
||||||
array(
|
array(
|
||||||
'id' => 'active_on',
|
'id' => 'cache_active_on',
|
||||||
'value' => 1,
|
'value' => 1,
|
||||||
'label' => $this->l('Enabled')
|
'label' => $this->l('Enabled')
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'id' => 'active_off',
|
'id' => 'cache_active_off',
|
||||||
'value' => 0,
|
'value' => 0,
|
||||||
'label' => $this->l('Disabled')
|
'label' => $this->l('Disabled')
|
||||||
)
|
)
|
||||||
),
|
)
|
||||||
'hint' => $this->l('Enable or disable caching system.')
|
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'type' => 'select',
|
'type' => 'radio',
|
||||||
'label' => $this->l('Caching system'),
|
'label' => $this->l('Caching system'),
|
||||||
'name' => 'caching_system',
|
'name' => 'caching_system',
|
||||||
'options' => array(
|
'hint' => $this->l('The CacheFS system should be used only when the infrastructure contains one front-end server. If you are not sure, ask your hosting company.'),
|
||||||
'query' => $caching_system,
|
'values' => array(
|
||||||
'id' => 'id',
|
array(
|
||||||
'name' => 'name'
|
'id' => 'CacheFs',
|
||||||
|
'value' => 'CacheFs',
|
||||||
|
'label' => $this->l('File System').(is_writable(_PS_CACHEFS_DIRECTORY_) ? '' : $warning_fs)
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'id' => 'CacheMemcache',
|
||||||
|
'value' => 'CacheMemcache',
|
||||||
|
'label' => $this->l('Memcached').(extension_loaded('memcache') ? '' : $warning_memcached)
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'id' => 'CacheApc',
|
||||||
|
'value' => 'CacheApc',
|
||||||
|
'label' => $this->l('APC').(extension_loaded('apc') ? '' : $warning_apc)
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'id' => 'CacheXcache',
|
||||||
|
'value' => 'CacheXcache',
|
||||||
|
'label' => $this->l('Xcache').(extension_loaded('xcache') ? '' : $warning_xcache)
|
||||||
|
),
|
||||||
|
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
@@ -448,7 +463,7 @@ class AdminPerformanceControllerCore extends AdminController
|
|||||||
);
|
);
|
||||||
|
|
||||||
$depth = Configuration::get('PS_CACHEFS_DIRECTORY_DEPTH');
|
$depth = Configuration::get('PS_CACHEFS_DIRECTORY_DEPTH');
|
||||||
$this->fields_value['active'] = _PS_CACHE_ENABLED_;
|
$this->fields_value['cache_active'] = _PS_CACHE_ENABLED_;
|
||||||
$this->fields_value['caching_system'] = _PS_CACHING_SYSTEM_;
|
$this->fields_value['caching_system'] = _PS_CACHING_SYSTEM_;
|
||||||
$this->fields_value['ps_cache_fs_directory_depth'] = $depth ? $depth : 1;
|
$this->fields_value['ps_cache_fs_directory_depth'] = $depth ? $depth : 1;
|
||||||
|
|
||||||
@@ -473,29 +488,6 @@ class AdminPerformanceControllerCore extends AdminController
|
|||||||
|
|
||||||
public function initContent()
|
public function initContent()
|
||||||
{
|
{
|
||||||
$php_dot_net_supported_langs = array('en', 'zh', 'fr', 'de', 'ja', 'pl', 'ro', 'ru', 'fa', 'es', 'tr');
|
|
||||||
$php_lang = in_array($this->context->language->iso_code, $php_dot_net_supported_langs) ?
|
|
||||||
$this->context->language->iso_code : 'en';
|
|
||||||
|
|
||||||
if (!extension_loaded('memcache'))
|
|
||||||
$this->warnings[] = $this->l('To use Memcached, you must install the Memcache PECL extension on your server.').'
|
|
||||||
<a href="http://www.php.net/manual/'.substr($php_lang, 0, 2).'/memcache.installation.php" target="_blank">
|
|
||||||
http://www.php.net/manual/'.substr($php_lang, 0, 2).'/memcache.installation.php
|
|
||||||
</a>';
|
|
||||||
if (!extension_loaded('apc'))
|
|
||||||
{
|
|
||||||
$this->warnings[] = $this->l('To use APC, you must install the APC PECL extension on your server.').'
|
|
||||||
<a href="http://php.net/manual/'.substr($php_lang, 0, 2).'/apc.installation.php" target="_blank">
|
|
||||||
http://php.net/manual/'.substr($php_lang, 0, 2).'/apc.installation.php
|
|
||||||
</a>';
|
|
||||||
}
|
|
||||||
if (!extension_loaded('xcache'))
|
|
||||||
$this->warnings[] = $this->l('To use Xcache, you must install the Xcache extension on your server.').'
|
|
||||||
<a href="http://xcache.lighttpd.net" target="_blank">http://xcache.lighttpd.net</a>';
|
|
||||||
|
|
||||||
if (!is_writable(_PS_CACHEFS_DIRECTORY_))
|
|
||||||
$this->warnings[] = sprintf($this->l('To use the CacheFS directory %s must be writable.'), realpath(_PS_CACHEFS_DIRECTORY_));
|
|
||||||
|
|
||||||
$this->initToolbar();
|
$this->initToolbar();
|
||||||
$this->display = '';
|
$this->display = '';
|
||||||
$this->content .= $this->renderForm();
|
$this->content .= $this->renderForm();
|
||||||
@@ -516,7 +508,6 @@ class AdminPerformanceControllerCore extends AdminController
|
|||||||
|
|
||||||
public function postProcess()
|
public function postProcess()
|
||||||
{
|
{
|
||||||
|
|
||||||
/* PrestaShop demo mode */
|
/* PrestaShop demo mode */
|
||||||
if (_PS_MODE_DEMO_)
|
if (_PS_MODE_DEMO_)
|
||||||
{
|
{
|
||||||
@@ -703,57 +694,61 @@ class AdminPerformanceControllerCore extends AdminController
|
|||||||
{
|
{
|
||||||
if ($this->tabAccess['edit'] === '1')
|
if ($this->tabAccess['edit'] === '1')
|
||||||
{
|
{
|
||||||
$prev_settings = file_get_contents(dirname(__FILE__).'/../../config/settings.inc.php');
|
$new_settings = $prev_settings = file_get_contents(dirname(__FILE__).'/../../config/settings.inc.php');
|
||||||
$new_settings = $prev_settings;
|
$cache_active = (bool)Tools::getValue('cache_active');
|
||||||
if (!Tools::getValue('active'))
|
|
||||||
$cache_active = 0;
|
|
||||||
else
|
|
||||||
$cache_active = 1;
|
|
||||||
|
|
||||||
if (!$caching_system = Tools::getValue('caching_system'))
|
if ($caching_system = Tools::getValue('caching_system'))
|
||||||
$this->errors[] = Tools::displayError('The caching system is missing.');
|
{
|
||||||
else
|
|
||||||
$new_settings = preg_replace(
|
$new_settings = preg_replace(
|
||||||
'/define\(\'_PS_CACHING_SYSTEM_\', \'([a-z0-9=\/+-_]+)\'\);/Ui',
|
'/define\(\'_PS_CACHING_SYSTEM_\', \'([a-z0-9=\/+-_]*)\'\);/Ui',
|
||||||
'define(\'_PS_CACHING_SYSTEM_\', \''.$caching_system.'\');',
|
'define(\'_PS_CACHING_SYSTEM_\', \''.$caching_system.'\');',
|
||||||
$new_settings
|
$new_settings
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($cache_active && $caching_system == 'CacheMemcache' && !extension_loaded('memcache'))
|
|
||||||
$this->errors[] = Tools::displayError('To use Memcached, you must install the Memcache PECL extension on your server.').'
|
|
||||||
<a href="http://www.php.net/manual/en/memcache.installation.php">http://www.php.net/manual/en/memcache.installation.php</a>';
|
|
||||||
elseif ($cache_active && $caching_system == 'CacheApc' && !extension_loaded('apc'))
|
|
||||||
$this->errors[] = Tools::displayError('To use APC cache, you must install the APC PECL extension on your server.').'
|
|
||||||
<a href="http://fr.php.net/manual/fr/apc.installation.php">http://fr.php.net/manual/fr/apc.installation.php</a>';
|
|
||||||
elseif ($cache_active && $caching_system == 'CacheXcache' && !extension_loaded('xcache'))
|
|
||||||
$this->errors[] = Tools::displayError('To use Xcache, you must install the Xcache extension on your server.').'
|
|
||||||
<a href="http://xcache.lighttpd.net">http://xcache.lighttpd.net</a>';
|
|
||||||
else if ($cache_active && $caching_system == 'CacheXcache' && !ini_get('xcache.var_size'))
|
|
||||||
$this->errors[] = Tools::displayError('To use Xcache, you must configure "xcache.var_size" for the Xcache extension (recommended value 16M to 64M).').'
|
|
||||||
<a href="http://xcache.lighttpd.net/wiki/XcacheIni">http://xcache.lighttpd.net/wiki/XcacheIni</a>';
|
|
||||||
elseif ($cache_active && $caching_system == 'CacheFs' && !is_writable(_PS_CACHEFS_DIRECTORY_))
|
|
||||||
$this->errors[] = sprintf(
|
|
||||||
Tools::displayError('To use CacheFS, the directory %s must be writable.'),
|
|
||||||
realpath(_PS_CACHEFS_DIRECTORY_)
|
|
||||||
);
|
|
||||||
|
|
||||||
if ($caching_system == 'CacheFs' && $cache_active)
|
|
||||||
{
|
|
||||||
if (!($depth = Tools::getValue('ps_cache_fs_directory_depth')))
|
|
||||||
$this->errors[] = Tools::displayError('Please set a directory depth.');
|
|
||||||
if (!count($this->errors))
|
|
||||||
{
|
|
||||||
CacheFs::deleteCacheDirectory();
|
|
||||||
CacheFs::createCacheDirectories((int)$depth);
|
|
||||||
Configuration::updateValue('PS_CACHEFS_DIRECTORY_DEPTH', (int)$depth);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
elseif ($caching_system == 'CacheMemcache' && $cache_active && !_PS_CACHE_ENABLED_ && _PS_CACHING_SYSTEM_ == 'CacheMemcache')
|
else
|
||||||
Cache::getInstance()->flush();
|
{
|
||||||
|
$cache_active = false;
|
||||||
|
$this->errors[] = Tools::displayError('The caching system is missing.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($cache_active)
|
||||||
|
{
|
||||||
|
if ($caching_system == 'CacheMemcache' && !extension_loaded('memcache'))
|
||||||
|
$this->errors[] = Tools::displayError('To use Memcached, you must install the Memcache PECL extension on your server.').'
|
||||||
|
<a href="http://www.php.net/manual/en/memcache.installation.php">http://www.php.net/manual/en/memcache.installation.php</a>';
|
||||||
|
elseif ($caching_system == 'CacheApc' && !extension_loaded('apc'))
|
||||||
|
$this->errors[] = Tools::displayError('To use APC cache, you must install the APC PECL extension on your server.').'
|
||||||
|
<a href="http://fr.php.net/manual/fr/apc.installation.php">http://fr.php.net/manual/fr/apc.installation.php</a>';
|
||||||
|
elseif ($caching_system == 'CacheXcache' && !extension_loaded('xcache'))
|
||||||
|
$this->errors[] = Tools::displayError('To use Xcache, you must install the Xcache extension on your server.').'
|
||||||
|
<a href="http://xcache.lighttpd.net">http://xcache.lighttpd.net</a>';
|
||||||
|
elseif ($caching_system == 'CacheXcache' && !ini_get('xcache.var_size'))
|
||||||
|
$this->errors[] = Tools::displayError('To use Xcache, you must configure "xcache.var_size" for the Xcache extension (recommended value 16M to 64M).').'
|
||||||
|
<a href="http://xcache.lighttpd.net/wiki/XcacheIni">http://xcache.lighttpd.net/wiki/XcacheIni</a>';
|
||||||
|
elseif ($caching_system == 'CacheFs' && !is_writable(_PS_CACHEFS_DIRECTORY_))
|
||||||
|
$this->errors[] = sprintf(
|
||||||
|
Tools::displayError('To use CacheFS, the directory %s must be writable.'),
|
||||||
|
realpath(_PS_CACHEFS_DIRECTORY_)
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($caching_system == 'CacheFs')
|
||||||
|
{
|
||||||
|
if (!($depth = Tools::getValue('ps_cache_fs_directory_depth')))
|
||||||
|
$this->errors[] = Tools::displayError('Please set a directory depth.');
|
||||||
|
if (!count($this->errors))
|
||||||
|
{
|
||||||
|
CacheFs::deleteCacheDirectory();
|
||||||
|
CacheFs::createCacheDirectories((int)$depth);
|
||||||
|
Configuration::updateValue('PS_CACHEFS_DIRECTORY_DEPTH', (int)$depth);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elseif ($caching_system == 'CacheMemcache' && !_PS_CACHE_ENABLED_ && _PS_CACHING_SYSTEM_ == 'CacheMemcache')
|
||||||
|
Cache::getInstance()->flush();
|
||||||
|
}
|
||||||
|
|
||||||
if (!count($this->errors))
|
if (!count($this->errors))
|
||||||
{
|
{
|
||||||
$new_settings = preg_replace('/define\(\'_PS_CACHE_ENABLED_\', \'([0-9])\'\);/Ui', 'define(\'_PS_CACHE_ENABLED_\', \''.(int)$cache_active.'\');', $new_settings);
|
$new_settings = preg_replace('/define\(\'_PS_CACHE_ENABLED_\', \'([01]?)\'\);/Ui', 'define(\'_PS_CACHE_ENABLED_\', \''.(int)$cache_active.'\');', $new_settings);
|
||||||
// If there is not settings file modification or if the backup and replacement of the settings file worked
|
// If there is not settings file modification or if the backup and replacement of the settings file worked
|
||||||
if ($new_settings == $prev_settings || (
|
if ($new_settings == $prev_settings || (
|
||||||
copy(dirname(__FILE__).'/../../config/settings.inc.php', dirname(__FILE__).'/../../config/settings.old.php')
|
copy(dirname(__FILE__).'/../../config/settings.inc.php', dirname(__FILE__).'/../../config/settings.old.php')
|
||||||
|
|||||||
Reference in New Issue
Block a user