From 2dabf0e18514b0e704f6dcb786dea7781e2d7597 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 23 Feb 2012 16:20:15 +0100 Subject: [PATCH] Fix: possibility to defined a specific path --- dev/skeletons/modMyModule.class.php | 12 +++++++----- htdocs/core/class/conf.class.php | 11 +++++++---- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/dev/skeletons/modMyModule.class.php b/dev/skeletons/modMyModule.class.php index 41120bfe5e1..06a1e79692f 100644 --- a/dev/skeletons/modMyModule.class.php +++ b/dev/skeletons/modMyModule.class.php @@ -68,12 +68,14 @@ class modMyModule extends DolibarrModules // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' $this->picto='generic'; - // Defined all module parts (triggers, login, substitutions, menus, etc...) (0=disable,1=enable) + // Defined all module parts (triggers, login, substitutions, menus, css, etc...) (0=disable,1=enable default path, '/mymodule/path/to/parts' for specific path) $this->module_parts = array(); - //$this->module_parts = array('triggers' => 1, - // 'login' => 0, - // 'substitutions' => 0, - // 'menus' => 0); + //$this->module_parts = array( 'triggers' => 1, + // 'login' => 0, + // 'substitutions' => '/specific/path/in/your/module', + // 'menus' => 0 + // 'css' => '/css/mymodule.css.php' + // 'barcode => /path/to/your/parts'); // Data directories to create when module is enabled. // Example: this->dirs = array("/mymodule/temp"); diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index af5eb08a77b..6e757c9d7da 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -143,12 +143,13 @@ class Conf if ($value && preg_match('/^MAIN_MODULE_/',$key)) { // If this is constant for a css file activated by a module + // TODO obsolete (see generic parts) if (preg_match('/^MAIN_MODULE_([A-Z_]+)_CSS$/i',$key,$reg)) { - $modulename = strtolower($reg[1]); - $this->css_modules[$modulename]=$value; + $modulename = strtolower($reg[1]); + $this->css_modules[$modulename]=$value; } - // If this is constant for a new tab page activated by a module. + // If this is constant for a new tab page activated by a module. elseif (preg_match('/^MAIN_MODULE_([A-Z_]+)_TABS_/i',$key)) { $params=explode(':',$value,2); @@ -171,6 +172,7 @@ class Conf $this->sms_engine_modules[$module]=$module; // Add this module in list of modules that provide SMS } // If this is constant for triggers activated by a module + // TODO obsolete (see generic parts) elseif (preg_match('/^MAIN_MODULE_([A-Z_]+)_BARCODE$/i',$key,$reg)) { $modulename = strtolower($reg[1]); @@ -182,7 +184,8 @@ class Conf $modulename = strtolower($reg[1]); $partname = strtolower($reg[2]); $varname = $partname.'_modules'; - $this->$varname = array_merge($this->$varname, array($modulename => '/'.$modulename.'/core/'.$partname.'/')); + $value = ($value === 1 ? '/'.$modulename.'/core/'.$partname.'/' : '/'.$modulename.'/'.$value); + $this->$varname = array_merge($this->$varname, array($modulename => $value)); } // TODO All of this part could be mutualized into one generic part