web/Zend/Dojo/Form/Element/NumberSpinner.php
changeset 0 4eba9c11703f
equal deleted inserted replaced
-1:000000000000 0:4eba9c11703f
       
     1 <?php
       
     2 /**
       
     3  * Zend 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  * It is also available through the world-wide-web at this URL:
       
    10  * http://framework.zend.com/license/new-bsd
       
    11  * If you did not receive a copy of the license and are unable to
       
    12  * obtain it through the world-wide-web, please send an email
       
    13  * to license@zend.com so we can send you a copy immediately.
       
    14  *
       
    15  * @category   Zend
       
    16  * @package    Zend_Dojo
       
    17  * @subpackage Form_Element
       
    18  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    20  */
       
    21 
       
    22 /** Zend_Dojo_Form_Element_ValidationTextBox */
       
    23 require_once 'Zend/Dojo/Form/Element/ValidationTextBox.php';
       
    24 
       
    25 /**
       
    26  * NumberSpinner dijit
       
    27  *
       
    28  * @uses       Zend_Dojo_Form_Element_ValidationTextBox
       
    29  * @package    Zend_Dojo
       
    30  * @subpackage Form_Element
       
    31  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    32  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    33  * @version    $Id: NumberSpinner.php 20096 2010-01-06 02:05:09Z bkarwin $
       
    34  */
       
    35 class Zend_Dojo_Form_Element_NumberSpinner extends Zend_Dojo_Form_Element_ValidationTextBox
       
    36 {
       
    37     /**
       
    38      * Use NumberSpinner dijit view helper
       
    39      * @var string
       
    40      */
       
    41     public $helper = 'NumberSpinner';
       
    42 
       
    43     /**
       
    44      * Set defaultTimeout
       
    45      *
       
    46      * @param  int $timeout
       
    47      * @return Zend_Dojo_Form_Element_NumberSpinner
       
    48      */
       
    49     public function setDefaultTimeout($timeout)
       
    50     {
       
    51         $this->setDijitParam('defaultTimeout', (int) $timeout);
       
    52         return $this;
       
    53     }
       
    54 
       
    55     /**
       
    56      * Retrieve defaultTimeout
       
    57      *
       
    58      * @return int|null
       
    59      */
       
    60     public function getDefaultTimeout()
       
    61     {
       
    62         return $this->getDijitParam('defaultTimeout');
       
    63     }
       
    64 
       
    65     /**
       
    66      * Set timeoutChangeRate
       
    67      *
       
    68      * @param  int $rate
       
    69      * @return Zend_Dojo_Form_Element_NumberSpinner
       
    70      */
       
    71     public function setTimeoutChangeRate($rate)
       
    72     {
       
    73         $this->setDijitParam('timeoutChangeRate', (int) $rate);
       
    74         return $this;
       
    75     }
       
    76 
       
    77     /**
       
    78      * Retrieve timeoutChangeRate
       
    79      *
       
    80      * @return int|null
       
    81      */
       
    82     public function getTimeoutChangeRate()
       
    83     {
       
    84         return $this->getDijitParam('timeoutChangeRate');
       
    85     }
       
    86 
       
    87     /**
       
    88      * Set largeDelta
       
    89      *
       
    90      * @param  int $delta
       
    91      * @return Zend_Dojo_Form_Element_NumberSpinner
       
    92      */
       
    93     public function setLargeDelta($delta)
       
    94     {
       
    95         $this->setDijitParam('largeDelta', (int) $delta);
       
    96         return $this;
       
    97     }
       
    98 
       
    99     /**
       
   100      * Retrieve largeDelta
       
   101      *
       
   102      * @return int|null
       
   103      */
       
   104     public function getLargeDelta()
       
   105     {
       
   106         return $this->getDijitParam('largeDelta');
       
   107     }
       
   108 
       
   109     /**
       
   110      * Set smallDelta
       
   111      *
       
   112      * @param  int $delta
       
   113      * @return Zend_Dojo_Form_Element_NumberSpinner
       
   114      */
       
   115     public function setSmallDelta($delta)
       
   116     {
       
   117         $this->setDijitParam('smallDelta', (int) $delta);
       
   118         return $this;
       
   119     }
       
   120 
       
   121     /**
       
   122      * Retrieve smallDelta
       
   123      *
       
   124      * @return int|null
       
   125      */
       
   126     public function getSmallDelta()
       
   127     {
       
   128         return $this->getDijitParam('smallDelta');
       
   129     }
       
   130 
       
   131     /**
       
   132      * Set intermediateChanges flag
       
   133      *
       
   134      * @param  bool $flag
       
   135      * @return Zend_Dojo_Form_Element_TextBox
       
   136      */
       
   137     public function setIntermediateChanges($flag)
       
   138     {
       
   139         $this->setDijitParam('intermediateChanges', (bool) $flag);
       
   140         return $this;
       
   141     }
       
   142 
       
   143     /**
       
   144      * Retrieve intermediateChanges flag
       
   145      *
       
   146      * @return bool
       
   147      */
       
   148     public function getIntermediateChanges()
       
   149     {
       
   150         if (!$this->hasDijitParam('intermediateChanges')) {
       
   151             return false;
       
   152         }
       
   153         return $this->getDijitParam('intermediateChanges');
       
   154     }
       
   155 
       
   156     /**
       
   157      * Set rangeMessage
       
   158      *
       
   159      * @param  string $message
       
   160      * @return Zend_Dojo_Form_Element_NumberSpinner
       
   161      */
       
   162     public function setRangeMessage($message)
       
   163     {
       
   164         $this->setDijitParam('rangeMessage', (string) $message);
       
   165         return $this;
       
   166     }
       
   167 
       
   168     /**
       
   169      * Retrieve rangeMessage
       
   170      *
       
   171      * @return string|null
       
   172      */
       
   173     public function getRangeMessage()
       
   174     {
       
   175         return $this->getDijitParam('rangeMessage');
       
   176     }
       
   177 
       
   178     /**
       
   179      * Set minimum value
       
   180      *
       
   181      * @param  int $value
       
   182      * @return Zend_Dojo_Form_Element_NumberSpinner
       
   183      */
       
   184     public function setMin($value)
       
   185     {
       
   186         $constraints = array();
       
   187         if ($this->hasDijitParam('constraints')) {
       
   188             $constraints = $this->getDijitParam('constraints');
       
   189         }
       
   190         $constraints['min'] = (int) $value;
       
   191         $this->setDijitParam('constraints', $constraints);
       
   192         return $this;
       
   193     }
       
   194 
       
   195     /**
       
   196      * Get minimum value
       
   197      *
       
   198      * @return null|int
       
   199      */
       
   200     public function getMin()
       
   201     {
       
   202         if (!$this->hasDijitParam('constraints')) {
       
   203             return null;
       
   204         }
       
   205         $constraints = $this->getDijitParam('constraints');
       
   206         if (!array_key_exists('min', $constraints)) {
       
   207             return null;
       
   208         }
       
   209         return $constraints['min'];
       
   210     }
       
   211 
       
   212     /**
       
   213      * Set maximum value
       
   214      *
       
   215      * @param  int $value
       
   216      * @return Zend_Dojo_Form_Element_NumberSpinner
       
   217      */
       
   218     public function setMax($value)
       
   219     {
       
   220         $constraints = array();
       
   221         if ($this->hasDijitParam('constraints')) {
       
   222             $constraints = $this->getDijitParam('constraints');
       
   223         }
       
   224         $constraints['max'] = (int) $value;
       
   225         $this->setDijitParam('constraints', $constraints);
       
   226         return $this;
       
   227     }
       
   228 
       
   229     /**
       
   230      * Get maximum value
       
   231      *
       
   232      * @return null|int
       
   233      */
       
   234     public function getMax()
       
   235     {
       
   236         if (!$this->hasDijitParam('constraints')) {
       
   237             return null;
       
   238         }
       
   239         $constraints = $this->getDijitParam('constraints');
       
   240         if (!array_key_exists('max', $constraints)) {
       
   241             return null;
       
   242         }
       
   243         return $constraints['max'];
       
   244     }
       
   245 }