@@ -27,58 +27,58 @@ |
||
| 27 | 27 | |
| 28 | 28 | class DataType_Integer extends DataType_Base { |
| 29 | 29 | |
| 30 | - public function getFormCode(): string { |
|
| 31 | - $min = null; |
|
| 32 | - $max = null; |
|
| 33 | - $unit = null; |
|
| 34 | - |
|
| 35 | - if (is_array($this->getDatatypeParams())) { |
|
| 36 | - $array = $this->getDatatypeParams(); |
|
| 37 | - |
|
| 38 | - if (isset($array['min'])) { |
|
| 39 | - $min = (int) $array['min']; |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - if (isset($array['max'])) { |
|
| 43 | - $max = (int) $array['max']; |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - if (isset($array['unit'])) { |
|
| 47 | - $unit = $array['unit']; |
|
| 48 | - } |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - return "<input type=\"number\" name=\"" . $this->getInputName() . "\" value=\"" . $this->getValue() . "\" step=\"1\"" . ($min != null ? " min=\"" . $min . "\"" : "") . "" . ($max != null ? " max=\"" . $max . "\"" : "") . " class=\"form-control\" />" . ($unit != null ? " " . $unit : ""); |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - public function validate(string $value): bool { |
|
| 55 | - $min = null; |
|
| 56 | - $max = null; |
|
| 57 | - $unit = null; |
|
| 58 | - |
|
| 59 | - if (is_array($this->getDatatypeParams())) { |
|
| 60 | - $array = $this->getDatatypeParams(); |
|
| 61 | - |
|
| 62 | - if (isset($array['min'])) { |
|
| 63 | - $min = (int) $array['min']; |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - if (isset($array['max'])) { |
|
| 67 | - $max = (int) $array['max']; |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - if (isset($array['unit'])) { |
|
| 71 | - $unit = $array['unit']; |
|
| 72 | - } |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - $val = new Validator_Int(); |
|
| 76 | - return $val->isValide($value) && ($min == null || $value >= $min); |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - protected function saveAsync($value) { |
|
| 80 | - Settings::setAsync($this->getKey(), (int) $value); |
|
| 81 | - } |
|
| 30 | + public function getFormCode(): string { |
|
| 31 | + $min = null; |
|
| 32 | + $max = null; |
|
| 33 | + $unit = null; |
|
| 34 | + |
|
| 35 | + if (is_array($this->getDatatypeParams())) { |
|
| 36 | + $array = $this->getDatatypeParams(); |
|
| 37 | + |
|
| 38 | + if (isset($array['min'])) { |
|
| 39 | + $min = (int) $array['min']; |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + if (isset($array['max'])) { |
|
| 43 | + $max = (int) $array['max']; |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + if (isset($array['unit'])) { |
|
| 47 | + $unit = $array['unit']; |
|
| 48 | + } |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + return "<input type=\"number\" name=\"" . $this->getInputName() . "\" value=\"" . $this->getValue() . "\" step=\"1\"" . ($min != null ? " min=\"" . $min . "\"" : "") . "" . ($max != null ? " max=\"" . $max . "\"" : "") . " class=\"form-control\" />" . ($unit != null ? " " . $unit : ""); |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + public function validate(string $value): bool { |
|
| 55 | + $min = null; |
|
| 56 | + $max = null; |
|
| 57 | + $unit = null; |
|
| 58 | + |
|
| 59 | + if (is_array($this->getDatatypeParams())) { |
|
| 60 | + $array = $this->getDatatypeParams(); |
|
| 61 | + |
|
| 62 | + if (isset($array['min'])) { |
|
| 63 | + $min = (int) $array['min']; |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + if (isset($array['max'])) { |
|
| 67 | + $max = (int) $array['max']; |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + if (isset($array['unit'])) { |
|
| 71 | + $unit = $array['unit']; |
|
| 72 | + } |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + $val = new Validator_Int(); |
|
| 76 | + return $val->isValide($value) && ($min == null || $value >= $min); |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + protected function saveAsync($value) { |
|
| 80 | + Settings::setAsync($this->getKey(), (int) $value); |
|
| 81 | + } |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | ?> |