// Fix delete multiple toolbar in AdminPerformanceController
This commit is contained in:
@@ -27,62 +27,7 @@
|
||||
|
||||
class AdminPerformanceController extends AdminController
|
||||
{
|
||||
public function initToolbar()
|
||||
{
|
||||
switch ($this->display)
|
||||
{
|
||||
case 'formSmarty':
|
||||
$this->toolbar_btn = array();
|
||||
$this->toolbar_btn['save'] = array(
|
||||
'href' => '#',
|
||||
'desc' => $this->l('Save')
|
||||
);
|
||||
break;
|
||||
|
||||
case 'formFeaturesDetachables':
|
||||
$this->toolbar_btn = array();
|
||||
$this->toolbar_btn['save-feature'] = array(
|
||||
'href' => '#',
|
||||
'desc' => $this->l('Save')
|
||||
);
|
||||
break;
|
||||
|
||||
case 'formCCC':
|
||||
$this->toolbar_btn = array();
|
||||
$this->toolbar_btn['save-ccc'] = array(
|
||||
'href' => '#',
|
||||
'desc' => $this->l('Save')
|
||||
);
|
||||
break;
|
||||
|
||||
case 'formMediaServer':
|
||||
$this->toolbar_btn = array();
|
||||
$this->toolbar_btn['save-media'] = array(
|
||||
'href' => '#',
|
||||
'desc' => $this->l('Save')
|
||||
);
|
||||
break;
|
||||
|
||||
case 'formCiphering':
|
||||
$this->toolbar_btn = array();
|
||||
$this->toolbar_btn['save-ciphering'] = array(
|
||||
'href' => '#',
|
||||
'desc' => $this->l('Save')
|
||||
);
|
||||
break;
|
||||
|
||||
case 'formCaching':
|
||||
$this->toolbar_btn = array();
|
||||
$this->toolbar_btn['save-caching'] = array(
|
||||
'href' => '#',
|
||||
'desc' => $this->l('Save')
|
||||
);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function initFormSmarty()
|
||||
public function initFieldsetSmarty()
|
||||
{
|
||||
$this->fields_form[0]['form'] = array(
|
||||
'legend' => array(
|
||||
@@ -90,6 +35,10 @@ class AdminPerformanceController extends AdminController
|
||||
'image' => '../img/admin/prefs.gif'
|
||||
),
|
||||
'input' => array(
|
||||
array(
|
||||
'type' => 'hidden',
|
||||
'name' => 'smarty_up'
|
||||
),
|
||||
array(
|
||||
'type' => 'radio',
|
||||
'label' => $this->l('Templates cache:'),
|
||||
@@ -107,13 +56,16 @@ class AdminPerformanceController extends AdminController
|
||||
'id' => 'smarty_force_compile_'._PS_SMARTY_CHECK_COMPILE_,
|
||||
'value' => _PS_SMARTY_CHECK_COMPILE_,
|
||||
'label' => $this->l('Compile cache if templates are updated'),
|
||||
'desc' => $this->l('Templates are recompiled when they are updated, if you experience compilation troubles when you update your templates files, you should use force compile instead of this option. It should never be used in a production environment.')
|
||||
'desc' => $this->l('Templates are recompiled when they are updated, if you experience compilation troubles
|
||||
when you update your templates files, you should use force compile instead of this option.
|
||||
It should never be used in a production environment.')
|
||||
),
|
||||
array(
|
||||
'id' => 'smarty_force_compile_'._PS_SMARTY_FORCE_COMPILE_,
|
||||
'value' => _PS_SMARTY_FORCE_COMPILE_,
|
||||
'label' => $this->l('Force compile'),
|
||||
'desc' => $this->l('This forces Smarty to (re)compile templates on every invocation. This is handy for development and debugging. It should never be used in a production environment.')
|
||||
'desc' => $this->l('This forces Smarty to (re)compile templates on every invocation.
|
||||
This is handy for development and debugging. It should never be used in a production environment.')
|
||||
)
|
||||
)
|
||||
),
|
||||
@@ -137,50 +89,26 @@ class AdminPerformanceController extends AdminController
|
||||
),
|
||||
'desc' => $this->l('Should be enabled except for debugging.')
|
||||
)
|
||||
),
|
||||
'submit' => array(
|
||||
'title' => $this->l(' Save '),
|
||||
'class' => 'button',
|
||||
'name' => 'submitSmartyConfig'
|
||||
)
|
||||
);
|
||||
|
||||
$this->fields_value = array(
|
||||
'smarty_force_compile' => Configuration::get('PS_SMARTY_FORCE_COMPILE'),
|
||||
'smarty_cache' => Configuration::get('PS_SMARTY_CACHE')
|
||||
);
|
||||
|
||||
$this->display = 'formSmarty';
|
||||
|
||||
$this->initToolbar();
|
||||
$this->getlanguages();
|
||||
$helper = new HelperForm();
|
||||
$helper->currentIndex = self::$currentIndex;
|
||||
$helper->token = $this->token;
|
||||
$helper->table = 'smarty';
|
||||
$helper->identifier = 'smarty';
|
||||
$helper->override_folder = 'performance/';
|
||||
$helper->toolbar_fix = false;
|
||||
$helper->first_call = true;
|
||||
$helper->languages = $this->_languages;
|
||||
$helper->default_form_language = $this->default_form_language;
|
||||
$helper->allow_employee_form_lang = $this->allow_employee_form_lang;
|
||||
$helper->fields_value = $this->fields_value;
|
||||
$helper->toolbar_btn = $this->toolbar_btn;
|
||||
$helper->title = $this->l('Smarty');
|
||||
|
||||
return $helper->generateForm($this->fields_form);
|
||||
$this->fields_value['smarty_force_compile'] = Configuration::get('PS_SMARTY_FORCE_COMPILE');
|
||||
$this->fields_value['smarty_cache'] = Configuration::get('PS_SMARTY_CACHE');
|
||||
}
|
||||
|
||||
public function initFormFeaturesDetachables()
|
||||
public function initFieldsetFeaturesDetachables()
|
||||
{
|
||||
$this->fields_form[0]['form'] = array(
|
||||
$this->fields_form[1]['form'] = array(
|
||||
'legend' => array(
|
||||
'title' => $this->l('Features detachables'),
|
||||
'image' => '../img/admin/tab-plugins.gif'
|
||||
),
|
||||
'desc' => $this->l('Some features can be disabled in order to improve performance.'),
|
||||
'input' => array(
|
||||
array(
|
||||
'type' => 'hidden',
|
||||
'name' => 'features_detachables_up'
|
||||
),
|
||||
array(
|
||||
'type' => 'radio',
|
||||
'label' => $this->l('Combination:'),
|
||||
@@ -222,55 +150,28 @@ class AdminPerformanceController extends AdminController
|
||||
),
|
||||
'desc' => $this->l('These features are going to be disabled:')
|
||||
)
|
||||
),
|
||||
'submit' => array(
|
||||
'title' => $this->l(' Save '),
|
||||
'class' => 'button',
|
||||
'name' => 'submitFeaturesDetachables',
|
||||
'id' => 'submitFeaturesDetachables'
|
||||
)
|
||||
);
|
||||
|
||||
$this->fields_value = array(
|
||||
'combination' => Combination::isFeatureActive(),
|
||||
'feature' => Feature::isFeatureActive()
|
||||
);
|
||||
|
||||
$this->tpl_vars = array('combination' => Combination::isCurrentlyUsed());
|
||||
|
||||
$this->display = 'formFeaturesDetachables';
|
||||
|
||||
$this->initToolbar();
|
||||
$this->getlanguages();
|
||||
$helper = new HelperForm();
|
||||
$helper->currentIndex = self::$currentIndex;
|
||||
$helper->token = $this->token;
|
||||
$helper->table = 'features_detachables';
|
||||
$helper->identifier = 'features_detachables';
|
||||
$helper->override_folder = 'performance/';
|
||||
$helper->tpl_vars = $this->tpl_vars;
|
||||
$helper->first_call = false;
|
||||
$helper->toolbar_fix = false;
|
||||
$helper->languages = $this->_languages;
|
||||
$helper->default_form_language = $this->default_form_language;
|
||||
$helper->allow_employee_form_lang = $this->allow_employee_form_lang;
|
||||
$helper->fields_value = $this->fields_value;
|
||||
$helper->toolbar_btn = $this->toolbar_btn;
|
||||
$helper->title = $this->l('Features Detachables');
|
||||
|
||||
return $helper->generateForm($this->fields_form);
|
||||
$this->fields_value['combination'] = Combination::isFeatureActive();
|
||||
$this->fields_value['feature'] = Feature::isFeatureActive();
|
||||
}
|
||||
|
||||
public function initFormCCC()
|
||||
public function initFieldsetCCC()
|
||||
{
|
||||
$this->fields_form[0]['form'] = array(
|
||||
$this->fields_form[2]['form'] = array(
|
||||
'legend' => array(
|
||||
'title' => $this->l('CCC (Combine, Compress and Cache)'),
|
||||
'image' => '../img/admin/arrow_in.png'
|
||||
),
|
||||
'desc' => $this->l('CCC allows you to reduce the loading time of your page. With these settings you will gain performance without even touching the code of your theme.
|
||||
'desc' => $this->l('CCC allows you to reduce the loading time of your page.
|
||||
With these settings you will gain performance without even touching the code of your theme.
|
||||
Make sure, however, that your theme is compatible with PrestaShop 1.4+. Otherwise, CCC will cause problems.'),
|
||||
'input' => array(
|
||||
array(
|
||||
'type' => 'hidden',
|
||||
'name' => 'ccc_up'
|
||||
),
|
||||
array(
|
||||
'type' => 'radio',
|
||||
'label' => $this->l('Smart cache for CSS:'),
|
||||
@@ -366,123 +267,75 @@ class AdminPerformanceController extends AdminController
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
'submit' => array(
|
||||
'title' => $this->l(' Save '),
|
||||
'class' => 'button',
|
||||
'name' => 'submitCCC',
|
||||
'id' => 'submitCCC'
|
||||
)
|
||||
);
|
||||
|
||||
$this->fields_value = array(
|
||||
'PS_CSS_THEME_CACHE' => Configuration::get('PS_CSS_THEME_CACHE'),
|
||||
'PS_JS_THEME_CACHE' => Configuration::get('PS_JS_THEME_CACHE'),
|
||||
'PS_HTML_THEME_COMPRESSION' => Configuration::get('PS_HTML_THEME_COMPRESSION'),
|
||||
'PS_JS_HTML_THEME_COMPRESSION' => Configuration::get('PS_JS_HTML_THEME_COMPRESSION'),
|
||||
'PS_HIGH_HTML_THEME_COMPRESSION' => Configuration::get('PS_HIGH_HTML_THEME_COMPRESSION')
|
||||
);
|
||||
|
||||
$this->display = 'formCCC';
|
||||
|
||||
$this->initToolbar();
|
||||
$this->getlanguages();
|
||||
$helper = new HelperForm();
|
||||
$helper->currentIndex = self::$currentIndex;
|
||||
$helper->token = $this->token;
|
||||
$helper->table = 'ccc';
|
||||
$helper->identifier = 'ccc';
|
||||
$helper->override_folder = 'performance/';
|
||||
$helper->tpl_vars = $this->tpl_vars;
|
||||
$helper->first_call = false;
|
||||
$helper->toolbar_fix = false;
|
||||
$helper->languages = $this->_languages;
|
||||
$helper->default_form_language = $this->default_form_language;
|
||||
$helper->allow_employee_form_lang = $this->allow_employee_form_lang;
|
||||
$helper->fields_value = $this->fields_value;
|
||||
$helper->toolbar_btn = $this->toolbar_btn;
|
||||
$helper->title = $this->l('CCC (Combine, Compress and Cache)');
|
||||
|
||||
return $helper->generateForm($this->fields_form);
|
||||
$this->fields_value['PS_CSS_THEME_CACHE'] = Configuration::get('PS_CSS_THEME_CACHE');
|
||||
$this->fields_value['PS_JS_THEME_CACHE'] = Configuration::get('PS_JS_THEME_CACHE');
|
||||
$this->fields_value['PS_HTML_THEME_COMPRESSION'] = Configuration::get('PS_HTML_THEME_COMPRESSION');
|
||||
$this->fields_value['PS_JS_HTML_THEME_COMPRESSION'] = Configuration::get('PS_JS_HTML_THEME_COMPRESSION');
|
||||
$this->fields_value['PS_HIGH_HTML_THEME_COMPRESSION'] = Configuration::get('PS_HIGH_HTML_THEME_COMPRESSION');
|
||||
}
|
||||
|
||||
public function initFormMediaServer()
|
||||
public function initFieldsetMediaServer()
|
||||
{
|
||||
$this->fields_form[0]['form'] = array(
|
||||
$this->fields_form[3]['form'] = array(
|
||||
'legend' => array(
|
||||
'title' => $this->l('Media servers (used only with CCC)'),
|
||||
'image' => '../img/admin/subdomain.gif'
|
||||
),
|
||||
'desc' => $this->l('You must enter another domain or subdomain in order to use cookieless static content.'),
|
||||
'input' => array(
|
||||
array(
|
||||
'type' => 'hidden',
|
||||
'name' => 'media_server_up'
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Media server #1:'),
|
||||
'name' => '_MEDIA_SERVER_1_',
|
||||
'size' => 30,
|
||||
'desc' => $this->l('Name of the second domain of your shop, (e.g., myshop-media-server-1.com). If you do not have another domain, leave this field blank')
|
||||
'desc' => $this->l('Name of the second domain of your shop, (e.g., myshop-media-server-1.com).
|
||||
If you do not have another domain, leave this field blank')
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Media server #2:'),
|
||||
'name' => '_MEDIA_SERVER_2_',
|
||||
'size' => 30,
|
||||
'desc' => $this->l('Name of the third domain of your shop, (e.g., myshop-media-server-2.com). If you do not have another domain, leave this field blank')
|
||||
'desc' => $this->l('Name of the third domain of your shop, (e.g., myshop-media-server-2.com).
|
||||
If you do not have another domain, leave this field blank')
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Media server #3:'),
|
||||
'name' => '_MEDIA_SERVER_3_',
|
||||
'size' => 30,
|
||||
'desc' => $this->l('Name of the fourth domain of your shop, (e.g., myshop-media-server-3.com). If you do not have another domain, leave this field blank')
|
||||
'desc' => $this->l('Name of the fourth domain of your shop, (e.g., myshop-media-server-3.com).
|
||||
If you do not have another domain, leave this field blank')
|
||||
),
|
||||
),
|
||||
'submit' => array(
|
||||
'title' => $this->l(' Save '),
|
||||
'class' => 'button',
|
||||
'name' => 'submitMediaServers',
|
||||
'id' => 'submitMediaServers'
|
||||
)
|
||||
);
|
||||
|
||||
$this->fields_value = array(
|
||||
'_MEDIA_SERVER_1_' => Tools::getValue('_MEDIA_SERVER_1_', _MEDIA_SERVER_1_),
|
||||
'_MEDIA_SERVER_2_' => Tools::getValue('_MEDIA_SERVER_2_', _MEDIA_SERVER_2_),
|
||||
'_MEDIA_SERVER_3_' => Tools::getValue('_MEDIA_SERVER_3_', _MEDIA_SERVER_3_)
|
||||
);
|
||||
|
||||
$this->display = 'formMediaServer';
|
||||
|
||||
$this->initToolbar();
|
||||
$this->getlanguages();
|
||||
$helper = new HelperForm();
|
||||
$helper->currentIndex = self::$currentIndex;
|
||||
$helper->token = $this->token;
|
||||
$helper->table = 'media_server';
|
||||
$helper->identifier = 'media_server';
|
||||
$helper->override_folder = 'performance/';
|
||||
$helper->tpl_vars = $this->tpl_vars;
|
||||
$helper->first_call = false;
|
||||
$helper->toolbar_fix = false;
|
||||
$helper->languages = $this->_languages;
|
||||
$helper->default_form_language = $this->default_form_language;
|
||||
$helper->allow_employee_form_lang = $this->allow_employee_form_lang;
|
||||
$helper->fields_value = $this->fields_value;
|
||||
$helper->toolbar_btn = $this->toolbar_btn;
|
||||
$helper->title = $this->l('Media servers (used only with CCC)');
|
||||
|
||||
return $helper->generateForm($this->fields_form);
|
||||
$this->fields_value['_MEDIA_SERVER_1_'] = Tools::getValue('_MEDIA_SERVER_1_', _MEDIA_SERVER_1_);
|
||||
$this->fields_value['_MEDIA_SERVER_2_'] = Tools::getValue('_MEDIA_SERVER_2_', _MEDIA_SERVER_2_);
|
||||
$this->fields_value['_MEDIA_SERVER_3_'] = Tools::getValue('_MEDIA_SERVER_3_', _MEDIA_SERVER_3_);
|
||||
}
|
||||
|
||||
public function initCiphering()
|
||||
public function initFieldsetCiphering()
|
||||
{
|
||||
$this->fields_form[0]['form'] = array(
|
||||
$this->fields_form[4]['form'] = array(
|
||||
'legend' => array(
|
||||
'title' => $this->l('Ciphering'),
|
||||
'image' => '../img/admin/computer_key.png'
|
||||
),
|
||||
'desc' => $this->l('Mcrypt is faster than our custom BlowFish class, but requires the PHP extension "mcrypt". If you change this configuration, all cookies will be reset.'),
|
||||
'desc' => $this->l('Mcrypt is faster than our custom BlowFish class, but requires the PHP extension "mcrypt".
|
||||
If you change this configuration, all cookies will be reset.'),
|
||||
'input' => array(
|
||||
array(
|
||||
'type' => 'hidden',
|
||||
'name' => 'ciphering_up'
|
||||
),
|
||||
array(
|
||||
'type' => 'radio',
|
||||
'label' => $this->l('Algorithm:'),
|
||||
@@ -502,41 +355,13 @@ class AdminPerformanceController extends AdminController
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
'submit' => array(
|
||||
'title' => $this->l(' Save '),
|
||||
'class' => 'button',
|
||||
'name' => 'submitCiphering',
|
||||
'id' => 'submitCiphering'
|
||||
)
|
||||
);
|
||||
|
||||
$this->fields_value = array('PS_CIPHER_ALGORITHM' => Configuration::get('PS_CIPHER_ALGORITHM'));
|
||||
|
||||
$this->display = 'formCiphering';
|
||||
|
||||
$this->initToolbar();
|
||||
$this->getlanguages();
|
||||
$helper = new HelperForm();
|
||||
$helper->currentIndex = self::$currentIndex;
|
||||
$helper->token = $this->token;
|
||||
$helper->table = 'ciphering';
|
||||
$helper->identifier = 'ciphering';
|
||||
$helper->override_folder = 'performance/';
|
||||
$helper->tpl_vars = $this->tpl_vars;
|
||||
$helper->first_call = false;
|
||||
$helper->toolbar_fix = false;
|
||||
$helper->languages = $this->_languages;
|
||||
$helper->default_form_language = $this->default_form_language;
|
||||
$helper->allow_employee_form_lang = $this->allow_employee_form_lang;
|
||||
$helper->fields_value = $this->fields_value;
|
||||
$helper->toolbar_btn = $this->toolbar_btn;
|
||||
$helper->title = $this->l('Ciphering');
|
||||
|
||||
return $helper->generateForm($this->fields_form);
|
||||
$this->fields_value['PS_CIPHER_ALGORITHM'] = Configuration::get('PS_CIPHER_ALGORITHM');
|
||||
}
|
||||
|
||||
public function initCaching()
|
||||
public function initFieldsetCaching()
|
||||
{
|
||||
$caching_system = array(
|
||||
0 => array(
|
||||
@@ -557,12 +382,16 @@ class AdminPerformanceController extends AdminController
|
||||
)
|
||||
);
|
||||
|
||||
$this->fields_form[0]['form'] = array(
|
||||
$this->fields_form[5]['form'] = array(
|
||||
'legend' => array(
|
||||
'title' => $this->l('Caching'),
|
||||
'image' => '../img/admin/computer_key.png'
|
||||
),
|
||||
'input' => array(
|
||||
array(
|
||||
'type' => 'hidden',
|
||||
'name' => 'cache_up'
|
||||
),
|
||||
array(
|
||||
'type' => 'radio',
|
||||
'label' => $this->l('Use cache:'),
|
||||
@@ -602,43 +431,33 @@ class AdminPerformanceController extends AdminController
|
||||
),
|
||||
'submit' => array(
|
||||
'title' => $this->l(' Save '),
|
||||
'class' => 'button',
|
||||
'name' => 'submitCaching',
|
||||
'id' => 'submitCaching'
|
||||
'class' => 'button'
|
||||
),
|
||||
'memcachedServers' => true
|
||||
);
|
||||
|
||||
$depth = Configuration::get('PS_CACHEFS_DIRECTORY_DEPTH');
|
||||
$this->fields_value = array(
|
||||
'active' => _PS_CACHE_ENABLED_,
|
||||
'caching_system' => _PS_CACHING_SYSTEM_,
|
||||
'ps_cache_fs_directory_depth' => $depth ? $depth : 1
|
||||
);
|
||||
$this->fields_value['active'] = _PS_CACHE_ENABLED_;
|
||||
$this->fields_value['caching_system'] = _PS_CACHING_SYSTEM_;
|
||||
$this->fields_value['ps_cache_fs_directory_depth'] = $depth ? $depth : 1;
|
||||
|
||||
$this->tpl_vars = array('servers' => CacheMemcache::getMemcachedServers());
|
||||
$this->tpl_form_vars['servers'] = CacheMemcache::getMemcachedServers();
|
||||
}
|
||||
|
||||
$this->display = 'formCaching';
|
||||
public function initForm()
|
||||
{
|
||||
// Initialize fieldset for a form
|
||||
$this->initFieldsetSmarty();
|
||||
$this->initFieldsetFeaturesDetachables();
|
||||
$this->initFieldsetCCC();
|
||||
$this->initFieldsetMediaServer();
|
||||
$this->initFieldsetCiphering();
|
||||
$this->initFieldsetCaching();
|
||||
|
||||
$this->initToolbar();
|
||||
$this->getlanguages();
|
||||
$helper = new HelperForm();
|
||||
$helper->currentIndex = self::$currentIndex;
|
||||
$helper->token = $this->token;
|
||||
$helper->table = 'caching';
|
||||
$helper->identifier = 'caching';
|
||||
$helper->override_folder = 'performance/';
|
||||
$helper->tpl_vars = $this->tpl_vars;
|
||||
$helper->first_call = false;
|
||||
$helper->toolbar_fix = false;
|
||||
$helper->languages = $this->_languages;
|
||||
$helper->default_form_language = $this->default_form_language;
|
||||
$helper->allow_employee_form_lang = $this->allow_employee_form_lang;
|
||||
$helper->fields_value = $this->fields_value;
|
||||
$helper->toolbar_btn = $this->toolbar_btn;
|
||||
$helper->title = $this->l('Caching');
|
||||
// Activate multiple fieldset
|
||||
$this->multiple_fieldsets = true;
|
||||
|
||||
return $helper->generateForm($this->fields_form);
|
||||
return parent::initForm();
|
||||
}
|
||||
|
||||
public function initContent()
|
||||
@@ -656,12 +475,9 @@ class AdminPerformanceController extends AdminController
|
||||
if (!is_writable(_PS_CACHEFS_DIRECTORY_))
|
||||
$this->warnings[] = $this->l('To use CacheFS the directory').' '.realpath(_PS_CACHEFS_DIRECTORY_).' '.$this->l('must be writable');
|
||||
|
||||
$this->content .= $this->initFormSmarty();
|
||||
$this->content .= $this->initFormFeaturesDetachables();
|
||||
$this->content .= $this->initFormCCC();
|
||||
$this->content .= $this->initFormMediaServer();
|
||||
$this->content .= $this->initCiphering();
|
||||
$this->content .= $this->initCaching();
|
||||
$this->initToolbar();
|
||||
$this->display = '';
|
||||
$this->content .= $this->initForm();
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
'content' => $this->content,
|
||||
@@ -669,166 +485,16 @@ class AdminPerformanceController extends AdminController
|
||||
));
|
||||
}
|
||||
|
||||
public function initToolbar()
|
||||
{
|
||||
$this->toolbar_btn['save'] = array(
|
||||
'href' => '#',
|
||||
'desc' => $this->l('Save')
|
||||
);
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if (Tools::isSubmit('submitAddsmarty'))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
Configuration::updateValue('PS_SMARTY_FORCE_COMPILE', Tools::getValue('smarty_force_compile', _PS_SMARTY_NO_COMPILE_));
|
||||
Configuration::updateValue('PS_SMARTY_CACHE', Tools::getValue('smarty_cache', 0));
|
||||
Tools::redirectAdmin(self::$currentIndex.'&token='.Tools::getValue('token').'&conf=4');
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
|
||||
}
|
||||
|
||||
if (Tools::isSubmit('submitFeaturesDetachables'))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
if (!Combination::isCurrentlyUsed())
|
||||
Configuration::updateValue('PS_COMBINATION_FEATURE_ACTIVE', Tools::getValue('combination'));
|
||||
Configuration::updateValue('PS_FEATURE_FEATURE_ACTIVE', Tools::getValue('feature'));
|
||||
Tools::redirectAdmin(self::$currentIndex.'&token='.Tools::getValue('token').'&conf=4');
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
|
||||
}
|
||||
|
||||
if (Tools::isSubmit('submitCCC'))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
if (
|
||||
!Configuration::updateValue('PS_CSS_THEME_CACHE', (int)Tools::getValue('PS_CSS_THEME_CACHE')) OR
|
||||
!Configuration::updateValue('PS_JS_THEME_CACHE', (int)Tools::getValue('PS_JS_THEME_CACHE')) OR
|
||||
!Configuration::updateValue('PS_HTML_THEME_COMPRESSION', (int)Tools::getValue('PS_HTML_THEME_COMPRESSION')) OR
|
||||
!Configuration::updateValue('PS_JS_HTML_THEME_COMPRESSION', (int)Tools::getValue('PS_JS_HTML_THEME_COMPRESSION')) OR
|
||||
!Configuration::updateValue('PS_HIGH_HTML_THEME_COMPRESSION', (int)Tools::getValue('PS_HIGH_HTML_THEME_COMPRESSION'))
|
||||
)
|
||||
$this->_errors[] = Tools::displayError('Unknown error.');
|
||||
else
|
||||
Tools::redirectAdmin(self::$currentIndex.'&token='.Tools::getValue('token').'&conf=4');
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
|
||||
}
|
||||
|
||||
if (Tools::isSubmit('submitMediaServers'))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
if (Tools::getValue('_MEDIA_SERVER_1_') != NULL AND !Validate::isFileName(Tools::getValue('_MEDIA_SERVER_1_')))
|
||||
$this->_errors[] = Tools::displayError('Media server #1 is invalid');
|
||||
if (Tools::getValue('_MEDIA_SERVER_2_') != NULL AND !Validate::isFileName(Tools::getValue('_MEDIA_SERVER_2_')))
|
||||
$this->_errors[] = Tools::displayError('Media server #2 is invalid');
|
||||
if (Tools::getValue('_MEDIA_SERVER_3_') != NULL AND !Validate::isFileName(Tools::getValue('_MEDIA_SERVER_3_')))
|
||||
$this->_errors[] = Tools::displayError('Media server #3 is invalid');
|
||||
if (!sizeof($this->_errors))
|
||||
{
|
||||
$baseUrls = array();
|
||||
$baseUrls['_MEDIA_SERVER_1_'] = Tools::getValue('_MEDIA_SERVER_1_');
|
||||
$baseUrls['_MEDIA_SERVER_2_'] = Tools::getValue('_MEDIA_SERVER_2_');
|
||||
$baseUrls['_MEDIA_SERVER_3_'] = Tools::getValue('_MEDIA_SERVER_3_');
|
||||
rewriteSettingsFile($baseUrls, NULL, NULL);
|
||||
unset($this->_fieldsGeneral['_MEDIA_SERVER_1_']);
|
||||
unset($this->_fieldsGeneral['_MEDIA_SERVER_2_']);
|
||||
unset($this->_fieldsGeneral['_MEDIA_SERVER_3_']);
|
||||
Tools::redirectAdmin(self::$currentIndex.'&token='.Tools::getValue('token').'&conf=4');
|
||||
}
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
|
||||
}
|
||||
|
||||
if (Tools::isSubmit('submitCiphering') AND Configuration::get('PS_CIPHER_ALGORITHM') != (int)Tools::getValue('PS_CIPHER_ALGORITHM'))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
$algo = (int)Tools::getValue('PS_CIPHER_ALGORITHM');
|
||||
$settings = file_get_contents(dirname(__FILE__).'/../../config/settings.inc.php');
|
||||
if ($algo)
|
||||
{
|
||||
if (!function_exists('mcrypt_encrypt'))
|
||||
$this->_errors[] = Tools::displayError('Mcrypt is not activated on this server.');
|
||||
else
|
||||
{
|
||||
if (!strstr($settings, '_RIJNDAEL_KEY_'))
|
||||
{
|
||||
$key_size = mcrypt_get_key_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB);
|
||||
$key = Tools::passwdGen($key_size);
|
||||
$settings = preg_replace('/define\(\'_COOKIE_KEY_\', \'([a-z0-9=\/+-_]+)\'\);/i', 'define(\'_COOKIE_KEY_\', \'\1\');'."\n".'define(\'_RIJNDAEL_KEY_\', \''.$key.'\');', $settings);
|
||||
}
|
||||
if (!strstr($settings, '_RIJNDAEL_IV_'))
|
||||
{
|
||||
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB);
|
||||
$iv = base64_encode(mcrypt_create_iv($iv_size, MCRYPT_RAND));
|
||||
$settings = preg_replace('/define\(\'_COOKIE_IV_\', \'([a-z0-9=\/+-_]+)\'\);/i', 'define(\'_COOKIE_IV_\', \'\1\');'."\n".'define(\'_RIJNDAEL_IV_\', \''.$iv.'\');', $settings);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!count($this->_errors))
|
||||
{
|
||||
if (file_put_contents(dirname(__FILE__).'/../../config/settings.inc.php', $settings))
|
||||
{
|
||||
Configuration::updateValue('PS_CIPHER_ALGORITHM', $algo);
|
||||
Tools::redirectAdmin(self::$currentIndex.'&token='.Tools::getValue('token').'&conf=4');
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('Cannot overwrite settings file.');
|
||||
}
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
|
||||
}
|
||||
|
||||
if (Tools::isSubmit('submitCaching'))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
$settings = file_get_contents(dirname(__FILE__).'/../../config/settings.inc.php');
|
||||
if (!Tools::getValue('active'))
|
||||
$cache_active = 0;
|
||||
else
|
||||
$cache_active = 1;
|
||||
if (!$caching_system = Tools::getValue('caching_system'))
|
||||
$this->_errors[] = Tools::displayError('Caching system is missing');
|
||||
else
|
||||
$settings = preg_replace('/define\(\'_PS_CACHING_SYSTEM_\', \'([a-z0-9=\/+-_]+)\'\);/Ui', 'define(\'_PS_CACHING_SYSTEM_\', \''.$caching_system.'\');', $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>';
|
||||
else if ($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>';
|
||||
else if ($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 == 'CacheFs' && !is_writable(_PS_CACHEFS_DIRECTORY_))
|
||||
$this->_errors[] = Tools::displayError('To use CacheFS the directory').' '.realpath(_PS_CACHEFS_DIRECTORY_).' '.Tools::displayError('must be writable');
|
||||
|
||||
if ($caching_system == 'CacheFs')
|
||||
{
|
||||
if (!($depth = Tools::getValue('ps_cache_fs_directory_depth')))
|
||||
$this->_errors[] = Tools::displayError('Please set a directory depth');
|
||||
if (!sizeof($this->_errors))
|
||||
{
|
||||
CacheFs::deleteCacheDirectory();
|
||||
CacheFs::createCacheDirectories((int)$depth);
|
||||
Configuration::updateValue('PS_CACHEFS_DIRECTORY_DEPTH', (int)$depth);
|
||||
}
|
||||
}
|
||||
if (!sizeof($this->_errors))
|
||||
{
|
||||
$settings = preg_replace('/define\(\'_PS_CACHE_ENABLED_\', \'([0-9])\'\);/Ui', 'define(\'_PS_CACHE_ENABLED_\', \''.(int)$cache_active.'\');', $settings);
|
||||
if (file_put_contents(dirname(__FILE__).'/../../config/settings.inc.php', $settings))
|
||||
Tools::redirectAdmin(self::$currentIndex.'&token='.Tools::getValue('token').'&conf=4');
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('Cannot overwrite settings file.');
|
||||
}
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
|
||||
}
|
||||
|
||||
if (Tools::isSubmit('submitAddServer'))
|
||||
{
|
||||
if ($this->tabAccess['add'] === '1')
|
||||
@@ -839,9 +505,11 @@ class AdminPerformanceController extends AdminController
|
||||
$this->_errors[] = Tools::displayError('Memcached port is missing');
|
||||
if (!Tools::getValue('memcachedWeight'))
|
||||
$this->_errors[] = Tools::displayError('Memcached weight is missing');
|
||||
if (!sizeof($this->_errors))
|
||||
if (!count($this->_errors))
|
||||
{
|
||||
if (CacheMemcache::addServer(pSQL(Tools::getValue('memcachedIp')), (int)Tools::getValue('memcachedPort'), (int)Tools::getValue('memcachedWeight')))
|
||||
if (CacheMemcache::addServer(pSQL(Tools::getValue('memcachedIp')),
|
||||
(int)Tools::getValue('memcachedPort'),
|
||||
(int)Tools::getValue('memcachedWeight')))
|
||||
Tools::redirectAdmin(self::$currentIndex.'&token='.Tools::getValue('token').'&conf=4');
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('Cannot add Memcached server');
|
||||
@@ -864,7 +532,183 @@ class AdminPerformanceController extends AdminController
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
|
||||
}
|
||||
|
||||
return parent::postProcess();
|
||||
$redirecAdmin = false;
|
||||
if ((bool)Tools::getValue('smarty_up'))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
Configuration::updateValue('PS_SMARTY_FORCE_COMPILE', Tools::getValue('smarty_force_compile', _PS_SMARTY_NO_COMPILE_));
|
||||
Configuration::updateValue('PS_SMARTY_CACHE', Tools::getValue('smarty_cache', 0));
|
||||
$redirecAdmin = true;
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
|
||||
}
|
||||
|
||||
if ((bool)Tools::getValue('features_detachables_up'))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
if (!Combination::isCurrentlyUsed())
|
||||
Configuration::updateValue('PS_COMBINATION_FEATURE_ACTIVE', Tools::getValue('combination'));
|
||||
Configuration::updateValue('PS_FEATURE_FEATURE_ACTIVE', Tools::getValue('feature'));
|
||||
$redirecAdmin = true;
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
|
||||
}
|
||||
|
||||
if ((bool)Tools::getValue('ccc_up'))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
if (!Configuration::updateValue('PS_CSS_THEME_CACHE', (int)Tools::getValue('PS_CSS_THEME_CACHE')) ||
|
||||
!Configuration::updateValue('PS_JS_THEME_CACHE', (int)Tools::getValue('PS_JS_THEME_CACHE')) ||
|
||||
!Configuration::updateValue('PS_HTML_THEME_COMPRESSION', (int)Tools::getValue('PS_HTML_THEME_COMPRESSION')) ||
|
||||
!Configuration::updateValue('PS_JS_HTML_THEME_COMPRESSION', (int)Tools::getValue('PS_JS_HTML_THEME_COMPRESSION')) ||
|
||||
!Configuration::updateValue('PS_HIGH_HTML_THEME_COMPRESSION', (int)Tools::getValue('PS_HIGH_HTML_THEME_COMPRESSION')))
|
||||
$this->_errors[] = Tools::displayError('Unknown error.');
|
||||
else
|
||||
$redirecAdmin = true;
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
|
||||
}
|
||||
|
||||
if ((bool)Tools::getValue('media_server_up'))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
if (Tools::getValue('_MEDIA_SERVER_1_') != null && !Validate::isFileName(Tools::getValue('_MEDIA_SERVER_1_')))
|
||||
$this->_errors[] = Tools::displayError('Media server #1 is invalid');
|
||||
if (Tools::getValue('_MEDIA_SERVER_2_') != null && !Validate::isFileName(Tools::getValue('_MEDIA_SERVER_2_')))
|
||||
$this->_errors[] = Tools::displayError('Media server #2 is invalid');
|
||||
if (Tools::getValue('_MEDIA_SERVER_3_') != null && !Validate::isFileName(Tools::getValue('_MEDIA_SERVER_3_')))
|
||||
$this->_errors[] = Tools::displayError('Media server #3 is invalid');
|
||||
if (!count($this->_errors))
|
||||
{
|
||||
$base_urls = array();
|
||||
$base_urls['_MEDIA_SERVER_1_'] = Tools::getValue('_MEDIA_SERVER_1_');
|
||||
$base_urls['_MEDIA_SERVER_2_'] = Tools::getValue('_MEDIA_SERVER_2_');
|
||||
$base_urls['_MEDIA_SERVER_3_'] = Tools::getValue('_MEDIA_SERVER_3_');
|
||||
rewriteSettingsFile($base_urls, null, null);
|
||||
unset($this->_fieldsGeneral['_MEDIA_SERVER_1_']);
|
||||
unset($this->_fieldsGeneral['_MEDIA_SERVER_2_']);
|
||||
unset($this->_fieldsGeneral['_MEDIA_SERVER_3_']);
|
||||
$redirecAdmin = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
|
||||
}
|
||||
|
||||
if ((bool)Tools::getValue('ciphering_up') && Configuration::get('PS_CIPHER_ALGORITHM') != (int)Tools::getValue('PS_CIPHER_ALGORITHM'))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
$algo = (int)Tools::getValue('PS_CIPHER_ALGORITHM');
|
||||
$settings = file_get_contents(dirname(__FILE__).'/../../config/settings.inc.php');
|
||||
if ($algo)
|
||||
{
|
||||
if (!function_exists('mcrypt_encrypt'))
|
||||
$this->_errors[] = Tools::displayError('Mcrypt is not activated on this server.');
|
||||
else
|
||||
{
|
||||
if (!strstr($settings, '_RIJNDAEL_KEY_'))
|
||||
{
|
||||
$key_size = mcrypt_get_key_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB);
|
||||
$key = Tools::passwdGen($key_size);
|
||||
$settings = preg_replace(
|
||||
'/define\(\'_COOKIE_KEY_\', \'([a-z0-9=\/+-_]+)\'\);/i',
|
||||
'define(\'_COOKIE_KEY_\', \'\1\');'."\n".'define(\'_RIJNDAEL_KEY_\', \''.$key.'\');',
|
||||
$settings
|
||||
);
|
||||
}
|
||||
if (!strstr($settings, '_RIJNDAEL_IV_'))
|
||||
{
|
||||
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB);
|
||||
$iv = base64_encode(mcrypt_create_iv($iv_size, MCRYPT_RAND));
|
||||
$settings = preg_replace(
|
||||
'/define\(\'_COOKIE_IV_\', \'([a-z0-9=\/+-_]+)\'\);/i',
|
||||
'define(\'_COOKIE_IV_\', \'\1\');'."\n".'define(\'_RIJNDAEL_IV_\', \''.$iv.'\');',
|
||||
$settings
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!count($this->_errors))
|
||||
{
|
||||
if (file_put_contents(dirname(__FILE__).'/../../config/settings.inc.php', $settings))
|
||||
{
|
||||
Configuration::updateValue('PS_CIPHER_ALGORITHM', $algo);
|
||||
$redirecAdmin = true;
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('Cannot overwrite settings file.');
|
||||
}
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
|
||||
}
|
||||
|
||||
if ((bool)Tools::getValue('cache_up'))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
$settings = file_get_contents(dirname(__FILE__).'/../../config/settings.inc.php');
|
||||
if (!Tools::getValue('active'))
|
||||
$cache_active = 0;
|
||||
else
|
||||
$cache_active = 1;
|
||||
if (!$caching_system = Tools::getValue('caching_system'))
|
||||
$this->_errors[] = Tools::displayError('Caching system is missing');
|
||||
else
|
||||
$settings = preg_replace(
|
||||
'/define\(\'_PS_CACHING_SYSTEM_\', \'([a-z0-9=\/+-_]+)\'\);/Ui',
|
||||
'define(\'_PS_CACHING_SYSTEM_\', \''.$caching_system.'\');',
|
||||
$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>';
|
||||
else if ($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>';
|
||||
else if ($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 == 'CacheFs' && !is_writable(_PS_CACHEFS_DIRECTORY_))
|
||||
$this->_errors[] = Tools::displayError('To use CacheFS the directory').' '.
|
||||
realpath(_PS_CACHEFS_DIRECTORY_).' '.Tools::displayError('must be writable');
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
if (!count($this->_errors))
|
||||
{
|
||||
$settings = preg_replace('/define\(\'_PS_CACHE_ENABLED_\', \'([0-9])\'\);/Ui', 'define(\'_PS_CACHE_ENABLED_\', \''.(int)$cache_active.'\');', $settings);
|
||||
if (file_put_contents(dirname(__FILE__).'/../../config/settings.inc.php', $settings))
|
||||
$redirecAdmin = true;
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('Cannot overwrite settings file.');
|
||||
}
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
|
||||
}
|
||||
|
||||
if ($redirecAdmin)
|
||||
Tools::redirectAdmin(self::$currentIndex.'&token='.Tools::getValue('token').'&conf=4');
|
||||
else
|
||||
return parent::postProcess();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user