Skip to content

Commit

Permalink
Merge branch 'develop' into new-ip-fields-on-soe-objects
Browse files Browse the repository at this point in the history
  • Loading branch information
Hystepik authored Sep 19, 2024
2 parents 8979a63 + f00a07e commit b192043
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 14 deletions.
17 changes: 11 additions & 6 deletions htdocs/core/boxes/modules_boxes.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
9 changes: 8 additions & 1 deletion htdocs/core/class/html.formother.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1211,7 +1211,7 @@ public function selectyear($selected = '', $htmlname = 'yearid', $useempty = 0,


/**
* 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
Expand All @@ -1237,8 +1237,14 @@ public static function getBoxesArea($user, $areacode)
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)) {
Expand All @@ -1248,6 +1254,7 @@ public static function getBoxesArea($user, $areacode)
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') {
Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/class/infobox.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public static function listBoxes($dbs, $mode, $zone, $user = null, $excludelist

// 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.
Expand Down
13 changes: 7 additions & 6 deletions htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit b192043

Please sign in to comment.