Grido@master
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo
  • Download

Namespaces

  • Grido
    • Components
      • Actions
      • Columns
      • Filters
    • DataSources
    • PropertyAccessors
    • Translations

Classes

  • Grido\Translations\FileTranslator
 1 <?php
 2 
 3 /**
 4  * This file is part of the Grido (https://github.com/o5/grido)
 5  *
 6  * Copyright (c) 2011 Petr Bugyík (http://petr.bugyik.cz)
 7  *
 8  * For the full copyright and license information, please view
 9  * the file LICENSE.md that was distributed with this source code.
10  */
11 
12 namespace Grido\Components\Filters;
13 
14 /**
15  * Number input filter.
16  *
17  * @package     Grido
18  * @subpackage  Components\Filters
19  * @author      Petr Bugyík
20  */
21 class Number extends Text
22 {
23     /** @var string */
24     protected $condition;
25 
26     /**
27      * @return \Nette\Forms\Controls\TextInput
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      * @param string $value
41      * @return Condition
42      * @throws \Exception
43      * @internal
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 
Grido@master API documentation generated by ApiGen