1 <?php
2
3 4 5 6 7 8 9 10
11
12 namespace Grido\Components\Filters;
13
14 15 16 17 18 19 20
21 class Number extends Text
22 {
23
24 protected $condition;
25
26 27 28
29 protected function getFormControl()
30 {
31 $control = parent::getFormControl();
32 $hint = 'Grido.HintNumber';
33 $control->getControlPrototype()->title = sprintf($this->translate($hint), rand(1, 9));
34 $control->getControlPrototype()->class[] = 'number';
35
36 return $control;
37 }
38
39 40 41 42 43 44
45 public function __getCondition($value)
46 {
47 $condition = parent::__getCondition($value);
48
49 if ($condition === NULL) {
50 $condition = Condition::setupEmpty();
51
52 if (preg_match('/(<>|[<|>]=?)?([-0-9,|.]+)/', $value, $matches)) {
53 $value = str_replace(',', '.', $matches[2]);
54 $operator = $matches[1]
55 ? $matches[1]
56 : '=';
57
58 $condition = Condition::setup($this->getColumn(), $operator . ' ?', $value);
59 }
60 }
61
62 return $condition;
63 }
64 }
65