X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=WEB-INF%2Flib%2Fform%2FFloatField.class.php;h=c4e9d9ef7f894a588c6cca3e4d0a18ae16468a1a;hb=ac5189157ef60820dd125400baee9f408a9ba2ea;hp=14c30df24e537b585465809c4d477f6dedeacbc7;hpb=a07b6f8bccda226991ced6fe25f1c9c508e423e5;p=timetracker.git diff --git a/WEB-INF/lib/form/FloatField.class.php b/WEB-INF/lib/form/FloatField.class.php index 14c30df2..c4e9d9ef 100644 --- a/WEB-INF/lib/form/FloatField.class.php +++ b/WEB-INF/lib/form/FloatField.class.php @@ -27,47 +27,46 @@ // +----------------------------------------------------------------------+ import('form.TextField'); - + class FloatField extends TextField { - var $mDelimiter = '.'; - var $mFFormat; - var $cClassName = "FloatField"; - function __construct($name) { - $this->mName = $name; - } - - function setLocalization($i18n) { - FormElement::setLocalization($i18n); - global $user; - $this->mDelimiter = $user->decimal_mark; - } - - function setFormat($format) { - $this->mFFormat = $format; - } - - function setValue($value) { - if (isset($this->mFFormat) && isset($value) && strlen($value)) { - $value = str_replace($this->mDelimiter,".",$value); - $value = sprintf("%".$this->mFFormat."f",$value); - $value = str_replace(".",$this->mDelimiter,$value); - } - $this->mValue = $value; - } - - function setValueSafe($value) { - // '.' to ',' , apply localisation - if (strlen($value)>0) - $this->mValue = str_replace(".",$this->mDelimiter,$value); - } - - function getValueSafe() { - // ',' to '.' - if (strlen($this->mValue)>0) { - return str_replace($this->mDelimiter,".",$this->mValue); - } else { - return null; - } - } + var $mDelimiter = '.'; + var $mFFormat; + var $class = 'FloatField'; + + function __construct($name) { + $this->name = $name; + } + + function setLocalization($i18n) { + FormElement::setLocalization($i18n); + global $user; + $this->mDelimiter = $user->decimal_mark; + } + + function setFormat($format) { + $this->mFFormat = $format; + } + + function setValue($value) { + if (isset($this->mFFormat) && isset($value) && strlen($value)) { + $value = str_replace($this->mDelimiter, '.', $value); + $value = sprintf('%'.$this->mFFormat.'f', $value); + $value = str_replace('.', $this->mDelimiter, $value); + } + $this->value = $value; + } + + function setValueSafe($value) { + // '.' to ',' , apply delimiter + if (strlen($value) > 0) + $this->value = str_replace('.', $this->mDelimiter, $value); + } + + function getValueSafe() { + // ',' to '.' + if (strlen($this->value) > 0) + return str_replace($this->mDelimiter, '.', $this->value); + return null; + } }