Overview

Packages

  • Auth
  • Config
  • Controller
  • Date
  • Db
  • Feed
    • Abstract
    • Writers
  • File
    • Decorator
  • Form
    • Element
  • Image
  • Log
    • Writer
  • Net
    • Exception
  • None
  • PHP
  • PHPMailer
  • Session
  • Util
  • Validate
    • Validator
  • Zend
    • Registry

Classes

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