File indexing completed on 2025-03-09 05:25:47
0001 <?php 0002 /** 0003 * Zend Framework 0004 * 0005 * LICENSE 0006 * 0007 * This source file is subject to the new BSD license that is bundled 0008 * with this package in the file LICENSE.txt. 0009 * It is also available through the world-wide-web at this URL: 0010 * http://framework.zend.com/license/new-bsd 0011 * If you did not receive a copy of the license and are unable to 0012 * obtain it through the world-wide-web, please send an email 0013 * to license@zend.com so we can send you a copy immediately. 0014 * 0015 * @category Zend 0016 * @package Zend_Dojo 0017 * @subpackage Form_Element 0018 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0019 * @license http://framework.zend.com/license/new-bsd New BSD License 0020 */ 0021 0022 /** Zend_Dojo_Form_Element_ValidationTextBox */ 0023 // require_once 'Zend/Dojo/Form/Element/ValidationTextBox.php'; 0024 0025 /** 0026 * NumberSpinner dijit 0027 * 0028 * @uses Zend_Dojo_Form_Element_ValidationTextBox 0029 * @package Zend_Dojo 0030 * @subpackage Form_Element 0031 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0032 * @license http://framework.zend.com/license/new-bsd New BSD License 0033 * @version $Id$ 0034 */ 0035 class Zend_Dojo_Form_Element_NumberSpinner extends Zend_Dojo_Form_Element_ValidationTextBox 0036 { 0037 /** 0038 * Use NumberSpinner dijit view helper 0039 * @var string 0040 */ 0041 public $helper = 'NumberSpinner'; 0042 0043 /** 0044 * Set defaultTimeout 0045 * 0046 * @param int $timeout 0047 * @return Zend_Dojo_Form_Element_NumberSpinner 0048 */ 0049 public function setDefaultTimeout($timeout) 0050 { 0051 $this->setDijitParam('defaultTimeout', (int) $timeout); 0052 return $this; 0053 } 0054 0055 /** 0056 * Retrieve defaultTimeout 0057 * 0058 * @return int|null 0059 */ 0060 public function getDefaultTimeout() 0061 { 0062 return $this->getDijitParam('defaultTimeout'); 0063 } 0064 0065 /** 0066 * Set timeoutChangeRate 0067 * 0068 * @param int $rate 0069 * @return Zend_Dojo_Form_Element_NumberSpinner 0070 */ 0071 public function setTimeoutChangeRate($rate) 0072 { 0073 $this->setDijitParam('timeoutChangeRate', (int) $rate); 0074 return $this; 0075 } 0076 0077 /** 0078 * Retrieve timeoutChangeRate 0079 * 0080 * @return int|null 0081 */ 0082 public function getTimeoutChangeRate() 0083 { 0084 return $this->getDijitParam('timeoutChangeRate'); 0085 } 0086 0087 /** 0088 * Set largeDelta 0089 * 0090 * @param int $delta 0091 * @return Zend_Dojo_Form_Element_NumberSpinner 0092 */ 0093 public function setLargeDelta($delta) 0094 { 0095 $this->setDijitParam('largeDelta', (float) $delta); 0096 return $this; 0097 } 0098 0099 /** 0100 * Retrieve largeDelta 0101 * 0102 * @return int|null 0103 */ 0104 public function getLargeDelta() 0105 { 0106 return $this->getDijitParam('largeDelta'); 0107 } 0108 0109 /** 0110 * Set smallDelta 0111 * 0112 * @param int $delta 0113 * @return Zend_Dojo_Form_Element_NumberSpinner 0114 */ 0115 public function setSmallDelta($delta) 0116 { 0117 $this->setDijitParam('smallDelta', (float) $delta); 0118 return $this; 0119 } 0120 0121 /** 0122 * Retrieve smallDelta 0123 * 0124 * @return int|null 0125 */ 0126 public function getSmallDelta() 0127 { 0128 return $this->getDijitParam('smallDelta'); 0129 } 0130 0131 /** 0132 * Set intermediateChanges flag 0133 * 0134 * @param bool $flag 0135 * @return Zend_Dojo_Form_Element_TextBox 0136 */ 0137 public function setIntermediateChanges($flag) 0138 { 0139 $this->setDijitParam('intermediateChanges', (bool) $flag); 0140 return $this; 0141 } 0142 0143 /** 0144 * Retrieve intermediateChanges flag 0145 * 0146 * @return bool 0147 */ 0148 public function getIntermediateChanges() 0149 { 0150 if (!$this->hasDijitParam('intermediateChanges')) { 0151 return false; 0152 } 0153 return $this->getDijitParam('intermediateChanges'); 0154 } 0155 0156 /** 0157 * Set rangeMessage 0158 * 0159 * @param string $message 0160 * @return Zend_Dojo_Form_Element_NumberSpinner 0161 */ 0162 public function setRangeMessage($message) 0163 { 0164 $this->setDijitParam('rangeMessage', (string) $message); 0165 return $this; 0166 } 0167 0168 /** 0169 * Retrieve rangeMessage 0170 * 0171 * @return string|null 0172 */ 0173 public function getRangeMessage() 0174 { 0175 return $this->getDijitParam('rangeMessage'); 0176 } 0177 0178 /** 0179 * Set minimum value 0180 * 0181 * @param int $value 0182 * @return Zend_Dojo_Form_Element_NumberSpinner 0183 */ 0184 public function setMin($value) 0185 { 0186 $constraints = array(); 0187 if ($this->hasDijitParam('constraints')) { 0188 $constraints = $this->getDijitParam('constraints'); 0189 } 0190 $constraints['min'] = (float) $value; 0191 $this->setDijitParam('constraints', $constraints); 0192 return $this; 0193 } 0194 0195 /** 0196 * Get minimum value 0197 * 0198 * @return null|int 0199 */ 0200 public function getMin() 0201 { 0202 if (!$this->hasDijitParam('constraints')) { 0203 return null; 0204 } 0205 $constraints = $this->getDijitParam('constraints'); 0206 if (!array_key_exists('min', $constraints)) { 0207 return null; 0208 } 0209 return $constraints['min']; 0210 } 0211 0212 /** 0213 * Set maximum value 0214 * 0215 * @param int $value 0216 * @return Zend_Dojo_Form_Element_NumberSpinner 0217 */ 0218 public function setMax($value) 0219 { 0220 $constraints = array(); 0221 if ($this->hasDijitParam('constraints')) { 0222 $constraints = $this->getDijitParam('constraints'); 0223 } 0224 $constraints['max'] = (float) $value; 0225 $this->setDijitParam('constraints', $constraints); 0226 return $this; 0227 } 0228 0229 /** 0230 * Get maximum value 0231 * 0232 * @return null|int 0233 */ 0234 public function getMax() 0235 { 0236 if (!$this->hasDijitParam('constraints')) { 0237 return null; 0238 } 0239 $constraints = $this->getDijitParam('constraints'); 0240 if (!array_key_exists('max', $constraints)) { 0241 return null; 0242 } 0243 return $constraints['max']; 0244 } 0245 }