mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-12-23 00:43:48 +01:00
LSattr_html::valueWithUnit : add translate_labels, store_integer and round_down parameters
This commit is contained in:
parent
3659031ed2
commit
1fe65e0d6b
2 changed files with 40 additions and 4 deletions
|
@ -11,9 +11,12 @@
|
|||
'[facteur2]' => '[label unit2]',
|
||||
[...]
|
||||
),
|
||||
'translate_labels' => [booléen],
|
||||
'nb_decimals' => [number of decimals],
|
||||
'dec_point' => '[decimals point]',
|
||||
'thousands_sep' => '[thousands separator]'
|
||||
'thousands_sep' => '[thousands separator]',
|
||||
'store_integer' => [booléen],
|
||||
'round_down' => [booléen],
|
||||
)
|
||||
),]]>
|
||||
...
|
||||
|
@ -29,6 +32,13 @@
|
|||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>translate_labels</term>
|
||||
<listitem>
|
||||
<simpara>Booléen permettant d'activer/désactiver la traduction des labels (Par defaut : <literal>Vrai</literal>).</simpara>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>nb_decimals</term>
|
||||
<listitem>
|
||||
|
@ -50,6 +60,22 @@
|
|||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>store_integer</term>
|
||||
<listitem>
|
||||
<simpara>Booléen permettant d'activer/désactiver le stockage de valeurs entières (Par defaut :
|
||||
<literal>Vrai</literal>).</simpara>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>round_down</term>
|
||||
<listitem>
|
||||
<simpara>Booléen permettant d'arrondir à l'entier inférieur (et non à l'entier supérieur
|
||||
par défaut) en cas de stockage de valeurs entières.</simpara>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
|
||||
</sect4>
|
||||
|
|
|
@ -44,7 +44,7 @@ class LSformElement_valueWithUnit extends LSformElement {
|
|||
if (isset($this -> params['html_options']['units']) && is_array($this -> params['html_options']['units'])) {
|
||||
$units=array();
|
||||
foreach($this -> params['html_options']['units'] as $sill => $label) {
|
||||
$units[$sill]=__($label);
|
||||
$units[$sill]=((!isset($this -> params['html_options']['translate_labels']) || $this -> params['html_options']['translate_labels'])?__($label):$label);
|
||||
}
|
||||
krsort($units);
|
||||
return $units;
|
||||
|
@ -162,8 +162,18 @@ class LSformElement_valueWithUnit extends LSformElement {
|
|||
$f = 1;
|
||||
if (isset($_POST[$this -> name.'_unitFact'][$key]) && ($_POST[$this -> name.'_unitFact'][$key]!=1)) {
|
||||
$f = $_POST[$this -> name.'_unitFact'][$key];
|
||||
}
|
||||
$return[$this -> name][$key] = ($val*$f);
|
||||
}
|
||||
if (isset($this -> params['html_options']['store_integer']) && $this -> params['html_options']['store_integer']) {
|
||||
if (isset($this -> params['html_options']['round_down']) && $this -> params['html_options']['round_down']) {
|
||||
$return[$this -> name][$key] = floor($val*$f);
|
||||
}
|
||||
else {
|
||||
$return[$this -> name][$key] = ceil($val*$f);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$return[$this -> name][$key] = ($val*$f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue