From dd8defde4b1f44f56cf9ef3c3b6b435a70faaae9 Mon Sep 17 00:00:00 2001 From: anuko Date: Sun, 5 Feb 2017 19:53:32 +0000 Subject: [PATCH] Refactored FloatField.class.php. --- WEB-INF/lib/form/FloatField.class.php | 81 +++++++++++++-------------- WEB-INF/templates/footer.tpl | 2 +- 2 files changed, 41 insertions(+), 42 deletions(-) diff --git a/WEB-INF/lib/form/FloatField.class.php b/WEB-INF/lib/form/FloatField.class.php index 14c30df2..9cd38bfd 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 $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 delimiter + 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); + return null; + } } diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index c07d43bb..81a80927 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.9.36.3565 | Copyright © Anuko | +  Anuko Time Tracker 1.9.36.3566 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} -- 2.20.1