From c0913acf923d3234920c88f26735e5ed9d713de4 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 15 Dec 2010 10:58:45 +0000 Subject: [PATCH] New: add directory for external module and other customization --- htdocs/admin/modules.php | 18 ++++++++++++++++-- htdocs/core/class/translate.class.php | 5 ++++- htdocs/lib/functions.lib.php | 9 ++++++++- htdocs/master.inc.php | 3 ++- 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index fc50cef2015..23c6e0fc606 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -369,7 +369,14 @@ if ($mode != 4) { if (preg_match('/^([^@]+)@([^@]+)$/i',$urlpage,$regs)) { - print ''.img_picto($langs->trans("Setup"),"setup").' '; + if (file_exists(DOL_URL_ROOT.'/'.$regs[2].'/admin/'.$regs[1])) + { + print ''.img_picto($langs->trans("Setup"),"setup").' '; + } + else + { + print ''.img_picto($langs->trans("Setup"),"setup").' '; + } } else { @@ -381,7 +388,14 @@ if ($mode != 4) } else if (preg_match('/^([^@]+)@([^@]+)$/i',$objMod->config_page_url,$regs)) { - print ''.img_picto($langs->trans("Setup"),"setup").''; + if (file_exists(DOL_URL_ROOT.'/'.$regs[2].'/admin/'.$regs[1])) + { + print ''.img_picto($langs->trans("Setup"),"setup").''; + } + else + { + print ''.img_picto($langs->trans("Setup"),"setup").''; + } } else { diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 9009e708f09..afa35333a72 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -179,8 +179,11 @@ class Translate { foreach($this->dir as $searchdir) { - // If $domain is "file@module" instead of "file" then we look for module lang file htdocs/module/langs/code_CODE/file.lang + // If $domain is "file@module" instead of "file" then we look for module lang file + // in htdocs/custom/modules/mymodule/langs/code_CODE/file.lang + // and in htdocs/mymodule/langs/code_CODE/file.lang for backward compatibility // instead of file htdocs/langs/code_CODE/filelang + if (preg_match('/custom$/i',$searchdir)) $searchdir = $searchdir . "/modules"; if (preg_match('/@/',$domain)) $searchdir = $searchdir."/".(!empty($modulename)?$modulename:$newdomain)."/langs"; else $searchdir=$searchdir."/langs"; diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index cf0ba313557..3c54d3b371f 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -1137,7 +1137,14 @@ function img_object($alt, $object, $cssclass='') if (preg_match('/^([^@]+)@([^@]+)$/i',$object,$regs)) { - return ''.dol_escape_htmltag($alt).''; + if (file_exists(DOL_URL_ROOT.'/'.$regs[2].'/img/object_'.$regs[1])) + { + return ''.dol_escape_htmltag($alt).''; + } + else + { + return ''.dol_escape_htmltag($alt).''; + } } return ''.dol_escape_htmltag($alt).''; diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php index 0c726232467..922692c8864 100644 --- a/htdocs/master.inc.php +++ b/htdocs/master.inc.php @@ -104,7 +104,8 @@ if (empty($dolibarr_main_data_root)) define('DOL_DOCUMENT_ROOT', $dolibarr_main_document_root); // Filesystem core php (htdocs) define('DOL_DATA_ROOT', $dolibarr_main_data_root); // Filesystem data (documents) define('DOL_CLASS_PATH', 'class/'); // Filesystem path to class dir -define('DOL_CUSTOM_PATH', $dolibarr_main_document_root.'/custom'); // Filesystem path to custom dir +define('DOL_CUSTOM_PATH', DOL_DOCUMENT_ROOT . '/custom'); // Filesystem path to custom dir +define('DOL_EXTMODULE_ROOT', DOL_CUSTOM_PATH . '/modules'); // Filesystem path to external modules dir // If dolibarr_main_url_root = auto (Hidden feature for developers only), we try to forge it. if ($dolibarr_main_url_root == 'auto' && ! empty($_SERVER["SCRIPT_URL"]) && ! empty($_SERVER["SCRIPT_URI"])) {