diff --git a/htdocs/core/boxes/modules_boxes.php b/htdocs/core/boxes/modules_boxes.php index c8ead22a95e..6877e50419a 100644 --- a/htdocs/core/boxes/modules_boxes.php +++ b/htdocs/core/boxes/modules_boxes.php @@ -103,32 +103,37 @@ class ModeleBoxes // Can't be abstract as it is instantiated to build "empty" bo public $box_order; /** - * @var int User ID + * @var int User ID */ public $fk_user; /** - * @var string Source file + * @var string Source file */ public $sourcefile; /** - * @var string Class name + * @var string Class name */ public $class; /** - * @var string ID + * @var string ID */ public $box_id; /** - * @var string Alphanumeric ID + * @var string Box language file if it needs a specific language file. + */ + public $lang; + + /** + * @var string Alphanumeric ID */ public $boxcode; /** - * @var string Note + * @var string Note */ public $note; diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 590859a1d24..37e7c6c538d 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -1211,7 +1211,7 @@ class FormOther /** - * Get array with HTML tabs with boxes of a particular area including personalized choices of user. + * Get array with HTML tabs with widgets/boxes of a particular area including personalized choices of user. * Class 'Form' must be known. * * @param User $user Object User @@ -1237,8 +1237,14 @@ class FormOther if (empty($user->conf->$confuserzone) || $box->fk_user == $user->id) { $boxidactivatedforuser[$box->id] = $box->id; // We keep only boxes to show for user } + + if (!empty($box->lang)) { + $langs->loadLangs(array($box->lang)); + $box->boxlabel = $langs->transnoentitiesnoconv($box->boxlabel); + } } + // Define selectboxlist $arrayboxtoactivatelabel = array(); if (!empty($user->conf->$confuserzone)) { @@ -1248,6 +1254,7 @@ class FormOther if (!empty($boxidactivatedforuser[$box->id])) { continue; // Already visible for user } + $label = $langs->transnoentitiesnoconv($box->boxlabel); //if (preg_match('/graph/',$box->class)) $label.=' ('.$langs->trans("Graph").')'; if (preg_match('/graph/', $box->class) && $conf->browser->layout != 'phone') { diff --git a/htdocs/core/class/infobox.class.php b/htdocs/core/class/infobox.class.php index 73dc687afd5..e8b8b11d7da 100644 --- a/htdocs/core/class/infobox.class.php +++ b/htdocs/core/class/infobox.class.php @@ -141,7 +141,7 @@ class InfoBox // TODO PERF Do not make "dol_include_once" here, nor "new" later. This means, we must store a 'depends' field to store modules list, then // the "enabled" condition for modules forbidden for external users and the depends condition can be done. - // Goal is to avoid making a "new" done for each boxes returned by select. + // Goal is to avoid to make a "new" done for each boxes returned by select. dol_include_once($relsourcefile); if (class_exists($boxname)) { $box = new $boxname($dbs, $obj->note); // Constructor may set properties like box->enabled. obj->note is note into box def, not user params. diff --git a/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php b/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php index 90321797398..0a1eca79027 100644 --- a/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php +++ b/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php @@ -50,7 +50,12 @@ class mymodulewidget1 extends ModeleBoxes /** * @var string Box label (in configuration page) */ - public $boxlabel; + public $boxlabel = 'MyWidget'; + + /** + * @var string Box language file if it needs a specific language file. + */ + public $lang = 'mymodule@mymodule'; /** * @var string[] Module dependencies @@ -71,14 +76,10 @@ class mymodulewidget1 extends ModeleBoxes */ public function __construct(DoliDB $db, $param = '') { - global $user, $conf, $langs; - // Translations - $langs->loadLangs(array("boxes", "mymodule@mymodule")); + global $user; parent::__construct($db, $param); - $this->boxlabel = $langs->transnoentitiesnoconv("MyWidget"); - $this->param = $param; // Condition when module is enabled or not