Overview

Namespaces

  • None
  • PHP
  • Pry
    • Auth
      • Interfaces
    • Config
    • Controller
    • Date
    • Db
    • Feed
      • Abstracts
      • Writers
    • File
      • Decorator
    • Form
      • Element
    • Image
    • Log
      • Writer
    • Net
      • Exception
    • Session
    • Util
    • Validate
      • Validator
    • View

Classes

  • AutoCompleter
  • Checkbox
  • Colorpicker
  • Date
  • DatePicker
  • Email
  • File
  • Hidden
  • Html
  • Ip
  • Mac
  • Multi
  • NumericStepper
  • Password
  • Radio
  • Select
  • Slider
  • Submit
  • Text
  • Textarea
  • Overview
  • Namespace
  • Class
  • Tree
  1: <?php
  2: 
  3: /**
  4:  * Pry Framework
  5:  *
  6:  * LICENSE
  7:  *
  8:  * This source file is subject to the new BSD license that is bundled
  9:  * with this package in the file LICENSE.txt.
 10:  * 
 11:  */
 12: 
 13: namespace Pry\Form\Element;
 14: 
 15: use Pry\Form\Error;
 16: 
 17: /**
 18:  * Element numeric stepper
 19:  * @category Pry
 20:  * @package Form
 21:  * @subpackage Form_Element
 22:  * @version 1.1.0 
 23:  * @author Olivier ROGER <oroger.fr>
 24:  */
 25: class NumericStepper extends Text
 26: {
 27: 
 28:     /**
 29:      * Valeur maxi autorisée
 30:      *
 31:      * @var mixed
 32:      * @access private
 33:      */
 34:     private $max;
 35: 
 36:     /**
 37:      * Valeur mini autorisée
 38:      *
 39:      * @var mixed
 40:      * @access private
 41:      */
 42:     private $min;
 43: 
 44:     /**
 45:      * Valeur de pas
 46:      *
 47:      * @var mixed
 48:      * @access public
 49:      */
 50:     private $step;
 51: 
 52:     /**
 53:      * Valeur de départ
 54:      *
 55:      * @var mixed
 56:      * @access private
 57:      */
 58:     private $start;
 59: 
 60:     /**
 61:      * Chemin vers le sprite contenant les boutons
 62:      * @var string
 63:      */
 64:     private $sprite;
 65: 
 66:     /**
 67:      * Constructeur. Initialise les valeurs par défaut
 68:      *
 69:      * @param string $nom
 70:      * @param Form_Form $form
 71:      */
 72:     public function __construct($nom, $form)
 73:     {
 74:         parent::__construct($nom, $form);
 75:         $this->max       = 99;
 76:         $this->min       = 0;
 77:         $this->step      = 1;
 78:         $this->start     = 0;
 79:         $this->sprite    = 'spinbox-sprite.png';
 80:         $this->container = '';
 81:         $this->value     = $this->start;
 82:     }
 83: 
 84:     /**
 85:      * Défini la valeur max
 86:      *
 87:      * @param mixed $value
 88:      * @access public
 89:      * @return Form_Element_NumericStepper
 90:      */
 91:     public function setMax($value)
 92:     {
 93:         $this->max = $value;
 94:         return $this;
 95:     }
 96: 
 97:     /**
 98:      * Défini la valeur mini
 99:      *
100:      * @param mixed $value
101:      * @access public
102:      * @return Form_Element_NumericStepper
103:      */
104:     public function setMin($value)
105:     {
106:         $this->min = $value;
107:         return $this;
108:     }
109: 
110:     /**
111:      * Défini la valeur de pas
112:      *
113:      * @param mixed $value
114:      * @access public
115:      * @return Form_Element_NumericStepper
116:      */
117:     public function setStep($value)
118:     {
119:         $this->step = $value;
120:         return $this;
121:     }
122: 
123:     /**
124:      * Défini la valeur de départ
125:      *
126:      * @param mixed $value
127:      * @access public
128:      * @return Form_Element_NumericStepper
129:      */
130:     public function startAt($value)
131:     {
132:         $this->startAt($value);
133:         $this->value($value);
134:         return $this;
135:     }
136: 
137:     /**
138:      * Défini le chemin des images des boutons.
139:      * Chemins relatifs à la page web
140:      *
141:      * @param string $up
142:      * @param string $down
143:      * @access public
144:      * @return Form_Element_NumericStepper
145:      */
146:     public function setSprite($path)
147:     {
148:         $this->sprite = $path;
149:         return $this;
150:     }
151: 
152:     /**
153:      * Valide la donnée recue
154:      *
155:      * @param mixed $value
156:      * @access public
157:      * @return boolean
158:      */
159:     public function isValid($value)
160:     {
161:         if (parent::isValid($value))
162:         {
163:             if (!is_numeric($value))
164:             {
165:                 $this->errorMsg = Error::NUMERIC;
166:                 return false;
167:             }
168:         }
169:         return true;
170:     }
171: 
172:     /**
173:      * Ecrit l'objet
174:      *
175:      * @access public
176:      * @return string
177:      */
178:     public function __toString()
179:     {
180:         //$this->check();
181:         $field = '';
182:         $field.= parent::__toString();
183:         $this->form->javascript .= '$("#' . $this->attrs['id'] . '").spinbox({min:' . $this->min . ',max:' . $this->max . ',step:' . $this->step . '});';
184:         return $field;
185:     }
186: 
187: }
188: 
189: ?>
Pry API documentation generated by ApiGen 2.8.0