File indexing completed on 2025-03-02 05:29:19
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 * DateTextBox 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_DateTextBox extends Zend_Dojo_Form_Element_ValidationTextBox 0036 { 0037 /** 0038 * Use DateTextBox dijit view helper 0039 * @var string 0040 */ 0041 public $helper = 'DateTextBox'; 0042 0043 /** 0044 * Allowed formatLength types 0045 * @var array 0046 */ 0047 protected $_allowedFormatTypes = array( 0048 'long', 0049 'short', 0050 'medium', 0051 'full', 0052 ); 0053 0054 /** 0055 * Allowed selector types 0056 * @var array 0057 */ 0058 protected $_allowedSelectorTypes = array( 0059 'time', 0060 'date', 0061 ); 0062 0063 /** 0064 * Set am,pm flag 0065 * 0066 * @param bool $am,pm 0067 * @return Zend_Dojo_Form_Element_DateTextBox 0068 */ 0069 public function setAmPm($flag) 0070 { 0071 $this->setConstraint('am,pm', (bool) $flag); 0072 return $this; 0073 } 0074 0075 /** 0076 * Retrieve am,pm flag 0077 * 0078 * @return bool 0079 */ 0080 public function getAmPm() 0081 { 0082 if (!$this->hasConstraint('am,pm')) { 0083 return false; 0084 } 0085 return ('true' ==$this->getConstraint('am,pm')); 0086 } 0087 0088 /** 0089 * Set strict flag 0090 * 0091 * @param bool $strict 0092 * @return Zend_Dojo_Form_Element_DateTextBox 0093 */ 0094 public function setStrict($flag) 0095 { 0096 $this->setConstraint('strict', (bool) $flag); 0097 return $this; 0098 } 0099 0100 /** 0101 * Retrieve strict flag 0102 * 0103 * @return bool 0104 */ 0105 public function getStrict() 0106 { 0107 if (!$this->hasConstraint('strict')) { 0108 return false; 0109 } 0110 return ('true' == $this->getConstraint('strict')); 0111 } 0112 0113 /** 0114 * Set locale 0115 * 0116 * @param string $locale 0117 * @return Zend_Dojo_Form_Element_DateTextBox 0118 */ 0119 public function setLocale($locale) 0120 { 0121 $this->setConstraint('locale', (string) $locale); 0122 return $this; 0123 } 0124 0125 /** 0126 * Retrieve locale 0127 * 0128 * @return string|null 0129 */ 0130 public function getLocale() 0131 { 0132 return $this->getConstraint('locale'); 0133 } 0134 0135 /** 0136 * Set date format pattern 0137 * 0138 * @param string $pattern 0139 * @return Zend_Dojo_Form_Element_NumberTextBox 0140 */ 0141 public function setDatePattern($pattern) 0142 { 0143 $this->setConstraint('datePattern', (string) $pattern); 0144 return $this; 0145 } 0146 0147 /** 0148 * Retrieve date format pattern 0149 * 0150 * @return string|null 0151 */ 0152 public function getDatePattern() 0153 { 0154 return $this->getConstraint('datePattern'); 0155 } 0156 0157 /** 0158 * Set numeric format formatLength 0159 * 0160 * @see $_allowedFormatTypes 0161 * @param string $formatLength 0162 * @return Zend_Dojo_Form_Element_NumberTextBox 0163 */ 0164 public function setFormatLength($formatLength) 0165 { 0166 $formatLength = strtolower($formatLength); 0167 if (!in_array($formatLength, $this->_allowedFormatTypes)) { 0168 // require_once 'Zend/Form/Element/Exception.php'; 0169 throw new Zend_Form_Element_Exception(sprintf('Invalid formatLength "%s" specified', $formatLength)); 0170 } 0171 0172 $this->setConstraint('formatLength', $formatLength); 0173 return $this; 0174 } 0175 0176 /** 0177 * Retrieve formatLength 0178 * 0179 * @return string|null 0180 */ 0181 public function getFormatLength() 0182 { 0183 return $this->getConstraint('formatLength'); 0184 } 0185 0186 /** 0187 * Set numeric format Selector 0188 * 0189 * @see $_allowedSelectorTypes 0190 * @param string $selector 0191 * @return Zend_Dojo_Form_Element_NumberTextBox 0192 */ 0193 public function setSelector($selector) 0194 { 0195 $selector = strtolower($selector); 0196 if (!in_array($selector, $this->_allowedSelectorTypes)) { 0197 // require_once 'Zend/Form/Element/Exception.php'; 0198 throw new Zend_Form_Element_Exception(sprintf('Invalid Selector "%s" specified', $selector)); 0199 } 0200 0201 $this->setConstraint('selector', $selector); 0202 return $this; 0203 } 0204 0205 /** 0206 * Retrieve selector 0207 * 0208 * @return string|null 0209 */ 0210 public function getSelector() 0211 { 0212 return $this->getConstraint('selector'); 0213 } 0214 }