X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=WEB-INF%2Flib%2Fform%2FFloatField.class.php;h=6bbfd64c38f687b4b650c151b245eb9660ca8236;hb=e1703495130c8ed88fe210f50a2a6b453b3c566b;hp=46bdb6d6f5f9d4c1904bd09bb3b4d4a9df8d3dbb;hpb=33399ff6a8bdfe9b989810dafe9c4dbf3cf3b685;p=timetracker.git diff --git a/WEB-INF/lib/form/FloatField.class.php b/WEB-INF/lib/form/FloatField.class.php index 46bdb6d6..6bbfd64c 100644 --- a/WEB-INF/lib/form/FloatField.class.php +++ b/WEB-INF/lib/form/FloatField.class.php @@ -27,47 +27,45 @@ // +----------------------------------------------------------------------+ import('form.TextField'); - + class FloatField extends TextField { - var $mDelimiter = '.'; - var $mFFormat; - var $cClassName = "FloatField"; - function FloatField($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 localize($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; + } }