From 1d600dd2f84105835e0513eaf0153c2f10a42ace Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 2 Aug 2009 17:13:59 +0000 Subject: [PATCH] Qual: Usage of smarty templates by some modules is now cleaner. --- dev/skeletons/modMyModule.class.php | 6 +++--- htdocs/admin/produit.php | 14 -------------- htdocs/core/conf.class.php | 9 ++++++++- htdocs/includes/modules/modDroitPret.class.php | 14 ++++---------- htdocs/includes/modules/modEditeur.class.php | 8 +++++--- htdocs/main.inc.php | 7 +++---- 6 files changed, 23 insertions(+), 35 deletions(-) diff --git a/dev/skeletons/modMyModule.class.php b/dev/skeletons/modMyModule.class.php index 80fe076c75f..2ef4f12efbe 100644 --- a/dev/skeletons/modMyModule.class.php +++ b/dev/skeletons/modMyModule.class.php @@ -88,8 +88,8 @@ class modMyModule extends DolibarrModules // Constants $this->const = array(); // List of particular constants to add when module is enabled - //Example: $this->const=array(0=>array('MODULE_MY_NEW_CONST1','chaine','myvalue','This is a constant to add',0), - // 1=>array('MODULE_MY_NEW_CONST2','chaine','myvalue','This is another constant to add',0) ); + //Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',0), + // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0) ); // Array to add new pages in new tabs $this->tabs = array('entity:Title:@mymodule:/mymodule/mynewtab.php?id=__ID__'); @@ -132,7 +132,7 @@ class modMyModule extends DolibarrModules // Main menu entries - $this->menu = array(); // List of menus to add + $this->menus = array(); // List of menus to add $r=0; // Add here entries to declare new menus diff --git a/htdocs/admin/produit.php b/htdocs/admin/produit.php index f18664ca5f6..294b68e1ef5 100644 --- a/htdocs/admin/produit.php +++ b/htdocs/admin/produit.php @@ -104,20 +104,6 @@ else if ($_POST["action"] == 'viewProdDescInForm') { dolibarr_set_const($db, "PRODUIT_DESC_IN_FORM", $_POST["activate_viewProdDescInForm"],'chaine',0,'',$conf->entity); } -/* -else if ($_POST["action"] == 'confirmDeleteProdLineInForm') -{ - dolibarr_set_const($db, "PRODUIT_CONFIRM_DELETE_LINE", $_POST["activate_confirmDeleteProdLineInForm"],'chaine',0,'',$conf->entity); -} -*/ -else if ($_POST["action"] == 'ProductCanvasAbility') -{ - // Create temp directory for smarty - if (! empty($dolibarr_smarty_compile)) create_exdir($dolibarr_smarty_compile); - if (! empty($dolibarr_smarty_cache)) create_exdir($dolibarr_smarty_cache); - - dolibarr_set_const($db, "MAIN_NEED_SMARTY", $_POST["ProductCanvasAbility"],'chaine',0,'',$conf->entity); -} else if ($_POST["action"] == 'usesearchtoselectproduct') { dolibarr_set_const($db, "PRODUIT_USE_SEARCH_TO_SELECT", $_POST["activate_usesearchtoselectproduct"],'chaine',0,'',$conf->entity); diff --git a/htdocs/core/conf.class.php b/htdocs/core/conf.class.php index 182023c98eb..bff3baace8a 100644 --- a/htdocs/core/conf.class.php +++ b/htdocs/core/conf.class.php @@ -53,6 +53,7 @@ class Conf var $css_modules=array(); var $tabs_modules=array(); + var $need_smarty=array(); var $modules=array(); var $logbuffer=array(); @@ -139,13 +140,19 @@ class Conf //print '->'.$module.'->'.$dir_name.' = '.$this->$module->$dir_name.'
'; } } + // If this is constant for a smarty need by a module + if (eregi('^MAIN_MODULE_([A-Z_]+)_NEEDSMARTY$',$key) && $value) + { + $module=strtolower($reg[1]); + // Add this module in list of module that need smarty + $this->need_smarty[]=$module; + } // If this is a module constant if (eregi('^MAIN_MODULE_([A-Z]+)$',$key,$reg) && $value) { $module=strtolower($reg[1]); //print "Module ".$module." is enabled
\n"; $this->$module->enabled=true; - // Add this module in list of enabled modules $this->modules[]=$module; } diff --git a/htdocs/includes/modules/modDroitPret.class.php b/htdocs/includes/modules/modDroitPret.class.php index 04974b92a01..ad049d31987 100644 --- a/htdocs/includes/modules/modDroitPret.class.php +++ b/htdocs/includes/modules/modDroitPret.class.php @@ -73,16 +73,10 @@ class modDroitPret extends DolibarrModules // Config pages $this->config_page_url = array("droitpret.php"); - // Constantes - $this->const=array(); - $r=0; - - $r++; - $this->const[$r][0] = "MAIN_NEED_SMARTY"; - $this->const[$r][1] = "chaine"; - $this->const[$r][2] = 1; - $this->const[$r][3] = 'Need smarty'; - $this->const[$r][4] = 0; + // Constants + //Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',0), + // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0) ); + $this->const=array(1=>array('MAIN_MODULE_DROITPRET_NEEDSMARTY',"chaine",1,'Need smarty',0)); // Boxes $this->boxes = array(); diff --git a/htdocs/includes/modules/modEditeur.class.php b/htdocs/includes/modules/modEditeur.class.php index e294d993a93..c39d5e5582e 100644 --- a/htdocs/includes/modules/modEditeur.class.php +++ b/htdocs/includes/modules/modEditeur.class.php @@ -75,10 +75,12 @@ class modEditeur extends DolibarrModules $this->needtotopmenu = array(); $this->langfiles = array("orders","bills","companies"); - // Constantes - $this->const=array(1=>array('MAIN_NEED_SMARTY','chaine',1,'Need smarty',0)); + // Constants + //Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',0), + // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0) ); + $this->const=array(1=>array('MAIN_MODULE_DROITPRET_NEEDSMARTY','chaine',1,'Need smarty',0)); - // Boites + // Boxes $this->boxes = array(); // Permissions diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index fa20e709aa1..4de3eb60fa9 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -569,11 +569,10 @@ else // Si utilisateur externe } -// For modules using Smarty -if ($conf->global->MAIN_NEED_SMARTY) +// If there is at least one module using Smarty +if (sizeof($conf->need_smarty) > 0) { - // SMARTY - // Definit dans le fichier de conf + // SMARTY (Defined into conf file) // $dolibarr_smarty_libs_dir="/home/www/dolibarr/external-libs/smarty/libs/"; // $dolibarr_smarty_compile="/home/www/dolibarr/documents/smarty/templates/temp"; // $dolibarr_smarty_cache="/home/www/dolibarr/documents/smarty/cache/temp";