[+] BO : Add debug mode system
This commit is contained in:
+10
-1
@@ -56,6 +56,8 @@ class HookCore extends ObjectModel
|
|||||||
*/
|
*/
|
||||||
public static $executed_hooks = array();
|
public static $executed_hooks = array();
|
||||||
|
|
||||||
|
public static $native_module;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ObjectModel::$definition
|
* @see ObjectModel::$definition
|
||||||
*/
|
*/
|
||||||
@@ -416,12 +418,19 @@ class HookCore extends ObjectModel
|
|||||||
// Look on modules list
|
// Look on modules list
|
||||||
$altern = 0;
|
$altern = 0;
|
||||||
$output = '';
|
$output = '';
|
||||||
|
|
||||||
|
if (!isset(Hook::$native_module))
|
||||||
|
Hook::$native_module = Module::getNativeModuleList();
|
||||||
|
|
||||||
foreach ($module_list as $array)
|
foreach ($module_list as $array)
|
||||||
{
|
{
|
||||||
// Check errors
|
// Check errors
|
||||||
if ($id_module && $id_module != $array['id_module'])
|
if ($id_module && $id_module != $array['id_module'])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if ((bool)Configuration::get('PS_DISABLE_NON_NATIVE_MODULE') && !in_array($array['module'], self::$native_module))
|
||||||
|
continue;
|
||||||
|
|
||||||
if (!($moduleInstance = Module::getInstanceByName($array['module'])))
|
if (!($moduleInstance = Module::getInstanceByName($array['module'])))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|||||||
@@ -1293,6 +1293,23 @@ abstract class ModuleCore
|
|||||||
return $db->executeS('SELECT * FROM `'._DB_PREFIX_.'module` m WHERE `name` NOT IN ('.implode(',', $arr_native_modules).') ');
|
return $db->executeS('SELECT * FROM `'._DB_PREFIX_.'module` m WHERE `name` NOT IN ('.implode(',', $arr_native_modules).') ');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getNativeModuleList()
|
||||||
|
{
|
||||||
|
$module_list_xml = _PS_ROOT_DIR_.self::CACHE_FILE_MODULES_LIST;
|
||||||
|
$native_modules = simplexml_load_file($module_list_xml);
|
||||||
|
$native_modules = $native_modules->modules;
|
||||||
|
$modules = array();
|
||||||
|
|
||||||
|
foreach ($native_modules as $native_modules_type)
|
||||||
|
if (in_array($native_modules_type['type'], array('native', 'partner')))
|
||||||
|
{
|
||||||
|
foreach ($native_modules_type->module as $module)
|
||||||
|
$modules[] = $module['name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $modules;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return installed modules
|
* Return installed modules
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -134,9 +134,48 @@ class AdminPerformanceControllerCore extends AdminController
|
|||||||
$this->fields_value['smarty_console_key'] = Configuration::get('PS_SMARTY_CONSOLE_KEY');
|
$this->fields_value['smarty_console_key'] = Configuration::get('PS_SMARTY_CONSOLE_KEY');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function initFieldsetFeaturesDetachables()
|
public function initFieldsetDebugMode()
|
||||||
{
|
{
|
||||||
$this->fields_form[1]['form'] = array(
|
$this->fields_form[1]['form'] = array(
|
||||||
|
'legend' => array(
|
||||||
|
'title' => $this->l('Debug mode'),
|
||||||
|
'image' => '../img/admin/prefs.gif'
|
||||||
|
),
|
||||||
|
'input' => array(
|
||||||
|
array(
|
||||||
|
'type' => 'radio',
|
||||||
|
'label' => $this->l('Disable non PrestaShop modules'),
|
||||||
|
'name' => 'native_module',
|
||||||
|
'class' => 't',
|
||||||
|
'is_bool' => true,
|
||||||
|
'values' => array(
|
||||||
|
array(
|
||||||
|
'id' => 'native_module_on',
|
||||||
|
'value' => 1,
|
||||||
|
'label' => $this->l('Enabled')
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'id' => 'native_module_off',
|
||||||
|
'value' => 0,
|
||||||
|
'label' => $this->l('Disabled')
|
||||||
|
)
|
||||||
|
),
|
||||||
|
'desc' => $this->l('Enable or disable non PrestaShop Modules.')
|
||||||
|
),
|
||||||
|
),
|
||||||
|
'submit' => array(
|
||||||
|
'title' => $this->l(' Save '),
|
||||||
|
'class' => 'button'
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->fields_value['native_module'] = Configuration::get('PS_DISABLE_NON_NATIVE_MODULE');
|
||||||
|
$this->fields_value['debug_mode'] = Configuration::get('PS_DEBUG_MODE');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function initFieldsetFeaturesDetachables()
|
||||||
|
{
|
||||||
|
$this->fields_form[2]['form'] = array(
|
||||||
'legend' => array(
|
'legend' => array(
|
||||||
'title' => $this->l('Optional features'),
|
'title' => $this->l('Optional features'),
|
||||||
'image' => '../img/admin/tab-plugins.gif'
|
'image' => '../img/admin/tab-plugins.gif'
|
||||||
@@ -197,7 +236,7 @@ class AdminPerformanceControllerCore extends AdminController
|
|||||||
|
|
||||||
public function initFieldsetCCC()
|
public function initFieldsetCCC()
|
||||||
{
|
{
|
||||||
$this->fields_form[2]['form'] = array(
|
$this->fields_form[3]['form'] = array(
|
||||||
'legend' => array(
|
'legend' => array(
|
||||||
'title' => $this->l('CCC (Combine, Compress and Cache)'),
|
'title' => $this->l('CCC (Combine, Compress and Cache)'),
|
||||||
'image' => '../img/admin/arrow_in.png'
|
'image' => '../img/admin/arrow_in.png'
|
||||||
@@ -317,7 +356,7 @@ class AdminPerformanceControllerCore extends AdminController
|
|||||||
|
|
||||||
public function initFieldsetMediaServer()
|
public function initFieldsetMediaServer()
|
||||||
{
|
{
|
||||||
$this->fields_form[3]['form'] = array(
|
$this->fields_form[4]['form'] = array(
|
||||||
'legend' => array(
|
'legend' => array(
|
||||||
'title' => $this->l('Media servers (use only with CCC)'),
|
'title' => $this->l('Media servers (use only with CCC)'),
|
||||||
'image' => '../img/admin/subdomain.gif'
|
'image' => '../img/admin/subdomain.gif'
|
||||||
@@ -359,7 +398,7 @@ class AdminPerformanceControllerCore extends AdminController
|
|||||||
|
|
||||||
public function initFieldsetCiphering()
|
public function initFieldsetCiphering()
|
||||||
{
|
{
|
||||||
$this->fields_form[4]['form'] = array(
|
$this->fields_form[5]['form'] = array(
|
||||||
'legend' => array(
|
'legend' => array(
|
||||||
'title' => $this->l('Ciphering'),
|
'title' => $this->l('Ciphering'),
|
||||||
'image' => '../img/admin/computer_key.png'
|
'image' => '../img/admin/computer_key.png'
|
||||||
@@ -416,7 +455,7 @@ class AdminPerformanceControllerCore extends AdminController
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->fields_form[5]['form'] = array(
|
$this->fields_form[6]['form'] = array(
|
||||||
'legend' => array(
|
'legend' => array(
|
||||||
'title' => $this->l('Caching'),
|
'title' => $this->l('Caching'),
|
||||||
'image' => '../img/admin/computer_key.png'
|
'image' => '../img/admin/computer_key.png'
|
||||||
@@ -483,11 +522,12 @@ class AdminPerformanceControllerCore extends AdminController
|
|||||||
{
|
{
|
||||||
// Initialize fieldset for a form
|
// Initialize fieldset for a form
|
||||||
$this->initFieldsetSmarty();
|
$this->initFieldsetSmarty();
|
||||||
|
$this->initFieldsetDebugMode();
|
||||||
$this->initFieldsetFeaturesDetachables();
|
$this->initFieldsetFeaturesDetachables();
|
||||||
$this->initFieldsetCCC();
|
$this->initFieldsetCCC();
|
||||||
$this->initFieldsetMediaServer();
|
$this->initFieldsetMediaServer();
|
||||||
$this->initFieldsetCiphering();
|
$this->initFieldsetCiphering();
|
||||||
$this->initFieldsetCaching();
|
$this->initFieldsetCaching();
|
||||||
|
|
||||||
// Activate multiple fieldset
|
// Activate multiple fieldset
|
||||||
$this->multiple_fieldsets = true;
|
$this->multiple_fieldsets = true;
|
||||||
@@ -799,6 +839,11 @@ class AdminPerformanceControllerCore extends AdminController
|
|||||||
Autoload::getInstance()->generateIndex();
|
Autoload::getInstance()->generateIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Tools::isSubmit('submitAddconfiguration'))
|
||||||
|
{
|
||||||
|
Configuration::updateGlobalValue('PS_DISABLE_NON_NATIVE_MODULE', (int)Tools::getValue('native_module'));
|
||||||
|
}
|
||||||
|
|
||||||
if ($redirectAdmin && (!isset($this->errors) || !count($this->errors)))
|
if ($redirectAdmin && (!isset($this->errors) || !count($this->errors)))
|
||||||
{
|
{
|
||||||
Hook::exec('action'.get_class($this).ucfirst($this->action).'After', array('controller' => $this, 'return' => ''));
|
Hook::exec('action'.get_class($this).ucfirst($this->action).'After', array('controller' => $this, 'return' => ''));
|
||||||
|
|||||||
Reference in New Issue
Block a user